Skip to content

Commit

Permalink
Fix unit tests errors
Browse files Browse the repository at this point in the history
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
  • Loading branch information
igorcanadi committed Sep 18, 2014
1 parent 51af7c3 commit 90b8c07
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
4 changes: 4 additions & 0 deletions db/corruption_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ TEST(CorruptionTest, CorruptedDescriptor) {
}

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

Expand Down
29 changes: 23 additions & 6 deletions db/db_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,7 @@ TEST(DBTest, IndexAndFilterBlocksOfNewTableAddedToCache) {

TEST(DBTest, GetPropertiesOfAllTablesTest) {
Options options = CurrentOptions();
options.max_background_flushes = 0;
Reopen(&options);
// Create 4 tables
for (int table = 0; table < 4; ++table) {
Expand Down Expand Up @@ -1520,7 +1521,10 @@ TEST(DBTest, GetPicksCorrectFile) {

TEST(DBTest, GetEncountersEmptyLevel) {
do {
CreateAndReopenWithCF({"pikachu"});
Options options = CurrentOptions();
options.max_background_flushes = 0;
options.disableDataSync = true;
CreateAndReopenWithCF({"pikachu"}, &options);
// Arrange for the following to happen:
// * sstable A in level 0
// * nothing in level 1
Expand Down Expand Up @@ -5124,7 +5128,9 @@ TEST(DBTest, Snapshot) {

TEST(DBTest, HiddenValuesAreRemoved) {
do {
CreateAndReopenWithCF({"pikachu"});
Options options = CurrentOptions();
options.max_background_flushes = 0;
CreateAndReopenWithCF({"pikachu"}, &options);
Random rnd(301);
FillLevels("a", "z", 1);

Expand Down Expand Up @@ -5215,7 +5221,9 @@ TEST(DBTest, CompactBetweenSnapshots) {
}

TEST(DBTest, DeletionMarkers1) {
CreateAndReopenWithCF({"pikachu"});
Options options = CurrentOptions();
options.max_background_flushes = 0;
CreateAndReopenWithCF({"pikachu"}, &options);
Put(1, "foo", "v1");
ASSERT_OK(Flush(1));
const int last = CurrentOptions().max_mem_compaction_level;
Expand Down Expand Up @@ -5250,7 +5258,9 @@ TEST(DBTest, DeletionMarkers1) {
}

TEST(DBTest, DeletionMarkers2) {
CreateAndReopenWithCF({"pikachu"});
Options options = CurrentOptions();
options.max_background_flushes = 0;
CreateAndReopenWithCF({"pikachu"}, &options);
Put(1, "foo", "v1");
ASSERT_OK(Flush(1));
const int last = CurrentOptions().max_mem_compaction_level;
Expand Down Expand Up @@ -5279,7 +5289,9 @@ TEST(DBTest, DeletionMarkers2) {

TEST(DBTest, OverlapInLevel0) {
do {
CreateAndReopenWithCF({"pikachu"});
Options options = CurrentOptions();
options.max_background_flushes = 0;
CreateAndReopenWithCF({"pikachu"}, &options);
int tmp = CurrentOptions().max_mem_compaction_level;
ASSERT_EQ(tmp, 2) << "Fix test to match config";

Expand Down Expand Up @@ -5457,7 +5469,9 @@ TEST(DBTest, CustomComparator) {
}

TEST(DBTest, ManualCompaction) {
CreateAndReopenWithCF({"pikachu"});
Options options = CurrentOptions();
options.max_background_flushes = 0;
CreateAndReopenWithCF({"pikachu"}, &options);
ASSERT_EQ(dbfull()->MaxMemCompactionLevel(), 2)
<< "Need to update this test to match kMaxMemCompactLevel";

Expand Down Expand Up @@ -5495,6 +5509,7 @@ TEST(DBTest, ManualCompaction) {

if (iter == 0) {
Options options = CurrentOptions();
options.max_background_flushes = 0;
options.num_levels = 3;
options.create_if_missing = true;
DestroyAndReopen(&options);
Expand Down Expand Up @@ -5594,6 +5609,7 @@ TEST(DBTest, DBOpen_Options) {
TEST(DBTest, DBOpen_Change_NumLevels) {
Options opts;
opts.create_if_missing = true;
opts.max_background_flushes = 0;
DestroyAndReopen(&opts);
ASSERT_TRUE(db_ != nullptr);
CreateAndReopenWithCF({"pikachu"}, &opts);
Expand Down Expand Up @@ -5777,6 +5793,7 @@ TEST(DBTest, ManifestWriteError) {
options.env = env_;
options.create_if_missing = true;
options.error_if_exists = false;
options.max_background_flushes = 0;
DestroyAndReopen(&options);
ASSERT_OK(Put("foo", "bar"));
ASSERT_EQ("bar", Get("foo"));
Expand Down
1 change: 1 addition & 0 deletions db/deletefile_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DeleteFileTest {
DeleteFileTest() {
db_ = nullptr;
env_ = Env::Default();
options_.max_background_flushes = 0;
options_.write_buffer_size = 1024*1024*1000;
options_.target_file_size_base = 1024*1024*1000;
options_.max_bytes_for_level_base = 1024*1024*1000;
Expand Down
1 change: 1 addition & 0 deletions tools/reduce_levels_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Status ReduceLevelTest::OpenDB(bool create_if_missing, int num_levels,
opt.num_levels = num_levels;
opt.create_if_missing = create_if_missing;
opt.max_mem_compaction_level = mem_table_compact_level;
opt.max_background_flushes = 0;
rocksdb::Status st = rocksdb::DB::Open(opt, dbname_, &db_);
if (!st.ok()) {
fprintf(stderr, "Can't open the db:%s\n", st.ToString().c_str());
Expand Down

0 comments on commit 90b8c07

Please sign in to comment.