Testing Actions
Before using actions in production deployments, test them to ensure they work correctly.
Testing Approaches
Section titled “Testing Approaches”Actions can be deployed directly on their own, as part of a sequence, or as part of a solution. Deploying an action directly is the fastest way to test it in isolation — create a deployment targeting a low-risk environment and specify the action ID as the deployment source.
1. Test Environment Deployment
Section titled “1. Test Environment Deployment”Create a dedicated testing environment:
| Environment | Purpose | Targets |
|---|---|---|
| Test | Action validation | 1-2 test machines |
| Development | Integration testing | Dev infrastructure |
Deploy the action directly (or add it to a sequence and deploy that) to a test environment first, before promoting it toward production. Scope the deployment to one or two test targets (see Target Selection) to limit blast radius while validating.
2. Dry Run Mode
Section titled “2. Dry Run Mode”Some script actions support a dry-run mode. Script content is not
variable-substituted, so the script reads resolved variables from their
MANTIS_* environment variables:
#!/bin/bashDRY_RUN="${DRY_RUN:-false}"
if [ "$DRY_RUN" = "true" ]; then echo "[DRY RUN] Would execute: docker pull $MANTIS_IMAGE"else docker pull "$MANTIS_IMAGE"fiAdd DRY_RUN as an environment variable and set to true for testing. The
image solution variable is injected as MANTIS_IMAGE.
What to Test
Section titled “What to Test”Functionality
Section titled “Functionality”| Test | How to Verify |
|---|---|
| Script executes | Check exit code is 0 |
| Expected output | Review stdout |
| Side effects | Verify changes on target |
| Arguments work | Test with different values |
Error Handling
Section titled “Error Handling”| Test | How to Verify |
|---|---|
| Missing arguments | Should fail gracefully |
| Invalid input | Should show clear error |
| Network failure | Should timeout appropriately |
| Permission denied | Should report access issue |
Edge Cases
Section titled “Edge Cases”| Test | Example |
|---|---|
| Empty strings | Argument with no value |
| Special characters | Paths with spaces |
| Large files | Big downloads or uploads |
| Long runtime | Operations near timeout |
Viewing Test Results
Section titled “Viewing Test Results”Execution Output
Section titled “Execution Output”After running, view the execution details:
┌─────────────────────────────────────────────────────────┐│ Execution Results │├─────────────────────────────────────────────────────────┤│ ││ Status: ✓ Completed ││ Duration: 12.3 seconds ││ Exit Code: 0 ││ ││ ───────────────────────────────────────────────────── ││ ││ Output: ││ ┌───────────────────────────────────────────────────┐ ││ │ Deploying version 1.0.0 to development │ ││ │ Pulling docker image... │ ││ │ Image pulled successfully │ ││ │ Starting container... │ ││ │ Container started on port 8080 │ ││ │ Health check passed │ ││ │ Deployment complete! │ ││ └───────────────────────────────────────────────────┘ ││ ││ [Close] │└─────────────────────────────────────────────────────────┘Error Output
Section titled “Error Output”When execution fails:
┌─────────────────────────────────────────────────────────┐│ Execution Results │├─────────────────────────────────────────────────────────┤│ ││ Status: ✗ Failed ││ Duration: 3.1 seconds ││ Exit Code: 1 ││ ││ ───────────────────────────────────────────────────── ││ ││ Error: ││ ┌───────────────────────────────────────────────────┐ ││ │ Error: Cannot connect to Docker daemon │ ││ │ Is docker running? │ ││ └───────────────────────────────────────────────────┘ ││ ││ Output: ││ ┌───────────────────────────────────────────────────┐ ││ │ Deploying version 1.0.0 to development │ ││ │ Pulling docker image... │ ││ └───────────────────────────────────────────────────┘ ││ │└─────────────────────────────────────────────────────────┘Testing Strategies
Section titled “Testing Strategies”Progressive Testing
Section titled “Progressive Testing”Test in stages from lowest to highest risk:
Version Testing
Section titled “Version Testing”When creating new action versions:
- Create the new version
- Deploy the action directly (or update a test sequence to use the new version and deploy that)
- Deploy to a test environment
- Monitor for issues
- Update production sequences or direct-action deployments
Regression Testing
Section titled “Regression Testing”When modifying actions:
| Test | Verify |
|---|---|
| Existing functionality | Still works |
| New functionality | Works as expected |
| Backward compatibility | Old arguments still work |
| Error cases | Still handled properly |
Writing Testable Actions
Section titled “Writing Testable Actions”Include Verbose Output
Section titled “Include Verbose Output”Inside a script, read resolved variables from their MANTIS_* environment
variables (script content is not {{...}}-substituted):
#!/bin/bashset -e
echo "=== Deploy Action v$MANTIS_VERSION ==="echo "Target: $(hostname)"echo "Date: $(date)"echo "Arguments: image=$MANTIS_IMAGE, tag=$MANTIS_TAG"
# ... rest of scriptAdd Validation Steps
Section titled “Add Validation Steps”#!/bin/bashset -e
# Validate argumentsif [ -z "$MANTIS_IMAGE" ]; then echo "ERROR: image variable is required" exit 1fi
# Validate environmentif ! command -v docker &> /dev/null; then echo "ERROR: docker is not installed" exit 1fi
# Proceed with deploymentecho "Validation passed, proceeding..."Return Meaningful Exit Codes
Section titled “Return Meaningful Exit Codes”#!/bin/bash
# Exit codes:# 0 - Success# 1 - General error# 2 - Invalid arguments# 3 - Environment issue# 4 - Deployment failed
if [ -z "$MANTIS_VERSION" ]; then echo "ERROR: version is required" exit 2fi
if ! docker info &> /dev/null; then echo "ERROR: Cannot connect to Docker" exit 3fi
if ! docker pull "myimage:$MANTIS_VERSION"; then echo "ERROR: Failed to pull image" exit 4fi
echo "Success!"exit 0Common Testing Issues
Section titled “Common Testing Issues”Action Works Locally, Fails on Target
Section titled “Action Works Locally, Fails on Target”| Possible Cause | Solution |
|---|---|
| Different OS | Check executor compatibility |
| Missing dependencies | Add prerequisite checks |
| Permission differences | Verify agent permissions |
| Network differences | Check firewall rules |
Timeout During Test
Section titled “Timeout During Test”| Possible Cause | Solution |
|---|---|
| Slow network | Increase timeout setting |
| Large download | Add progress output |
| Hanging command | Add timeout to commands |
| Infinite loop | Add loop limits |
Arguments Not Substituted
Section titled “Arguments Not Substituted”| Possible Cause | Solution |
|---|---|
| Typo in variable name | Check spelling |
| Missing variable definition | Add to solution / action |
| Expecting substitution inside script content | Script content is not substituted — read MANTIS_* env vars |
| Wrong placeholder syntax | Use {{var}} or ${var} in arguments |
Test Checklist
Section titled “Test Checklist”Before promoting to production:
- Action executes successfully on test target
- All required arguments are validated
- Error cases return non-zero exit codes
- Output is clear and informative
- Timeout is set appropriately
- No secrets are logged
- Rollback/cleanup is possible
Next Steps
Section titled “Next Steps”- Versioning - Publish tested versions
- Creating Sequences - Use actions in sequences
- Overview - Return to actions overview
