@ -304,8 +304,11 @@ TEST_F(OptionsTest, GetOptionsFromMapTest) {
ASSERT_EQ ( new_db_opt . strict_bytes_per_sync , true ) ;
ASSERT_EQ ( new_db_opt . strict_bytes_per_sync , true ) ;
db_options_map [ " max_open_files " ] = " hello " ;
db_options_map [ " max_open_files " ] = " hello " ;
ASSERT_NOK (
Status s =
GetDBOptionsFromMap ( exact , base_db_opt , db_options_map , & new_db_opt ) ) ;
GetDBOptionsFromMap ( exact , base_db_opt , db_options_map , & new_db_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_OK (
ASSERT_OK (
RocksDBOptionsParser : : VerifyDBOptions ( exact , base_db_opt , new_db_opt ) ) ;
RocksDBOptionsParser : : VerifyDBOptions ( exact , base_db_opt , new_db_opt ) ) ;
ASSERT_OK (
ASSERT_OK (
@ -313,8 +316,9 @@ TEST_F(OptionsTest, GetOptionsFromMapTest) {
// unknow options should fail parsing without ignore_unknown_options = true
// unknow options should fail parsing without ignore_unknown_options = true
db_options_map [ " unknown_db_option " ] = " 1 " ;
db_options_map [ " unknown_db_option " ] = " 1 " ;
ASSERT_NOK (
s = GetDBOptionsFromMap ( exact , base_db_opt , db_options_map , & new_db_opt ) ;
GetDBOptionsFromMap ( exact , base_db_opt , db_options_map , & new_db_opt ) ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_OK (
ASSERT_OK (
RocksDBOptionsParser : : VerifyDBOptions ( exact , base_db_opt , new_db_opt ) ) ;
RocksDBOptionsParser : : VerifyDBOptions ( exact , base_db_opt , new_db_opt ) ) ;
@ -399,22 +403,29 @@ TEST_F(OptionsTest, GetColumnFamilyOptionsFromStringTest) {
ASSERT_EQ ( kMoName , std : : string ( new_cf_opt . merge_operator - > Name ( ) ) ) ;
ASSERT_EQ ( kMoName , std : : string ( new_cf_opt . merge_operator - > Name ( ) ) ) ;
// Wrong key/value pair
// Wrong key/value pair
ASSERT_NOK ( GetColumnFamilyOptionsFromString (
Status s = GetColumnFamilyOptionsFromString (
config_options , base_cf_opt ,
config_options , base_cf_opt ,
" write_buffer_size=13;max_write_buffer_number; " , & new_cf_opt ) ) ;
" write_buffer_size=13;max_write_buffer_number; " , & new_cf_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_OK ( RocksDBOptionsParser : : VerifyCFOptions ( config_options , base_cf_opt ,
ASSERT_OK ( RocksDBOptionsParser : : VerifyCFOptions ( config_options , base_cf_opt ,
new_cf_opt ) ) ;
new_cf_opt ) ) ;
// Error Paring value
// Error Pars ing value
ASSERT_NOK ( GetColumnFamilyOptionsFromString (
s = GetColumnFamilyOptionsFromString (
config_options , base_cf_opt ,
config_options , base_cf_opt ,
" write_buffer_size=13;max_write_buffer_number=; " , & new_cf_opt ) ) ;
" write_buffer_size=13;max_write_buffer_number=; " , & new_cf_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_OK ( RocksDBOptionsParser : : VerifyCFOptions ( config_options , base_cf_opt ,
ASSERT_OK ( RocksDBOptionsParser : : VerifyCFOptions ( config_options , base_cf_opt ,
new_cf_opt ) ) ;
new_cf_opt ) ) ;
// Missing option name
// Missing option name
ASSERT_NOK ( GetColumnFamilyOptionsFromString (
s = GetColumnFamilyOptionsFromString (
config_options , base_cf_opt , " write_buffer_size=13; =100; " , & new_cf_opt ) ) ;
config_options , base_cf_opt , " write_buffer_size=13; =100; " , & new_cf_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_OK ( RocksDBOptionsParser : : VerifyCFOptions ( config_options , base_cf_opt ,
ASSERT_OK ( RocksDBOptionsParser : : VerifyCFOptions ( config_options , base_cf_opt ,
new_cf_opt ) ) ;
new_cf_opt ) ) ;
@ -787,7 +798,10 @@ TEST_F(OptionsTest, OldInterfaceTest) {
ASSERT_EQ ( new_db_opt . track_and_verify_wals_in_manifest , true ) ;
ASSERT_EQ ( new_db_opt . track_and_verify_wals_in_manifest , true ) ;
ASSERT_EQ ( new_db_opt . max_open_files , 32 ) ;
ASSERT_EQ ( new_db_opt . max_open_files , 32 ) ;
db_options_map [ " unknown_option " ] = " 1 " ;
db_options_map [ " unknown_option " ] = " 1 " ;
ASSERT_NOK ( GetDBOptionsFromMap ( base_db_opt , db_options_map , & new_db_opt ) ) ;
Status s = GetDBOptionsFromMap ( base_db_opt , db_options_map , & new_db_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_OK (
ASSERT_OK (
RocksDBOptionsParser : : VerifyDBOptions ( exact , base_db_opt , new_db_opt ) ) ;
RocksDBOptionsParser : : VerifyDBOptions ( exact , base_db_opt , new_db_opt ) ) ;
ASSERT_OK ( GetDBOptionsFromMap ( base_db_opt , db_options_map , & new_db_opt , true ,
ASSERT_OK ( GetDBOptionsFromMap ( base_db_opt , db_options_map , & new_db_opt , true ,
@ -799,11 +813,13 @@ TEST_F(OptionsTest, OldInterfaceTest) {
ASSERT_EQ ( new_db_opt . create_if_missing , false ) ;
ASSERT_EQ ( new_db_opt . create_if_missing , false ) ;
ASSERT_EQ ( new_db_opt . error_if_exists , false ) ;
ASSERT_EQ ( new_db_opt . error_if_exists , false ) ;
ASSERT_EQ ( new_db_opt . max_open_files , 42 ) ;
ASSERT_EQ ( new_db_opt . max_open_files , 42 ) ;
ASSERT_NOK ( GetDBOptionsFromString (
s = GetDBOptionsFromString (
base_db_opt ,
base_db_opt ,
" create_if_missing=false;error_if_exists=false;max_open_files=42; "
" create_if_missing=false;error_if_exists=false;max_open_files=42; "
" unknown_option=1; " ,
" unknown_option=1; " ,
& new_db_opt ) ) ;
& new_db_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_OK (
ASSERT_OK (
RocksDBOptionsParser : : VerifyDBOptions ( exact , base_db_opt , new_db_opt ) ) ;
RocksDBOptionsParser : : VerifyDBOptions ( exact , base_db_opt , new_db_opt ) ) ;
}
}
@ -848,19 +864,23 @@ TEST_F(OptionsTest, GetBlockBasedTableOptionsFromString) {
EXPECT_EQ ( bfp . GetWholeBitsPerKey ( ) , 5 ) ;
EXPECT_EQ ( bfp . GetWholeBitsPerKey ( ) , 5 ) ;
// unknown option
// unknown option
ASSERT_NOK ( GetBlockBasedTableOptionsFromString (
Status s = GetBlockBasedTableOptionsFromString (
config_options , table_opt ,
config_options , table_opt ,
" cache_index_and_filter_blocks=1;index_type=kBinarySearch; "
" cache_index_and_filter_blocks=1;index_type=kBinarySearch; "
" bad_option=1 " ,
" bad_option=1 " ,
& new_opt ) ) ;
& new_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_EQ ( static_cast < bool > ( table_opt . cache_index_and_filter_blocks ) ,
ASSERT_EQ ( static_cast < bool > ( table_opt . cache_index_and_filter_blocks ) ,
new_opt . cache_index_and_filter_blocks ) ;
new_opt . cache_index_and_filter_blocks ) ;
ASSERT_EQ ( table_opt . index_type , new_opt . index_type ) ;
ASSERT_EQ ( table_opt . index_type , new_opt . index_type ) ;
// unrecognized index type
// unrecognized index type
ASSERT_NOK ( GetBlockBasedTableOptionsFromString (
s = GetBlockBasedTableOptionsFromString (
config_options , table_opt ,
config_options , table_opt ,
" cache_index_and_filter_blocks=1;index_type=kBinarySearchXX " , & new_opt ) ) ;
" cache_index_and_filter_blocks=1;index_type=kBinarySearchXX " , & new_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_EQ ( table_opt . cache_index_and_filter_blocks ,
ASSERT_EQ ( table_opt . cache_index_and_filter_blocks ,
new_opt . cache_index_and_filter_blocks ) ;
new_opt . cache_index_and_filter_blocks ) ;
ASSERT_EQ ( table_opt . index_type , new_opt . index_type ) ;
ASSERT_EQ ( table_opt . index_type , new_opt . index_type ) ;
@ -874,21 +894,23 @@ TEST_F(OptionsTest, GetBlockBasedTableOptionsFromString) {
ASSERT_EQ ( table_opt . index_type , new_opt . index_type ) ;
ASSERT_EQ ( table_opt . index_type , new_opt . index_type ) ;
// unrecognized filter policy name
// unrecognized filter policy name
ASSERT_NOK (
s = GetBlockBasedTableOptionsFromString ( config_options , table_opt ,
GetBlockBasedTableOptionsFromString ( config_options , table_opt ,
" cache_index_and_filter_blocks=1; "
" cache_index_and_filter_blocks=1; "
" filter_policy=bloomfilterxx:4:true " ,
" filter_policy=bloomfilterxx:4:true " ,
& new_opt ) ) ;
& new_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_EQ ( table_opt . cache_index_and_filter_blocks ,
ASSERT_EQ ( table_opt . cache_index_and_filter_blocks ,
new_opt . cache_index_and_filter_blocks ) ;
new_opt . cache_index_and_filter_blocks ) ;
ASSERT_EQ ( table_opt . filter_policy , new_opt . filter_policy ) ;
ASSERT_EQ ( table_opt . filter_policy , new_opt . filter_policy ) ;
// unrecognized filter policy config
// unrecognized filter policy config
ASSERT_NOK (
s = GetBlockBasedTableOptionsFromString ( config_options , table_opt ,
GetBlockBasedTableOptionsFromString ( config_options , table_opt ,
" cache_index_and_filter_blocks=1; "
" cache_index_and_filter_blocks=1; "
" filter_policy=bloomfilter:4 " ,
" filter_policy=bloomfilter:4 " ,
& new_opt ) ) ;
& new_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_EQ ( table_opt . cache_index_and_filter_blocks ,
ASSERT_EQ ( table_opt . cache_index_and_filter_blocks ,
new_opt . cache_index_and_filter_blocks ) ;
new_opt . cache_index_and_filter_blocks ) ;
ASSERT_EQ ( table_opt . filter_policy , new_opt . filter_policy ) ;
ASSERT_EQ ( table_opt . filter_policy , new_opt . filter_policy ) ;
@ -1021,18 +1043,22 @@ TEST_F(OptionsTest, GetPlainTableOptionsFromString) {
ASSERT_TRUE ( new_opt . store_index_in_file ) ;
ASSERT_TRUE ( new_opt . store_index_in_file ) ;
// unknown option
// unknown option
ASSERT_NOK ( GetPlainTableOptionsFromString (
Status s = GetPlainTableOptionsFromString (
config_options , table_opt ,
config_options , table_opt ,
" user_key_len=66;bloom_bits_per_key=20;hash_table_ratio=0.5; "
" user_key_len=66;bloom_bits_per_key=20;hash_table_ratio=0.5; "
" bad_option=1 " ,
" bad_option=1 " ,
& new_opt ) ) ;
& new_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
// unrecognized EncodingType
// unrecognized EncodingType
ASSERT_NOK ( GetPlainTableOptionsFromString (
s = GetPlainTableOptionsFromString (
config_options , table_opt ,
config_options , table_opt ,
" user_key_len=66;bloom_bits_per_key=20;hash_table_ratio=0.5; "
" user_key_len=66;bloom_bits_per_key=20;hash_table_ratio=0.5; "
" encoding_type=kPrefixXX " ,
" encoding_type=kPrefixXX " ,
& new_opt ) ) ;
& new_opt ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
}
}
# endif // !ROCKSDB_LITE
# endif // !ROCKSDB_LITE
@ -1151,23 +1177,29 @@ TEST_F(OptionsTest, GetOptionsFromStringTest) {
base_options . dump_malloc_stats = false ;
base_options . dump_malloc_stats = false ;
base_options . write_buffer_size = 1024 ;
base_options . write_buffer_size = 1024 ;
Options bad_options = new_options ;
Options bad_options = new_options ;
ASSERT_NOK ( GetOptionsFromString ( config_options , base_options ,
Status s = GetOptionsFromString ( config_options , base_options ,
" create_if_missing=XX;dump_malloc_stats=true " ,
" create_if_missing=XX;dump_malloc_stats=true " ,
& bad_options ) ) ;
& bad_options ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_EQ ( bad_options . dump_malloc_stats , false ) ;
ASSERT_EQ ( bad_options . dump_malloc_stats , false ) ;
bad_options = new_options ;
bad_options = new_options ;
ASSERT_NOK ( GetOptionsFromString ( config_options , base_options ,
s = GetOptionsFromString ( config_options , base_options ,
" write_buffer_size=XX;dump_malloc_stats=true " ,
" write_buffer_size=XX;dump_malloc_stats=true " ,
& bad_options ) ) ;
& bad_options ) ;
ASSERT_NOK ( s ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_EQ ( bad_options . dump_malloc_stats , false ) ;
ASSERT_EQ ( bad_options . dump_malloc_stats , false ) ;
// Test a bad value for a TableFactory Option returns a failure
// Test a bad value for a TableFactory Option returns a failure
bad_options = new_options ;
bad_options = new_options ;
ASSERT_NOK ( GetOptionsFromString ( config_options , base_options ,
s = GetOptionsFromString ( config_options , base_options ,
" write_buffer_size=16;dump_malloc_stats=true "
" write_buffer_size=16;dump_malloc_stats=true "
" block_based_table_factory={block_size=XX;}; " ,
" block_based_table_factory={block_size=XX;}; " ,
& bad_options ) ) ;
& bad_options ) ;
ASSERT_TRUE ( s . IsInvalidArgument ( ) ) ;
ASSERT_EQ ( bad_options . dump_malloc_stats , false ) ;
ASSERT_EQ ( bad_options . dump_malloc_stats , false ) ;
ASSERT_EQ ( bad_options . write_buffer_size , 1024 ) ;
ASSERT_EQ ( bad_options . write_buffer_size , 1024 ) ;