From d06d4c68ca15076cd06fafaff9c9762d9bd532d1 Mon Sep 17 00:00:00 2001 From: Aleksandr Sorokoumov <918393+Gerrrr@users.noreply.github.com> Date: Thu, 5 Aug 2021 15:57:31 +0200 Subject: [PATCH] STAR-836 Fix TestCompaction_with_UnifiedCompactionStrategy.bloomfilter_size_test (#41) Co-authored-by: Branimir Lambov (cherry picked from commit 7777fa9c7a478bb3795bc1c0e5602cbae2921faf) --- compaction_test.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/compaction_test.py b/compaction_test.py index a0d5d25e86..107b0c8b7f 100644 --- a/compaction_test.py +++ b/compaction_test.py @@ -114,6 +114,8 @@ def test_bloomfilter_size(self, strategy): else: if strategy == "DateTieredCompactionStrategy": strategy_string = "strategy=DateTieredCompactionStrategy,base_time_seconds=86400" # we want a single sstable, so make sure we don't have a tiny first window + elif self.strategy == "UnifiedCompactionStrategy": + strategy_string = "strategy=UnifiedCompactionStrategy,max_sstables_to_compact=4" # disable layout-preserving compaction which can leave more than one sstable else: strategy_string = "strategy={}".format(strategy) min_bf_size = 100000 @@ -121,18 +123,21 @@ def test_bloomfilter_size(self, strategy): cluster = self.cluster cluster.populate(1).start() [node1] = cluster.nodelist() + logger.debug("Compaction: " + strategy_string) for x in range(0, 5): node1.stress(['write', 'n=100K', "no-warmup", "cl=ONE", "-rate", "threads=300", "-schema", "replication(factor=1)", "compaction({},enabled=false)".format(strategy_string)]) node1.flush() + logger.debug(node1.nodetool('cfstats keyspace1.standard1').stdout) node1.nodetool('enableautocompaction') node1.wait_for_compactions() table_name = 'standard1' - output = node1.nodetool('cfstats').stdout + output = node1.nodetool('cfstats keyspace1.standard1').stdout + logger.debug(output) output = output[output.find(table_name):] output = output[output.find("Bloom filter space used"):] bfSize = int(output[output.find(":") + 1:output.find("\n")].strip()) @@ -153,7 +158,12 @@ def test_bloomfilter_size(self, strategy): logger.debug("bloom filter size is: {}".format(bfSize)) logger.debug("size factor = {}".format(size_factor)) - assert bfSize >= size_factor * min_bf_size + # In the case where the number of sstables is greater than the number of directories, it's possible this to be + # both with unique keys (where the bf size will remain close to the unadjusted limit) or with repetitions + # of keys (where the bf size will be a multiple of the expected). Permit both by only using the size factor on + # the maximum size. Note that the test is designed to end up with size_factor == 1 and most runs do so, thus + # this is not a loosening of the test in the common case, only ensures that we don't end up with flakes. + assert bfSize >= min_bf_size assert bfSize <= size_factor * max_bf_size @pytest.mark.parametrize("strategy", strategies)