From dd22e8a553912e4be0710d1dc0c9f746b0c2e796 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Tue, 29 Jul 2025 12:50:03 -0300 Subject: [PATCH] SIENTIAPDE-1172 Update values.yaml and tests to incorporate mail_type parameter for notification handling - Changed GITHUB_BRANCH in values.yaml to reflect the new alert pipeline. - Added 'mail_type' parameter to various test cases in SlotManager and notification workflows to enhance notification specificity and tracking. - Ensured consistency in test data structures across multiple test functions. --- .../activities/test_slot_manager.py | 25 ++++++++++++------- .../test_load_notification_package.py | 13 +++++++--- values.yaml | 4 +-- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/tests/orchestrator/activities/test_slot_manager.py b/tests/orchestrator/activities/test_slot_manager.py index d43112c..debf0a7 100644 --- a/tests/orchestrator/activities/test_slot_manager.py +++ b/tests/orchestrator/activities/test_slot_manager.py @@ -217,7 +217,8 @@ async def test_get_last_data_timestamp_none(slot_manager): test_data = { **metadata, 'workflow_name': 'test_pipeline', - 'schedule_name': 'test_schedule' + 'schedule_name': 'test_schedule', + 'mail_type': 'test_mail_type' } slot_manager.get = MagicMock(return_value=None) @@ -233,7 +234,8 @@ async def test_get_last_data_timestamp_not_none(slot_manager): test_data = { **metadata, 'workflow_name': 'test_pipeline', - 'schedule_name': 'test_schedule' + 'schedule_name': 'test_schedule', + 'mail_type': 'test_mail_type' } slot_manager.get = MagicMock(return_value='2023-01-01 12:00:00') @@ -241,7 +243,7 @@ async def test_get_last_data_timestamp_not_none(slot_manager): result = await slot_manager.get_last_data_timestamp(test_data) slot_manager.get.assert_called_once_with( - 'notification_last_timestamp' + 'notification_last_timestamp:test_mail_type' ) assert result == '2023-01-01 12:00:00' @@ -253,7 +255,8 @@ async def test_get_last_data_timestamp_error(slot_manager): test_data = { **metadata, 'workflow_name': 'test_pipeline', - 'schedule_name': 'test_schedule' + 'schedule_name': 'test_schedule', + 'mail_type': 'test_mail_type' } slot_manager.send_notification = MagicMock() @@ -286,7 +289,8 @@ async def test_put_last_data_timestamp_empty_dataframe(slot_manager): **metadata, 'workflow_name': 'test_pipeline', 'schedule_name': 'test_schedule', - 'data': DataFrame(columns=['name', 'value', 'timestamp']).to_dict('records') + 'data': DataFrame(columns=['name', 'value', 'timestamp']).to_dict('records'), + 'mail_type': 'test_mail_type' } slot_manager.set = MagicMock() @@ -311,7 +315,8 @@ async def test_put_last_data_timestamp_not_empty_dataframe(slot_manager): **metadata, 'workflow_name': 'test_pipeline', 'schedule_name': 'test_schedule', - 'data': data.to_dict('records') + 'data': data.to_dict('records'), + 'mail_type': 'test_mail_type' } slot_manager.set = MagicMock() @@ -321,7 +326,7 @@ async def test_put_last_data_timestamp_not_empty_dataframe(slot_manager): assert result == '2023-01-01 12:00:01' slot_manager.set.assert_called_once_with( - 'notification_last_timestamp', + 'notification_last_timestamp:test_mail_type', '2023-01-01 12:00:01', ttl=18000 ) @@ -338,7 +343,8 @@ async def test_put_last_data_timestamp_error(slot_manager): 'name': ['sensor1', 'sensor2'], 'value': [25.5, 30.0], 'timestamp': ['2023-01-01 12:00:00'] * 2 - }).to_dict('records') + }).to_dict('records'), + 'mail_type': 'test_mail_type' } slot_manager.send_notification = MagicMock() @@ -401,7 +407,8 @@ async def test_filter_notification_alerts(slot_manager): 'contents': ['core_alerts'] } ], - 'notification_ttl': 300 + 'notification_ttl': 300, + 'mail_type': 'test_mail_type' } response = await slot_manager.filter_notification_alerts(input_data) diff --git a/tests/orchestrator/workflows/subworkflows/test_load_notification_package.py b/tests/orchestrator/workflows/subworkflows/test_load_notification_package.py index 3841728..dc77662 100644 --- a/tests/orchestrator/workflows/subworkflows/test_load_notification_package.py +++ b/tests/orchestrator/workflows/subworkflows/test_load_notification_package.py @@ -24,6 +24,7 @@ metadata = { async def test_run(workflow_mock, load_notification_package): input_data = { 'metadata': metadata, + 'mail_type': 'test_mail_type', 'base_data_filter': { 'level': 'ERROR' } @@ -62,7 +63,10 @@ async def test_run(workflow_mock, load_notification_package): workflow_mock.start_local_activity_method.assert_has_calls([ call( Activities.get_last_data_timestamp, - input_data['metadata'], + { + **input_data['metadata'], + 'mail_type': 'test_mail_type' + }, start_to_close_timeout=ANY, retry_policy=ANY ) @@ -110,7 +114,8 @@ async def test_run(workflow_mock, load_notification_package): { 'id': '1', } - ] + ], + 'mail_type': 'test_mail_type' }, start_to_close_timeout=ANY, retry_policy=ANY @@ -123,6 +128,7 @@ async def test_run(workflow_mock, load_notification_package): async def test_run_no_data(workflow_mock, load_notification_package): input_data = { 'metadata': metadata, + 'mail_type': 'test_mail_type', 'base_data_filter': { 'level': 'ERROR' } @@ -152,7 +158,8 @@ async def test_run_no_data(workflow_mock, load_notification_package): 'metadata': metadata, 'base_data_filter': { 'level': 'ERROR' - } + }, + 'mail_type': 'test_mail_type' } workflow_mock.start_local_activity_method.side_effect = [ diff --git a/values.yaml b/values.yaml index 05b3754..0453d96 100644 --- a/values.yaml +++ b/values.yaml @@ -132,7 +132,7 @@ env: - name: GITHUB_REPO_URL value: "git@github.com:Aignosi/sientia-dataops-orchestrator_temporal.git" - name: GITHUB_BRANCH - value: "SIENTIAPDE-1171-criar-pipeline-de-retreino-laborious" + value: "SIENTIAPDE-1172-criar-pipeline-de-alertas-orquestrador" - name: PYTHON_APP value: "orchestrator.worker.worker" @@ -216,4 +216,4 @@ ssh: # kubectl create secret generic smtp-credentials \ # --namespace sientia \ -# --from-literal=app_password='sua-senha-de-app-de-16-digitos' \ No newline at end of file +# --from-literal=app_password='sua-senha-de-app-de-16-digitos'