Skip to content

Commit

Permalink
Add test serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Shrews committed Jul 11, 2024
1 parent bdc0159 commit 43f8271
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,15 @@ def project_fixtures(tmp_path):
yield dest

shutil.rmtree(dest, ignore_errors=True)


def pytest_collection_modifyitems(session, config, items):
# pylint: disable=W0613
# 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)')
)
4 changes: 4 additions & 0 deletions test/integration/test_transmit_worker_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ commands = pytest -vv -n auto {posargs:test/unit} {[shared]pytest_cov_args}

[testenv:integration{,-py39,-py310,-py311,-py312,-py313}]
description = Run integration tests
commands = pytest -vv -n auto {posargs:test/integration} {[shared]pytest_cov_args}
commands =
pytest -vv -n auto -m "not serial" {posargs:test/integration} {[shared]pytest_cov_args}
pytest -n 0 -m "serial" {posargs:test/integration} {[shared]pytest_cov_args}

[testenv:docs]
description = Build documentation
Expand Down

0 comments on commit 43f8271

Please sign in to comment.