From e3d4e140753e19083c777b0c3d42d0ff94bae4bd Mon Sep 17 00:00:00 2001 From: sdong Date: Mon, 19 Oct 2015 23:40:15 -0700 Subject: [PATCH] DBCompactionTestWithParam.ManualCompaction to verify block cache is not filled in manual compaction Summary: Manual compaction should not fill block cache. Add the verification in unit test Test Plan: Run the test Reviewers: yhchiang, kradhakrishnan, rven, IslamAbdelRahman, anthony, igor Reviewed By: igor Subscribers: leveldb, dhruba Differential Revision: https://reviews.facebook.net/D49089 --- db/db_compaction_test.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/db/db_compaction_test.cc b/db/db_compaction_test.cc index 615adbdc0..be53fdfde 100644 --- a/db/db_compaction_test.cc +++ b/db/db_compaction_test.cc @@ -1227,6 +1227,7 @@ TEST_F(DBCompactionTest, L0_CompactionBug_Issue44_b) { TEST_P(DBCompactionTestWithParam, ManualCompaction) { Options options = CurrentOptions(); options.max_subcompactions = max_subcompactions_; + options.statistics = rocksdb::CreateDBStatistics(); CreateAndReopenWithCF({"pikachu"}, options); // iter - 0 with 7 levels @@ -1258,7 +1259,14 @@ TEST_P(DBCompactionTestWithParam, ManualCompaction) { // Compact all MakeTables(1, "a", "z", 1); ASSERT_EQ("1,0,2", FilesPerLevel(1)); + + uint64_t prev_block_cache_add = + options.statistics->getTickerCount(BLOCK_CACHE_ADD); db_->CompactRange(CompactRangeOptions(), handles_[1], nullptr, nullptr); + // Verify manual compaction doesn't fill block cache + ASSERT_EQ(prev_block_cache_add, + options.statistics->getTickerCount(BLOCK_CACHE_ADD)); + ASSERT_EQ("0,0,1", FilesPerLevel(1)); if (iter == 0) { @@ -1266,6 +1274,7 @@ TEST_P(DBCompactionTestWithParam, ManualCompaction) { options.max_background_flushes = 0; options.num_levels = 3; options.create_if_missing = true; + options.statistics = rocksdb::CreateDBStatistics(); DestroyAndReopen(options); CreateAndReopenWithCF({"pikachu"}, options); }