Skip to content

Commit 2ceb3ef

Browse files
anand1976archang19
authored andcommitted
Add a cleanup target to crash_test.mk (#14286)
Summary: Pull Request resolved: #14286 Add the db_c leanup target which can be used by CI test scripts to delete the db on failure. The db_crashtest.py doesn't automatically delete on error. Reviewed By: jaykorean Differential Revision: D91912877 fbshipit-source-id: d36ec0896fba64faaafe055d8673e437e85d0c3a
1 parent edc7620 commit 2ceb3ef

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

crash_test.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ CRASHTEST_PY=$(PYTHON) -u tools/db_crashtest.py --stress_cmd=$(DB_STRESS_CMD) --
3434
whitebox_crash_test_with_txn whitebox_crash_test_with_ts \
3535
whitebox_crash_test_with_optimistic_txn \
3636
whitebox_crash_test_with_tiered_storage \
37+
crash_test_db_cleanup \
3738

3839
crash_test: $(DB_STRESS_CMD)
3940
# Do not parallelize
@@ -161,6 +162,9 @@ whitebox_crash_test_with_optimistic_txn: $(DB_STRESS_CMD)
161162
$(CRASHTEST_PY) --optimistic_txn whitebox --random_kill_odd \
162163
$(CRASH_TEST_KILL_ODD) $(CRASH_TEST_EXT_ARGS)
163164

165+
crash_test_db_cleanup: $(DB_STRESS_CMD)
166+
$(DB_STRESS_CMD) --delete_dir_and_exit=$(TEST_TMPDIR)
167+
164168
# Old names DEPRECATED
165169
crash_test_with_txn: crash_test_with_wc_txn
166170
whitebox_crash_test_with_txn: whitebox_crash_test_with_wc_txn

db_stress_tool/db_stress_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ DECLARE_bool(verify_before_write);
101101
DECLARE_bool(histogram);
102102
DECLARE_bool(destroy_db_initially);
103103
DECLARE_bool(destroy_db_and_exit);
104+
DECLARE_string(delete_dir_and_exit);
104105
DECLARE_bool(verbose);
105106
DECLARE_bool(progress_reports);
106107
DECLARE_uint64(db_write_buffer_size);

db_stress_tool/db_stress_gflags.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ DEFINE_bool(destroy_db_and_exit, false,
139139
"Destroys the database dir and exits. Useful for cleanup without "
140140
"running stress test. Other options are mostly ignored.");
141141

142+
DEFINE_string(delete_dir_and_exit, "",
143+
"Recursively deletes the specified directory and exits. "
144+
"Useful for cleaning up TEST_TMPDIR after crash tests.");
145+
142146
DEFINE_bool(verbose, false, "Verbose");
143147

144148
DEFINE_bool(progress_reports, true,

db_stress_tool/db_stress_tool.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,20 @@ int db_stress_tool(int argc, char** argv) {
111111
}
112112
}
113113

114+
// Handle --delete_dir_and_exit early, before other option validation
115+
if (!FLAGS_delete_dir_and_exit.empty()) {
116+
s = DestroyDir(raw_env, FLAGS_delete_dir_and_exit);
117+
if (s.ok()) {
118+
fprintf(stdout, "Successfully deleted directory %s\n",
119+
FLAGS_delete_dir_and_exit.c_str());
120+
return 0;
121+
} else {
122+
fprintf(stderr, "Failed to delete directory %s: %s\n",
123+
FLAGS_delete_dir_and_exit.c_str(), s.ToString().c_str());
124+
return 1;
125+
}
126+
}
127+
114128
FLAGS_rep_factory = StringToRepFactory(FLAGS_memtablerep.c_str());
115129

116130
// The number of background threads should be at least as much the

0 commit comments

Comments
 (0)