@ -39,9 +39,8 @@ class TestFileNumberGenerator {
class BlobFileBuilderTest : public testing : : Test {
class BlobFileBuilderTest : public testing : : Test {
protected :
protected :
BlobFileBuilderTest ( ) : mock_env_ ( Env : : Default ( ) ) {
BlobFileBuilderTest ( )
fs_ = mock_env_ . GetFileSystem ( ) ;
: mock_env_ ( Env : : Default ( ) ) , fs_ ( mock_env_ . GetFileSystem ( ) . get ( ) ) { }
}
void VerifyBlobFile ( uint64_t blob_file_number ,
void VerifyBlobFile ( uint64_t blob_file_number ,
const std : : string & blob_file_path ,
const std : : string & blob_file_path ,
@ -109,7 +108,7 @@ class BlobFileBuilderTest : public testing::Test {
}
}
MockEnv mock_env_ ;
MockEnv mock_env_ ;
std : : shared_ptr < FileSystem > fs_ ;
FileSystem * fs_ ;
FileOptions file_options_ ;
FileOptions file_options_ ;
} ;
} ;
@ -139,7 +138,7 @@ TEST_F(BlobFileBuilderTest, BuildAndCheckOneFile) {
std : : vector < std : : string > blob_file_paths ;
std : : vector < std : : string > blob_file_paths ;
std : : vector < BlobFileAddition > blob_file_additions ;
std : : vector < BlobFileAddition > blob_file_additions ;
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ . get ( ) ,
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ ,
& immutable_cf_options , & mutable_cf_options ,
& immutable_cf_options , & mutable_cf_options ,
& file_options_ , job_id , column_family_id ,
& file_options_ , job_id , column_family_id ,
column_family_name , io_priority , write_hint ,
column_family_name , io_priority , write_hint ,
@ -222,7 +221,7 @@ TEST_F(BlobFileBuilderTest, BuildAndCheckMultipleFiles) {
std : : vector < std : : string > blob_file_paths ;
std : : vector < std : : string > blob_file_paths ;
std : : vector < BlobFileAddition > blob_file_additions ;
std : : vector < BlobFileAddition > blob_file_additions ;
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ . get ( ) ,
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ ,
& immutable_cf_options , & mutable_cf_options ,
& immutable_cf_options , & mutable_cf_options ,
& file_options_ , job_id , column_family_id ,
& file_options_ , job_id , column_family_id ,
column_family_name , io_priority , write_hint ,
column_family_name , io_priority , write_hint ,
@ -307,7 +306,7 @@ TEST_F(BlobFileBuilderTest, InlinedValues) {
std : : vector < std : : string > blob_file_paths ;
std : : vector < std : : string > blob_file_paths ;
std : : vector < BlobFileAddition > blob_file_additions ;
std : : vector < BlobFileAddition > blob_file_additions ;
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ . get ( ) ,
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ ,
& immutable_cf_options , & mutable_cf_options ,
& immutable_cf_options , & mutable_cf_options ,
& file_options_ , job_id , column_family_id ,
& file_options_ , job_id , column_family_id ,
column_family_name , io_priority , write_hint ,
column_family_name , io_priority , write_hint ,
@ -359,7 +358,7 @@ TEST_F(BlobFileBuilderTest, Compression) {
std : : vector < std : : string > blob_file_paths ;
std : : vector < std : : string > blob_file_paths ;
std : : vector < BlobFileAddition > blob_file_additions ;
std : : vector < BlobFileAddition > blob_file_additions ;
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ . get ( ) ,
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ ,
& immutable_cf_options , & mutable_cf_options ,
& immutable_cf_options , & mutable_cf_options ,
& file_options_ , job_id , column_family_id ,
& file_options_ , job_id , column_family_id ,
column_family_name , io_priority , write_hint ,
column_family_name , io_priority , write_hint ,
@ -441,7 +440,7 @@ TEST_F(BlobFileBuilderTest, CompressionError) {
std : : vector < std : : string > blob_file_paths ;
std : : vector < std : : string > blob_file_paths ;
std : : vector < BlobFileAddition > blob_file_additions ;
std : : vector < BlobFileAddition > blob_file_additions ;
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ . get ( ) ,
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ ,
& immutable_cf_options , & mutable_cf_options ,
& immutable_cf_options , & mutable_cf_options ,
& file_options_ , job_id , column_family_id ,
& file_options_ , job_id , column_family_id ,
column_family_name , io_priority , write_hint ,
column_family_name , io_priority , write_hint ,
@ -518,7 +517,7 @@ TEST_F(BlobFileBuilderTest, Checksum) {
std : : vector < std : : string > blob_file_paths ;
std : : vector < std : : string > blob_file_paths ;
std : : vector < BlobFileAddition > blob_file_additions ;
std : : vector < BlobFileAddition > blob_file_additions ;
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ . get ( ) ,
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs_ ,
& immutable_cf_options , & mutable_cf_options ,
& immutable_cf_options , & mutable_cf_options ,
& file_options_ , job_id , column_family_id ,
& file_options_ , job_id , column_family_id ,
column_family_name , io_priority , write_hint ,
column_family_name , io_priority , write_hint ,
@ -571,13 +570,11 @@ class BlobFileBuilderIOErrorTest
protected :
protected :
BlobFileBuilderIOErrorTest ( )
BlobFileBuilderIOErrorTest ( )
: mock_env_ ( Env : : Default ( ) ) ,
: mock_env_ ( Env : : Default ( ) ) ,
fault_injection_env_ ( & mock_env_ ) ,
fs_ ( mock_env_ . GetFileSystem ( ) . get ( ) ) ,
fs_ ( fault_injection_env_ . GetFileSystem ( ) ) ,
sync_point_ ( GetParam ( ) ) { }
sync_point_ ( GetParam ( ) ) { }
MockEnv mock_env_ ;
MockEnv mock_env_ ;
FaultInjectionTestEnv fault_injection_env_ ;
FileSystem * fs_ ;
std : : shared_ptr < FileSystem > fs_ ;
FileOptions file_options_ ;
FileOptions file_options_ ;
std : : string sync_point_ ;
std : : string sync_point_ ;
} ;
} ;
@ -598,11 +595,11 @@ TEST_P(BlobFileBuilderIOErrorTest, IOError) {
Options options ;
Options options ;
options . cf_paths . emplace_back (
options . cf_paths . emplace_back (
test : : PerThreadDBPath ( & fault_injection_env_ ,
test : : PerThreadDBPath ( & mock_env_ , " BlobFileBuilderIOErrorTest_IOError " ) ,
" BlobFileBuilderIOErrorTest_IOError " ) ,
0 ) ;
0 ) ;
options . enable_blob_files = true ;
options . enable_blob_files = true ;
options . blob_file_size = value_size ;
options . blob_file_size = value_size ;
options . env = & mock_env_ ;
ImmutableCFOptions immutable_cf_options ( options ) ;
ImmutableCFOptions immutable_cf_options ( options ) ;
MutableCFOptions mutable_cf_options ( options ) ;
MutableCFOptions mutable_cf_options ( options ) ;
@ -616,15 +613,17 @@ TEST_P(BlobFileBuilderIOErrorTest, IOError) {
std : : vector < std : : string > blob_file_paths ;
std : : vector < std : : string > blob_file_paths ;
std : : vector < BlobFileAddition > blob_file_additions ;
std : : vector < BlobFileAddition > blob_file_additions ;
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & fault_injection_env _,
BlobFileBuilder builder ( TestFileNumberGenerator ( ) , & mock_env_ , fs _,
fs_ . get ( ) , & immutable_cf_options , & mutable_cf_options ,
& immutable_cf_options , & mutable_cf_options ,
& file_options_ , job_id , column_family_id ,
& file_options_ , job_id , column_family_id ,
column_family_name , io_priority , write_hint ,
column_family_name , io_priority , write_hint ,
& blob_file_paths , & blob_file_additions ) ;
& blob_file_paths , & blob_file_additions ) ;
SyncPoint : : GetInstance ( ) - > SetCallBack ( sync_point_ , [ this ] ( void * /* arg */ ) {
SyncPoint : : GetInstance ( ) - > SetCallBack ( sync_point_ , [ this ] ( void * arg ) {
fault_injection_env_ . SetFilesystemActive ( false ,
Status * const s = static_cast < Status * > ( arg ) ;
Status : : IOError ( sync_point_ ) ) ;
assert ( s ) ;
( * s ) = Status : : IOError ( sync_point_ ) ;
} ) ;
} ) ;
SyncPoint : : GetInstance ( ) - > EnableProcessing ( ) ;
SyncPoint : : GetInstance ( ) - > EnableProcessing ( ) ;