diff --git a/redis_benchmarks_specification/__runner__/runner.py b/redis_benchmarks_specification/__runner__/runner.py index a9f44f8..78e432d 100644 --- a/redis_benchmarks_specification/__runner__/runner.py +++ b/redis_benchmarks_specification/__runner__/runner.py @@ -2671,6 +2671,14 @@ def delete_temporary_files( if not success: logging.error(f"Memtier benchmark failed: {stderr}") + # Clean up database after failure (timeout or error) + if args.flushall_on_every_test_end or args.flushall_on_every_test_start: + logging.warning("Benchmark failed - cleaning up database with FLUSHALL") + try: + for r in redis_conns: + r.flushall() + except Exception as e: + logging.error(f"FLUSHALL failed after benchmark failure: {e}") # Continue with the test but log the failure client_container_stdout = f"ERROR: {stderr}" @@ -3014,6 +3022,15 @@ def delete_temporary_files( print("-" * 60) test_result = False + # Clean up database after exception to prevent contamination of next test + if args.flushall_on_every_test_end or args.flushall_on_every_test_start: + logging.warning("Exception caught - cleaning up database with FLUSHALL") + try: + for r in redis_conns: + r.flushall() + except Exception as e: + logging.error(f"FLUSHALL failed after exception: {e}") + # Check if user requested exit via Ctrl+C if _exit_requested: logging.info(