From 37de39cdbec84d7cbfb43ae41f08b7197d69ce85 Mon Sep 17 00:00:00 2001 From: afonso pinto Date: Thu, 15 Oct 2026 20:03:53 +0100 Subject: [PATCH 1/2] CH-296 Allow a custom command for workflow exit handlers --- .../cloudharness/workflows/operations.py | 1 + .../tests/test_on_exit_notify.py | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/libraries/cloudharness-common/cloudharness/workflows/operations.py b/libraries/cloudharness-common/cloudharness/workflows/operations.py index dbc3886e9..d4dacdec7 100644 --- a/libraries/cloudharness-common/cloudharness/workflows/operations.py +++ b/libraries/cloudharness-common/cloudharness/workflows/operations.py @@ -181,6 +181,7 @@ def add_on_exit_notify_handler(self, spec): exit_task = CustomTask( name="exit-handler", image_name=self.on_exit_notify.get('image', 'workflows-notify-queue'), + command=self.on_exit_notify.get('command'), **env_args ) spec['onExit'] = 'exit-handler' diff --git a/libraries/cloudharness-common/tests/test_on_exit_notify.py b/libraries/cloudharness-common/tests/test_on_exit_notify.py index d5375e616..abc369653 100644 --- a/libraries/cloudharness-common/tests/test_on_exit_notify.py +++ b/libraries/cloudharness-common/tests/test_on_exit_notify.py @@ -104,6 +104,37 @@ def test_function(): print("✓ Test passed: Backward compatibility works correctly") +def test_on_exit_notify_supports_command_override(): + """A custom exit image can replace its default startup command.""" + task = tasks.CustomTask('test-task', 'busybox') + command = ['python', '-m', 'example.notifier'] + operation = operations.PipelineOperation( + 'test-command-exit', [task], + on_exit_notify={ + 'image': 'application-image', + 'command': command, + 'queue': 'results', + 'payload': '{"ingestion_id": "example"}', + }, + ) + + workflow = operation.to_workflow() + exit_template = next( + template for template in workflow['spec']['templates'] + if template['name'] == 'exit-handler' + ) + environment = { + item['name']: item['value'] + for item in exit_template['container']['env'] if 'value' in item + } + + assert workflow['spec']['onExit'] == 'exit-handler' + assert exit_template['container']['command'] == command + assert environment['workflow_result'] == '{{workflow.status}}' + assert environment['queue_name'] == 'results' + assert environment['payload'] == '{"ingestion_id": "example"}' + + def test_on_exit_notify_mixed_usage(): """Test mixed usage with some optional parameters""" print("Testing on_exit_notify with mixed usage (queue but no payload)...") @@ -179,5 +210,6 @@ def test_function(): # Should use default image assert 'workflows-notify-queue' in exit_template['container']['image'], f"Should use default image, got {exit_template['container']['image']}" + assert 'command' not in exit_template['container'] print("✓ Test passed: Default image works correctly") From d2445adccc08308faff444d96d8782bb7a3473c1 Mon Sep 17 00:00:00 2001 From: afonso pinto Date: Thu, 15 Oct 2026 23:33:51 +0100 Subject: [PATCH 2/2] CH-296 Fix spacing between deployment CLI tests --- tools/deployment-cli-tools/tests/test_helm.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/deployment-cli-tools/tests/test_helm.py b/tools/deployment-cli-tools/tests/test_helm.py index 3b28c3959..7ed243704 100644 --- a/tools/deployment-cli-tools/tests/test_helm.py +++ b/tools/deployment-cli-tools/tests/test_helm.py @@ -1704,6 +1704,8 @@ def test_find_chart_images_resolves_empty_tag_from_app_version(): assert find_chart_images({'image': {'repository': 'a/b', 'tag': ''}}) == [ ChartImageRef(path=('image',), value={'repository': 'a/b'}), ] + + def test_instances_expand_into_applications(tmp_path): """An instance is deployed as an application of its own, inheriting the parent's configuration.""" out_folder = tmp_path / 'test_instances_expand_into_applications'