# ShieldAI Load Tests

k6 load testing suite for ShieldAI services.

## Prerequisites

- k6 v0.45+ installed
- Target services running on staging environment
- Authentication tokens for API access

## Running Tests

### Local Execution

```bash
# Run against local development environment
k6 run --env BASE_URL=http://localhost:3000 --env AUTH_TOKEN=dev-token src/darkwatch.js

# Run with results output
k6 run --out json=results.json src/darkwatch.js
```

### CI/CD Execution

```bash
# Run on staging environment
k6 run --env BASE_URL=https://staging-api.freno.me --env AUTH_TOKEN=$STAGING_AUTH_TOKEN src/darkwatch.js
```

## Test Configuration

Each test script includes:

- **Stages**: Ramp-up, sustained load, ramp-down
- **Thresholds**: P99 latency and error rate limits
- **Metrics**: Custom metrics for error tracking

### Current Thresholds

| Service | P99 Latency | Error Rate |
|---------|-------------|------------|
| Darkwatch | < 200ms | < 1% |

## Metrics Collection

Run with output options:

```bash
# JSON output for analysis
k6 run --out json=darkwatch-results.json src/darkwatch.js

# InfluxDB for visualization
k6 run --out influxdb=http://influxdb:8086/k6 src/darkwatch.js
```

## Next Steps

1. Create load test scripts for Spamshield and Voiceprint
2. Integrate with GitHub Actions CI pipeline
3. Set up metrics visualization dashboard
4. Configure alerting on threshold breaches
