DBTablePropertiesTest.GetPropertiesOfTablesInRange: Fix Flaky

Summary:
Summary
There is a possibility that there is no L0 file after writing the data. Generate an L0 file to make it work.

Test Plan: Run the test many times.

Reviewers: andrewkr, yiwu

Reviewed By: yiwu

Subscribers: leveldb, andrewkr, dhruba

Differential Revision: https://reviews.facebook.net/D60825
This commit is contained in:
sdong 2016-07-15 10:51:59 -07:00
parent d9cfaa2b16
commit 2a282e5f54

View File

@ -138,14 +138,14 @@ TEST_F(DBTablePropertiesTest, GetPropertiesOfTablesInRange) {
Options options; Options options;
options.create_if_missing = true; options.create_if_missing = true;
options.write_buffer_size = 4096; options.write_buffer_size = 4096;
options.max_write_buffer_number = 8; options.max_write_buffer_number = 3;
options.level0_file_num_compaction_trigger = 2; options.level0_file_num_compaction_trigger = 2;
options.level0_slowdown_writes_trigger = 2; options.level0_slowdown_writes_trigger = 2;
options.level0_stop_writes_trigger = 4; options.level0_stop_writes_trigger = 4;
options.target_file_size_base = 2048; options.target_file_size_base = 2048;
options.max_bytes_for_level_base = 10240; options.max_bytes_for_level_base = 10240;
options.max_bytes_for_level_multiplier = 4; options.max_bytes_for_level_multiplier = 4;
options.soft_rate_limit = 1.1; options.hard_pending_compaction_bytes_limit = 16 * 1024;
options.num_levels = 8; options.num_levels = 8;
DestroyAndReopen(options); DestroyAndReopen(options);
@ -155,6 +155,12 @@ TEST_F(DBTablePropertiesTest, GetPropertiesOfTablesInRange) {
ASSERT_OK(Put(test::RandomKey(&rnd, 5), RandomString(&rnd, 102))); ASSERT_OK(Put(test::RandomKey(&rnd, 5), RandomString(&rnd, 102)));
} }
Flush(); Flush();
dbfull()->TEST_WaitForCompact();
if (NumTableFilesAtLevel(0) == 0) {
ASSERT_OK(Put(test::RandomKey(&rnd, 5), RandomString(&rnd, 102)));
Flush();
}
db_->PauseBackgroundWork(); db_->PauseBackgroundWork();
// Ensure that we have at least L0, L1 and L2 // Ensure that we have at least L0, L1 and L2