Deflake FlushStaleColumnFamilies test (#10409)

Summary:
Make the Stale Flush test more robust by explicitly checking the target CF is
flushed.  Currently it's flaky because the default CF may have more than 3
SSTs.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10409

Test Plan:
the test more likely to fail on a resource limited host:
```
gtest-parallel ./column_family_test --gtest_filter=FormatDef/ColumnFamilyTest.FlushStaleColumnFamilies/0 -r 1000 -w 100
```

Reviewed By: ajkr

Differential Revision: D38116383

Pulled By: jay-zhuang

fbshipit-source-id: e27cc56f76f14d0936504f126104e3d87e3d0d5f
main
Jay Zhuang 2 years ago committed by Facebook GitHub Bot
parent 84e9b6ee2d
commit 3134471457
  1. 19
      db/column_family_test.cc

@ -2207,9 +2207,22 @@ TEST_P(ColumnFamilyTest, FlushStaleColumnFamilies) {
PutRandomData(0, 100, 1000); // flush
WaitForFlush(0);
WaitForFlush(2);
// 3 files for default column families, 1 file for column family [two], zero
// files for column family [one], because it's empty
AssertCountLiveFiles(4);
// at least 3 files for default column families, 1 file for column family
// [two], zero files for column family [one], because it's empty
std::vector<LiveFileMetaData> metadata;
db_->GetLiveFilesMetaData(&metadata);
ASSERT_GE(metadata.size(), 4);
bool has_cf1_sst = false;
bool has_cf2_sst = false;
for (const auto& file : metadata) {
if (file.column_family_name == "one") {
has_cf1_sst = true;
} else if (file.column_family_name == "two") {
has_cf2_sst = true;
}
}
ASSERT_FALSE(has_cf1_sst);
ASSERT_TRUE(has_cf2_sst);
ASSERT_OK(Flush(0));
ASSERT_EQ(0, dbfull()->TEST_total_log_size());

Loading…
Cancel
Save