From d60ae5b1c7e70efd32c7b8ccd939fa0ecc94e9a2 Mon Sep 17 00:00:00 2001 From: Jay Zhuang Date: Mon, 14 Jun 2021 08:10:37 -0700 Subject: [PATCH] Fix flaky ManualCompactionMax test (#8396) Summary: Recalculate the total size after generate new sst files. New generated files might have different size as the previous time which could cause the test failed. Pull Request resolved: https://github.com/facebook/rocksdb/pull/8396 Test Plan: ``` gtest-parallel ./db_compaction_test --gtest_filter=DBCompactionTest.ManualCompactionMax -r 1000 -w 100 ``` Reviewed By: akankshamahajan15 Differential Revision: D29083299 Pulled By: jay-zhuang fbshipit-source-id: 49d4bd619cefc0f9a1f452f8759ff4c2ba1b6fdb --- db/db_compaction_test.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/db/db_compaction_test.cc b/db/db_compaction_test.cc index 37bea4ab1f..98836d4275 100644 --- a/db/db_compaction_test.cc +++ b/db/db_compaction_test.cc @@ -5208,11 +5208,12 @@ TEST_F(DBCompactionTest, ManualCompactionMax) { ASSERT_TRUE(num_compactions.load() == 1); // split the compaction to 5 - uint64_t total = (l1_avg_size * 10) + (l2_avg_size * 100); int num_split = 5; - opts.max_compaction_bytes = total / num_split; DestroyAndReopen(opts); generate_sst_func(); + uint64_t total_size = (l1_avg_size * 10) + (l2_avg_size * 100); + opts.max_compaction_bytes = total_size / num_split; + Reopen(opts); num_compactions.store(0); ASSERT_OK(db_->CompactRange(cro, nullptr, nullptr)); ASSERT_TRUE(num_compactions.load() == num_split); @@ -5230,8 +5231,9 @@ TEST_F(DBCompactionTest, ManualCompactionMax) { opts.max_compaction_bytes = 0; DestroyAndReopen(opts); generate_sst_func(); + total_size = (l1_avg_size * 10) + (l2_avg_size * 100); Status s = db_->SetOptions( - {{"max_compaction_bytes", std::to_string(total / num_split)}}); + {{"max_compaction_bytes", std::to_string(total_size / num_split)}}); ASSERT_OK(s); num_compactions.store(0);