From 75b525ed6098e461e71be85523757ac9ee5da17d Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Thu, 11 Jul 2024 12:06:35 -0400 Subject: [PATCH] Add test serialization --- pytest.ini | 1 + test/conftest.py | 11 +++++++++++ test/integration/test_transmit_worker_process.py | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/pytest.ini b/pytest.ini index f50948367..89e70cf99 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,6 +1,7 @@ [pytest] markers = test_all_runtimes: Generate a test for each supported container runtime + serial: Tests that need to run serially testpaths = test addopts = -r a diff --git a/test/conftest.py b/test/conftest.py index 6d22a36ec..cc9362256 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -102,3 +102,14 @@ def project_fixtures(tmp_path): yield dest shutil.rmtree(dest, ignore_errors=True) + + +def pytest_collection_modifyitems(session, config, items): + # mark serial items as skipped if it looks like we're running with some obvious kinds of parallelism + numproc = getattr(config.known_args_namespace, 'numprocesses', None) + + if isinstance(numproc, int) and numproc > 1: + for serial_item in (i for i in items if any(i.iter_markers(name='serial'))): + serial_item.add_marker( + pytest.mark.skip(reason='test requires serial execution (add --numprocesses 0 to allow)') + ) diff --git a/test/integration/test_transmit_worker_process.py b/test/integration/test_transmit_worker_process.py index 540e5dc61..f136fe930 100644 --- a/test/integration/test_transmit_worker_process.py +++ b/test/integration/test_transmit_worker_process.py @@ -109,6 +109,10 @@ def test_remote_job_interface(self, tmp_path, project_fixtures, job_type): incoming_buffer.close() self.check_artifacts(str(process_dir), job_type) + # The keepalive tests will run serially since Python 3.13 somehow causes a longer delay + # in the tests, thus causing the keepalive timeout count to exceed the hardcoded value + # of 5. + @pytest.mark.serial @pytest.mark.parametrize("keepalive_setting", [ 0, # keepalive explicitly disabled, default 1, # emit keepalives every 1s