Skip to content

Commit 4cfb0eb

Browse files
committed
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
1 parent f681030 commit 4cfb0eb

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

tools/db_crashtest.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
import logging
99
import tempfile
1010
import subprocess
11+
import shutil
1112

1213
# This script runs and kills db_stress multiple times. It checks consistency
13-
# in case of unsafe crashes in Rocksdb.
14+
# in case of unsafe crashes in RocksDB.
1415

1516
def main(argv):
1617
try:
@@ -59,6 +60,8 @@ def main(argv):
5960
+ str(ops_per_thread) + "\nwrite_buffer_size="
6061
+ str(write_buf_size) + "\n")
6162

63+
dbname = tempfile.mkdtemp(prefix='rocksdb_crashtest_')
64+
6265
while time.time() < exit_time:
6366
run_had_errors = False
6467
killtime = time.time() + interval
@@ -98,7 +101,7 @@ def main(argv):
98101
""" % (ops_per_thread,
99102
threads,
100103
write_buf_size,
101-
tempfile.mkdtemp(),
104+
dbname,
102105
random.randint(0, 1),
103106
random.randint(0, 1),
104107
random.randint(0, 1)))
@@ -139,5 +142,8 @@ def main(argv):
139142

140143
time.sleep(1) # time to stabilize before the next run
141144

145+
# we need to clean up after ourselves -- only do this on test success
146+
shutil.rmtree(dbname, True)
147+
142148
if __name__ == "__main__":
143149
sys.exit(main(sys.argv[1:]))

tools/db_crashtest2.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import logging
99
import tempfile
1010
import subprocess
11+
import shutil
1112

1213
# This python script runs db_stress multiple times. Some runs with
1314
# kill_random_test that causes rocksdb to crash at various points in code.
@@ -78,6 +79,7 @@ def main(argv):
7879
# nomral run
7980
additional_opts = "--ops_per_thread=" + str(ops_per_thread)
8081

82+
dbname = tempfile.mkdtemp(prefix='rocksdb_crashtest_')
8183
cmd = re.sub('\s+', ' ', """
8284
./db_stress
8385
--test_batches_snapshots=%s
@@ -113,7 +115,7 @@ def main(argv):
113115
""" % (random.randint(0, 1),
114116
threads,
115117
write_buf_size,
116-
tempfile.mkdtemp(),
118+
dbname,
117119
random.randint(0, 1),
118120
random.randint(0, 1),
119121
random.randint(0, 1),
@@ -154,6 +156,8 @@ def main(argv):
154156
if (stdoutdata.find('fail') >= 0):
155157
print "TEST FAILED. Output has 'fail'!!!\n"
156158
sys.exit(2)
159+
# we need to clean up after ourselves -- only do this on test success
160+
shutil.rmtree(dbname, True)
157161

158162
check_mode = (check_mode + 1) % total_check_mode
159163

0 commit comments

Comments
 (0)