Add k6 smoke test triggered on every deployment #126

Open
opened 2026-03-27 18:36:47 +01:00 by marcel · 1 comment
Owner

Problem

There are no load or performance tests. After every deployment, there is no automated check that the application responds within acceptable latency or that the error rate is acceptable. A performance regression — a slow query introduced by a new index, a MinIO connection pool misconfiguration — will only be noticed when a user complains.

Why This Matters

This application handles file uploads to MinIO and full-text search queries against PostgreSQL. Both are I/O-bound operations with real latency characteristics. A smoke test with thresholds catches obvious breakage immediately after deploy without requiring a full load test run.

What Needs To Be Done

  1. Create load-tests/smoke.js:

    import http from 'k6/http';
    import { check } from 'k6';
    
    export const options = {
      vus: 5,
      duration: '1m',
      thresholds: {
        http_req_duration: ['p(95)<500'],  // 95th percentile under 500ms
        http_req_failed: ['rate<0.01'],    // less than 1% error rate
      },
    };
    
    export default function () {
      const res = http.get(`${__ENV.BASE_URL}/api/documents`);
      check(res, { 'status is 200': (r) => r.status === 200 });
    }
    
  2. Add a smoke-test CI job that runs after the E2E job on merges to main:

    smoke-test:
      needs: e2e-tests
      # Runs k6 smoke test against the deployed instance
      # Fails if p95 > 500ms or error rate > 1%
    
  3. Define thresholds as non-negotiable CI gates:

    • p(95) < 500ms for all API endpoints
    • Error rate < 1%
  4. Separate nightly load test (ramp to expected traffic, 10 minutes) can be added later — the smoke test is the minimum viable gate.

Acceptance Criteria

  • load-tests/smoke.js committed to repo
  • Smoke test runs in CI on merge to main
  • CI fails if p95 > 500ms or error rate > 1%
  • k6 summary report uploaded as CI artifact
## Problem There are no load or performance tests. After every deployment, there is no automated check that the application responds within acceptable latency or that the error rate is acceptable. A performance regression — a slow query introduced by a new index, a MinIO connection pool misconfiguration — will only be noticed when a user complains. ## Why This Matters This application handles file uploads to MinIO and full-text search queries against PostgreSQL. Both are I/O-bound operations with real latency characteristics. A smoke test with thresholds catches obvious breakage immediately after deploy without requiring a full load test run. ## What Needs To Be Done 1. Create `load-tests/smoke.js`: ```javascript import http from 'k6/http'; import { check } from 'k6'; export const options = { vus: 5, duration: '1m', thresholds: { http_req_duration: ['p(95)<500'], // 95th percentile under 500ms http_req_failed: ['rate<0.01'], // less than 1% error rate }, }; export default function () { const res = http.get(`${__ENV.BASE_URL}/api/documents`); check(res, { 'status is 200': (r) => r.status === 200 }); } ``` 2. Add a `smoke-test` CI job that runs after the E2E job on merges to `main`: ```yaml smoke-test: needs: e2e-tests # Runs k6 smoke test against the deployed instance # Fails if p95 > 500ms or error rate > 1% ``` 3. Define thresholds as non-negotiable CI gates: - `p(95) < 500ms` for all API endpoints - Error rate `< 1%` 4. Separate nightly load test (ramp to expected traffic, 10 minutes) can be added later — the smoke test is the minimum viable gate. ## Acceptance Criteria - [ ] `load-tests/smoke.js` committed to repo - [ ] Smoke test runs in CI on merge to `main` - [ ] CI fails if p95 > 500ms or error rate > 1% - [ ] k6 summary report uploaded as CI artifact
marcel added the testdescoped labels 2026-03-28 08:06:02 +01:00
Author
Owner

Currently there is no deployment, so will keep that for later

Currently there is no deployment, so will keep that for later
Sign in to join this conversation.
No Label descoped test
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#126