From 4cfb0eb40fb838cee1b38bf393351dc8f8c1bf16 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Thu, 20 Mar 2014 11:11:08 -0700 Subject: [PATCH] Delete rocksdb dir after crashtest Summary: We should clean up after ourselves. Last crashtest failed because the disk on the cibuild machine was full. Also, db_crashtest is supposed to run the test on the same database in every iteration. This isn't the case currently, because every run creates a new tmp directory. It's fixed with this diff. Test Plan: ran it Reviewers: ljin Reviewed By: ljin CC: leveldb Differential Revision: https://reviews.facebook.net/D17073 --- tools/db_crashtest.py | 10 ++++++++-- tools/db_crashtest2.py | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index 2979a05080..d81fd0885e 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 68cc42cf3d..274fcde4ee 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