From 9d115d3689f9b6b7fd85dae528918e19311ab5ba Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Wed, 13 Sep 2017 11:48:16 -0700 Subject: [PATCH] regression test for missing init options Summary: test the `DBOptions(const Options&)` and `ColumnFamilyOptions(const Options&)` constructors. Actually this'll work better once we refactor `RandomInitDBOptions` / `RandomInitCFOptions` to use the authoritative sources of struct members: `db_options_type_info` / `cf_options_type_info` (internal task T21804189 for this). Closes https://github.com/facebook/rocksdb/pull/2873 Differential Revision: D5817141 Pulled By: ajkr fbshipit-source-id: 8567c20feced9d1751fdf1f4383e2af30f7e3591 --- options/options_helper.h | 2 +- options/options_settable_test.cc | 2 +- options/options_test.cc | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/options/options_helper.h b/options/options_helper.h index 9586120391..cad57edf2a 100644 --- a/options/options_helper.h +++ b/options/options_helper.h @@ -414,7 +414,7 @@ static std::unordered_map cf_options_type_info = { OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}}, {"purge_redundant_kvs_while_flush", {offset_of(&ColumnFamilyOptions::purge_redundant_kvs_while_flush), - OptionType::kBoolean, OptionVerificationType::kNormal, false, 0}}, + OptionType::kBoolean, OptionVerificationType::kDeprecated, false, 0}}, {"verify_checksums_in_compaction", {0, OptionType::kBoolean, OptionVerificationType::kDeprecated, true, 0}}, {"soft_pending_compaction_bytes_limit", diff --git a/options/options_settable_test.cc b/options/options_settable_test.cc index ab9989fb46..eacfd90575 100644 --- a/options/options_settable_test.cc +++ b/options/options_settable_test.cc @@ -369,6 +369,7 @@ TEST_F(OptionsSettableTest, ColumnFamilyOptionsAllFieldsSettable) { options->compression_opts = CompressionOptions(); options->hard_rate_limit = 0; options->soft_rate_limit = 0; + options->purge_redundant_kvs_while_flush = false; options->compaction_options_fifo = CompactionOptionsFIFO(); options->max_mem_compaction_level = 0; @@ -423,7 +424,6 @@ TEST_F(OptionsSettableTest, ColumnFamilyOptionsAllFieldsSettable) { "inplace_update_support=false;" "compaction_style=kCompactionStyleFIFO;" "compaction_pri=kMinOverlappingRatio;" - "purge_redundant_kvs_while_flush=true;" "hard_pending_compaction_bytes_limit=0;" "disable_auto_compactions=false;" "report_bg_io_stats=true;", diff --git a/options/options_test.cc b/options/options_test.cc index fc4939beb4..55bb9605df 100644 --- a/options/options_test.cc +++ b/options/options_test.cc @@ -660,6 +660,24 @@ TEST_F(OptionsTest, DBOptionsSerialization) { ASSERT_OK(RocksDBOptionsParser::VerifyDBOptions(base_options, new_options)); } +TEST_F(OptionsTest, OptionsComposeDecompose) { + // build an Options from DBOptions + CFOptions, then decompose it to verify + // we get same constituent options. + DBOptions base_db_opts; + ColumnFamilyOptions base_cf_opts; + + Random rnd(301); + test::RandomInitDBOptions(&base_db_opts, &rnd); + test::RandomInitCFOptions(&base_cf_opts, &rnd); + + Options base_opts(base_db_opts, base_cf_opts); + DBOptions new_db_opts(base_opts); + ColumnFamilyOptions new_cf_opts(base_opts); + + ASSERT_OK(RocksDBOptionsParser::VerifyDBOptions(base_db_opts, new_db_opts)); + ASSERT_OK(RocksDBOptionsParser::VerifyCFOptions(base_cf_opts, new_cf_opts)); +} + TEST_F(OptionsTest, ColumnFamilyOptionsSerialization) { ColumnFamilyOptions base_opt, new_opt; Random rnd(302);