From 26c8c347c29dbd82b26438b5f95142ffb8b24762 Mon Sep 17 00:00:00 2001 From: Kevin Hunter Kesling Date: Fri, 21 Jul 2023 09:26:15 -0400 Subject: [PATCH] Verify a test pre-condition As seen in CI at least once, it's possible that the noop() function takes too long to complete. Address by: - increasing the timeout - removing the now-deemed-extraneous other parameterizations - and verifying the test pre-condition first. ("We expect to get a result!") Reference problem observed: https://github.com/Parsl/parsl/pull/2812#issuecomment-1645072179 --- parsl/tests/test_python_apps/test_timeout.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/parsl/tests/test_python_apps/test_timeout.py b/parsl/tests/test_python_apps/test_timeout.py index d12b82d3c3..1b0513322c 100644 --- a/parsl/tests/test_python_apps/test_timeout.py +++ b/parsl/tests/test_python_apps/test_timeout.py @@ -15,9 +15,13 @@ def kernel(fail=False): raise TimeoutTestSpecificException() -@pytest.mark.parametrize("timeout_dur", (0.005, 0.01, 0.1)) -def test_timeout(timeout_dur): - timeout(kernel, timeout_dur)() +def test_timeout(): + timeout_dur = 0.1 + try: + timeout(kernel, timeout_dur)() # nominally returns "instantly" + except AppTimeout: + pytest.skip("Pre-condition failed: result not received in timely fashion") + assert False try: time.sleep(timeout_dur + 0.01) # this is the verification @@ -25,7 +29,7 @@ def test_timeout(timeout_dur): assert False, "Timer was not cancelled!" -@pytest.mark.parametrize("timeout_dur", (0.005, 0.01, 0.1)) +@pytest.mark.parametrize("timeout_dur", (0.005, 0.01)) def test_timeout_after_exception(timeout_dur): with pytest.raises(TimeoutTestSpecificException): timeout(kernel, timeout_dur)(True)