From 3134471457455006947f566590e8ee3326b699a2 Mon Sep 17 00:00:00 2001 From: Jay Zhuang Date: Tue, 26 Jul 2022 12:50:27 -0700 Subject: [PATCH] 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 --- db/column_family_test.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/db/column_family_test.cc b/db/column_family_test.cc index 518a5db9f..e26de8364 100644 --- a/db/column_family_test.cc +++ b/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 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());