Skip to content

DX-2104: make schema tests hermetic (no live spec fetch)#34

Merged
lloyd-cio merged 1 commit into
mainfrom
dx-2104-hermetic-schema-tests
Jun 12, 2026
Merged

DX-2104: make schema tests hermetic (no live spec fetch)#34
lloyd-cio merged 1 commit into
mainfrom
dx-2104-hermetic-schema-tests

Conversation

@lloyd-cio

Copy link
Copy Markdown
Contributor

Problem

DX-2104: the cio schema tests run the real command, which loads the route registry by downloading the OpenAPI specs from a live endpoint (us.fly.customer.io). The public-export validation runs go test ./... over the exported tree, so a transient network reset on that fetch fails the whole export:

TestSchema_ListResources: failed to load API specs:
  read https://us.fly.customer.io/v1/openapi.json: connection reset by peer
FAIL go test ./...

(Seen blocking the DX-2103 export verification, run 27435049667.)

Fix (test-only, no production changes)

Add setupSchemaTest: a local httptest spec server serving Journeys + CDP fixtures (with a campaigns resource, so the assertions resolve) plus an isolated temp HOME cache, wired in through CIO_API_URL. Point the five TestSchema_* tests at it.

schema.go is the only production consumer of routes.LoadRegistry, and the override seams already existed (CIO_API_URL → client BaseURLLoadRegistryOptions.BaseURL; temp HOME isolates the spec cache), so no production code changed.

Verification

  • go test ./... passes normally.
  • Offline proof: go test ./... passes with all external HTTP(S) routed to a dead proxy (HTTPS_PROXY=http://127.0.0.1:1, localhost bypassed) and GOPROXY=off — confirming no test reaches the network. A control curl to the real host through that proxy fails as expected.

This makes the export validator's go test hermetic, so exports no longer flake on network.

The `cio schema` tests ran the real command, which downloads the OpenAPI
specs from a live endpoint (us.fly.customer.io) via the route registry. In
the public-export validation (`go test ./...` over the exported tree) a
transient network reset on that fetch failed the whole export.

Add setupSchemaTest: a local httptest spec server (Journeys + CDP fixtures
with a campaigns resource) plus an isolated temp HOME cache, wired in via
CIO_API_URL. Point the five TestSchema_* tests at it. Test-only; no
production changes.

Verified: full `go test ./...` passes with all external HTTP(S) routed to a
dead proxy (localhost bypassed), confirming no test reaches the network.
@lloyd-cio lloyd-cio merged commit ff2cee0 into main Jun 12, 2026
3 checks passed
@lloyd-cio lloyd-cio deleted the dx-2104-hermetic-schema-tests branch June 12, 2026 20:56
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