@ -2688,6 +2688,74 @@ TEST_F(DBTest2, TraceAndReplay) {
ASSERT_OK ( DestroyDB ( dbname2 , options ) ) ;
}
TEST_F ( DBTest2 , TraceWithLimit ) {
Options options = CurrentOptions ( ) ;
options . merge_operator = MergeOperators : : CreatePutOperator ( ) ;
ReadOptions ro ;
WriteOptions wo ;
TraceOptions trace_opts ;
EnvOptions env_opts ;
CreateAndReopenWithCF ( { " pikachu " } , options ) ;
Random rnd ( 301 ) ;
// test the max trace file size options
trace_opts . max_trace_file_size = 5 ;
std : : string trace_filename = dbname_ + " /rocksdb.trace1 " ;
std : : unique_ptr < TraceWriter > trace_writer ;
ASSERT_OK ( NewFileTraceWriter ( env_ , env_opts , trace_filename , & trace_writer ) ) ;
ASSERT_OK ( db_ - > StartTrace ( trace_opts , std : : move ( trace_writer ) ) ) ;
ASSERT_OK ( Put ( 0 , " a " , " 1 " ) ) ;
ASSERT_OK ( Put ( 0 , " b " , " 1 " ) ) ;
ASSERT_OK ( Put ( 0 , " c " , " 1 " ) ) ;
ASSERT_OK ( db_ - > EndTrace ( ) ) ;
std : : string dbname2 = test : : TmpDir ( env_ ) + " /db_replay2 " ;
std : : string value ;
ASSERT_OK ( DestroyDB ( dbname2 , options ) ) ;
// Using a different name than db2, to pacify infer's use-after-lifetime
// warnings (http://fbinfer.com).
DB * db2_init = nullptr ;
options . create_if_missing = true ;
ASSERT_OK ( DB : : Open ( options , dbname2 , & db2_init ) ) ;
ColumnFamilyHandle * cf ;
ASSERT_OK (
db2_init - > CreateColumnFamily ( ColumnFamilyOptions ( ) , " pikachu " , & cf ) ) ;
delete cf ;
delete db2_init ;
DB * db2 = nullptr ;
std : : vector < ColumnFamilyDescriptor > column_families ;
ColumnFamilyOptions cf_options ;
cf_options . merge_operator = MergeOperators : : CreatePutOperator ( ) ;
column_families . push_back ( ColumnFamilyDescriptor ( " default " , cf_options ) ) ;
column_families . push_back (
ColumnFamilyDescriptor ( " pikachu " , ColumnFamilyOptions ( ) ) ) ;
std : : vector < ColumnFamilyHandle * > handles ;
ASSERT_OK ( DB : : Open ( DBOptions ( ) , dbname2 , column_families , & handles , & db2 ) ) ;
env_ - > SleepForMicroseconds ( 100 ) ;
// Verify that the keys don't already exist
ASSERT_TRUE ( db2 - > Get ( ro , handles [ 0 ] , " a " , & value ) . IsNotFound ( ) ) ;
ASSERT_TRUE ( db2 - > Get ( ro , handles [ 0 ] , " b " , & value ) . IsNotFound ( ) ) ;
ASSERT_TRUE ( db2 - > Get ( ro , handles [ 0 ] , " c " , & value ) . IsNotFound ( ) ) ;
std : : unique_ptr < TraceReader > trace_reader ;
ASSERT_OK ( NewFileTraceReader ( env_ , env_opts , trace_filename , & trace_reader ) ) ;
Replayer replayer ( db2 , handles_ , std : : move ( trace_reader ) ) ;
ASSERT_OK ( replayer . Replay ( ) ) ;
ASSERT_TRUE ( db2 - > Get ( ro , handles [ 0 ] , " a " , & value ) . IsNotFound ( ) ) ;
ASSERT_TRUE ( db2 - > Get ( ro , handles [ 0 ] , " b " , & value ) . IsNotFound ( ) ) ;
ASSERT_TRUE ( db2 - > Get ( ro , handles [ 0 ] , " c " , & value ) . IsNotFound ( ) ) ;
for ( auto handle : handles ) {
delete handle ;
}
delete db2 ;
ASSERT_OK ( DestroyDB ( dbname2 , options ) ) ;
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest2 , PinnableSliceAndMmapReads ) {