DX-2104: make schema tests hermetic (no live spec fetch)#34
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DX-2104: the
cio schematests 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 runsgo test ./...over the exported tree, so a transient network reset on that fetch fails the whole export:(Seen blocking the DX-2103 export verification, run
27435049667.)Fix (test-only, no production changes)
Add
setupSchemaTest: a localhttptestspec server serving Journeys + CDP fixtures (with acampaignsresource, so the assertions resolve) plus an isolated tempHOMEcache, wired in throughCIO_API_URL. Point the fiveTestSchema_*tests at it.schema.gois the only production consumer ofroutes.LoadRegistry, and the override seams already existed (CIO_API_URL→ clientBaseURL→LoadRegistryOptions.BaseURL; tempHOMEisolates the spec cache), so no production code changed.Verification
go test ./...passes normally.go test ./...passes with all external HTTP(S) routed to a dead proxy (HTTPS_PROXY=http://127.0.0.1:1, localhost bypassed) andGOPROXY=off— confirming no test reaches the network. A controlcurlto the real host through that proxy fails as expected.This makes the export validator's
go testhermetic, so exports no longer flake on network.