@@ -193,6 +193,25 @@ def increase_sstable_generations(self, sstables):
193
193
def uuid_sstable_identifiers_enabled (self , session ):
194
194
return 'true' == session .execute ("select value from system_views.settings where name = 'uuid_sstable_identifiers_enabled'" )[0 ][0 ]
195
195
196
+ def get_latest_generation (self , sstables ):
197
+ """
198
+ Get the latest generation ID of the provided sstables
199
+ """
200
+ latest_gen = None
201
+ for table_or_index , table_sstables in list (sstables .items ()):
202
+ gen = max (parse .search ('{}-{generation}-{}.{}' , s ).named ['generation' ] for s in table_sstables )
203
+ latest_gen = gen if latest_gen is None else max ([gen , latest_gen ])
204
+ return latest_gen
205
+
206
+ def get_earliest_generation (self , sstables ):
207
+ """
208
+ Get the earliest generation ID of the provided sstables
209
+ """
210
+ earliest_gen = None
211
+ for table_or_index , table_sstables in list (sstables .items ()):
212
+ gen = min (parse .search ('{}-{generation}-{}.{}' , s ).named ['generation' ] for s in table_sstables )
213
+ earliest_gen = gen if earliest_gen is None else min ([gen , earliest_gen ])
214
+ return earliest_gen
196
215
197
216
@since ('2.2' )
198
217
class TestScrubIndexes (TestHelper ):
@@ -258,13 +277,16 @@ def test_scrub_static_table(self):
258
277
if should_assert_sstables :
259
278
self .increase_sstable_generations (initial_sstables )
260
279
assert initial_sstables == scrubbed_sstables
280
+ assert self .get_latest_generation (initial_sstables ) < self .get_earliest_generation (scrubbed_sstables )
261
281
262
282
users = self .query_users (session )
263
283
assert initial_users == users
264
284
265
285
# Scrub and check sstables and data again
286
+ initial_sstables = scrubbed_sstables
266
287
scrubbed_sstables = self .scrub ('users' , 'gender_idx' , 'state_idx' , 'birth_year_idx' )
267
288
289
+ assert self .get_latest_generation (initial_sstables ) < self .get_earliest_generation (scrubbed_sstables )
268
290
if should_assert_sstables :
269
291
self .increase_sstable_generations (initial_sstables )
270
292
assert initial_sstables == scrubbed_sstables
@@ -301,6 +323,7 @@ def test_standalone_scrub(self):
301
323
302
324
scrubbed_sstables = self .standalonescrub ('users' , 'gender_idx' , 'state_idx' , 'birth_year_idx' )
303
325
326
+ assert self .get_latest_generation (initial_sstables ) < self .get_earliest_generation (scrubbed_sstables )
304
327
if should_assert_sstables :
305
328
self .increase_sstable_generations (initial_sstables )
306
329
assert initial_sstables == scrubbed_sstables
@@ -337,15 +360,18 @@ def test_scrub_collections_table(self):
337
360
initial_sstables = self .flush ('users' , 'user_uuids_idx' )
338
361
scrubbed_sstables = self .scrub ('users' , 'user_uuids_idx' )
339
362
363
+ assert self .get_latest_generation (initial_sstables ) < self .get_earliest_generation (scrubbed_sstables )
340
364
if should_assert_sstables :
341
365
self .increase_sstable_generations (initial_sstables )
342
366
assert initial_sstables == scrubbed_sstables
343
367
344
368
users = list (session .execute (("SELECT * from users where uuids contains {some_uuid}" ).format (some_uuid = _id )))
345
369
assert initial_users == users
346
370
371
+ initial_sstables = scrubbed_sstables
347
372
scrubbed_sstables = self .scrub ('users' , 'user_uuids_idx' )
348
373
374
+ assert self .get_latest_generation (initial_sstables ) < self .get_earliest_generation (scrubbed_sstables )
349
375
if should_assert_sstables :
350
376
self .increase_sstable_generations (initial_sstables )
351
377
assert initial_sstables == scrubbed_sstables
@@ -402,6 +428,7 @@ def test_nodetool_scrub(self):
402
428
initial_sstables = self .flush ('users' )
403
429
scrubbed_sstables = self .scrub ('users' )
404
430
431
+ assert self .get_latest_generation (initial_sstables ) < self .get_earliest_generation (scrubbed_sstables )
405
432
if should_assert_sstables :
406
433
self .increase_sstable_generations (initial_sstables )
407
434
assert initial_sstables == scrubbed_sstables
@@ -410,8 +437,10 @@ def test_nodetool_scrub(self):
410
437
assert initial_users == users
411
438
412
439
# Scrub and check sstables and data again
440
+ initial_sstables = scrubbed_sstables
413
441
scrubbed_sstables = self .scrub ('users' )
414
442
443
+ assert self .get_latest_generation (initial_sstables ) < self .get_earliest_generation (scrubbed_sstables )
415
444
if should_assert_sstables :
416
445
self .increase_sstable_generations (initial_sstables )
417
446
assert initial_sstables == scrubbed_sstables
@@ -448,6 +477,7 @@ def test_standalone_scrub(self):
448
477
449
478
scrubbed_sstables = self .standalonescrub ('users' )
450
479
480
+ assert self .get_latest_generation (initial_sstables ) < self .get_earliest_generation (scrubbed_sstables )
451
481
if should_assert_sstables :
452
482
self .increase_sstable_generations (initial_sstables )
453
483
assert initial_sstables == scrubbed_sstables
@@ -480,6 +510,7 @@ def test_standalone_scrub_essential_files_only(self):
480
510
481
511
scrubbed_sstables = self .standalonescrub (table = 'users' , acceptable_errors = ["WARN.*Could not recreate or deserialize existing bloom filter, continuing with a pass-through bloom filter but this will significantly impact reads performance" ])
482
512
513
+ assert self .get_latest_generation (initial_sstables ) < self .get_earliest_generation (scrubbed_sstables )
483
514
if should_assert_sstables :
484
515
self .increase_sstable_generations (initial_sstables )
485
516
assert initial_sstables == scrubbed_sstables
0 commit comments