Skip to content

feat: add load test image build and push steps to CI/CD workflow#12

Merged
DanielPopoola merged 1 commit into
masterfrom
go-version
Apr 12, 2026
Merged

feat: add load test image build and push steps to CI/CD workflow#12
DanielPopoola merged 1 commit into
masterfrom
go-version

Conversation

@DanielPopoola
Copy link
Copy Markdown
Owner

@DanielPopoola DanielPopoola commented Apr 12, 2026

Title:
feat: load testing infrastructure and CI/CD pipeline


Description:

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

  • Chores
    • Enhanced the deployment pipeline to generate and publish two distinct container images: one for production deployments and a new dedicated image for load testing. The build workflow now explicitly labels production builds and creates load test images with separate tagging in the container registry.

@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

The workflow now builds and publishes two distinct container images: the existing build job is relabeled as "production," and a new build-loadtest job is added (dependent on test) to construct and push a separate loadtest image using Dockerfile.loadtest to GHCR.

Changes

Cohort / File(s) Summary
CI/CD Workflow Enhancement
.github/workflows/deploy.yml
Added new build-loadtest job that builds and pushes a loadtest container image to GHCR with auto-generated tags; relabeled existing build job step as "production"; removed comments from deploy script; minor whitespace cleanup.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A new test image hops into place,
Loadtest builds at a faster pace,
Docker tags dance and GHCR gleams,
Two images now fulfill our dreams! 📦✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding load test image build and push steps to the CI/CD workflow, which aligns with the primary modification in .github/workflows/deploy.yml.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 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 87c5b18 into master Apr 12, 2026
4 of 5 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