test(federation): integration tests for federated tier gateway boot (FED-M1-07) #476

Merged
jason.woltje merged 1 commits from feat/federation-m1-integration into main 2026-04-20 01:13:11 +00:00
Owner

Summary

FED-M1-07 — Adds three integration tests that exercise the federated tier against a live docker-compose federated profile. Real services, no mocks.

Tests

File Assertion
federated-boot.success.integration.test.ts detectAndAssertTier resolves; pg_extension row for vector exists
federated-boot.pg-unreachable.integration.test.ts Throws TierDetectionError with service: 'postgres' when PG port is closed
federated-pgvector.integration.test.ts TEMP table with vector(3) column round-trips [1,2,3]

Skip gating

All three tests are gated behind process.env.FEDERATED_INTEGRATION === '1' using describe.skipIf(!run). Running pnpm test without the env var skips them cleanly (4 tests, all skipped, exit 0). CI prologue is responsible for compose lifecycle — tests do not manage docker.

Closed-port reservation

Test B uses net.createServer().listen(0) to reserve an ephemeral port and immediately release it, then targets that port. This avoids host-port collisions with other Postgres clusters that an arbitrary "5499" assumption would have risked (caught by independent code review).

Code review feedback addressed

Independent sonnet review (VERDICT: B) flagged two IMPORTANT items, both fixed in this PR:

  1. Port 5499 collision risk → reserved-port helper above
  2. afterAll and sql scoped outside describe → moved both inside describe.skipIf block; cleanup only runs when describe activates

Verification

$ docker compose -f docker-compose.federated.yml --profile federated up -d
$ FEDERATED_INTEGRATION=1 pnpm --filter @mosaicstack/gateway test src/__tests__/integration/

 Test Files  3 passed (3)
      Tests  4 passed (4)

$ pnpm --filter @mosaicstack/gateway test src/__tests__/integration/   # no env var
 Tests  4 skipped (4)

Independent surface verification (haiku) confirmed file paths, imports, skip pattern, no new dependencies, lint + typecheck pass.

Test plan

  • CI green (typecheck + lint + format gates pass; integration tests skip without env var)
  • Manual smoke: spin up federated compose stack and rerun with FEDERATED_INTEGRATION=1

Refs #460

## Summary FED-M1-07 — Adds three integration tests that exercise the federated tier against a live docker-compose `federated` profile. Real services, no mocks. ## Tests | File | Assertion | | --- | --- | | `federated-boot.success.integration.test.ts` | `detectAndAssertTier` resolves; `pg_extension` row for `vector` exists | | `federated-boot.pg-unreachable.integration.test.ts` | Throws `TierDetectionError` with `service: 'postgres'` when PG port is closed | | `federated-pgvector.integration.test.ts` | TEMP table with `vector(3)` column round-trips `[1,2,3]` | ## Skip gating All three tests are gated behind `process.env.FEDERATED_INTEGRATION === '1'` using `describe.skipIf(!run)`. Running `pnpm test` without the env var skips them cleanly (4 tests, all skipped, exit 0). CI prologue is responsible for compose lifecycle — tests do not manage docker. ## Closed-port reservation Test B uses `net.createServer().listen(0)` to reserve an ephemeral port and immediately release it, then targets that port. This avoids host-port collisions with other Postgres clusters that an arbitrary "5499" assumption would have risked (caught by independent code review). ## Code review feedback addressed Independent sonnet review (VERDICT: B) flagged two IMPORTANT items, both fixed in this PR: 1. **Port 5499 collision risk** → reserved-port helper above 2. **`afterAll` and `sql` scoped outside `describe`** → moved both inside `describe.skipIf` block; cleanup only runs when describe activates ## Verification ``` $ docker compose -f docker-compose.federated.yml --profile federated up -d $ FEDERATED_INTEGRATION=1 pnpm --filter @mosaicstack/gateway test src/__tests__/integration/ Test Files 3 passed (3) Tests 4 passed (4) $ pnpm --filter @mosaicstack/gateway test src/__tests__/integration/ # no env var Tests 4 skipped (4) ``` Independent surface verification (haiku) confirmed file paths, imports, skip pattern, no new dependencies, lint + typecheck pass. ## Test plan - [ ] CI green (typecheck + lint + format gates pass; integration tests skip without env var) - [ ] Manual smoke: spin up federated compose stack and rerun with `FEDERATED_INTEGRATION=1` Refs #460
jason.woltje added 1 commit 2026-04-20 01:12:50 +00:00
test(federation): integration tests for federated tier gateway boot (FED-M1-07)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
1720f533a5
Adds three integration tests gated by FEDERATED_INTEGRATION=1 that exercise
the federated tier against a live docker-compose federated profile:

- federated-boot.success — detectAndAssertTier resolves; pg_extension lists vector
- federated-boot.pg-unreachable — fail-fast TierDetectionError(service=postgres)
  using OS-reserved closed port to avoid host-port collisions
- federated-pgvector — TEMP table with vector(3) column round-trips data

Real services, no mocks. Tests skip cleanly when env var is unset.

Refs #460
jason.woltje merged commit 78251d4af8 into main 2026-04-20 01:13:11 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaicstack/stack#476