diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index 2979a0508..d81fd0885 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -8,9 +8,10 @@ import getopt import logging import tempfile import subprocess +import shutil # This script runs and kills db_stress multiple times. It checks consistency -# in case of unsafe crashes in Rocksdb. +# in case of unsafe crashes in RocksDB. def main(argv): try: @@ -59,6 +60,8 @@ def main(argv): + str(ops_per_thread) + "\nwrite_buffer_size=" + str(write_buf_size) + "\n") + dbname = tempfile.mkdtemp(prefix='rocksdb_crashtest_') + while time.time() < exit_time: run_had_errors = False killtime = time.time() + interval @@ -98,7 +101,7 @@ def main(argv): """ % (ops_per_thread, threads, write_buf_size, - tempfile.mkdtemp(), + dbname, random.randint(0, 1), random.randint(0, 1), random.randint(0, 1))) @@ -139,5 +142,8 @@ def main(argv): time.sleep(1) # time to stabilize before the next run + # we need to clean up after ourselves -- only do this on test success + shutil.rmtree(dbname, True) + if __name__ == "__main__": sys.exit(main(sys.argv[1:])) diff --git a/tools/db_crashtest2.py b/tools/db_crashtest2.py index 68cc42cf3..274fcde4e 100644 --- a/tools/db_crashtest2.py +++ b/tools/db_crashtest2.py @@ -8,6 +8,7 @@ import getopt import logging import tempfile import subprocess +import shutil # This python script runs db_stress multiple times. Some runs with # kill_random_test that causes rocksdb to crash at various points in code. @@ -78,6 +79,7 @@ def main(argv): # nomral run additional_opts = "--ops_per_thread=" + str(ops_per_thread) + dbname = tempfile.mkdtemp(prefix='rocksdb_crashtest_') cmd = re.sub('\s+', ' ', """ ./db_stress --test_batches_snapshots=%s @@ -113,7 +115,7 @@ def main(argv): """ % (random.randint(0, 1), threads, write_buf_size, - tempfile.mkdtemp(), + dbname, random.randint(0, 1), random.randint(0, 1), random.randint(0, 1), @@ -154,6 +156,8 @@ 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