From 48af457c1dc5320f1d4669db8db5fe7f4f465ebe Mon Sep 17 00:00:00 2001 From: Andreas Eknes Lie Date: Tue, 1 Oct 2024 09:43:30 +0200 Subject: [PATCH] Add tests for bjobs_exec_host parsing --- .../unit_tests/scheduler/test_lsf_driver.py | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/ert/unit_tests/scheduler/test_lsf_driver.py b/tests/ert/unit_tests/scheduler/test_lsf_driver.py index f068e64d87a..489baa54e3d 100644 --- a/tests/ert/unit_tests/scheduler/test_lsf_driver.py +++ b/tests/ert/unit_tests/scheduler/test_lsf_driver.py @@ -36,6 +36,7 @@ filter_job_ids_on_submission_time, parse_bhist, parse_bjobs, + parse_bjobs_exec_hosts, ) from tests.ert.utils import poll, wait_until @@ -444,15 +445,45 @@ def test_parse_bjobs_happy_path(bjobs_output, expected): assert parse_bjobs(bjobs_output) == expected +@pytest.mark.parametrize( + "bjobs_output, expected", + [ + pytest.param( + "1^RUN^st-vgrid01", + {"1": "st-vgrid01"}, + id="one_host", + ), + pytest.param("1^DONE^-", {}, id="no_host"), + pytest.param( + "1^DONE^st-vgrid02\n2^RUN^-", + {"1": "st-vgrid02"}, + id="only_one_host_outputs", + ), + ], +) +def test_parse_bjobs_exec_hosts_happy_path(bjobs_output, expected): + assert parse_bjobs_exec_hosts(bjobs_output) == expected + + @given( st.integers(min_value=1), - nonempty_string_without_whitespace(), st.from_type(JobState), ) -def test_parse_bjobs(job_id, username, job_state): +def test_parse_bjobs(job_id, job_state): assert parse_bjobs(f"{job_id}^{job_state}^-") == {str(job_id): job_state} +@given( + st.integers(min_value=1), + st.from_type(JobState), + nonempty_string_without_whitespace(), +) +def test_parse_bjobs_exec_host(job_id, job_state, exec_host): + assert parse_bjobs_exec_hosts(f"{job_id}^{job_state}^{exec_host}") == { + str(job_id): exec_host + } + + @given(nonempty_string_without_whitespace().filter(lambda x: x not in valid_jobstates)) def test_parse_bjobs_invalid_state_is_ignored(random_state): assert parse_bjobs(f"1^{random_state}") == {}