Skip to content

Keep tests in git

A test file describes one performance test as code. You commit it next to the script it runs, review changes in pull requests, and let CI sync it to MaxoPerf. This page shows the file layout, the sync rules and the case where console edits get overwritten.

.maxoperf/
tests/
checkout.yml
perf/
checkout/
script.js
users.csv

Every *.yml or *.yaml file in .maxoperf/tests/ is one test. Paths inside the file (entrypoint, assets) are relative to the repository root.

  1. Create .maxoperf/tests/checkout.yml:

    version: 1
    name: "Checkout soak" # the key: unique per project
    projectId: "prj-0123456789" # optional if the project is passed another way
    engineKind: "k6"
    entrypoint: "perf/checkout/script.js"
    assets: ["perf/checkout/users.csv"]
    loadProfile: { virtualUsers: 50, agentCount: 1, rampUpSeconds: 30, durationSeconds: 300 }
    locationPlan: { managedRegions: ["us-east-1"] } # or privateDatacenterId: "pdc-..."
    failureCriteria:
    - { subject: "p95", condition: ">", threshold: 800, unit: "ms" }
    - { subject: "fail", condition: ">", threshold: 0 }
    tags: ["smoke", "checkout"]
    config: ["TARGET_URL"] # workspace config values to bind, by key
    secrets: ["CHECKOUT_API_TOKEN"] # workspace secrets to bind, by key
  2. Create the workspace config value TARGET_URL and the secret CHECKOUT_API_TOKEN in the console first. A listed key that does not exist fails the sync and the error names the key. See Manage test secrets.

  3. Run the action with command: push to sync without running:

    - uses: MaxoPerf/github-action@v1
    with:
    api-key: ${{ secrets.MAXOPERF_API_KEY }}
    account-id: ${{ vars.MAXOPERF_ACCOUNT_ID }}
    command: push

    From a terminal the equivalent is npx @maxoperf/cli push.

FieldRequiredMeaning
versionyesAlways 1.
nameyesThe test’s identity. Sync finds the test by exact name within the project.
projectIdnoProject the test lives in.
engineKindyesThe engine that runs the script, for example k6 or jmeter.
entrypointyesPath of the main script, relative to the repository root.
assetsnoExtra files uploaded with the test, such as CSV data.
loadProfileyesVirtual users, runner count, ramp-up and duration.
locationPlan or privateDatacenterIdone of themWhere the test runs.
failureCriterianoConditions that fail a run. Each needs subject, condition (>, <, >=, <=, =, ==) and a numeric threshold.
tagsnoTags on the test. Deploy hooks select tests by tag.
confignoNames of workspace config values to bind.
secretsnoNames of workspace secrets to bind.

An unknown key makes the file fail with a message naming the key, and nothing is sent for that file. Only plain, upload-mode, single performance tests fit the format. Browser settings, runner sizes and other console-only settings are not part of it.

The project comes from the first of: the project-id input or --project flag, the file’s projectId, then the MAXOPERF_PROJECT_ID environment variable. If none is set, the file fails.

For each file, sync does the following in order:

  1. Finds the test by name in the project, or creates it.
  2. Replaces the bindings with exactly the config and secrets keys you list.
  3. Uploads every file whose content hash changed and deletes test files that are no longer listed.
  4. Writes the full configuration from the YAML and marks the test as managed from git.

A second sync of an unchanged repository uploads nothing and creates nothing.

A test synced from git shows where it came from and warns that console edits are overwritten.

If a matrix of jobs syncs a test that does not exist yet, two jobs can both create it. Sync once in an earlier job, then fan out:

jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: MaxoPerf/github-action@v1
with:
api-key: ${{ secrets.MAXOPERF_API_KEY }}
account-id: ${{ vars.MAXOPERF_ACCOUNT_ID }}
command: push
load-test:
needs: sync
strategy:
matrix:
test: [checkout, search]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: MaxoPerf/github-action@v1
with:
api-key: ${{ secrets.MAXOPERF_API_KEY }}
account-id: ${{ vars.MAXOPERF_ACCOUNT_ID }}
tests: .maxoperf/tests/${{ matrix.test }}.yml

If duplicates already exist, every later sync fails that file and names both test ids, so it is never silent. Do not start runs of a test while a push of the same test is still running.