@ -18,8 +18,8 @@ def main(argv):
try :
try :
opts , args = getopt . getopt ( argv , " hd:t:i:o:b: " )
opts , args = getopt . getopt ( argv , " hd:t:i:o:b: " )
except getopt . GetoptError :
except getopt . GetoptError :
print " db_crashtest.py -d <duration_test> -t <#threads> " \
print ( " db_crashtest.py -d <duration_test> -t <#threads> "
" -i <interval for one run> -o <ops_per_thread> \n "
" -i <interval for one run> -o <ops_per_thread> \n " )
sys . exit ( 2 )
sys . exit ( 2 )
# default values, will be overridden by cmdline args
# default values, will be overridden by cmdline args
@ -32,9 +32,9 @@ def main(argv):
for opt , arg in opts :
for opt , arg in opts :
if opt == ' -h ' :
if opt == ' -h ' :
print " db_crashtest.py -d <duration_test> -t <#threads> " \
print ( " db_crashtest.py -d <duration_test> "
" -i <interval for one run> -o <ops_per_thread> " \
" -t <#threads> -i <interval for one run>"
" -b <write_buffer_size> \n "
" -o <ops_per_thread> -b <write_buffer_size>\n " )
sys . exit ( )
sys . exit ( )
elif opt == ( " -d " ) :
elif opt == ( " -d " ) :
duration = int ( arg )
duration = int ( arg )
@ -47,18 +47,23 @@ def main(argv):
elif opt == ( " -b " ) :
elif opt == ( " -b " ) :
write_buf_size = int ( arg )
write_buf_size = int ( arg )
else :
else :
print " db_crashtest.py -d <duration_test> -t <#threads> " \
print ( " db_crashtest.py -d <duration_test> "
" -i <interval for one run> -o <ops_per_thread> " \
" -t <#threads> -i <interval for one run>"
" -b <write_buffer_size> \n "
" -o <ops_per_thread> -b <write_buffer_size>\n " )
sys . exit ( 2 )
sys . exit ( 2 )
exit_time = time . time ( ) + duration
exit_time = time . time ( ) + duration
dirpath = tempfile . mkdtemp ( )
dirpath = tempfile . mkdtemp ( )
print ( " Running crash-test with \n interval_between_crash= "
+ str ( interval ) + " \n total-duration= " + str ( duration )
+ " \n threads= " + str ( threads ) + " \n ops_per_thread= "
+ str ( ops_per_thread ) + " \n write_buffer_size= "
+ str ( write_buf_size ) + " \n " )
while time . time ( ) < exit_time :
while time . time ( ) < exit_time :
run_had_errors = False
run_had_errors = False
print " Running db_stress \n "
killtime = time . time ( ) + interval
killtime = time . time ( ) + interval
child = subprocess . Popen ( [ ' ./db_stress \
child = subprocess . Popen ( [ ' ./db_stress \
- - test_batches_snapshots = 1 \
- - test_batches_snapshots = 1 \
@ -70,21 +75,22 @@ def main(argv):
- - readpercent = 50 \
- - readpercent = 50 \
- - db = ' + dirpath + ' \
- - db = ' + dirpath + ' \
- - max_key = 1000 ' ], stderr=subprocess.PIPE, shell=True)
- - max_key = 1000 ' ], stderr=subprocess.PIPE, shell=True)
print ( " Running db_stress with pid= %d \n " % child . pid )
time . sleep ( interval )
time . sleep ( interval )
while True :
while True :
if time . time ( ) > killtime :
if time . time ( ) > killtime :
if child . poll ( ) is not None :
if child . poll ( ) is not None :
logging . warn ( " WARNING: db_stress complet ed before kill \n " )
print ( " WARNING: db_stress end ed before kill \n " )
else :
else :
child . kill ( )
child . kill ( )
print " KILLED \n "
print ( " KILLED %d \n " % child . pid )
time . sleep ( 1 ) # time to stabilize after a kill
time . sleep ( 1 ) # time to stabilize after a kill
while True :
while True :
line = child . stderr . readline ( ) . strip ( )
line = child . stderr . readline ( ) . strip ( )
if line != ' ' :
if line != ' ' :
run_had_errors = True
run_had_errors = True
print ' *** ' + line + ' ^ '
print ( ' *** ' + line + ' ^ ' )
else :
else :
break
break
if run_had_errors :
if run_had_errors :