Skip to content

Commit

Permalink
crash_test: clean up DB copies in whitebox and narrow test (#159)
Browse files Browse the repository at this point in the history
The debugging backup logic in whitebox wasn't cleaning up DB copies on
timeout because the cleanup logic was inside the loop. Move it to the end
of the function to ensure that backups are cleaned up on success.

Also make sure to clean up DB backup copies in the narrow test.
  • Loading branch information
isaac-io authored and udi-speedb committed Oct 31, 2023
1 parent ea0be2a commit 5401fb7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tools/db_crashtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,8 @@ def narrow_crash_main(args, unknown_args):
time.sleep(2) # time to stabilize before the next run

shutil.rmtree(dbname, True)
for ctr in range(max(0, counter - 2), counter):
shutil.rmtree('{}_{}'.format(dbname, ctr), True)


# This script runs and kills db_stress multiple times. It checks consistency
Expand Down Expand Up @@ -1039,7 +1041,7 @@ def blackbox_crash_main(args, unknown_args):
# we need to clean up after ourselves -- only do this on test success
shutil.rmtree(dbname, True)
for ctr in range(max(0, counter - 2), counter):
shutil.rmtree('{}_{}'.format(dbname, ctr))
shutil.rmtree('{}_{}'.format(dbname, ctr), True)


# This python script runs db_stress multiple times. Some runs with
Expand Down Expand Up @@ -1236,12 +1238,12 @@ def whitebox_crash_main(args, unknown_args):
expected_values_dir = None

check_mode = (check_mode + 1) % total_check_mode
for ctr in range(max(0, counter - 2), counter):
shutil.rmtree('{}_{}'.format(dbname, ctr))
counter = 0

time.sleep(1) # time to stabilize after a kill

for ctr in range(max(0, counter - 2), counter):
shutil.rmtree('{}_{}'.format(dbname, ctr), True)


def bool_converter(v):
s = v.lower().strip()
Expand Down Expand Up @@ -1304,7 +1306,7 @@ def main():
args, unknown_args = parser.parse_known_args()

test_tmpdir = os.environ.get(_TEST_DIR_ENV_VAR)
if test_tmpdir is not None and not args.skip_tmpdir_check:
if test_tmpdir and not args.skip_tmpdir_check:
isdir = False
try:
isdir = os.path.isdir(test_tmpdir)
Expand Down

0 comments on commit 5401fb7

Please sign in to comment.