From e526b7140212da43d2b5c059cb73366d1f6f1232 Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Thu, 6 Nov 2014 13:53:02 -0800 Subject: [PATCH] Make PartialCompactionFailure Test more robust. Summary: Make PartialCompactionFailure Test more robust. Test Plan: export ROCKSDB_TESTS=PartialCompactionFailure ./db_test Reviewers: ljin, sdong, igor Reviewed By: igor Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D28425 --- db/db_test.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index d4237b424..e1818a8a5 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -8958,9 +8958,8 @@ TEST(DBTest, PartialCompactionFailure) { } dbfull()->TEST_WaitForFlushMemTable(); - // Make sure the number of L0 files can trigger compaction. - ASSERT_GE(NumTableFilesAtLevel(0), - options.level0_file_num_compaction_trigger); + // Make sure there're some L0 files we can compact + ASSERT_GT(NumTableFilesAtLevel(0), 0); auto previous_num_level0_files = NumTableFilesAtLevel(0); // The number of NewWritableFiles calls required by each operation. @@ -8973,11 +8972,15 @@ TEST(DBTest, PartialCompactionFailure) { // Expect compaction to fail here as one file will fail its // creation. - dbfull()->TEST_WaitForCompact(); + ASSERT_TRUE(!db_->CompactRange(nullptr, nullptr).ok()); + // Verify L0 -> L1 compaction does fail. ASSERT_EQ(NumTableFilesAtLevel(1), 0); + // Verify all L0 files are still there. - ASSERT_EQ(NumTableFilesAtLevel(0), previous_num_level0_files); + // We use GE here as occasionally there might be additional + // memtables being flushed. + ASSERT_GE(NumTableFilesAtLevel(0), previous_num_level0_files); // All key-values must exist after compaction fails. for (int k = 0; k < kNumInsertedKeys; ++k) {