@ -299,8 +299,31 @@ TEST_F(DBSSTTest, RateLimitedDelete) {
rocksdb : : SyncPoint : : GetInstance ( ) - > SetCallBack (
rocksdb : : SyncPoint : : GetInstance ( ) - > SetCallBack (
" DeleteScheduler::BackgroundEmptyTrash:Wait " ,
" DeleteScheduler::BackgroundEmptyTrash:Wait " ,
[ & ] ( void * arg ) { penalties . push_back ( * ( static_cast < int * > ( arg ) ) ) ; } ) ;
[ & ] ( void * arg ) { penalties . push_back ( * ( static_cast < int * > ( arg ) ) ) ; } ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > SetCallBack (
" InstrumentedCondVar::TimedWaitInternal " , [ & ] ( void * arg ) {
// Turn timed wait into a simulated sleep
uint64_t * abs_time_us = static_cast < uint64_t * > ( arg ) ;
int64_t cur_time = 0 ;
env_ - > GetCurrentTime ( & cur_time ) ;
if ( * abs_time_us > static_cast < uint64_t > ( cur_time ) ) {
env_ - > addon_time_ . fetch_add ( * abs_time_us -
static_cast < uint64_t > ( cur_time ) ) ;
}
// Randomly sleep shortly
env_ - > addon_time_ . fetch_add (
static_cast < uint64_t > ( Random : : GetTLSInstance ( ) - > Uniform ( 10 ) ) ) ;
// Set wait until time to before current to force not to sleep.
int64_t real_cur_time = 0 ;
Env : : Default ( ) - > GetCurrentTime ( & real_cur_time ) ;
* abs_time_us = static_cast < uint64_t > ( real_cur_time ) ;
} ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > EnableProcessing ( ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > EnableProcessing ( ) ;
env_ - > no_sleep_ = true ;
env_ - > time_elapse_only_sleep_ = true ;
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . disable_auto_compactions = true ;
options . disable_auto_compactions = true ;
options . env = env_ ;
options . env = env_ ;
@ -348,6 +371,7 @@ TEST_F(DBSSTTest, RateLimitedDelete) {
ASSERT_EQ ( expected_penlty , penalties [ i ] ) ;
ASSERT_EQ ( expected_penlty , penalties [ i ] ) ;
}
}
ASSERT_GT ( time_spent_deleting , expected_penlty * 0.9 ) ;
ASSERT_GT ( time_spent_deleting , expected_penlty * 0.9 ) ;
ASSERT_LT ( time_spent_deleting , expected_penlty * 1.1 ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
}
}