@ -40,6 +40,7 @@ class FlushJobTest : public testing::Test {
EXPECT_OK ( env_ - > CreateDirIfMissing ( dbname_ ) ) ;
EXPECT_OK ( env_ - > CreateDirIfMissing ( dbname_ ) ) ;
db_options_ . db_paths . emplace_back ( dbname_ ,
db_options_ . db_paths . emplace_back ( dbname_ ,
std : : numeric_limits < uint64_t > : : max ( ) ) ;
std : : numeric_limits < uint64_t > : : max ( ) ) ;
db_options_ . statistics = rocksdb : : CreateDBStatistics ( ) ;
// TODO(icanadi) Remove this once we mock out VersionSet
// TODO(icanadi) Remove this once we mock out VersionSet
NewDB ( ) ;
NewDB ( ) ;
std : : vector < ColumnFamilyDescriptor > column_families ;
std : : vector < ColumnFamilyDescriptor > column_families ;
@ -138,16 +139,22 @@ TEST_F(FlushJobTest, NonEmpty) {
EventLogger event_logger ( db_options_ . info_log . get ( ) ) ;
EventLogger event_logger ( db_options_ . info_log . get ( ) ) ;
SnapshotChecker * snapshot_checker = nullptr ; // not relavant
SnapshotChecker * snapshot_checker = nullptr ; // not relavant
FlushJob flush_job (
FlushJob flush_job ( dbname_ , versions_ - > GetColumnFamilySet ( ) - > GetDefault ( ) ,
dbname_ , versions_ - > GetColumnFamilySet ( ) - > GetDefault ( ) , db_options_ ,
db_options_ , * cfd - > GetLatestMutableCFOptions ( ) ,
* cfd - > GetLatestMutableCFOptions ( ) , env_options_ , versions_ . get ( ) , & mutex_ ,
env_options_ , versions_ . get ( ) , & mutex_ , & shutting_down_ ,
& shutting_down_ , { } , kMaxSequenceNumber , snapshot_checker , & job_context ,
{ } , kMaxSequenceNumber , snapshot_checker , & job_context ,
nullptr , nullptr , nullptr , kNoCompression , nullptr , & event_logger , true ) ;
nullptr , nullptr , nullptr , kNoCompression ,
db_options_ . statistics . get ( ) , & event_logger , true ) ;
HistogramData hist ;
FileMetaData fd ;
FileMetaData fd ;
mutex_ . Lock ( ) ;
mutex_ . Lock ( ) ;
flush_job . PickMemTable ( ) ;
flush_job . PickMemTable ( ) ;
ASSERT_OK ( flush_job . Run ( & fd ) ) ;
ASSERT_OK ( flush_job . Run ( & fd ) ) ;
mutex_ . Unlock ( ) ;
mutex_ . Unlock ( ) ;
db_options_ . statistics - > histogramData ( FLUSH_TIME , & hist ) ;
ASSERT_GT ( hist . average , 0.0 ) ;
ASSERT_EQ ( ToString ( 0 ) , fd . smallest . user_key ( ) . ToString ( ) ) ;
ASSERT_EQ ( ToString ( 0 ) , fd . smallest . user_key ( ) . ToString ( ) ) ;
ASSERT_EQ ( " 9999a " ,
ASSERT_EQ ( " 9999a " ,
fd . largest . user_key ( ) . ToString ( ) ) ; // range tombstone end key
fd . largest . user_key ( ) . ToString ( ) ) ; // range tombstone end key
@ -210,12 +217,15 @@ TEST_F(FlushJobTest, Snapshots) {
env_options_ , versions_ . get ( ) , & mutex_ , & shutting_down_ ,
env_options_ , versions_ . get ( ) , & mutex_ , & shutting_down_ ,
snapshots , kMaxSequenceNumber , snapshot_checker ,
snapshots , kMaxSequenceNumber , snapshot_checker ,
& job_context , nullptr , nullptr , nullptr , kNoCompression ,
& job_context , nullptr , nullptr , nullptr , kNoCompression ,
nullptr , & event_logger , true ) ;
db_options_ . statistics . get ( ) , & event_logger , true ) ;
mutex_ . Lock ( ) ;
mutex_ . Lock ( ) ;
flush_job . PickMemTable ( ) ;
flush_job . PickMemTable ( ) ;
ASSERT_OK ( flush_job . Run ( ) ) ;
ASSERT_OK ( flush_job . Run ( ) ) ;
mutex_ . Unlock ( ) ;
mutex_ . Unlock ( ) ;
mock_table_factory_ - > AssertSingleFile ( inserted_keys ) ;
mock_table_factory_ - > AssertSingleFile ( inserted_keys ) ;
HistogramData hist ;
db_options_ . statistics - > histogramData ( FLUSH_TIME , & hist ) ;
ASSERT_GT ( hist . average , 0.0 ) ;
job_context . Clean ( ) ;
job_context . Clean ( ) ;
}
}