Printing the options that db_crashtest.py is run with

Summary: To know which options the crashtest was run with. Also changed print to sys.stdout.write which is more standard.

Test Plan: python tools/db_crashtest.py

Reviewers: vamsi, akushner, dhruba

Reviewed By: akushner

Differential Revision: https://reviews.facebook.net/D10119
main
Mayank Agarwal 12 years ago
parent 7730587120
commit f51b375062
  1. 2
      Makefile
  2. 30
      tools/db_crashtest.py

@ -116,7 +116,7 @@ ldb_tests: all $(PROGRAMS) $(TOOLS)
python tools/ldb_test.py python tools/ldb_test.py
crash_test: db_stress crash_test: db_stress
python tools/db_crashtest.py python -u tools/db_crashtest.py
valgrind_check: all $(PROGRAMS) $(TESTS) valgrind_check: all $(PROGRAMS) $(TESTS)
echo TESTS THAT HAVE VALGRIND ERRORS > $(VALGRIND_DIR)/valgrind_failed_tests; \ echo TESTS THAT HAVE VALGRIND ERRORS > $(VALGRIND_DIR)/valgrind_failed_tests; \

@ -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 \ninterval_between_crash="
+ str(interval) + "\ntotal-duration=" + str(duration)
+ "\nthreads=" + str(threads) + "\nops_per_thread="
+ str(ops_per_thread) + "\nwrite_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 completed before kill\n") print("WARNING: db_stress ended 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:

Loading…
Cancel
Save