From 17bb9e683b6536646e0f759c5634a4650b3a5845 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index fcec2ecdbefa98..415011166cf37d 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: @@ -574,6 +577,11 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage= if not result.wasSuccessful(): sys.exit("Early exiting after failure in TestFramework unit tests") + # Exit the test if there is not enough space on the testing dir + testdir_disk_usage_stats = shutil.disk_usage(tmpdir) + if (testdir_disk_usage_stats.free < MIN_FREE_SPACE): + sys.exit(f"Tests aborted: Insufficient space available in directory: {tmpdir}") + flags = ['--cachedir={}'.format(cache_dir)] + args if enable_coverage: @@ -655,7 +663,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):