Fix unit tests errors

Summary: Those were introduced with 2fb1fea30f 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
This commit is contained in:
Igor Canadi 2014-09-18 13:32:44 -07:00
parent 51af7c326c
commit 90b8c07b48
4 changed files with 29 additions and 6 deletions

View File

@ -332,6 +332,9 @@ TEST(CorruptionTest, CorruptedDescriptor) {
} }
TEST(CorruptionTest, CompactionInputError) { TEST(CorruptionTest, CompactionInputError) {
Options options;
options.max_background_flushes = 0;
Reopen(&options);
Build(10); Build(10);
DBImpl* dbi = reinterpret_cast<DBImpl*>(db_); DBImpl* dbi = reinterpret_cast<DBImpl*>(db_);
dbi->TEST_FlushMemTable(); dbi->TEST_FlushMemTable();
@ -351,6 +354,7 @@ TEST(CorruptionTest, CompactionInputErrorParanoid) {
options.paranoid_checks = true; options.paranoid_checks = true;
options.write_buffer_size = 131072; options.write_buffer_size = 131072;
options.max_write_buffer_number = 2; options.max_write_buffer_number = 2;
options.max_background_flushes = 0;
Reopen(&options); Reopen(&options);
DBImpl* dbi = reinterpret_cast<DBImpl*>(db_); DBImpl* dbi = reinterpret_cast<DBImpl*>(db_);

View File

@ -1325,6 +1325,7 @@ TEST(DBTest, IndexAndFilterBlocksOfNewTableAddedToCache) {
TEST(DBTest, GetPropertiesOfAllTablesTest) { TEST(DBTest, GetPropertiesOfAllTablesTest) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.max_background_flushes = 0;
Reopen(&options); Reopen(&options);
// Create 4 tables // Create 4 tables
for (int table = 0; table < 4; ++table) { for (int table = 0; table < 4; ++table) {
@ -1520,7 +1521,10 @@ TEST(DBTest, GetPicksCorrectFile) {
TEST(DBTest, GetEncountersEmptyLevel) { TEST(DBTest, GetEncountersEmptyLevel) {
do { do {
CreateAndReopenWithCF({"pikachu"}); Options options = CurrentOptions();
options.max_background_flushes = 0;
options.disableDataSync = true;
CreateAndReopenWithCF({"pikachu"}, &options);
// Arrange for the following to happen: // Arrange for the following to happen:
// * sstable A in level 0 // * sstable A in level 0
// * nothing in level 1 // * nothing in level 1
@ -5124,7 +5128,9 @@ TEST(DBTest, Snapshot) {
TEST(DBTest, HiddenValuesAreRemoved) { TEST(DBTest, HiddenValuesAreRemoved) {
do { do {
CreateAndReopenWithCF({"pikachu"}); Options options = CurrentOptions();
options.max_background_flushes = 0;
CreateAndReopenWithCF({"pikachu"}, &options);
Random rnd(301); Random rnd(301);
FillLevels("a", "z", 1); FillLevels("a", "z", 1);
@ -5215,7 +5221,9 @@ TEST(DBTest, CompactBetweenSnapshots) {
} }
TEST(DBTest, DeletionMarkers1) { TEST(DBTest, DeletionMarkers1) {
CreateAndReopenWithCF({"pikachu"}); Options options = CurrentOptions();
options.max_background_flushes = 0;
CreateAndReopenWithCF({"pikachu"}, &options);
Put(1, "foo", "v1"); Put(1, "foo", "v1");
ASSERT_OK(Flush(1)); ASSERT_OK(Flush(1));
const int last = CurrentOptions().max_mem_compaction_level; const int last = CurrentOptions().max_mem_compaction_level;
@ -5250,7 +5258,9 @@ TEST(DBTest, DeletionMarkers1) {
} }
TEST(DBTest, DeletionMarkers2) { TEST(DBTest, DeletionMarkers2) {
CreateAndReopenWithCF({"pikachu"}); Options options = CurrentOptions();
options.max_background_flushes = 0;
CreateAndReopenWithCF({"pikachu"}, &options);
Put(1, "foo", "v1"); Put(1, "foo", "v1");
ASSERT_OK(Flush(1)); ASSERT_OK(Flush(1));
const int last = CurrentOptions().max_mem_compaction_level; const int last = CurrentOptions().max_mem_compaction_level;
@ -5279,7 +5289,9 @@ TEST(DBTest, DeletionMarkers2) {
TEST(DBTest, OverlapInLevel0) { TEST(DBTest, OverlapInLevel0) {
do { do {
CreateAndReopenWithCF({"pikachu"}); Options options = CurrentOptions();
options.max_background_flushes = 0;
CreateAndReopenWithCF({"pikachu"}, &options);
int tmp = CurrentOptions().max_mem_compaction_level; int tmp = CurrentOptions().max_mem_compaction_level;
ASSERT_EQ(tmp, 2) << "Fix test to match config"; ASSERT_EQ(tmp, 2) << "Fix test to match config";
@ -5457,7 +5469,9 @@ TEST(DBTest, CustomComparator) {
} }
TEST(DBTest, ManualCompaction) { TEST(DBTest, ManualCompaction) {
CreateAndReopenWithCF({"pikachu"}); Options options = CurrentOptions();
options.max_background_flushes = 0;
CreateAndReopenWithCF({"pikachu"}, &options);
ASSERT_EQ(dbfull()->MaxMemCompactionLevel(), 2) ASSERT_EQ(dbfull()->MaxMemCompactionLevel(), 2)
<< "Need to update this test to match kMaxMemCompactLevel"; << "Need to update this test to match kMaxMemCompactLevel";
@ -5495,6 +5509,7 @@ TEST(DBTest, ManualCompaction) {
if (iter == 0) { if (iter == 0) {
Options options = CurrentOptions(); Options options = CurrentOptions();
options.max_background_flushes = 0;
options.num_levels = 3; options.num_levels = 3;
options.create_if_missing = true; options.create_if_missing = true;
DestroyAndReopen(&options); DestroyAndReopen(&options);
@ -5594,6 +5609,7 @@ TEST(DBTest, DBOpen_Options) {
TEST(DBTest, DBOpen_Change_NumLevels) { TEST(DBTest, DBOpen_Change_NumLevels) {
Options opts; Options opts;
opts.create_if_missing = true; opts.create_if_missing = true;
opts.max_background_flushes = 0;
DestroyAndReopen(&opts); DestroyAndReopen(&opts);
ASSERT_TRUE(db_ != nullptr); ASSERT_TRUE(db_ != nullptr);
CreateAndReopenWithCF({"pikachu"}, &opts); CreateAndReopenWithCF({"pikachu"}, &opts);
@ -5777,6 +5793,7 @@ TEST(DBTest, ManifestWriteError) {
options.env = env_; options.env = env_;
options.create_if_missing = true; options.create_if_missing = true;
options.error_if_exists = false; options.error_if_exists = false;
options.max_background_flushes = 0;
DestroyAndReopen(&options); DestroyAndReopen(&options);
ASSERT_OK(Put("foo", "bar")); ASSERT_OK(Put("foo", "bar"));
ASSERT_EQ("bar", Get("foo")); ASSERT_EQ("bar", Get("foo"));

View File

@ -34,6 +34,7 @@ class DeleteFileTest {
DeleteFileTest() { DeleteFileTest() {
db_ = nullptr; db_ = nullptr;
env_ = Env::Default(); env_ = Env::Default();
options_.max_background_flushes = 0;
options_.write_buffer_size = 1024*1024*1000; options_.write_buffer_size = 1024*1024*1000;
options_.target_file_size_base = 1024*1024*1000; options_.target_file_size_base = 1024*1024*1000;
options_.max_bytes_for_level_base = 1024*1024*1000; options_.max_bytes_for_level_base = 1024*1024*1000;

View File

@ -76,6 +76,7 @@ Status ReduceLevelTest::OpenDB(bool create_if_missing, int num_levels,
opt.num_levels = num_levels; opt.num_levels = num_levels;
opt.create_if_missing = create_if_missing; opt.create_if_missing = create_if_missing;
opt.max_mem_compaction_level = mem_table_compact_level; opt.max_mem_compaction_level = mem_table_compact_level;
opt.max_background_flushes = 0;
rocksdb::Status st = rocksdb::DB::Open(opt, dbname_, &db_); rocksdb::Status st = rocksdb::DB::Open(opt, dbname_, &db_);
if (!st.ok()) { if (!st.ok()) {
fprintf(stderr, "Can't open the db:%s\n", st.ToString().c_str()); fprintf(stderr, "Can't open the db:%s\n", st.ToString().c_str());