Files
integraci-dagger-modules/perf-test/README.md
T

56 lines
2.4 KiB
Markdown

# perf-test (Dagger module)
> **Verified 2026-07-16**: dagger v0.21.7 `develop` + `go build` + `dagger
> functions` pass (`dagger.json` pins `engineVersion: v0.21.7`). Generated
> code (`dagger.gen.go`, `internal/`) is gitignored; run `dagger develop` to
> regenerate.
Performance / load testing module for IntegraCI. Runs a load test against a
target URL using either [k6](https://grafana.com/oss/k6/) (`grafana/k6`,
default) or [Locust](https://locust.io/) (`locustio/locust`), captures the
run summary, and optionally POSTs the results to the IntegraCI API.
## Function
### `run`
| Param | Type | Required | Default | Description |
| ------------ | ----------- | -------- | -------- | ---------------------------------------------------- |
| `targetURL` | `string` | yes | — | Target URL to load test |
| `tool` | `string` | no | `k6` | Load tool: `k6` or `locust` |
| `vus` | `int` | no | `10` | Virtual users / concurrent clients |
| `duration` | `string` | no | `30s` | Test duration / run time (e.g. `30s`, `5m`) |
| `source` | `Directory` | no | — | Custom `script.js` (k6) or `locustfile.py` (Locust) |
| `apiURL` | `string` | no | — | IntegraCI API URL for posting results |
| `token` | `string` | no | — | JWT token for API authentication |
| `serviceID` | `string` | no | — | Service ID to link perf-test results |
When `apiURL`, `token`, and `serviceID` are all supplied, the run summary is
POSTed to `<apiURL>/api/v1/services/<serviceID>/perf-results`.
## Usage
```bash
# k6 (default), 50 VUs for 30s
dagger call run --target-url https://staging.example.com --vus 50 --duration 30s
# Locust instead of k6
dagger call run --target-url https://staging.example.com --tool locust --vus 100 --duration 2m
# Post results back to IntegraCI
dagger call run \
--target-url https://staging.example.com \
--api-url http://localhost:8000 \
--token "$TOKEN" \
--service-id "$SVC_ID"
```
## Before using
```bash
cd dagger/perf-test
dagger develop # generates the Go SDK bindings (dag, *Directory, ...)
dagger functions # confirm `run` is discovered
dagger call run --target-url https://example.com --vus 1 --duration 5s
```