CI-gated performance test
Problem: A deployment can bring in a performance regression. You want your CI pipeline to run a performance test on every release candidate, report the key metrics, and fail the build when the result is worse than your baseline. All of that has to happen before the code ships to production.
Test type: Baseline regression test triggered from CI.
Prerequisites
Section titled “Prerequisites”- A MaxoPerf account with a test that has a clean baseline run.
- A MaxoPerf API key (
mpak_...) and your account id, stored as a secret in your CI provider (GitHub Actions, GitLab CI, CircleCI, etc.). - Failure criteria configured on the test. The criteria decide whether the run ends with status
passedorfailed. - The test ID from the MaxoPerf console (visible in the URL when the test is open:
/tests/tst-xxxxxxxx).
See Run tests from CI for the how-to reference.
Step by step in MaxoPerf
Section titled “Step by step in MaxoPerf”1. Configure failure criteria on the test
Section titled “1. Configure failure criteria on the test”Before you wire up CI, tell the test when to fail. In the MaxoPerf console:
- Open the test, switch to Configuration, and scroll to Failure criteria.
- Add your thresholds, for example
p95 latency > 300msanderror rate > 0.5 %. - Save.
The CI pipeline reads the run status field to decide pass or fail. CI needs no custom logic.
2. Store the API key and account id in CI
Section titled “2. Store the API key and account id in CI”In your CI provider, add a secret named MAXOPERF_TOKEN with your MaxoPerf API key and a variable named MAXOPERF_ACCOUNT_ID with your account id (shown on Settings → API keys). Every API call sends the account id in the X-Account-Id header.
3. Add the pipeline step
Section titled “3. Add the pipeline step”GitHub Actions example:
name: Performance gate
on: push: branches: [main, 'release/**']
jobs: perf: runs-on: ubuntu-latest steps: - name: Trigger MaxoPerf run id: start run: | RUN=$(curl -sf -X POST \ -H "Authorization: Bearer ${{ secrets.MAXOPERF_TOKEN }}" \ -H "X-Account-Id: ${{ vars.MAXOPERF_ACCOUNT_ID }}" \ -H "Content-Type: application/json" \ https://app.maxoperf.com/v1/runs \ -d '{"testId": "tst-1234abcd56"}') echo "run_id=$(echo $RUN | jq -r .runId)" >> $GITHUB_OUTPUT
- name: Wait for run to complete run: | for i in $(seq 1 60); do STATUS=$(curl -sf \ -H "Authorization: Bearer ${{ secrets.MAXOPERF_TOKEN }}" \ -H "X-Account-Id: ${{ vars.MAXOPERF_ACCOUNT_ID }}" \ https://app.maxoperf.com/v1/runs/${{ steps.start.outputs.run_id }} \ | jq -r .status) echo "Run status: $STATUS" if [ "$STATUS" = "passed" ]; then echo "Run passed failure criteria." exit 0 elif [ "$STATUS" = "failed" ] || [ "$STATUS" = "cancelled" ]; then echo "Run did not pass failure criteria — status: $STATUS" exit 1 fi sleep 10 done echo "Timed out waiting for run." exit 1Replace tst-1234abcd56 with your real test ID.
GitLab CI example:
perf-gate: stage: test script: - | RUN_ID=$(curl -sf -X POST \ -H "Authorization: Bearer $MAXOPERF_TOKEN" \ -H "X-Account-Id: $MAXOPERF_ACCOUNT_ID" \ -H "Content-Type: application/json" \ https://app.maxoperf.com/v1/runs \ -d "{\"testId\": \"tst-1234abcd56\"}" | jq -r .runId) echo "Started run: $RUN_ID" for i in $(seq 1 60); do STATUS=$(curl -sf \ -H "Authorization: Bearer $MAXOPERF_TOKEN" \ -H "X-Account-Id: $MAXOPERF_ACCOUNT_ID" \ https://app.maxoperf.com/v1/runs/$RUN_ID | jq -r .status) [ "$STATUS" = "passed" ] && exit 0 [ "$STATUS" = "failed" ] || [ "$STATUS" = "cancelled" ] && exit 1 sleep 10 done exit 14. Verify the pipeline run in the console
Section titled “4. Verify the pipeline run in the console”- Open the Runs list in the MaxoPerf console after the CI step fires.
- The run started by CI appears with the test name and a timestamp matching the pipeline execution.
- Click the run to see the full result: per-label latency, error rate, and the failure-criteria verdict.
Verify
Section titled “Verify”- The CI step exits
0when the run status ispassedand1when it isfailedorcancelled. - The run appears in the MaxoPerf console. Runs started with a
ciContextshow a CI chip with the repository, branch and commit. - Failure criteria violations show on the run overview with the exact threshold that was breached.
Variations
Section titled “Variations”- Point a run at another environment: pass
"configOverrides": {"TARGET_URL": "https://staging.example.com"}in the trigger body. The test must readTARGET_URLfrom its environment. - Record the commit on the run: add
"ciContext": {"provider": "github", "sha": "$GITHUB_SHA", "branch": "$GITHUB_REF_NAME"}to the trigger body. The console shows it as a CI chip, and the runs list can filter by branch. - Retry safely: send an
Idempotency-Keyheader. The same key andtestIdwithin 24 hours returns the original run instead of starting another. - Webhook instead of polling: configure a MaxoPerf webhook that POSTs to your CI pipeline’s callback URL when the run completes. You no longer need the polling loop.
- Parallel CI jobs: trigger a matrix of tests (smoke, load, API) in parallel CI jobs. Each job polls its own
run_id.
Where to go next
Section titled “Where to go next”- Failure criteria pass/fail gates: set the thresholds behind the CI pass/fail signal.
- Run tests from CI: the how-to reference for the API-driven workflow.
- Comparing runs and baselines: after the CI gate passes, compare the run to the release baseline.
- API reference: the full HTTP surface for automation.