Skip to content

Commit

Permalink
STAR-836 Fix TestCompaction_with_UnifiedCompactionStrategy.bloomfilte…
Browse files Browse the repository at this point in the history
…r_size_test (#41)

Co-authored-by: Branimir Lambov <[email protected]>
(cherry picked from commit 7777fa9)
  • Loading branch information
Gerrrr authored and jacek-lewandowski committed Aug 25, 2021
1 parent 9196eaa commit d06d4c6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions compaction_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,30 @@ 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
max_bf_size = 150000
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())
Expand All @@ -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)
Expand Down

0 comments on commit d06d4c6

Please sign in to comment.