Allow a custom DB cleanup command to be passed to db_crashtest.py (#10883)

Summary:
This option allows a custom cleanup command line for a non-Posix file system to be used by db_crashtest.py to cleanup between runs.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10883

Test Plan: Run the whitebox crash test

Reviewed By: pdillinger

Differential Revision: D40726424

Pulled By: anand1976

fbshipit-source-id: b827f6b583ff78f9ca75ced2d96f7e58f5200432
main
anand76 2 years ago committed by Facebook GitHub Bot
parent 22ff8c5af7
commit bf497e91ad
  1. 2
      crash_test.mk
  2. 16
      tools/db_crashtest.py

@ -8,7 +8,7 @@ DB_STRESS_CMD?=./db_stress
include common.mk include common.mk
CRASHTEST_MAKE=$(MAKE) -f crash_test.mk CRASHTEST_MAKE=$(MAKE) -f crash_test.mk
CRASHTEST_PY=$(PYTHON) -u tools/db_crashtest.py --stress_cmd=$(DB_STRESS_CMD) CRASHTEST_PY=$(PYTHON) -u tools/db_crashtest.py --stress_cmd=$(DB_STRESS_CMD) --cleanup_cmd='$(DB_CLEANUP_CMD)'
.PHONY: crash_test crash_test_with_atomic_flush crash_test_with_txn \ .PHONY: crash_test crash_test_with_atomic_flush crash_test_with_txn \
crash_test_with_best_efforts_recovery crash_test_with_ts \ crash_test_with_best_efforts_recovery crash_test_with_ts \

@ -210,6 +210,7 @@ _TEST_DIR_ENV_VAR = "TEST_TMPDIR"
_DEBUG_LEVEL_ENV_VAR = "DEBUG_LEVEL" _DEBUG_LEVEL_ENV_VAR = "DEBUG_LEVEL"
stress_cmd = "./db_stress" stress_cmd = "./db_stress"
cleanup_cmd = None
def is_release_mode(): def is_release_mode():
@ -224,6 +225,10 @@ def get_dbname(test_name):
else: else:
dbname = test_tmpdir + "/" + test_dir_name dbname = test_tmpdir + "/" + test_dir_name
shutil.rmtree(dbname, True) shutil.rmtree(dbname, True)
if cleanup_cmd is not None:
print("Running DB cleanup command - %s\n" % cleanup_cmd)
# Ignore failure
os.system(cleanup_cmd)
os.mkdir(dbname) os.mkdir(dbname)
return dbname return dbname
@ -691,6 +696,7 @@ def gen_cmd(params, unknown_params):
"write_policy", "write_policy",
"stress_cmd", "stress_cmd",
"test_tiered_storage", "test_tiered_storage",
"cleanup_cmd",
} }
and v is not None and v is not None
] ]
@ -926,6 +932,12 @@ def whitebox_crash_main(args, unknown_args):
# we need to clean up after ourselves -- only do this on test # we need to clean up after ourselves -- only do this on test
# success # success
shutil.rmtree(dbname, True) shutil.rmtree(dbname, True)
if cleanup_cmd is not None:
print("Running DB cleanup command - %s\n" % cleanup_cmd)
ret = os.system(cleanup_cmd)
if ret != 0:
print("TEST FAILED. DB cleanup returned error %d\n" % ret)
sys.exit(1)
os.mkdir(dbname) os.mkdir(dbname)
if (expected_values_dir is not None): if (expected_values_dir is not None):
shutil.rmtree(expected_values_dir, True) shutil.rmtree(expected_values_dir, True)
@ -938,6 +950,7 @@ def whitebox_crash_main(args, unknown_args):
def main(): def main():
global stress_cmd global stress_cmd
global cleanup_cmd
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="This script runs and kills \ description="This script runs and kills \
@ -953,6 +966,7 @@ def main():
parser.add_argument("--write_policy", choices=["write_committed", "write_prepared"]) parser.add_argument("--write_policy", choices=["write_committed", "write_prepared"])
parser.add_argument("--stress_cmd") parser.add_argument("--stress_cmd")
parser.add_argument("--test_tiered_storage", action="store_true") parser.add_argument("--test_tiered_storage", action="store_true")
parser.add_argument("--cleanup_cmd")
all_params = dict( all_params = dict(
list(default_params.items()) list(default_params.items())
@ -987,6 +1001,8 @@ def main():
if args.stress_cmd: if args.stress_cmd:
stress_cmd = args.stress_cmd stress_cmd = args.stress_cmd
if args.cleanup_cmd:
cleanup_cmd = args.cleanup_cmd
if args.test_type == "blackbox": if args.test_type == "blackbox":
blackbox_crash_main(args, unknown_args) blackbox_crash_main(args, unknown_args)
if args.test_type == "whitebox": if args.test_type == "whitebox":

Loading…
Cancel
Save