From 80ac7412b5f056ac23ca7a2296ba1811acdcc2f8 Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Wed, 8 Dec 2021 21:56:33 -0800 Subject: [PATCH] Polish/deflake BackupEngineTest.FileCollision (#9257) Summary: Use smaller and more predictable behaviors Pull Request resolved: https://github.com/facebook/rocksdb/pull/9257 Test Plan: gtest-parallel --repeat=N ./backupable_db_test --gtest_filter=BackupEngineTest.FileCollision before (N=50) we see inconsistent sets of SST files $ find /dev/shm/rocksdb_blah/ | grep -o '/00.*sst' | grep -o '^[^_]*' | sort | uniq -c 49 /000009 3 /000010 1 /000010.sst 49 /000012 3 /000013 1 /000013.sst 49 /000015 2 /000016 1 /000016.sst 22 /000018 2 /000019 1 /000019.sst 29 /000020 11 /000021 2 /000021.sst 46 /000022 2 /000022.sst 4 /000023 1 /000023.sst 27 /000025 And after (N=5000) we see $ find /dev/shm/rocksdb_blah/ | grep -o '/00.*sst' | grep -o '^[^_]*' | sort | uniq -c 10000 /000009 10000 /000012 5000 /000015 Reviewed By: ajkr Differential Revision: D32888393 Pulled By: pdillinger fbshipit-source-id: 5bfd075b3184bb66c5613758a53f431c406e9808 --- utilities/backupable/backupable_db_test.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/utilities/backupable/backupable_db_test.cc b/utilities/backupable/backupable_db_test.cc index 0c2ff66b18..80111fc1c2 100644 --- a/utilities/backupable/backupable_db_test.cc +++ b/utilities/backupable/backupable_db_test.cc @@ -1014,12 +1014,12 @@ class BackupEngineTestWithParam : public BackupEngineTest, }; TEST_F(BackupEngineTest, FileCollision) { - const int keys_iteration = 5000; + const int keys_iteration = 100; for (const auto& sopt : kAllShareOptions) { OpenDBAndBackupEngine(true /* destroy_old_data */, false /* dummy */, sopt); FillDB(db_.get(), 0, keys_iteration); ASSERT_OK(backup_engine_->CreateNewBackup(db_.get())); - FillDB(db_.get(), 0, keys_iteration); + FillDB(db_.get(), keys_iteration, keys_iteration * 2); ASSERT_OK(backup_engine_->CreateNewBackup(db_.get())); CloseDBAndBackupEngine(); @@ -1027,10 +1027,12 @@ TEST_F(BackupEngineTest, FileCollision) { // collision. ASSERT_OK(DestroyDB(dbname_, options_)); - // open with old backup + // open fresh DB, but old backups present OpenDBAndBackupEngine(false /* destroy_old_data */, false /* dummy */, sopt); - FillDB(db_.get(), 0, keys_iteration * 2); + FillDB(db_.get(), 0, keys_iteration); + ASSERT_OK(db_->Flush(FlushOptions())); // like backup would do + FillDB(db_.get(), keys_iteration, keys_iteration * 2); if (sopt != kShareNoChecksum) { ASSERT_OK(backup_engine_->CreateNewBackup(db_.get())); } else {