test(e2e): build stack binaries once per run via TestMain (RIG-2738) - #668
Open
rigel-mintaka wants to merge 1 commit into
Open
test(e2e): build stack binaries once per run via TestMain (RIG-2738)#668rigel-mintaka wants to merge 1 commit into
rigel-mintaka wants to merge 1 commit into
Conversation
The e2e fixture rebuilt the three stack child binaries (compass-postgres, compass-server, compass-runner) on every NewFixture call — 11 stand-ups per suite run, so 33 go-build invocations into 11 throwaway temp dirs. The binaries are identical across every fixture in a run, so hoist the build into a package TestMain that compiles them once into one shared dir and exports it on PATH for the whole run. NewFixture now just prepends that shared dir. Behaviour-preserving: the ProcessSupervisor still resolves each child by bare name via exec.LookPath against the same PATH entry; only the build count changes (33 -> 3 per run). Serial suite, one shared dir, no cross-test coupling beyond the already-shared PATH the fixtures all set identically. RIG-2738 mechanical lever L1. Shared-stack + shared-external-PG levers (L2/L3) are the RIG-2742 harness-consolidation design, not this PR. Co-authored-by: Matt Wilkinson <matt@rigel.build>
|
Compass engineering docs preview: https://compass-rig-2738-testmain-bu.compass-eng-docs.pages.dev Deployed from |
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.
What
Build the three stack child binaries (
compass-postgres,compass-server,compass-runner) once per e2e run via a packageTestMain, instead of rebuilding them on everyNewFixture.RIG-2738 mechanical lever L1.
Why
The
dogfood-e2esuite stands up ~11 fixtures per run (10 podman-tagged tests,TestLegSixTeardownIdempotencecallsNewFixturetwice). EachNewFixtureranbuildBinariesFromModuleRoot, which invokedgo buildthree times into a throwawayt.TempDir— 33go buildinvocations into 11 dirs per run, all producing identical binaries.The binaries never differ across fixtures in a run, so one build serves the whole suite.
TestMaincompiles them once into a single dir and exports it onPATHfor the run;NewFixtureno longer builds anything.How
go/e2e/main_test.go(//go:build podman) withTestMain: builds once (guarded bypodmanUsable()so a container-less sandbox still skips-and-exits without building), setsPATHprocess-wide, runs, cleans up the shared bin dir after.buildBinariesFromModuleRoot(t)→ t-freebuildStackBinaries() (string, error), moved intomain_test.go; the per-fixture build +t.Setenv("PATH", ...)dropped fromNewFixture.Behaviour-preserving. The
ProcessSupervisorstill resolves each child by bare name viaexec.LookPathagainst the samePATHentry — only the build count changes (33 → 3 per run). The suite is serial (not.Parallel,go testdefault), so one shared bin dir has no cross-test coupling beyond thePATHevery fixture already set identically.Why
TestMainis//go:build podmanTestMaingoverns the whole package's test lifecycle, andgo/e2ecarries a deliberately untagged hermetic lane (cannedmodel_test.go) that runs under a plaingo testwith no container and no stack. TaggingTestMainpodmankeeps it out of that build, so the hermetic lane keeps Go's defaultTestMainand never triggers a stack-binary build. Verified:go vet ./e2e/(untagged) andgo vet -tags podman ./e2e/both clean.Scope
L1 only. The dominant levers — a shared long-lived stack across legs (kills ~11 cold container boots) and a shared external postgres (kills ~11
initdbs) — are the RIG-2742 harness-consolidation design, not this PR (see the profiling on RIG-2738 comment-877222b7 and the grounding on RIG-2742 comment-0586f7af). Keeping the topology change in one place.Test
Ran the full podman suite locally (
CGO_ENABLED=1 go test -tags podman -race -v -timeout 20m ./e2e/...): 9 of 11 podman legs PASS off the once-built TestMain binaries — confirming the build-once mechanism serves every fixture correctly. Two legs (TestLegFivePersistAndResume,TestLegSixTeardownIdempotence) failed onRemoveAgentWorkspace RPC: context deadline exceeded— a container-teardown timeout, a path this change does not touch (the documented cold-rootless-podman contention class), because this dev box was running the whole agent wave against one shared podman engine under-race.Verified that's environmental, not this change: both legs PASS in isolation on unmodified main (
ok, exit 0 — LegFive 90.7s / LegSix 78.9s) AND PASS in isolation on this branch (ok, exit 0 — LegFive 56.3s / LegSix 60.5s). Same binaries, no teardown timeout when the podman engine isn't contended. CI runsdogfood-e2ein a dedicated privileged container with no competing wave, matching the isolated (green) case.RIG-2738