From 3b985233f58802cc90405a248a22bf81799c7e0e Mon Sep 17 00:00:00 2001 From: Leo Toff Date: Sun, 12 May 2024 09:36:18 -0700 Subject: [PATCH 1/2] Add -r flag to nodetool-tablestats calls (-r stands for raw, or --no-human-readable) --- compaction_test.py | 8 ++++---- dtest.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compaction_test.py b/compaction_test.py index b37db3ece6..ba853f71b5 100644 --- a/compaction_test.py +++ b/compaction_test.py @@ -79,7 +79,7 @@ def test_data_size(self): node1.flush() table_name = 'standard1' - output = node1.nodetool('tablestats').stdout + output = node1.nodetool('tablestats -r').stdout if output.find(table_name) != -1: output = output[output.find(table_name):] output = output[output.find("Space used (live)"):] @@ -92,7 +92,7 @@ def test_data_size(self): node1.compact() node1.wait_for_compactions() - output = node1.nodetool('tablestats').stdout + output = node1.nodetool('tablestats -r').stdout if output.find(table_name) != -1: output = output[output.find(table_name):] output = output[output.find("Space used (live)"):] @@ -136,7 +136,7 @@ def test_bloomfilter_size(self, strategy): node1.wait_for_compactions() table_name = 'standard1' - output = node1.nodetool('tablestats').stdout + output = node1.nodetool('tablestats -r').stdout output = output[output.find(table_name):] output = output[output.find("Bloom filter space used"):] bfSize = int(output[output.find(":") + 1:output.find("\n")].strip()) @@ -595,7 +595,7 @@ def skip_if_not_supported(self, strategy): pytest.skip('DateTieredCompactionStrategy is not supported in Cassandra 5.0 and later') def grep_sstables_in_each_level(node, table_name): - output = node.nodetool('tablestats').stdout + output = node.nodetool('tablestats -r').stdout output = output[output.find(table_name):] output = output[output.find("SSTables in each level"):] return output[output.find(":") + 1:output.find("\n")].strip() diff --git a/dtest.py b/dtest.py index da7b31a711..36000df9ad 100644 --- a/dtest.py +++ b/dtest.py @@ -422,7 +422,7 @@ def data_size(node, ks, cf): @return: data size in bytes """ hack_legacy_parsing(node) - tablestats = node.nodetool("tablestats {}.{}".format(ks,cf))[0] + tablestats = node.nodetool("tablestats {}.{} -r".format(ks,cf))[0] regex = re.compile(r'[\t]') stats_lines = [regex.sub("", s) for s in tablestats.split('\n') if regex.sub("", s).startswith('Space used (total)')] From be9495a5bc41b223f0d0e62b7cf29bde5558d402 Mon Sep 17 00:00:00 2001 From: Leo Toff Date: Mon, 13 May 2024 20:27:23 -0700 Subject: [PATCH 2/2] Refactor a call to nodetool tablestats with -r flag --- dtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtest.py b/dtest.py index 36000df9ad..a521fa7d48 100644 --- a/dtest.py +++ b/dtest.py @@ -422,7 +422,7 @@ def data_size(node, ks, cf): @return: data size in bytes """ hack_legacy_parsing(node) - tablestats = node.nodetool("tablestats {}.{} -r".format(ks,cf))[0] + tablestats = node.nodetool("tablestats -r {}.{}".format(ks,cf))[0] regex = re.compile(r'[\t]') stats_lines = [regex.sub("", s) for s in tablestats.split('\n') if regex.sub("", s).startswith('Space used (total)')]