Tests
Write test suites for an app, run them against a deployment on its cluster or on your own workers, and read the runs.
A suite is a group of test files for one app, with the settings to run them: the runner (pytest, go, jest, maven, gradle, dotnet or your own command), the environment variables, and where the results come from. A run is one execution of one version of a suite against one deployment of the app. Open Tests in the sidebar for the workspace, Runs for everything that has run, and Workers for the machines that run tests outside your clusters.
What reads a run
A run is evidence about a snapshot only when you name the snapshot when you start it (snapshotId on POST /test-runs). A stage's test rule and the snapshot's Tests check then read it (below). A run started without a snapshot is still kept and shown, and counts toward no verdict.
Suites and versions
A suite holds versions. A version is a named set of settings and files; each time you save it, that is a new revision, kept for good, so a run can say exactly what it ran. One version is the active one, which runs use unless they name another. You can compare two versions, or two revisions of one, side by side, restore an earlier revision as the newest, and see a suite's history.
If two people edit the same version, the second save is refused with test.revision_conflict and the answer says which revision it is now at, instead of overwriting the first. The editor then offers to reload.
Who may do what
| Permission | What it allows | Held by |
|---|---|---|
test:read | See an app's suites and their runs | Team members, app owners, and anyone who reads everything |
test:author | Write, rename, duplicate and delete suites and their versions | Team members and app owners (not a Viewer) |
test:run | Start and cancel runs on a deployment | Team members and app owners (not a Viewer) |
testenv:manage | Set the variables every test gets | Owners |
testworker:manage | Register and remove workers and their groups | Owners |
A suite you cannot read answers 404, like any place you cannot see. When you start a batch, the suites you may not run are left out and named in the answer; if none may be run, the answer is a 403.
Variables every test gets
Variables can be set for the whole organization, for one environment or for one deployment; the narrower place wins when two share a name. A value is plain text or a reference to a secret, and a secret is shown as its reference, never its value. Names starting with WARDN_, and CI, belong to Wardn and cannot be set.
Runs and batches
A run names the version and revision it ran, the deployment, the snapshot it judged when you asked about one, and where it executes: on the deployment's cluster, on one worker, or on any worker. Starting several suites makes a batch, which you can cancel or run again for the failures only. A run's output is kept up to 4 MiB; a longer one is cut and says so.
A result is reported once. If the same finish is posted twice, or a late report arrives for a run that has already ended, nothing changes. A run that stops reporting is declared interrupted, so a worker that dies does not leave a run running for ever.
Running in a cluster
A run aimed at the deployment's cluster becomes a Kubernetes Job in the deployment's namespace. The server signs a run-test command and sends it to the cluster's operator; the operator creates the Job as the deployment's service account (wardn-deployer), so the account needs the right to create Jobs there, which the admin ClusterRole gives. The Job has two containers: an init container copies the Wardn test agent in, and your suite's image then runs the agent, which writes the suite's files, runs the command, and reports results and logs back to the server with a token made for that one run.
What you must set up:
- The run-tests capability is on by default for a connected operator; turn it off under the cluster's Operator tab to refuse all runs there.
WARDN_TEST_CALLBACK_URLis the address a test pod reaches the Wardn API at. Without it no cluster run is started and the run fails saying so.WARDN_TEST_AGENT_IMAGEis the agent's image (defaultghcr.io/future-pirate-king/test-agent:latest); build it fromdeploy/docker/Dockerfile.agent(from the repository root).- A suite names the image it runs in: a pinned image or a registry image.
A run waits while its operator is away and is declared lost if the pod never reports. A relative report path (junit.xml) is read from the directory the command ran in. Once a run finishes, its pass count is evidence about the snapshot: the deployment's test list shows it, and a stage with a tests rule reads "5 of 5 passed" in the snapshot's verdict. Rules in a stage's qualification section judge a snapshot that already runs there; they never hold it back from arriving.
Workers
A worker is a machine that picks queued runs up and runs them in Docker containers. Workers belong to groups; a run can be aimed at one worker or at any. Registering a worker shows its token once, and only a hash of it is kept; rotating the token ends the old one at once. A worker is shown as online when it has reported in the last 90 seconds.
Install the daemon
Registering a worker shows the install steps for a Linux machine with Docker. They copy the wardn-test-agent binary out of the test-agent image, create a service user that may use Docker, write the server address and the token to a private file and start wardn-test-agent worker under systemd. The daemon only dials out: nothing listens on the machine. It is set with these variables:
| Variable | Meaning |
|---|---|
WARDN_SERVER_URL | The server's address, as the machine reaches it. |
WARDN_WORKER_TOKEN or WARDN_WORKER_TOKEN_FILE | The worker's token, or a file that holds it. |
WARDN_WORKER_CALLBACK_URL | Where the test containers report, when that differs from the server address. |
WARDN_WORKER_DIR | Where each run is prepared. |
WARDN_WORKER_DOCKER | The Docker command, when it is not docker. |
WARDN_WORKER_NETWORK | The Docker network for test containers. |
How a run gets there
The daemon reports in every few seconds and, when it has a free slot, asks for runs. The server hands each queued run to exactly one worker; a worker that is disabled is given none. The daemon pulls the suite's image, starts a container with its own binary inside as the test agent and waits. The agent in the container reports output and results with a token made for that one run, and the daemon reports how the container ended.
A run that nothing reports on for two minutes is declared interrupted (the server's WARDN_TEST_RUN_SILENCE). While the machine lives its daemon keeps the runs it holds alive, and the agent in a container keeps its own run alive, so a worker that is killed does not lose a run whose container is still reporting. If the machine and the container are both gone, or the network is cut for longer than that, the run is declared lost, and a report that arrives afterwards changes nothing.
Tests as evidence for a stage
A test rule in a pipeline stage's Qualification section asks that tests passed against the snapshot the stage runs. The check reads every run made against that snapshot: with none it reads No test results yet and the verdict stays qualifying; while one runs it shows progress ("212 of 412 done"); with a failed or errored run it fails and rejects the snapshot; with runs that all passed it passes ("412 of 412 passed"). See Qualification and sign-off.
api() { curl -fsS -H "Authorization: Bearer $WARDN_TOKEN" -H 'Content-Type: application/json' "$@"; }
# Run one suite on the deployment, as evidence about the snapshot it runs now.
api -X POST "$WARDN_API_URL/api/v1/test-runs" -d '{
"suiteIds": ["'"$SUITE_ID"'"],
"deploymentId": "'"$DEPLOYMENT_ID"'",
"snapshotId": "'"$SNAPSHOT_ID"'",
"targetKind": "cluster"
}'Nothing starts a run for you when a snapshot arrives, and the Run buttons of the web app do not name a snapshot yet: start the run from CI or a script with snapshotId (find it with GET /deployments/{deploymentId}/snapshots). The deployment's Tests tab lists each suite with its last result. test:run is needed to start one.
The API
Everything here is in the API reference: operations under Testing such as createTestSuite, createTestRuns, getTestRun and listTestWorkers.