From dbe3ed5fe5efda8bee050fad8ff8f4092dedc5e9 Mon Sep 17 00:00:00 2001 From: Brandon Odiwuor Date: Sun, 28 Jan 2024 11:33:17 +0300 Subject: [PATCH] test: Handle functional test disk-full error --- test/functional/test_runner.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index fcec2ecdbefa98..93e7c76434e82a 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -30,6 +30,9 @@ os.environ["REQUIRE_WALLET_TYPE_SET"] = "1" +# Should fail testing and immediately stop if free space falls below. +MIN_FREE_SPACE = 1250 * 1024 * 1024 + # Formatting. Default colors to empty strings. DEFAULT, BOLD, GREEN, RED = ("", ""), ("", ""), ("", ""), ("", "") try: @@ -559,6 +562,10 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage= if os.path.isdir(cache_dir): print("%sWARNING!%s There is a cache directory here: %s. If tests fail unexpectedly, try deleting the cache directory." % (BOLD[1], BOLD[0], cache_dir)) + # Exit the test if there is not enough space on the testing dir + if shutil.disk_usage(tmpdir).free < MIN_FREE_SPACE: + sys.exit(f"Tests aborted: Insufficient space available in directory: {tmpdir}") + # Test Framework Tests print("Running Unit Tests for Test Framework Modules") @@ -655,7 +662,7 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage= all_passed = all_passed and coverage_passed - # Clean up dangling processes if any. This may only happen with --failfast option. + # Clean up dangling processes if any. This may only happen with --failfast option or not enough space on test directory. # Killing the process group will also terminate the current process but that is # not an issue if not os.getenv("CI_FAILFAST_TEST_LEAVE_DANGLING") and len(job_queue.jobs):