Skip to content

Commit bf497e9

Browse files
anand76facebook-github-bot
anand76
authored andcommitted
Allow a custom DB cleanup command to be passed to db_crashtest.py (facebook#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: facebook#10883 Test Plan: Run the whitebox crash test Reviewed By: pdillinger Differential Revision: D40726424 Pulled By: anand1976 fbshipit-source-id: b827f6b583ff78f9ca75ced2d96f7e58f5200432
1 parent 22ff8c5 commit bf497e9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

crash_test.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ DB_STRESS_CMD?=./db_stress
88
include common.mk
99

1010
CRASHTEST_MAKE=$(MAKE) -f crash_test.mk
11-
CRASHTEST_PY=$(PYTHON) -u tools/db_crashtest.py --stress_cmd=$(DB_STRESS_CMD)
11+
CRASHTEST_PY=$(PYTHON) -u tools/db_crashtest.py --stress_cmd=$(DB_STRESS_CMD) --cleanup_cmd='$(DB_CLEANUP_CMD)'
1212

1313
.PHONY: crash_test crash_test_with_atomic_flush crash_test_with_txn \
1414
crash_test_with_best_efforts_recovery crash_test_with_ts \

tools/db_crashtest.py

+16
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210
_DEBUG_LEVEL_ENV_VAR = "DEBUG_LEVEL"
211211

212212
stress_cmd = "./db_stress"
213+
cleanup_cmd = None
213214

214215

215216
def is_release_mode():
@@ -224,6 +225,10 @@ def get_dbname(test_name):
224225
else:
225226
dbname = test_tmpdir + "/" + test_dir_name
226227
shutil.rmtree(dbname, True)
228+
if cleanup_cmd is not None:
229+
print("Running DB cleanup command - %s\n" % cleanup_cmd)
230+
# Ignore failure
231+
os.system(cleanup_cmd)
227232
os.mkdir(dbname)
228233
return dbname
229234

@@ -691,6 +696,7 @@ def gen_cmd(params, unknown_params):
691696
"write_policy",
692697
"stress_cmd",
693698
"test_tiered_storage",
699+
"cleanup_cmd",
694700
}
695701
and v is not None
696702
]
@@ -926,6 +932,12 @@ def whitebox_crash_main(args, unknown_args):
926932
# we need to clean up after ourselves -- only do this on test
927933
# success
928934
shutil.rmtree(dbname, True)
935+
if cleanup_cmd is not None:
936+
print("Running DB cleanup command - %s\n" % cleanup_cmd)
937+
ret = os.system(cleanup_cmd)
938+
if ret != 0:
939+
print("TEST FAILED. DB cleanup returned error %d\n" % ret)
940+
sys.exit(1)
929941
os.mkdir(dbname)
930942
if (expected_values_dir is not None):
931943
shutil.rmtree(expected_values_dir, True)
@@ -938,6 +950,7 @@ def whitebox_crash_main(args, unknown_args):
938950

939951
def main():
940952
global stress_cmd
953+
global cleanup_cmd
941954

942955
parser = argparse.ArgumentParser(
943956
description="This script runs and kills \
@@ -953,6 +966,7 @@ def main():
953966
parser.add_argument("--write_policy", choices=["write_committed", "write_prepared"])
954967
parser.add_argument("--stress_cmd")
955968
parser.add_argument("--test_tiered_storage", action="store_true")
969+
parser.add_argument("--cleanup_cmd")
956970

957971
all_params = dict(
958972
list(default_params.items())
@@ -987,6 +1001,8 @@ def main():
9871001

9881002
if args.stress_cmd:
9891003
stress_cmd = args.stress_cmd
1004+
if args.cleanup_cmd:
1005+
cleanup_cmd = args.cleanup_cmd
9901006
if args.test_type == "blackbox":
9911007
blackbox_crash_main(args, unknown_args)
9921008
if args.test_type == "whitebox":

0 commit comments

Comments
 (0)