From 08f19dbc3ba703d97350be315d70969351114ffb Mon Sep 17 00:00:00 2001 From: Andreas Eknes Lie Date: Tue, 1 Oct 2024 09:35:32 +0200 Subject: [PATCH] Update bjobs output with placeholder for exec_hosts in tests --- src/ert/scheduler/lsf_driver.py | 3 +-- .../unit_tests/scheduler/test_lsf_driver.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/ert/scheduler/lsf_driver.py b/src/ert/scheduler/lsf_driver.py index c68f5caf661..117ead8c9fe 100644 --- a/src/ert/scheduler/lsf_driver.py +++ b/src/ert/scheduler/lsf_driver.py @@ -108,7 +108,7 @@ class JobData: iens: int job_state: AnyJob submitted_timestamp: float - exec_hosts: str + exec_hosts: str = "-" def parse_bjobs(bjobs_output: str) -> Dict[str, JobState]: @@ -372,7 +372,6 @@ async def submit( iens=iens, job_state=QueuedJob(job_state="PEND"), submitted_timestamp=time.time(), - exec_hosts="-", ) self._iens2jobid[iens] = job_id diff --git a/tests/ert/unit_tests/scheduler/test_lsf_driver.py b/tests/ert/unit_tests/scheduler/test_lsf_driver.py index 280526f52d8..d37f800b355 100644 --- a/tests/ert/unit_tests/scheduler/test_lsf_driver.py +++ b/tests/ert/unit_tests/scheduler/test_lsf_driver.py @@ -429,13 +429,13 @@ def test_parse_bjobs_gives_empty_result_on_random_input(some_text): "bjobs_output, expected", [ pytest.param( - "1^RUN", + "1^RUN^-", {"1": "RUN"}, id="basic", ), - pytest.param("1^DONE", {"1": "DONE"}, id="done"), + pytest.param("1^DONE^-", {"1": "DONE"}, id="done"), pytest.param( - "1^DONE\n2^RUN", + "1^DONE^-\n2^RUN^-", {"1": "DONE", "2": "RUN"}, id="two_jobs", ), @@ -451,7 +451,7 @@ def test_parse_bjobs_happy_path(bjobs_output, expected): st.from_type(JobState), ) def test_parse_bjobs(job_id, username, job_state): - assert parse_bjobs(f"{job_id}^{job_state}") == {str(job_id): job_state} + assert parse_bjobs(f"{job_id}^{job_state}^-") == {str(job_id): job_state} @given(nonempty_string_without_whitespace().filter(lambda x: x not in valid_jobstates)) @@ -461,7 +461,7 @@ def test_parse_bjobs_invalid_state_is_ignored(random_state): def test_parse_bjobs_invalid_state_is_logged(caplog): # (cannot combine caplog with hypothesis) - parse_bjobs("1^FOO") + parse_bjobs("1^FOO^-") assert "Unknown state FOO" in caplog.text @@ -469,7 +469,7 @@ def test_parse_bjobs_invalid_state_is_logged(caplog): "bjobs_script, expectation", [ pytest.param( - "echo '1^DONE'; exit 0", + "echo '1^DONE^-'; exit 0", does_not_raise(), id="all-good", ), @@ -485,13 +485,13 @@ def test_parse_bjobs_invalid_state_is_logged(caplog): id="empty_cluster_specific_id", ), pytest.param( - "echo '1^DONE'; echo 'Job <2> is not found' >&2 ; exit 255", + "echo '1^DONE^-'; echo 'Job <2> is not found' >&2 ; exit 255", # If we have some success and some failures, actual command returns 255 does_not_raise(), id="error_for_irrelevant_job_id", ), pytest.param( - "echo '2^DONE'", + "echo '2^DONE^-'", pytest.raises(asyncio.TimeoutError), id="wrong-job-id", ), @@ -501,7 +501,7 @@ def test_parse_bjobs_invalid_state_is_logged(caplog): id="exit-1", ), pytest.param( - "echo '1^DONE'; exit 1", + "echo '1^DONE^-'; exit 1", # (this is not observed in reality) does_not_raise(), id="correct_output_but_exitcode_1",