add a test case to make sure chaning num_levels will fail Summary:

Summary: as subject

Test Plan: db_test

Reviewers: dhruba, MarkCallaghan

Reviewed By: MarkCallaghan

Differential Revision: https://reviews.facebook.net/D6303
This commit is contained in:
heyongqiang 2012-10-29 15:25:01 -07:00
parent 321dfdc3ae
commit 925f60d39d

View File

@ -1682,6 +1682,28 @@ TEST(DBTest, DBOpen_Options) {
db = NULL;
}
TEST(DBTest, DBOpen_Change_NumLevels) {
std::string dbname = test::TmpDir() + "/db_change_num_levels";
DestroyDB(dbname, Options());
Options opts;
Status s;
opts.create_if_missing = true;
s = DB::Open(opts, dbname, &db_);
ASSERT_OK(s);
ASSERT_TRUE(db_ != NULL);
db_->Put(WriteOptions(), "a", "123");
db_->Put(WriteOptions(), "b", "234");
db_->CompactRange(NULL, NULL);
delete db_;
db_ = NULL;
opts.create_if_missing = false;
opts.num_levels = 2;
s = DB::Open(opts, dbname, &db_);
ASSERT_TRUE(strstr(s.ToString().c_str(), "Corruption") != NULL);
ASSERT_TRUE(db_ == NULL);
}
// Check that number of files does not grow when we are out of space
TEST(DBTest, NoSpace) {
Options options = CurrentOptions();