@ -63,7 +63,11 @@ TEST_F(OptionsUtilTest, SaveAndLoad) {
DBOptions loaded_db_opt ;
std : : vector < ColumnFamilyDescriptor > loaded_cf_descs ;
ASSERT_OK ( LoadOptionsFromFile ( kFileName , env_ . get ( ) , & loaded_db_opt ,
ConfigOptions config_options ;
config_options . ignore_unknown_options = false ;
config_options . input_strings_escaped = true ;
config_options . env = env_ . get ( ) ;
ASSERT_OK ( LoadOptionsFromFile ( config_options , kFileName , & loaded_db_opt ,
& loaded_cf_descs ) ) ;
ConfigOptions exact ;
exact . sanity_level = ConfigOptions : : kSanityLevelExactMatch ;
@ -142,19 +146,6 @@ TEST_F(OptionsUtilTest, SaveAndLoadWithCacheCheck) {
ASSERT_EQ ( loaded_bbt_opt - > block_cache . get ( ) , cache . get ( ) ) ;
}
}
// Test the old interface
ASSERT_OK ( LoadOptionsFromFile ( kFileName , env_ . get ( ) , & loaded_db_opt ,
& loaded_cf_descs , false , & cache ) ) ;
for ( size_t i = 0 ; i < loaded_cf_descs . size ( ) ; i + + ) {
auto * loaded_bbt_opt =
loaded_cf_descs [ i ]
. options . table_factory - > GetOptions < BlockBasedTableOptions > ( ) ;
// Expect the same cache will be loaded
if ( loaded_bbt_opt ! = nullptr ) {
ASSERT_EQ ( loaded_bbt_opt - > block_cache . get ( ) , cache . get ( ) ) ;
}
}
ASSERT_OK ( DestroyDB ( dbname_ , Options ( loaded_db_opt , cf_opts [ 0 ] ) ) ) ;
}
@ -386,11 +377,8 @@ TEST_F(OptionsUtilTest, LatestOptionsNotFound) {
ASSERT_TRUE ( s . IsNotFound ( ) ) ;
ASSERT_TRUE ( s . IsPathNotFound ( ) ) ;
s = LoadLatestOptions ( dbname_ , options . env , & options , & cf_descs ) ;
ASSERT_TRUE ( s . IsNotFound ( ) ) ;
ASSERT_TRUE ( s . IsPathNotFound ( ) ) ;
s = LoadLatestOptions ( config_opts , dbname_ , & options , & cf_descs ) ;
ASSERT_TRUE ( s . IsNotFound ( ) ) ;
ASSERT_TRUE ( s . IsPathNotFound ( ) ) ;
s = GetLatestOptionsFileName ( dbname_ , options . env , & options_file_name ) ;
@ -404,7 +392,7 @@ TEST_F(OptionsUtilTest, LatestOptionsNotFound) {
ASSERT_TRUE ( s . IsNotFound ( ) ) ;
ASSERT_TRUE ( s . IsPathNotFound ( ) ) ;
s = LoadLatestOptions ( dbname_ , options . env , & options , & cf_descs ) ;
s = LoadLatestOptions ( config_opts , dbname_ , & options , & cf_descs ) ;
ASSERT_TRUE ( s . IsNotFound ( ) ) ;
ASSERT_TRUE ( s . IsPathNotFound ( ) ) ;
@ -641,6 +629,9 @@ TEST_F(OptionsUtilTest, RenameDatabaseDirectory) {
DBOptions db_opts ;
std : : vector < ColumnFamilyDescriptor > cf_descs ;
std : : vector < ColumnFamilyHandle * > handles ;
ConfigOptions ignore_opts ;
ignore_opts . ignore_unknown_options = false ;
ignore_opts . env = options . env ;
options . create_if_missing = true ;
@ -651,7 +642,7 @@ TEST_F(OptionsUtilTest, RenameDatabaseDirectory) {
auto new_dbname = dbname_ + " _2 " ;
ASSERT_OK ( options . env - > RenameFile ( dbname_ , new_dbname ) ) ;
ASSERT_OK ( LoadLatestOptions ( new_dbname , options . env , & db_opts , & cf_descs ) ) ;
ASSERT_OK ( LoadLatestOptions ( ignore_opts , new_dbname , & db_opts , & cf_descs ) ) ;
ASSERT_EQ ( cf_descs . size ( ) , 1U ) ;
db_opts . create_if_missing = false ;
@ -675,20 +666,23 @@ TEST_F(OptionsUtilTest, WalDirSettings) {
DBOptions db_opts ;
std : : vector < ColumnFamilyDescriptor > cf_descs ;
std : : vector < ColumnFamilyHandle * > handles ;
ConfigOptions ignore_opts ;
ignore_opts . ignore_unknown_options = false ;
ignore_opts . env = options . env ;
options . create_if_missing = true ;
// Open a DB with no wal dir set. The wal_dir should stay empty
ASSERT_OK ( DB : : Open ( options , dbname_ , & db ) ) ;
delete db ;
ASSERT_OK ( LoadLatestOptions ( dbname_ , options . env , & db_opts , & cf_descs ) ) ;
ASSERT_OK ( LoadLatestOptions ( ignore_opts , dbname_ , & db_opts , & cf_descs ) ) ;
ASSERT_EQ ( db_opts . wal_dir , " " ) ;
// Open a DB with wal_dir == dbname. The wal_dir should be set to empty
options . wal_dir = dbname_ ;
ASSERT_OK ( DB : : Open ( options , dbname_ , & db ) ) ;
delete db ;
ASSERT_OK ( LoadLatestOptions ( dbname_ , options . env , & db_opts , & cf_descs ) ) ;
ASSERT_OK ( LoadLatestOptions ( ignore_opts , dbname_ , & db_opts , & cf_descs ) ) ;
ASSERT_EQ ( db_opts . wal_dir , " " ) ;
// Open a DB with no wal_dir but a db_path==dbname_. The wal_dir should be
@ -697,7 +691,7 @@ TEST_F(OptionsUtilTest, WalDirSettings) {
options . db_paths . emplace_back ( dbname_ , std : : numeric_limits < uint64_t > : : max ( ) ) ;
ASSERT_OK ( DB : : Open ( options , dbname_ , & db ) ) ;
delete db ;
ASSERT_OK ( LoadLatestOptions ( dbname_ , options . env , & db_opts , & cf_descs ) ) ;
ASSERT_OK ( LoadLatestOptions ( ignore_opts , dbname_ , & db_opts , & cf_descs ) ) ;
ASSERT_EQ ( db_opts . wal_dir , " " ) ;
// Open a DB with no wal_dir==dbname_ and db_path==dbname_. The wal_dir
@ -706,7 +700,7 @@ TEST_F(OptionsUtilTest, WalDirSettings) {
options . db_paths . emplace_back ( dbname_ , std : : numeric_limits < uint64_t > : : max ( ) ) ;
ASSERT_OK ( DB : : Open ( options , dbname_ , & db ) ) ;
delete db ;
ASSERT_OK ( LoadLatestOptions ( dbname_ , options . env , & db_opts , & cf_descs ) ) ;
ASSERT_OK ( LoadLatestOptions ( ignore_opts , dbname_ , & db_opts , & cf_descs ) ) ;
ASSERT_EQ ( db_opts . wal_dir , " " ) ;
ASSERT_OK ( DestroyDB ( dbname_ , options ) ) ;
@ -717,7 +711,7 @@ TEST_F(OptionsUtilTest, WalDirSettings) {
std : : numeric_limits < uint64_t > : : max ( ) ) ;
ASSERT_OK ( DB : : Open ( options , dbname_ , & db ) ) ;
delete db ;
ASSERT_OK ( LoadLatestOptions ( dbname_ , options . env , & db_opts , & cf_descs ) ) ;
ASSERT_OK ( LoadLatestOptions ( ignore_opts , dbname_ , & db_opts , & cf_descs ) ) ;
ASSERT_EQ ( db_opts . wal_dir , dbname_ ) ;
ASSERT_OK ( DestroyDB ( dbname_ , options ) ) ;
@ -726,7 +720,7 @@ TEST_F(OptionsUtilTest, WalDirSettings) {
options . db_paths . clear ( ) ;
ASSERT_OK ( DB : : Open ( options , dbname_ , & db ) ) ;
delete db ;
ASSERT_OK ( LoadLatestOptions ( dbname_ , options . env , & db_opts , & cf_descs ) ) ;
ASSERT_OK ( LoadLatestOptions ( ignore_opts , dbname_ , & db_opts , & cf_descs ) ) ;
ASSERT_EQ ( db_opts . wal_dir , dbname_ + " /wal " ) ;
ASSERT_OK ( DestroyDB ( dbname_ , options ) ) ;
}
@ -737,6 +731,9 @@ TEST_F(OptionsUtilTest, WalDirInOptins) {
DBOptions db_opts ;
std : : vector < ColumnFamilyDescriptor > cf_descs ;
std : : vector < ColumnFamilyHandle * > handles ;
ConfigOptions ignore_opts ;
ignore_opts . ignore_unknown_options = false ;
ignore_opts . env = options . env ;
// Store an options file with wal_dir=dbname_ and make sure it still loads
// when the input wal_dir is empty
@ -750,12 +747,12 @@ TEST_F(OptionsUtilTest, WalDirInOptins) {
ASSERT_OK ( PersistRocksDBOptions ( options , { " default " } , { options } ,
dbname_ + " / " + options_file ,
options . env - > GetFileSystem ( ) . get ( ) ) ) ;
ASSERT_OK ( LoadLatestOptions ( dbname_ , options . env , & db_opts , & cf_descs ) ) ;
ASSERT_OK ( LoadLatestOptions ( ignore_opts , dbname_ , & db_opts , & cf_descs ) ) ;
ASSERT_EQ ( db_opts . wal_dir , dbname_ ) ;
options . wal_dir = " " ;
ASSERT_OK ( DB : : Open ( options , dbname_ , & db ) ) ;
delete db ;
ASSERT_OK ( LoadLatestOptions ( dbname_ , options . env , & db_opts , & cf_descs ) ) ;
ASSERT_OK ( LoadLatestOptions ( ignore_opts , dbname_ , & db_opts , & cf_descs ) ) ;
ASSERT_EQ ( db_opts . wal_dir , " " ) ;
}
} // namespace ROCKSDB_NAMESPACE