|
|
@ -500,7 +500,8 @@ TEST_F(OptionsUtilTest, LoadLatestOptions) { |
|
|
|
static void WriteOptionsFile(Env* env, const std::string& path, |
|
|
|
static void WriteOptionsFile(Env* env, const std::string& path, |
|
|
|
const std::string& options_file, int major, |
|
|
|
const std::string& options_file, int major, |
|
|
|
int minor, const std::string& db_opts, |
|
|
|
int minor, const std::string& db_opts, |
|
|
|
const std::string& cf_opts) { |
|
|
|
const std::string& cf_opts, |
|
|
|
|
|
|
|
const std::string& bbt_opts = "") { |
|
|
|
std::string options_file_header = |
|
|
|
std::string options_file_header = |
|
|
|
"\n" |
|
|
|
"\n" |
|
|
|
"[Version]\n" |
|
|
|
"[Version]\n" |
|
|
@ -516,6 +517,8 @@ static void WriteOptionsFile(Env* env, const std::string& path, |
|
|
|
ASSERT_OK(wf->Append( |
|
|
|
ASSERT_OK(wf->Append( |
|
|
|
"[CFOptions \"default\"] # column family must be specified\n" + |
|
|
|
"[CFOptions \"default\"] # column family must be specified\n" + |
|
|
|
cf_opts + "\n")); |
|
|
|
cf_opts + "\n")); |
|
|
|
|
|
|
|
ASSERT_OK(wf->Append("[TableOptions/BlockBasedTable \"default\"]\n" + |
|
|
|
|
|
|
|
bbt_opts + "\n")); |
|
|
|
ASSERT_OK(wf->Close()); |
|
|
|
ASSERT_OK(wf->Close()); |
|
|
|
|
|
|
|
|
|
|
|
std::string latest_options_file; |
|
|
|
std::string latest_options_file; |
|
|
@ -567,9 +570,20 @@ TEST_F(OptionsUtilTest, BadLatestOptions) { |
|
|
|
s = LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs); |
|
|
|
s = LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs); |
|
|
|
ASSERT_NOK(s); |
|
|
|
ASSERT_NOK(s); |
|
|
|
ASSERT_TRUE(s.IsInvalidArgument()); |
|
|
|
ASSERT_TRUE(s.IsInvalidArgument()); |
|
|
|
|
|
|
|
// Write an options file for a previous minor release with an unknown BBT
|
|
|
|
|
|
|
|
// Option
|
|
|
|
|
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0003", ROCKSDB_MAJOR, |
|
|
|
|
|
|
|
ROCKSDB_MINOR - 1, "", "", "unknown_bbt_opt=true"); |
|
|
|
|
|
|
|
s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs); |
|
|
|
|
|
|
|
ASSERT_NOK(s); |
|
|
|
|
|
|
|
ASSERT_TRUE(s.IsInvalidArgument()); |
|
|
|
|
|
|
|
// Even though ignore_unknown_options=true, we still return an error...
|
|
|
|
|
|
|
|
s = LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs); |
|
|
|
|
|
|
|
ASSERT_NOK(s); |
|
|
|
|
|
|
|
ASSERT_TRUE(s.IsInvalidArgument()); |
|
|
|
|
|
|
|
|
|
|
|
// Write an options file for the current release with an unknown DB Option
|
|
|
|
// Write an options file for the current release with an unknown DB Option
|
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0003", ROCKSDB_MAJOR, |
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0004", ROCKSDB_MAJOR, |
|
|
|
ROCKSDB_MINOR, "unknown_db_opt=true", ""); |
|
|
|
ROCKSDB_MINOR, "unknown_db_opt=true", ""); |
|
|
|
s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs); |
|
|
|
s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs); |
|
|
|
ASSERT_NOK(s); |
|
|
|
ASSERT_NOK(s); |
|
|
@ -580,7 +594,7 @@ TEST_F(OptionsUtilTest, BadLatestOptions) { |
|
|
|
ASSERT_TRUE(s.IsInvalidArgument()); |
|
|
|
ASSERT_TRUE(s.IsInvalidArgument()); |
|
|
|
|
|
|
|
|
|
|
|
// Write an options file for the current release with an unknown CF Option
|
|
|
|
// Write an options file for the current release with an unknown CF Option
|
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0004", ROCKSDB_MAJOR, |
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0005", ROCKSDB_MAJOR, |
|
|
|
ROCKSDB_MINOR, "", "unknown_cf_opt=true"); |
|
|
|
ROCKSDB_MINOR, "", "unknown_cf_opt=true"); |
|
|
|
s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs); |
|
|
|
s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs); |
|
|
|
ASSERT_NOK(s); |
|
|
|
ASSERT_NOK(s); |
|
|
@ -591,7 +605,7 @@ TEST_F(OptionsUtilTest, BadLatestOptions) { |
|
|
|
ASSERT_TRUE(s.IsInvalidArgument()); |
|
|
|
ASSERT_TRUE(s.IsInvalidArgument()); |
|
|
|
|
|
|
|
|
|
|
|
// Write an options file for the current release with an invalid DB Option
|
|
|
|
// Write an options file for the current release with an invalid DB Option
|
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0005", ROCKSDB_MAJOR, |
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0006", ROCKSDB_MAJOR, |
|
|
|
ROCKSDB_MINOR, "create_if_missing=hello", ""); |
|
|
|
ROCKSDB_MINOR, "create_if_missing=hello", ""); |
|
|
|
s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs); |
|
|
|
s = LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs); |
|
|
|
ASSERT_NOK(s); |
|
|
|
ASSERT_NOK(s); |
|
|
@ -602,20 +616,20 @@ TEST_F(OptionsUtilTest, BadLatestOptions) { |
|
|
|
ASSERT_TRUE(s.IsInvalidArgument()); |
|
|
|
ASSERT_TRUE(s.IsInvalidArgument()); |
|
|
|
|
|
|
|
|
|
|
|
// Write an options file for the next release with an invalid DB Option
|
|
|
|
// Write an options file for the next release with an invalid DB Option
|
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0006", ROCKSDB_MAJOR, |
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0007", ROCKSDB_MAJOR, |
|
|
|
ROCKSDB_MINOR + 1, "create_if_missing=hello", ""); |
|
|
|
ROCKSDB_MINOR + 1, "create_if_missing=hello", ""); |
|
|
|
ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs)); |
|
|
|
ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs)); |
|
|
|
ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs)); |
|
|
|
ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs)); |
|
|
|
|
|
|
|
|
|
|
|
// Write an options file for the next release with an unknown DB Option
|
|
|
|
// Write an options file for the next release with an unknown DB Option
|
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0007", ROCKSDB_MAJOR, |
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0008", ROCKSDB_MAJOR, |
|
|
|
ROCKSDB_MINOR + 1, "unknown_db_opt=true", ""); |
|
|
|
ROCKSDB_MINOR + 1, "unknown_db_opt=true", ""); |
|
|
|
ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs)); |
|
|
|
ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs)); |
|
|
|
// Ignore the errors for future releases when ignore_unknown_options=true
|
|
|
|
// Ignore the errors for future releases when ignore_unknown_options=true
|
|
|
|
ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs)); |
|
|
|
ASSERT_OK(LoadLatestOptions(ignore_opts, dbname_, &db_opts, &cf_descs)); |
|
|
|
|
|
|
|
|
|
|
|
// Write an options file for the next major release with an unknown CF Option
|
|
|
|
// Write an options file for the next major release with an unknown CF Option
|
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0008", ROCKSDB_MAJOR + 1, |
|
|
|
WriteOptionsFile(options.env, dbname_, "OPTIONS-0009", ROCKSDB_MAJOR + 1, |
|
|
|
ROCKSDB_MINOR, "", "unknown_cf_opt=true"); |
|
|
|
ROCKSDB_MINOR, "", "unknown_cf_opt=true"); |
|
|
|
ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs)); |
|
|
|
ASSERT_NOK(LoadLatestOptions(config_opts, dbname_, &db_opts, &cf_descs)); |
|
|
|
// Ignore the errors for future releases when ignore_unknown_options=true
|
|
|
|
// Ignore the errors for future releases when ignore_unknown_options=true
|
|
|
|