Skip to content

feat: load testing infrastructure and CI/CD pipeline#11

Merged
DanielPopoola merged 2 commits into
masterfrom
go-version
Apr 12, 2026
Merged

feat: load testing infrastructure and CI/CD pipeline#11
DanielPopoola merged 2 commits into
masterfrom
go-version

Conversation

@DanielPopoola
Copy link
Copy Markdown
Owner

@DanielPopoola DanielPopoola commented Apr 12, 2026

What this does

Adds the complete deployment pipeline and load testing infrastructure for FairQueue.

CI/CD Pipeline (.github/workflows/deploy.yml)

Runs on every push to master. Three jobs in sequence:

  • test — runs golangci-lint and go test ./... including integration tests via testcontainers
  • build — builds and pushes both the production image (fairqueue:latest) and load test image (fairqueue-loadtest:latest) to GitHub Container Registry in parallel
  • deploy — SSHes into VPS and restarts the production container with the new image

Load Test Infrastructure

Mock gateway (internal/gateway/mock/gateway.go) — implements gateway.PaymentGateway with instant success responses, isolating FairQueue's performance from Paystack's rate limits.

Load test server (cmd/loadtest/main.go) — identical to the production server but wires the mock gateway and exposes three test-only endpoints:

  • POST /loadtest/seed — creates a known organizer for k6 setup()
  • GET /loadtest/otp — reads OTP from Redis so k6 can authenticate without email
  • GET /loadtest/stats — returns claim counts vs inventory for correctness assertions

Three k6 scenarios (loadtest/scripts/):

  • 01_thundering_herd.js — 50,000 VUs ramping over 60s, stress testing queue join against Redis and Postgres
  • 02_sustained_load.js — 1,000 VUs running the full flow for 30 minutes, catching memory and goroutine leaks
  • 03_correctness_check.js — single iteration asserting claimed_count <= total_inventory after a test run

Load Test Workflow (.github/workflows/loadtest.yml)

Manually triggered via workflow_dispatch with a scenario dropdown. Three jobs:

  1. Starts the load test stack on the VPS (pulls image from registry, seeds organizer, waits for health)
  2. Installs k6 on the Actions runner and runs the selected scenario against the VPS
  3. Tears down the stack unconditionally (if: always()) so the VPS is never left in a dirty state

Deployment

  • Dockerfile.loadtest — builds cmd/loadtest binary
  • docker-compose.loadtest.yml — isolated Postgres and Redis for load testing, no shared state with production

Required secrets

VPS_HOST, VPS_USER, VPS_SSH_KEY, VPS_SSH_FINGERPRINT  — existing
LOADTEST_ENV_FILE                                       — new, contents of .env.loadtest

Summary by CodeRabbit

  • New Features

    • Added comprehensive load testing framework with three test scenarios (high-volume burst traffic, sustained load, and correctness validation) deployable via CI/CD workflow dispatch with performance metrics collection.
  • Chores

    • Added load test environment configuration files and Docker Compose setup with PostgreSQL and Redis services for isolated testing infrastructure.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR adds a complete end-to-end load testing infrastructure including a dedicated Go entrypoint that reuses production wiring, Docker containerization, GitHub Actions workflow for orchestration, mock payment gateway, and three k6 load test scripts for different scenarios (thundering herd, sustained load, correctness validation).

Changes

Cohort / File(s) Summary
Configuration & Gitignore
.env.loadtest.example, .gitignore
Added load test environment configuration template with server ports, database/Redis settings, auth tokens, worker timing, and Paystack placeholders; updated gitignore to exclude .env.loadtest.
Linting Configuration
.golangci.yaml
Added per-path linter exclusions for loadtest/ directory applying errcheck, gocritic, gosec, govet, staticcheck.
Docker & Orchestration
Dockerfile.loadtest, docker-compose.loadtest.yml
New multi-stage Dockerfile builds statically-linked Go binary with Swagger generation; docker-compose defines loadtest-app, loadtest-postgres (16-alpine), and loadtest-redis (7-alpine) services with healthchecks and persistent volumes.
GitHub Actions Workflow
.github/workflows/loadtest.yml
New workflow dispatch pipeline with scenario selection (thundering_herd, sustained_load, correctness_check); deploys via SSH, manages stack lifecycle, waits for health readiness, seeds organizer, runs k6 with environment injection, and teardown.
Load Test Application
cmd/loadtest/main.go, internal/gateway/mock/gateway.go
Main entrypoint bootstraps production wiring (config, logger, Postgres, Redis, workers) and HTTP server on port 8082; adds custom endpoints (POST /loadtest/seed, GET /loadtest/otp, GET /loadtest/stats) for test orchestration. Mock gateway provides deterministic payment verification for load tests.
k6 Load Test Scripts
loadtest/scripts/01_thundering_herd.js, loadtest/scripts/02_sustained_load.js, loadtest/scripts/03_correctness_check.js
Three k6 test scenarios: thundering herd ramps 50k VUs over 60s testing queue join latency; sustained load holds 1k VUs for 25 minutes executing full customer flow (OTP, queue, claim, payment); correctness check validates stats endpoint constraints.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Phase 4 Implementation  #6: Load test infrastructure directly reuses the Phase 4 API, router, hub, workers, services, and authentication pieces, building upon that foundation with new mock gateway and test orchestration components.

Poem

🐰 A warren of tests now hops at scale,
Thundering herds and sustained trails,
Mock gateways dance, Redis stores the tale,
Docker composes the perfect tale—
Load testing triumph shall never fail! 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main changes: it adds load testing infrastructure (Dockerfile, k6 scripts, mock gateway, load test server) and a CI/CD pipeline (GitHub Actions workflow), which are the core contributions of this changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch go-version

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@DanielPopoola DanielPopoola merged commit b57cd2d into master Apr 12, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant