From e2a3bfe74bb1fb86f3bb24d2eab0e1cfe7de0cff Mon Sep 17 00:00:00 2001 From: sdong Date: Mon, 3 Aug 2015 18:11:14 -0700 Subject: [PATCH] First half of whitebox_crash_test to keep crashing the same DB Summary: Currently, whitebox crash test is not really executed, because the DB is destroyed after each crash. With this fix, in the first half of the time, DB will keep opening the crashed DB and continue from there. Test Plan: "make whitebox_crash_test" and see the same DB keeps crashing and being reopened. Reviewers: IslamAbdelRahman, yhchiang, rven, kradhakrishnan Reviewed By: kradhakrishnan Subscribers: leveldb, dhruba Differential Revision: https://reviews.facebook.net/D43503 --- tools/db_crashtest2.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/db_crashtest2.py b/tools/db_crashtest2.py index 9abd6f170..931b73907 100644 --- a/tools/db_crashtest2.py +++ b/tools/db_crashtest2.py @@ -60,7 +60,9 @@ def main(argv): "-b \n" sys.exit(2) - exit_time = time.time() + duration + cur_time = time.time() + exit_time = cur_time + duration + half_time = cur_time + duration / 2 print "Running whitebox-crash-test with \ntotal-duration=" + str(duration) \ + "\nthreads=" + str(threads) + "\nops_per_thread=" \ @@ -213,10 +215,14 @@ def main(argv): if (stdoutdata.find('fail') >= 0): print "TEST FAILED. Output has 'fail'!!!\n" sys.exit(2) - # we need to clean up after ourselves -- only do this on test success - shutil.rmtree(dbname, True) - check_mode = (check_mode + 1) % total_check_mode + # First half of the duration, keep doing kill test. For the next half, + # try different modes. + if time.time() > half_time: + # we need to clean up after ourselves -- only do this on test + # success + shutil.rmtree(dbname, True) + check_mode = (check_mode + 1) % total_check_mode time.sleep(1) # time to stabilize after a kill