From 7cbf177ff3d51a5f9bbdc4d4015b259c9d7995a1 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 15 Oct 2024 17:14:38 +0200 Subject: [PATCH 1/2] 86: Add system test to check if the first and last progress updates are received. --- system_tests/src/test_workflows_steps.py | 37 ++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/system_tests/src/test_workflows_steps.py b/system_tests/src/test_workflows_steps.py index 93cc269..70a3a67 100644 --- a/system_tests/src/test_workflows_steps.py +++ b/system_tests/src/test_workflows_steps.py @@ -4,6 +4,7 @@ import re import threading import unittest +import uuid from datetime import timedelta from pathlib import Path from pprint import pformat @@ -91,8 +92,8 @@ def submit_a_job( workflow_type: str, params_dict: ParamsDict, omotes_job_result_handler: OmotesJobHandler, -): - omotes_client.submit_job( +) -> Job: + return omotes_client.submit_job( esdl=esdl_file, workflow_type=omotes_client.get_workflow_type_manager().get_workflow_by_name(workflow_type), job_timeout=timedelta(hours=1), @@ -285,3 +286,35 @@ def test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped(self) "./test_esdl/output/test__grow_optimizer_default__happy_path_2ndsource_merit_order_swapped.esdl" ) self.compare_esdl(expected_esdl, result_handler.result.output_esdl) + + def test__simulator__check_if_progress_updates_are_received(self) -> None: + # Arrange + result_handler = OmotesJobHandler() + esdl_file = retrieve_esdl_file("./test_esdl/input/simulator_tutorial.esdl") + workflow_type = "simulator" + timeout_seconds = 60.0 + params_dict = { + "timestep": datetime.timedelta(hours=1), + "start_time": datetime.datetime(2019, 1, 1, 0, 0, 0), + "end_time": datetime.datetime(2019, 1, 1, 3, 0, 0), + } + + # Act + with omotes_client() as omotes_client_: + submitted_job = submit_a_job( + omotes_client_, esdl_file, workflow_type, params_dict, result_handler + ) + result_handler.wait_until_result(timeout_seconds) + + # Assert + self.expect_a_result(result_handler, JobResult.SUCCEEDED) + first_update = next( + (update for update in result_handler.progress_updates if update.progress == 0.0), None + ) + last_update = next( + (update for update in result_handler.progress_updates if update.progress == 1.0), None + ) + self.assertIsNotNone(first_update) + self.assertEqual(submitted_job.id, uuid.UUID(first_update.uuid)) + self.assertIsNotNone(last_update) + self.assertEqual(submitted_job.id, uuid.UUID(last_update.uuid)) From 5eb696e10a8a7b3f16423c615cf73a44a3533e36 Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Tue, 15 Oct 2024 17:29:21 +0200 Subject: [PATCH 2/2] 86: Fix merge that went wrong. Add missing lines to progress update system test. --- system_tests/src/test_workflows_steps.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system_tests/src/test_workflows_steps.py b/system_tests/src/test_workflows_steps.py index df95fc1..bef9aa8 100644 --- a/system_tests/src/test_workflows_steps.py +++ b/system_tests/src/test_workflows_steps.py @@ -330,7 +330,10 @@ def test__simulator__check_if_progress_updates_are_received(self) -> None: submitted_job = submit_a_job( omotes_client_, esdl_file, workflow_type, params_dict, result_handler ) + result_handler.wait_until_result(timeout_seconds) + # Assert + self.expect_a_result(result_handler, JobResult.SUCCEEDED) first_update = next( (update for update in result_handler.progress_updates if update.progress == 0.0), None )