Quick guide for go test -tags=integration on handler, service, repository, grpc, embedding, event (Streams).
- Postgres with migrations applied (
DATABASE_URL, e.g.postgres://pcmi:pcmi@127.0.0.1:5432/pcmi?sslmode=disable). - For HTTP handler tests: Redis not required on host — tests use miniredis in-process.
- For gRPC live (
make test-integration-live): API listening onGRPC_HOST(defaultlocalhost:50051) and keyGRPC_TEST_API_KEY(Makefile default:testkey123).
| Port | Use |
|---|---|
5432 |
Postgres — bufconn, live, handler integration |
6379 |
Redis — full stack (make infra-up); not needed for bufconn gRPC |
50051 |
gRPC — only live tests and integration-smoke job |
8000 |
HTTP — SDK smoke / ci_integration_smoke.sh |
| Target | Server | Postgres | :50051 | Notes |
|---|---|---|---|---|
make test-integration-bufconn |
In-process (bufconn) | Yes | No | -run '^TestIntegrationBufconn_' |
make test-integration-live |
TCP on GRPC_HOST |
Yes (env) | Yes | -run '^TestGRPC|^TestResolveTenantIntegration$' |
make test-integration |
Both in sequence | Yes | Yes (live phase) |
If GRPC_TEST_API_KEY is not set, live tests in internal/grpc/integration_test.go call t.Skip. The Makefile always sets GRPC_TEST_API_KEY=testkey123 → without an API on :50051 the run fails (is not skipped).
Recommended sequence for live:
make infra-up
make test-integration-live
# optional, after infra-up: make infra-wait # GET /v1/ready on :8000Deps only + API on host:
make infra-deps-up
go run ./cmd/api # another terminal
make test-integration-liveGitHub CI: the go job runs go test -tags=integration ./internal/... without GRPC_TEST_API_KEY → live skipped. The integration-smoke job starts API/worker and runs go test -tags=integration ./internal/grpc/... with the key — parity with make act-integration-smoke locally. See local-ci.md.
Tests in internal/event/ with tag integration and miniredis in-process (TestStreamIntegration_*). No Postgres or :50051 required. Useful after changes to the Streams backend in internal/event.
make test-streams-integrationexport DATABASE_URL='postgres://pcmi:pcmi@127.0.0.1:5432/pcmi?sslmode=disable'
# PCMI_SKIP_SSE_HTTPTEST=1 is the default if you use newIntegrationHTTPApp; explicit when running go test manually:
PCMI_SKIP_SSE_HTTPTEST=1 go test -tags=integration -count=1 ./internal/handler/...
# With embedding in the same run:
PCMI_SKIP_SSE_HTTPTEST=1 go test -tags=integration -count=1 ./internal/handler/... ./internal/embedding/...make ci-like-github already sets PCMI_SKIP_SSE_HTTPTEST=1 in Phase F (go test ./internal/...).
go test -tags=integration ./internal/handler/...appears blocked for many minutes without output.- After ~10 minutes it fails with Go package timeout (default 10m), stack trace in
miniredis/netpoll/httptest. - Typical logs before timeout:
timeout waiting for SSE GETorhttptest.Server blocked in Close after 5 seconds.
The test TestIntegrationHTTP_EventStreamMemoryStored opens a GET SSE on httptest.Server wrapping the Fiber app via adaptor.FiberApp. With the race detector (and often without it), the stream connection can:
- not complete headers within 30s (
startGatetimeout in the test); - leave
io.Copyon the response body blocked aftercancel; - cause
httptest.Server.Closeto block until package timeout.
On GitHub Actions the test is already Skip when GITHUB_ACTIONS=true. Locally the problem is the same.
No functional coverage is lost:
scripts/ci_integration_smoke.sh—curlonGET /v1/events+memory.storedwith a real HTTP server.- CI job
integration-smoke(aftergo buildof API/worker on port 8000).
| Variable | Default in newIntegrationHTTPApp |
Effect |
|---|---|---|
PCMI_SKIP_SSE_HTTPTEST |
1 (unless you force SSE) |
Skips TestIntegrationHTTP_EventStreamMemoryStored |
PCMI_FORCE_SSE_HTTPTEST |
— | If 1, does not set the automatic skip; runs the SSE httptest (can take up to timeout) |
DATABASE_URL |
— | Required for handler/service/repository integration tests |
GITHUB_ACTIONS |
— | On GHA runner the SSE httptest is always skipped |
PCMI_FORCE_SSE_HTTPTEST=1 PCMI_SKIP_SSE_HTTPTEST=0 \
go test -tags=integration -count=1 -timeout 15m -v ./internal/handler/... \
-run TestIntegrationHTTP_EventStreamMemoryStoredUse an explicit timeout (-timeout 15m) and expect possible failures or long waits.
go test -race -tags=integration ./internal/...— can stay silent between packages for many minutes; normal on laptops.- Mitigations:
PCMI_GO_TEST_P=1,CI_LIKE_NO_RACE=1(local-only scriptci_like_github.sh),CI_LIKE_GO_VERBOSE=1,CI_LIKE_HEARTBEAT_SECS=120.
See also local-ci.md and scripts/ci_like_github.sh --help.
- SSE test:
internal/handler/integration_http_e2e_test.go—TestIntegrationHTTP_EventStreamMemoryStored - HTTP integration helper:
newIntegrationHTTPAppin the same file - CI smoke:
scripts/ci_integration_smoke.sh(section "SSE memory.stored")