Skip to content

perf(tests): stub managed-dolt store openers in preflight tests#2077

Open
hexsprite wants to merge 4 commits into
gastownhall:mainfrom
hexsprite:perf/test-stub-managed-dolt-openers
Open

perf(tests): stub managed-dolt store openers in preflight tests#2077
hexsprite wants to merge 4 commits into
gastownhall:mainfrom
hexsprite:perf/test-stub-managed-dolt-openers

Conversation

@hexsprite
Copy link
Copy Markdown
Contributor

Summary

Stacked on #2069 — depends on the preflight ordering tests added there. Merge #2069 first.

The four managed-dolt preflight ordering tests in cmd/gc/city_runtime_test.go spawn a real dolt sql-server per test (~12s each) because newControllerState → openCityStoreAt and newCityRuntime → sweep store both open a live bd-backed store. Cost: ~38s of wall time for three tests that only verify call ordering.

This change:

  • Adds two test-overridable package vars: newControllerStateOpenCityStore (api_state.go) and newCityRuntimeOpenSweepStore (city_runtime.go). Production paths unchanged — defaults still call the real openers.
  • Adds stubManagedDoltStoreOpeners(t *testing.T) test helper that swaps both with beads.NewMemStore() returners and restores via t.Cleanup.
  • Installs the helper in the three preflight tests that previously spawned dolt.

Result

Test Before After
TestCityRuntimeTickPreflightsManagedDoltBeforeSessionSnapshot 16.90s 0.04s
TestCityRuntimeRunStartupPreflightsManagedDoltBeforeSessionSnapshot 16.45s 0.05s
TestNewCityRuntimePreflightsManagedDoltPublicationBeforeStartupStoreWork 16.32s 0.01s
TestCityRuntimeControlDispatcherPreflightsManagedDoltBeforeSessionSnapshot 0.66s 0.73s

4-test aggregate: 50.5s → 0.96s.

Full cmd/gc suite (677 tests) still passes.

Closes hq-wvcvb.

Test plan

  • go test ./cmd/gc/ -run preflight tests
  • go test ./cmd/gc/ -count=1 (full package)
  • Confirm ordering invariant still asserted: preflight event is recorded before any session-list event

hexsprite added 4 commits May 13, 2026 10:00
`gc prompt` and `gc prompt synth` were added to the CLI without
regenerating docs/reference/cli.md from cmd/genschema. The pre-commit
hook auto-regenerates this file when staged Go changes touch CLI
definitions, so the drift surfaced on an unrelated PR's commit.

Run: `go run ./cmd/genschema`
Adds TestCLIDocsFreshness, which walks the live cobra tree and asserts
every non-hidden command has a heading in docs/reference/cli.md. The
prior pre-commit hook silently regenerated cli.md and stapled it to
whichever commit happened to touch Go files, so CLI drift leaked onto
unrelated PRs. This catches the drift in CI/pre-commit and points at
the right fix: go run ./cmd/genschema.

Structural rather than byte-equal — cobra registers `completion`/`help`
only on Execute, which the in-test render path skips.
Two tests build CityRuntime directly, skipping newTestCityRuntime.
ensureManagedDoltPublishedForRuntime spawns real dolt sql-server at
construction/tick even with stub callbacks, leaving orphaned children.

Add cleanupManagedDoltTestCity(t, cityPath) for both tests.

Refs hq-bgb3v
The managed-dolt preflight ordering tests spawned a real dolt sql-server
per test (~12s each) via newControllerState's openCityStoreAt call and
newCityRuntime's sweep store open. With three tests on the hot path this
cost ~38s of wall time for behavior that only verifies ordering and
never needs a live store.

Add two test-overridable package vars (newControllerStateOpenCityStore,
newCityRuntimeOpenSweepStore) and a stubManagedDoltStoreOpeners(t)
helper that swaps in fresh in-memory stores. Restored via t.Cleanup.

Result: 4 target tests drop from ~50s -> ~1s aggregate. Full cmd/gc
suite still green (677 tests).

Closes hq-wvcvb.
@hexsprite hexsprite requested a review from csells as a code owner May 13, 2026 18:06
@github-actions github-actions Bot added the status/needs-triage Inbox — we haven't looked at it yet label May 13, 2026
@randy-release-manager randy-release-manager Bot added kind/chore Internal improvement (refactor, tests, CI, tooling) priority/p2 Medium — real problem, workaround exists and removed status/needs-triage Inbox — we haven't looked at it yet labels May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/chore Internal improvement (refactor, tests, CI, tooling) priority/p2 Medium — real problem, workaround exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant