Skip to content

Commit

Permalink
Fix flaky ManualCompactionMax test (facebook#8396)
Browse files Browse the repository at this point in the history
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: facebook#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
  • Loading branch information
jay-zhuang authored and facebook-github-bot committed Jun 14, 2021
1 parent 0d0aa57 commit d60ae5b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions db/db_compaction_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit d60ae5b

Please sign in to comment.