Resume Testing Example¶
This example demonstrates the workflow resumption functionality, allowing you to: - Test workflow failure and recovery - Resume from failed steps - Start from specific steps - Handle required parameters during resumption
Workflow File¶
# Test Resume Workflow
# This workflow is designed to test the workflow resumption functionality.
# It has three steps that can be used to verify different resume scenarios:
#
# How to test:
# 1. Run without required_param - will fail at first step:
# yaml-workflow run workflows/test_resume.yaml
#
# 2. Resume the failed workflow:
# yaml-workflow run workflows/test_resume.yaml --resume required_param=test
#
# 3. Try to resume a completed workflow (should fail):
# yaml-workflow run workflows/test_resume.yaml --resume
#
# 4. Start from a specific step (fresh run):
# yaml-workflow run workflows/test_resume.yaml --start-from process_data required_param=test
name: Test Resume
description: A simple workflow to test resumption functionality
steps:
# Step 1: Validate required parameter
# This step will fail if required_param is not provided
- name: check_required_param
task: shell
command: |
if [ -z "{{ required_param|default('') }}" ]; then
echo "Error: required_param is required" >&2
exit 1
fi
echo "required_param is {{ required_param }}"
echo "{{ required_param }}" > "output/check_result.txt"
outputs:
check_result: "{{ required_param }}"
# Step 2: Process the data
# Creates a file with the parameter value
- name: process_data
task: shell
command: |
echo "Processing data with {{ required_param }}"
echo "{{ required_param }}" > "output/result.txt"
outputs:
process_result: "{{ required_param }}"
# Step 3: Final verification
# Reads and displays the processed result
- name: final_step
task: shell
command: |
echo "Final step - reading result"
cat "output/result.txt"
outputs:
final_result: "$(cat output/result.txt)"
Features Demonstrated¶
- Workflow Resumption
- Resume from failed steps
- Start from specific steps
-
Handle required parameters
-
Parameter Validation
- Required parameter checking
-
Error handling for missing parameters
-
Step Dependencies
- Sequential step execution
- Output capture between steps
-
File-based state persistence
-
Error Handling
- Graceful failure on missing parameters
- Error message output
- Exit code handling
Test Scenarios¶
1. Initial Failure¶
Run without required parameter:
Expected output:
2. Resume After Failure¶
Resume with required parameter:
Expected output:
3. Resume Completed Workflow¶
Try to resume a completed workflow:
Expected output:
4. Start from Specific Step¶
Start from the process_data step:
Expected output:
Tips for Testing¶
-
Clean State
-
Check Output Files
-
Monitor Step Execution
- Watch for step progression
- Check error messages
- Verify output files