diff --git a/db/db_test.cc b/db/db_test.cc index e5a8f87118e59f20f2185b6a0d9248c72e7a7e61..6c8bba8684a4b44d03414caf81a8bf31ac6d2522 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -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();