From 4f297ad05fad3a0455020b5b019777c84bb94770 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Sun, 3 Jun 2018 21:28:41 -0700 Subject: [PATCH] Fix crash test check for direct I/O Summary: We need to keep the DB directory around since the direct IO check in "db_crashtest.py" relies on it existing. This PR fixes an issue where it was removed after each stress test run during the second half of whitebox crash testing. Closes https://github.com/facebook/rocksdb/pull/3946 Differential Revision: D8247998 Pulled By: ajkr fbshipit-source-id: 4e7cffbdab9b40df125e7842d0d59916e76261d3 --- tools/db_crashtest.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/db_crashtest.py b/tools/db_crashtest.py index 02120d55a..dc33d6a99 100644 --- a/tools/db_crashtest.py +++ b/tools/db_crashtest.py @@ -52,9 +52,11 @@ default_params = { "writepercent": 35, } +_TEST_DIR_ENV_VAR = 'TEST_TMPDIR' + def get_dbname(test_name): - test_tmpdir = os.environ.get("TEST_TMPDIR") + test_tmpdir = os.environ.get(_TEST_DIR_ENV_VAR) if test_tmpdir is None or test_tmpdir == "": dbname = tempfile.mkdtemp(prefix='rocksdb_crashtest_' + test_name) else: @@ -333,6 +335,7 @@ def whitebox_crash_main(args, unknown_args): # we need to clean up after ourselves -- only do this on test # success shutil.rmtree(dbname, True) + os.mkdir(dbname) cmd_params.pop('expected_values_path', None) check_mode = (check_mode + 1) % total_check_mode @@ -357,6 +360,12 @@ def main(): # unknown_args are passed directly to db_stress args, unknown_args = parser.parse_known_args() + test_tmpdir = os.environ.get(_TEST_DIR_ENV_VAR) + if test_tmpdir is not None and not os.path.isdir(test_tmpdir): + print('%s env var is set to a non-existent directory: %s' % + (_TEST_DIR_ENV_VAR, test_tmpdir)) + sys.exit(1) + if args.test_type == 'blackbox': blackbox_crash_main(args, unknown_args) if args.test_type == 'whitebox':