Last updated 2026-05-18
Testing
The repository uses multiple gates before an image is published.
Unit Tests
go test ./...Unit tests cover configuration validation, YAML limit parsing, limit validation, Redis key derivation, embedded Lua script presence, and command helpers, plus Prometheus metric exposition.
Redis Integration
docker run --rm -p 16379:6379 redis:7.4-alpineQUOTA_TEST_REDIS_URL=redis://localhost:16379/0 go test -race -count=1 ./...
Redis-backed tests cover fixed windows, sliding windows, token buckets,
leaky buckets, GCRA, reservations, reservation increments and shrinkage,
expiry-policy refunds, finalization refunds, releases, reservation
overages, concurrency leases, lease expiry, idempotency, invalid
algorithm/RPC combinations,
usage inspection, explain behavior, a concurrent contention stress case for
Redis Lua atomicity, Redis script reload after
SCRIPT FLUSH, lifecycle idempotency metrics, and a real gRPC
client/server round trip.
Docker Compose E2E
test/e2e/docker-compose-critical-rpcs.sh
The e2e test builds the Docker image, starts Redis and the service, and
exercises the critical public gRPC surface with grpcurl using
dummy workspace and assistant data. It covers
GetRedisStatus, ValidateLimits,
Consume, GetCurrentUsage,
Explain, Reserve,
GetReservation, IncrementReservation,
FinalizeReservation, ReleaseReservation,
AcquireLease,
GetLease, RenewLease, and
ReleaseLease, plus idempotency, denial behavior, and
Prometheus metrics. It also checks the standard gRPC health service reports
SERVING.
Release Gates
Release tags run Redis integration tests and Docker Compose critical RPC
e2e before the multi-arch GHCR image is pushed. The release workflow then
inspects the published manifest, pulls the versioned GHCR image, and runs
quota-service version from that pulled image before creating
the GitHub Release.