Skip to content

Testing Actions

Before using actions in production deployments, test them to ensure they work correctly.

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.

Create a dedicated testing environment:

EnvironmentPurposeTargets
TestAction validation1-2 test machines
DevelopmentIntegration testingDev 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.

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/bash
DRY_RUN="${DRY_RUN:-false}"
if [ "$DRY_RUN" = "true" ]; then
echo "[DRY RUN] Would execute: docker pull $MANTIS_IMAGE"
else
docker pull "$MANTIS_IMAGE"
fi

Add DRY_RUN as an environment variable and set to true for testing. The image solution variable is injected as MANTIS_IMAGE.

TestHow to Verify
Script executesCheck exit code is 0
Expected outputReview stdout
Side effectsVerify changes on target
Arguments workTest with different values
TestHow to Verify
Missing argumentsShould fail gracefully
Invalid inputShould show clear error
Network failureShould timeout appropriately
Permission deniedShould report access issue
TestExample
Empty stringsArgument with no value
Special charactersPaths with spaces
Large filesBig downloads or uploads
Long runtimeOperations near timeout

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] │
└─────────────────────────────────────────────────────────┘

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... │ │
│ └───────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────┘

Test in stages from lowest to highest risk:

When creating new action versions:

  1. Create the new version
  2. Deploy the action directly (or update a test sequence to use the new version and deploy that)
  3. Deploy to a test environment
  4. Monitor for issues
  5. Update production sequences or direct-action deployments

When modifying actions:

TestVerify
Existing functionalityStill works
New functionalityWorks as expected
Backward compatibilityOld arguments still work
Error casesStill handled properly

Inside a script, read resolved variables from their MANTIS_* environment variables (script content is not {{...}}-substituted):

#!/bin/bash
set -e
echo "=== Deploy Action v$MANTIS_VERSION ==="
echo "Target: $(hostname)"
echo "Date: $(date)"
echo "Arguments: image=$MANTIS_IMAGE, tag=$MANTIS_TAG"
# ... rest of script
#!/bin/bash
set -e
# Validate arguments
if [ -z "$MANTIS_IMAGE" ]; then
echo "ERROR: image variable is required"
exit 1
fi
# Validate environment
if ! command -v docker &> /dev/null; then
echo "ERROR: docker is not installed"
exit 1
fi
# Proceed with deployment
echo "Validation passed, proceeding..."
#!/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 2
fi
if ! docker info &> /dev/null; then
echo "ERROR: Cannot connect to Docker"
exit 3
fi
if ! docker pull "myimage:$MANTIS_VERSION"; then
echo "ERROR: Failed to pull image"
exit 4
fi
echo "Success!"
exit 0
Possible CauseSolution
Different OSCheck executor compatibility
Missing dependenciesAdd prerequisite checks
Permission differencesVerify agent permissions
Network differencesCheck firewall rules
Possible CauseSolution
Slow networkIncrease timeout setting
Large downloadAdd progress output
Hanging commandAdd timeout to commands
Infinite loopAdd loop limits
Possible CauseSolution
Typo in variable nameCheck spelling
Missing variable definitionAdd to solution / action
Expecting substitution inside script contentScript content is not substituted — read MANTIS_* env vars
Wrong placeholder syntaxUse {{var}} or ${var} in arguments

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