# Isis Load Testing Suite

k6 load tests for Isis generation queue behavior.

## Scripts

- `enqueue-throughput.js`: Sustained and burst enqueue throughput for
  `POST /api/v1/jobs`.
- `worker-consumption.js`: Seeds jobs, then stresses status/queue-position
  polling while workers consume.

## Prerequisites

1. Install [k6](https://k6.io/docs/getting-started/installation/).
2. Run Isis Generation API and worker services.
3. Set `JWT_SECRET` to match the API auth configuration.

## Quick Start

```bash
# Enqueue throughput
k6 run testing/performance/k6/isis/enqueue-throughput.js

# Worker consumption
k6 run testing/performance/k6/isis/worker-consumption.js
```

## Environment Variables

| Variable                   | Default                 | Description                              |
| -------------------------- | ----------------------- | ---------------------------------------- |
| `ISIS_API_URL`             | `http://localhost:4001` | Isis generation API base URL             |
| `JWT_SECRET`               | `isis-load-test-secret` | JWT secret used to sign load-test tokens |
| `ISIS_ENQUEUE_STAGE_*_RPS` | see script              | Per-stage request rates for enqueue test |
| `ISIS_WORKER_SEED_COUNT`   | `250`                   | Number of jobs seeded before worker test |
| `ISIS_WORKER_STAGE_*_VUS`  | see script              | Per-stage VU targets for worker test     |

## Nx Targets

```bash
# Enqueue throughput
pnpm exec nx run @isis/generation-api:load-test

# Worker consumption
pnpm exec nx run @isis/generation-api:load-test --configuration=worker

# Run both sequentially
pnpm exec nx run @isis/generation-api:load-test --configuration=combined
```
