@ -956,29 +956,50 @@ TEST_F(BlobDBTest, ColumnFamilyNotSupported) {
TEST_F ( BlobDBTest , GetLiveFilesMetaData ) {
TEST_F ( BlobDBTest , GetLiveFilesMetaData ) {
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
BlobDBOptions bdb_options ;
BlobDBOptions bdb_options ;
bdb_options . blob_dir = " blob_dir " ;
bdb_options . blob_dir = " blob_dir " ;
bdb_options . path_relative = true ;
bdb_options . path_relative = true ;
bdb_options . ttl_range_secs = 10 ;
bdb_options . min_blob_size = 0 ;
bdb_options . min_blob_size = 0 ;
bdb_options . disable_background_tasks = true ;
bdb_options . disable_background_tasks = true ;
Open ( bdb_options ) ;
Options options ;
options . env = mock_env_ . get ( ) ;
Open ( bdb_options , options ) ;
std : : map < std : : string , std : : string > data ;
std : : map < std : : string , std : : string > data ;
for ( size_t i = 0 ; i < 100 ; i + + ) {
for ( size_t i = 0 ; i < 100 ; i + + ) {
PutRandom ( " key " + ToString ( i ) , & rnd , & data ) ;
PutRandom ( " key " + ToString ( i ) , & rnd , & data ) ;
}
}
constexpr uint64_t expiration = 1000ULL ;
PutRandomUntil ( " key100 " , expiration , & rnd , & data ) ;
std : : vector < LiveFileMetaData > metadata ;
std : : vector < LiveFileMetaData > metadata ;
blob_db_ - > GetLiveFilesMetaData ( & metadata ) ;
blob_db_ - > GetLiveFilesMetaData ( & metadata ) ;
ASSERT_EQ ( 1U , metadata . size ( ) ) ;
ASSERT_EQ ( 2U , metadata . size ( ) ) ;
// Path should be relative to db_name, but begin with slash.
// Path should be relative to db_name, but begin with slash.
std : : string filename = " /blob_dir/000001.blob " ;
const std : : string filename1 ( " /blob_dir/000001.blob " ) ;
ASSERT_EQ ( filename , metadata [ 0 ] . name ) ;
ASSERT_EQ ( filename1 , metadata [ 0 ] . name ) ;
ASSERT_EQ ( 1 , metadata [ 0 ] . file_number ) ;
ASSERT_EQ ( 1 , metadata [ 0 ] . file_number ) ;
ASSERT_EQ ( " default " , metadata [ 0 ] . column_family_name ) ;
ASSERT_EQ ( 0 , metadata [ 0 ] . oldest_ancester_time ) ;
ASSERT_EQ ( kDefaultColumnFamilyName , metadata [ 0 ] . column_family_name ) ;
const std : : string filename2 ( " /blob_dir/000002.blob " ) ;
ASSERT_EQ ( filename2 , metadata [ 1 ] . name ) ;
ASSERT_EQ ( 2 , metadata [ 1 ] . file_number ) ;
ASSERT_EQ ( expiration , metadata [ 1 ] . oldest_ancester_time ) ;
ASSERT_EQ ( kDefaultColumnFamilyName , metadata [ 1 ] . column_family_name ) ;
std : : vector < std : : string > livefile ;
std : : vector < std : : string > livefile ;
uint64_t mfs ;
uint64_t mfs ;
ASSERT_OK ( blob_db_ - > GetLiveFiles ( livefile , & mfs , false ) ) ;
ASSERT_OK ( blob_db_ - > GetLiveFiles ( livefile , & mfs , false ) ) ;
ASSERT_EQ ( 4U , livefile . size ( ) ) ;
ASSERT_EQ ( 5U , livefile . size ( ) ) ;
ASSERT_EQ ( filename , livefile [ 3 ] ) ;
ASSERT_EQ ( filename1 , livefile [ 3 ] ) ;
ASSERT_EQ ( filename2 , livefile [ 4 ] ) ;
VerifyDB ( data ) ;
VerifyDB ( data ) ;
}
}