From ec101cd49a8ba328dc0ae8e28d9bf088019300b4 Mon Sep 17 00:00:00 2001 From: Jonah Cohen Date: Thu, 6 Nov 2014 17:28:49 -0800 Subject: [PATCH] Correctly test both compaction styles in CompactionDeletionTriggerReopen Summary: CompactionDeletionTriggerReopen wasn't actually testing universal compaction. Test Plan: db_test Reviewers: sdong, igor Reviewed By: igor Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D28443 --- db/db_test.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index 8ddaa0c7c..091e373fa 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -3157,10 +3157,15 @@ Options DeletionTriggerOptions() { } // anonymous namespace TEST(DBTest, CompactionDeletionTrigger) { - Options options = CurrentOptions(DeletionTriggerOptions()); - for (int tid = 0; tid < 2; ++tid) { uint64_t db_size[2]; + Options options = CurrentOptions(DeletionTriggerOptions()); + + if (tid == 1) { + // second pass with universal compaction + options.compaction_style = kCompactionStyleUniversal; + options.num_levels = 1; + } DestroyAndReopen(options); Random rnd(301); @@ -3184,10 +3189,6 @@ TEST(DBTest, CompactionDeletionTrigger) { // must have much smaller db size. ASSERT_GT(db_size[0] / 3, db_size[1]); - - // repeat the test with universal compaction - options.compaction_style = kCompactionStyleUniversal; - options.num_levels = 1; } } @@ -3196,6 +3197,12 @@ TEST(DBTest, CompactionDeletionTriggerReopen) { uint64_t db_size[3]; Options options = CurrentOptions(DeletionTriggerOptions()); + if (tid == 1) { + // second pass with universal compaction + options.compaction_style = kCompactionStyleUniversal; + options.num_levels = 1; + } + DestroyAndReopen(options); Random rnd(301); @@ -3238,10 +3245,6 @@ TEST(DBTest, CompactionDeletionTriggerReopen) { db_size[2] = Size(Key(0), Key(kTestSize - 1)); // this time we're expecting significant drop in size. ASSERT_GT(db_size[0] / 3, db_size[2]); - - // repeat the test with universal compaction - options.compaction_style = kCompactionStyleUniversal; - options.num_levels = 1; } }