Skip to content

Commit 90b8c07

Browse files
committed
Fix unit tests errors
Summary: Those were introduced with facebook/rocksdb@2fb1fea because the flushing behavior changed when max_background_flushes is > 0. Test Plan: make check Reviewers: ljin, yhchiang, sdong Reviewed By: sdong Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D23577
1 parent 51af7c3 commit 90b8c07

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

db/corruption_test.cc

+4
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,9 @@ TEST(CorruptionTest, CorruptedDescriptor) {
332332
}
333333

334334
TEST(CorruptionTest, CompactionInputError) {
335+
Options options;
336+
options.max_background_flushes = 0;
337+
Reopen(&options);
335338
Build(10);
336339
DBImpl* dbi = reinterpret_cast<DBImpl*>(db_);
337340
dbi->TEST_FlushMemTable();
@@ -351,6 +354,7 @@ TEST(CorruptionTest, CompactionInputErrorParanoid) {
351354
options.paranoid_checks = true;
352355
options.write_buffer_size = 131072;
353356
options.max_write_buffer_number = 2;
357+
options.max_background_flushes = 0;
354358
Reopen(&options);
355359
DBImpl* dbi = reinterpret_cast<DBImpl*>(db_);
356360

db/db_test.cc

+23-6
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,7 @@ TEST(DBTest, IndexAndFilterBlocksOfNewTableAddedToCache) {
13251325

13261326
TEST(DBTest, GetPropertiesOfAllTablesTest) {
13271327
Options options = CurrentOptions();
1328+
options.max_background_flushes = 0;
13281329
Reopen(&options);
13291330
// Create 4 tables
13301331
for (int table = 0; table < 4; ++table) {
@@ -1520,7 +1521,10 @@ TEST(DBTest, GetPicksCorrectFile) {
15201521

15211522
TEST(DBTest, GetEncountersEmptyLevel) {
15221523
do {
1523-
CreateAndReopenWithCF({"pikachu"});
1524+
Options options = CurrentOptions();
1525+
options.max_background_flushes = 0;
1526+
options.disableDataSync = true;
1527+
CreateAndReopenWithCF({"pikachu"}, &options);
15241528
// Arrange for the following to happen:
15251529
// * sstable A in level 0
15261530
// * nothing in level 1
@@ -5124,7 +5128,9 @@ TEST(DBTest, Snapshot) {
51245128

51255129
TEST(DBTest, HiddenValuesAreRemoved) {
51265130
do {
5127-
CreateAndReopenWithCF({"pikachu"});
5131+
Options options = CurrentOptions();
5132+
options.max_background_flushes = 0;
5133+
CreateAndReopenWithCF({"pikachu"}, &options);
51285134
Random rnd(301);
51295135
FillLevels("a", "z", 1);
51305136

@@ -5215,7 +5221,9 @@ TEST(DBTest, CompactBetweenSnapshots) {
52155221
}
52165222

52175223
TEST(DBTest, DeletionMarkers1) {
5218-
CreateAndReopenWithCF({"pikachu"});
5224+
Options options = CurrentOptions();
5225+
options.max_background_flushes = 0;
5226+
CreateAndReopenWithCF({"pikachu"}, &options);
52195227
Put(1, "foo", "v1");
52205228
ASSERT_OK(Flush(1));
52215229
const int last = CurrentOptions().max_mem_compaction_level;
@@ -5250,7 +5258,9 @@ TEST(DBTest, DeletionMarkers1) {
52505258
}
52515259

52525260
TEST(DBTest, DeletionMarkers2) {
5253-
CreateAndReopenWithCF({"pikachu"});
5261+
Options options = CurrentOptions();
5262+
options.max_background_flushes = 0;
5263+
CreateAndReopenWithCF({"pikachu"}, &options);
52545264
Put(1, "foo", "v1");
52555265
ASSERT_OK(Flush(1));
52565266
const int last = CurrentOptions().max_mem_compaction_level;
@@ -5279,7 +5289,9 @@ TEST(DBTest, DeletionMarkers2) {
52795289

52805290
TEST(DBTest, OverlapInLevel0) {
52815291
do {
5282-
CreateAndReopenWithCF({"pikachu"});
5292+
Options options = CurrentOptions();
5293+
options.max_background_flushes = 0;
5294+
CreateAndReopenWithCF({"pikachu"}, &options);
52835295
int tmp = CurrentOptions().max_mem_compaction_level;
52845296
ASSERT_EQ(tmp, 2) << "Fix test to match config";
52855297

@@ -5457,7 +5469,9 @@ TEST(DBTest, CustomComparator) {
54575469
}
54585470

54595471
TEST(DBTest, ManualCompaction) {
5460-
CreateAndReopenWithCF({"pikachu"});
5472+
Options options = CurrentOptions();
5473+
options.max_background_flushes = 0;
5474+
CreateAndReopenWithCF({"pikachu"}, &options);
54615475
ASSERT_EQ(dbfull()->MaxMemCompactionLevel(), 2)
54625476
<< "Need to update this test to match kMaxMemCompactLevel";
54635477

@@ -5495,6 +5509,7 @@ TEST(DBTest, ManualCompaction) {
54955509

54965510
if (iter == 0) {
54975511
Options options = CurrentOptions();
5512+
options.max_background_flushes = 0;
54985513
options.num_levels = 3;
54995514
options.create_if_missing = true;
55005515
DestroyAndReopen(&options);
@@ -5594,6 +5609,7 @@ TEST(DBTest, DBOpen_Options) {
55945609
TEST(DBTest, DBOpen_Change_NumLevels) {
55955610
Options opts;
55965611
opts.create_if_missing = true;
5612+
opts.max_background_flushes = 0;
55975613
DestroyAndReopen(&opts);
55985614
ASSERT_TRUE(db_ != nullptr);
55995615
CreateAndReopenWithCF({"pikachu"}, &opts);
@@ -5777,6 +5793,7 @@ TEST(DBTest, ManifestWriteError) {
57775793
options.env = env_;
57785794
options.create_if_missing = true;
57795795
options.error_if_exists = false;
5796+
options.max_background_flushes = 0;
57805797
DestroyAndReopen(&options);
57815798
ASSERT_OK(Put("foo", "bar"));
57825799
ASSERT_EQ("bar", Get("foo"));

db/deletefile_test.cc

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class DeleteFileTest {
3434
DeleteFileTest() {
3535
db_ = nullptr;
3636
env_ = Env::Default();
37+
options_.max_background_flushes = 0;
3738
options_.write_buffer_size = 1024*1024*1000;
3839
options_.target_file_size_base = 1024*1024*1000;
3940
options_.max_bytes_for_level_base = 1024*1024*1000;

tools/reduce_levels_test.cc

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Status ReduceLevelTest::OpenDB(bool create_if_missing, int num_levels,
7676
opt.num_levels = num_levels;
7777
opt.create_if_missing = create_if_missing;
7878
opt.max_mem_compaction_level = mem_table_compact_level;
79+
opt.max_background_flushes = 0;
7980
rocksdb::Status st = rocksdb::DB::Open(opt, dbname_, &db_);
8081
if (!st.ok()) {
8182
fprintf(stderr, "Can't open the db:%s\n", st.ToString().c_str());

0 commit comments

Comments
 (0)