From fb5bdbf9875bb2c9b583b82eb6d881ac2c39ddc7 Mon Sep 17 00:00:00 2001 From: sdong Date: Mon, 18 May 2015 11:47:16 -0700 Subject: [PATCH] DBTest.DynamicLevelMaxBytesCompactRange: make sure L0 is not empty before running compact range Summary: DBTest.DynamicLevelMaxBytesCompactRange needs to make sure L0 is not empty to properly cover the code paths we want to cover. However, current codes have a bug that might leave the condition not held. Improve the test to ensure it. Test Plan: Run the test in an environment that is used to fail. Also run it many times. Subscribers: leveldb, dhruba Differential Revision: https://reviews.facebook.net/D38631 --- db/db_test.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index 94918b72d..94e4d6a5e 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -11219,9 +11219,12 @@ TEST_F(DBTest, DynamicLevelMaxBytesCompactRange) { } Flush(); dbfull()->TEST_WaitForCompact(); - ASSERT_OK( - Put(Key(static_cast(rnd.Uniform(kMaxKey))), RandomString(&rnd, 80))); - Flush(); + if (NumTableFilesAtLevel(0) == 0) { + // Make sure level 0 is not empty + ASSERT_OK(Put(Key(static_cast(rnd.Uniform(kMaxKey))), + RandomString(&rnd, 80))); + Flush(); + } ASSERT_TRUE(db_->GetIntProperty("rocksdb.base-level", &int_prop)); ASSERT_EQ(3U, int_prop);