Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
32 changes: 32 additions & 0 deletions libraries/cloudharness-common/tests/test_on_exit_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)...")
Expand Down Expand Up @@ -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")
2 changes: 2 additions & 0 deletions tools/deployment-cli-tools/tests/test_helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Loading