Postman
Overview
This guide explains how to run Postman tests against Signadot sandboxes. You can run these tests either:
- Directly in your CI pipeline using Newman (Postman's CLI)
- Using Signadot Jobs for sandbox-aware test execution
Set Up Routing Context
To run tests against sandboxes, you'll need to configure Postman to include the appropriate routing headers. This is required regardless of whether you're running tests in CI or using Signadot Jobs.
Configure Postman Environment
- Create a new environment variable called
routing_key
- Set up your requests to include the routing header:
baggage: {{routing_key}}
- You can set this up as a collection-level pre-request script or in individual requests
Running Tests in CI
To run tests directly in your CI pipeline:
- Create a sandbox for testing
- Get the sandbox's routing key
- Install Newman and run tests:
npm install -g newman
newman run your_collection.json \
--env-var routing_key=<your-sandbox-routing-key> \
-r cli,json
Running Tests as Signadot Jobs
For sandbox-aware test execution, you can run tests as Signadot Jobs. This provides additional benefits:
- Automatic test failure if the sandbox is terminated or fails
- Built-in artifact collection
- Integrated test reporting
Create Job Runner Group
First, create a Job Runner Group:
your_project/.signadot/testing/postman-runner.yaml
name: postman
spec:
cluster: "@{cluster}"
labels:
env: "@{env}"
# We will be using Postman's Newman collection runner to run the tests. However,
# since its image doesn't contain git (which we will need), we'll be using
# the node image instead.
image: node:latest
jobTimeout: 30m
scaling:
manual:
desiredPods: 1
Create Job Specification
your_project/.signadot/testing/postman-integration-job.yaml
spec:
namePrefix: integration-api
runnerGroup: postman
script: |
#!/bin/bash
set -e
npm install -g newman
# Clone the git repo
echo "Cloning repo"
git clone --single-branch -b "@{branch}" \
https://github.com/<org>/<repo>.git
# Run all postman tests
cd <repo>
set +e
newman run your_postman_collection.json \
-r cli,json \
--env-var routing_key=$SIGNADOT_ROUTING_KEY
E2E_EXIT_CODE=$?
set -e
# Compress the newman directory so that it can be uploaded as a single artifact.
tar czf postman-report.tar.gz newman
exit $E2E_EXIT_CODE
routingContext:
sandbox: "@{sandbox}"
uploadArtifact:
- path: your_project/postman-report.tar.gz
tip
The code block between set +e
and set -e
allows the job to continue execution
while saving the test status for proper reporting.