diff --git a/tests/ert/unit_tests/forward_model_runner/test_event_reporter.py b/tests/ert/unit_tests/forward_model_runner/test_event_reporter.py index 237c80a66d7..99a23804e3f 100644 --- a/tests/ert/unit_tests/forward_model_runner/test_event_reporter.py +++ b/tests/ert/unit_tests/forward_model_runner/test_event_reporter.py @@ -43,8 +43,8 @@ def test_report_with_successful_start_message_argument(unused_tcp_port): reporter.report(Start(fmstep1)) reporter.report(Finish()) - assert len(mock_server.messages) == 1 - event = event_from_json(mock_server.messages[0]) + assert len(mock_server.messages) == 3 + event = event_from_json(mock_server.messages[1]) assert type(event) is ForwardModelStepStart assert event.ensemble == "ens_id" assert event.real == "0" @@ -70,8 +70,8 @@ def test_report_with_failed_start_message_argument(unused_tcp_port): reporter.report(msg) reporter.report(Finish()) - assert len(mock_server.messages) == 2 - event = event_from_json(mock_server.messages[1]) + assert len(mock_server.messages) == 4 # 2 msgs + connect, disconnect + event = event_from_json(mock_server.messages[2]) assert type(event) is ForwardModelStepFailure assert event.error_msg == "massive_failure" @@ -89,8 +89,8 @@ async def test_report_with_successful_exit_message_argument(unused_tcp_port): reporter.report(Exited(fmstep1, 0)) reporter.report(Finish().with_error("failed")) - assert len(mock_server.messages) == 1 - event = event_from_json(mock_server.messages[0]) + assert len(mock_server.messages) == 3 + event = event_from_json(mock_server.messages[1]) assert type(event) is ForwardModelStepSuccess @@ -107,8 +107,10 @@ def test_report_with_failed_exit_message_argument(unused_tcp_port): reporter.report(Exited(fmstep1, 1).with_error("massive_failure")) reporter.report(Finish()) - assert len(mock_server.messages) == 1 - event = event_from_json(mock_server.messages[0]) + assert len(mock_server.messages) == 3 + assert mock_server.messages[0] == "CONNECT" + assert mock_server.messages[2] == "DISCONNECT" + event = event_from_json(mock_server.messages[1]) assert type(event) is ForwardModelStepFailure assert event.error_msg == "massive_failure" @@ -126,8 +128,11 @@ def test_report_with_running_message_argument(unused_tcp_port): reporter.report(Running(fmstep1, ProcessTreeStatus(max_rss=100, rss=10))) reporter.report(Finish()) - assert len(mock_server.messages) == 1 - event = event_from_json(mock_server.messages[0]) + assert len(mock_server.messages) == 3 + + assert mock_server.messages[0] == "CONNECT" + assert mock_server.messages[2] == "DISCONNECT" + event = event_from_json(mock_server.messages[1]) assert type(event) is ForwardModelStepRunning assert event.max_memory_usage == 100 assert event.current_memory_usage == 10 @@ -146,7 +151,7 @@ def test_report_only_job_running_for_successful_run(unused_tcp_port): reporter.report(Running(fmstep1, ProcessTreeStatus(max_rss=100, rss=10))) reporter.report(Finish()) - assert len(mock_server.messages) == 1 + assert len(mock_server.messages) == 3 def test_report_with_failed_finish_message_argument(unused_tcp_port): @@ -162,7 +167,7 @@ def test_report_with_failed_finish_message_argument(unused_tcp_port): reporter.report(Running(fmstep1, ProcessTreeStatus(max_rss=100, rss=10))) reporter.report(Finish().with_error("massive_failure")) - assert len(mock_server.messages) == 1 + assert len(mock_server.messages) == 3 def test_report_inconsistent_events(unused_tcp_port): @@ -234,4 +239,6 @@ def test_report_with_reconnected_reporter_but_finished_jobs(unused_tcp_port): if reporter._event_publisher_thread.is_alive(): reporter._event_publisher_thread.join() assert reporter._done.is_set() - assert len(mock_server.messages) == 3, "expected 3 Job running messages" + assert len(mock_server.messages) == 5, ( + "expected 3 Job running messages and CONNECT and DISCONNECT" + )