Files
goodgo-platform/load-tests/README.md
Ho Ngoc Hai 33c2e5ac1d feat(load-tests): add K6 coverage for search, admin, and MCP endpoints
Add three new K6 load test scripts to cover previously untested API surfaces:

- search-advanced.js: Combined geo + text + filter queries, paginated deep
  search, and sort variations against /search and /search/geo (300 peak VUs)
- admin.js: Moderation queue CRUD, bulk moderation, dashboard stats, audit
  logs, and user management endpoints (50 peak VUs)
- mcp.js: MCP server discovery, SSE connection, property-search tool calls,
  valuation/batch-valuation, and feature extraction (120 peak VUs)

Also updates README with new suite documentation, per-suite custom thresholds,
and adds the new suites to the CI workflow_dispatch selector.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-11 20:14:52 +07:00

96 lines
2.9 KiB
Markdown

# K6 Load Testing — Goodgo Platform
## Overview
Performance load tests for critical API paths using [K6](https://k6.io/).
## Test Suites
| Script | Target | Peak VUs | Duration |
|--------|--------|----------|----------|
| `auth.js` | Login/Register | 100 | 2min |
| `listings.js` | Search + Detail | 500 | 3min |
| `search.js` | Text + Geo search | 200 | 3min |
| `search-advanced.js` | Combined geo + text + filters, pagination | 300 | 3min |
| `admin.js` | Moderation queue, dashboard, audit logs | 50 | 2.5min |
| `mcp.js` | MCP server discovery, property-search, valuation | 120 | 2.5min |
| `payments.js` | Create + List | 50 | 2min |
## SLA Thresholds
| Metric | Threshold |
|--------|-----------|
| p50 latency | < 200ms |
| p95 latency | < 500ms |
| p99 latency | < 1000ms |
| Error rate | < 1% |
### Per-Suite Custom Thresholds
| Suite | Metric | Threshold |
|-------|--------|-----------|
| search-advanced | advanced_search_duration p95 | < 800ms |
| search-advanced | geo_filter_search_duration p95 | < 800ms |
| admin | moderation_action_duration p95 | < 800ms |
| admin | admin_dashboard_duration p95 | < 500ms |
| mcp | mcp_property_search_duration p95 | < 1500ms |
| mcp | mcp_valuation_duration p95 | < 1000ms |
| mcp | mcp_batch_valuation_duration p95 | < 2000ms |
## Prerequisites
```bash
# Install K6
brew install k6 # macOS
# or: https://grafana.com/docs/k6/latest/set-up/install-k6/
# Start the API
pnpm --filter @goodgo/api run dev
```
## Running Tests
```bash
# Run individual suite
k6 run load-tests/scripts/auth.js
k6 run load-tests/scripts/listings.js
k6 run load-tests/scripts/search.js
k6 run load-tests/scripts/search-advanced.js
k6 run load-tests/scripts/admin.js
k6 run load-tests/scripts/mcp.js
k6 run load-tests/scripts/payments.js
# Run against a custom API URL
k6 run -e API_BASE_URL=https://staging.goodgo.vn load-tests/scripts/auth.js
# Run all suites sequentially
for f in load-tests/scripts/*.js; do k6 run "$f"; done
# Export results as JSON
k6 run --out json=results/auth.json load-tests/scripts/auth.js
```
## CI Integration
The `load-test.yml` workflow runs as an optional manual stage in GitHub Actions.
Trigger via `workflow_dispatch` with a suite selector.
## Directory Structure
```
load-tests/
├── lib/
│ └── config.js # Shared config, helpers, SLA thresholds
├── scripts/
│ ├── auth.js # Auth flow load tests
│ ├── listings.js # Listings search + detail
│ ├── search.js # Full-text + geo search (basic)
│ ├── search-advanced.js # Combined geo + text + filter search
│ ├── admin.js # Admin moderation, dashboard, audit
│ ├── mcp.js # MCP server endpoints (property-search, valuation)
│ └── payments.js # Payment creation + listing
├── results/
│ └── BASELINE-REPORT.md # Baseline performance report
└── README.md
```