@@ -114,25 +114,30 @@ def test_bloomfilter_size(self, strategy):
114114 else :
115115 if strategy == "DateTieredCompactionStrategy" :
116116 strategy_string = "strategy=DateTieredCompactionStrategy,base_time_seconds=86400" # we want a single sstable, so make sure we don't have a tiny first window
117+ elif self .strategy == "UnifiedCompactionStrategy" :
118+ strategy_string = "strategy=UnifiedCompactionStrategy,max_sstables_to_compact=4" # disable layout-preserving compaction which can leave more than one sstable
117119 else :
118120 strategy_string = "strategy={}" .format (strategy )
119121 min_bf_size = 100000
120122 max_bf_size = 150000
121123 cluster = self .cluster
122124 cluster .populate (1 ).start ()
123125 [node1 ] = cluster .nodelist ()
126+ logger .debug ("Compaction: " + strategy_string )
124127
125128 for x in range (0 , 5 ):
126129 node1 .stress (['write' , 'n=100K' , "no-warmup" , "cl=ONE" , "-rate" ,
127130 "threads=300" , "-schema" , "replication(factor=1)" ,
128131 "compaction({},enabled=false)" .format (strategy_string )])
129132 node1 .flush ()
133+ logger .debug (node1 .nodetool ('cfstats keyspace1.standard1' ).stdout )
130134
131135 node1 .nodetool ('enableautocompaction' )
132136 node1 .wait_for_compactions ()
133137
134138 table_name = 'standard1'
135- output = node1 .nodetool ('cfstats' ).stdout
139+ output = node1 .nodetool ('cfstats keyspace1.standard1' ).stdout
140+ logger .debug (output )
136141 output = output [output .find (table_name ):]
137142 output = output [output .find ("Bloom filter space used" ):]
138143 bfSize = int (output [output .find (":" ) + 1 :output .find ("\n " )].strip ())
@@ -153,7 +158,12 @@ def test_bloomfilter_size(self, strategy):
153158
154159 logger .debug ("bloom filter size is: {}" .format (bfSize ))
155160 logger .debug ("size factor = {}" .format (size_factor ))
156- assert bfSize >= size_factor * min_bf_size
161+ # In the case where the number of sstables is greater than the number of directories, it's possible this to be
162+ # both with unique keys (where the bf size will remain close to the unadjusted limit) or with repetitions
163+ # of keys (where the bf size will be a multiple of the expected). Permit both by only using the size factor on
164+ # the maximum size. Note that the test is designed to end up with size_factor == 1 and most runs do so, thus
165+ # this is not a loosening of the test in the common case, only ensures that we don't end up with flakes.
166+ assert bfSize >= min_bf_size
157167 assert bfSize <= size_factor * max_bf_size
158168
159169 @pytest .mark .parametrize ("strategy" , strategies )
0 commit comments