Skip to content

fix(ui): stop handler tests from booting real Canton stacks - #325

Merged
zheli merged 1 commit into
mainfrom
fix/hermetic-handler-tests
Aug 21, 2026
Merged

fix(ui): stop handler tests from booting real Canton stacks#325
zheli merged 1 commit into
mainfrom
fix/hermetic-handler-tests

Conversation

@zheli

@zheli zheli commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #322, which sealed only the start path.

Problem

handleCreate, handleResumeInstance and realRecreateWork called localnet.RunUp directly on a detached context.Background() goroutine. Any test reaching them booted a real Canton stack that outlived the test run.

Confirmed empirically: on a clean host, make test on main leaks 9 containers under compose project canton-pebble, traced via container labels to the devkit-handlers-tests-* tempdir.

Those stranded containers then make later runs take the fast-start branch and return 204/500 instead of 202. That is the failure #322 diagnosed — it looked "pre-existing" on a developer machine while CI stayed green, because CI runners start clean.

Fix

Two latent flakes surfaced

TestCancelUp_HappyPath and TestCreate_DuplicateNameReturns409 silently depended on the real RunUp being slow (pulling images) to keep a job in-flight. Both now install a blocking stub that returns on ctx.Done(), matching their existing jobs.Cancel + waitJobsDrain teardown. TestCreate_DuplicateNameReturns409 was failing under -race on main for this reason.

TestResume_StoppedInstance202 now asserts what its own comment said it could not ("we cannot easily assert the goroutine reaches RunUp"): that bring-up receives the recorded version, pinning the no-silent-upgrade rule.

Verification

  • make test exit 0, container delta 0 (was +9 on main)
  • go test -race -count=3 green; plain -count=3 green
  • make lint -> 0 issues.

No user-facing behaviour change, so no docs/changes-from-proposal.md entry (internal indirection + tests only).

handleCreate, handleResumeInstance and realRecreateWork called
localnet.RunUp directly on a detached context, so any test reaching
them booted a real Canton stack that outlived the run. The stranded
containers then made later runs take the fast-start branch and return
204/500 instead of 202 — the failure that looked "pre-existing" on a
developer machine while CI stayed green on clean runners.

Route those call sites through the package-level seam #322 already
introduced, and default runUp to a no-op in TestMain so the property
holds for tests added later instead of one call site at a time. This
matches the existing runPreflightForVersion stub, which is process-wide
for the same reason.

TestCancelUp_HappyPath and TestCreate_DuplicateNameReturns409 silently
depended on the real RunUp being slow enough to keep a job in-flight.
They now install a blocking stub, which also removes the timing flake
that made the latter fail under -race.
@zheli
zheli merged commit e6d0f54 into main Aug 21, 2026
4 checks passed
@zheli
zheli deleted the fix/hermetic-handler-tests branch August 21, 2026 07:52
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