From 64117bcaf45ad2be0ee55d1fcac1f1c1af4f6b2b Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Fri, 12 Jan 2024 12:46:36 +0000 Subject: [PATCH] Unify test cases for remote/local workers in case of failure --- tests/integration/test_slurm.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/tests/integration/test_slurm.py b/tests/integration/test_slurm.py index 18a546d9..ab833227 100644 --- a/tests/integration/test_slurm.py +++ b/tests/integration/test_slurm.py @@ -17,7 +17,10 @@ def test_project_check(job_controller): assert check(print_errors=True) is None -@pytest.mark.parametrize("worker", ["test_local_worker", "test_remote_worker"]) +@pytest.mark.parametrize( + "worker", + ["test_local_worker", "test_remote_worker"], +) def test_submit_flow(worker, job_controller): from jobflow import Flow @@ -39,7 +42,10 @@ def test_submit_flow(worker, job_controller): assert job_controller.count_flows({}) == 1 -@pytest.mark.parametrize("worker", ["test_local_worker", "test_remote_worker"]) +@pytest.mark.parametrize( + "worker", + ["test_local_worker", "test_remote_worker"], +) def test_submit_flow_with_dependencies(worker, job_controller): from jobflow import Flow @@ -63,7 +69,10 @@ def test_submit_flow_with_dependencies(worker, job_controller): assert job_controller.count_flows({}) == 1 -@pytest.mark.parametrize("worker", ["test_local_worker", "test_remote_worker"]) +@pytest.mark.parametrize( + "worker", + ["test_local_worker", "test_remote_worker"], +) def test_expected_failure(worker, job_controller): from jobflow import Flow @@ -78,17 +87,12 @@ def test_expected_failure(worker, job_controller): flow = Flow([job_1, job_2]) submit_flow(flow, worker=worker) - runner = Runner() - runner.run(ticks=10) - assert job_controller.count_jobs({}) == 2 assert len(job_controller.get_jobs({})) == 2 assert job_controller.count_flows({}) == 1 - if worker == "test_local_worker": - assert job_controller.count_jobs(state=JobState.FAILED) == 2 - assert job_controller.count_flows(state=FlowState.FAILED) == 1 - else: - # The remote flow will be left in a running state until the remote errors can be rectified - assert job_controller.count_jobs(state=JobState.REMOTE_ERROR) == 2 - assert job_controller.count_flows(state=FlowState.RUNNING) == 1 + runner = Runner() + runner.run(ticks=10) + + assert job_controller.count_jobs(state=JobState.FAILED) == 2 + assert job_controller.count_flows(state=FlowState.FAILED) == 1