Repository navigation
fix(localnet): keep tests from booting the real shared observability stack - #362
Merged
Merged
Conversation
…stack TestRunUp_InheritsOptInProfilesOnReup re-ups an instance whose stored profiles include observability, so RunUp probes the shared stack via EnsureSharedStack. The test stubbed the instance compose runner but not newSharedRunner, so every `go test ./internal/localnet/...` ran a real `docker compose up` and left canton-devkit-observability-prometheus and -grafana running from the test's TempDir. Because the shared project name is fixed, any unstubbed test can also discover (DiscoverPort) or tear down (Stop is `-p`-only) a developer's real shared stack. So beyond stubbing the two tests that reached it: - newSharedRunner now returns a refusing runner when testing.Testing() is true, unless CANTON_DEVKIT_TEST_ALLOW_SHARED_STACK=1. Callers treat the refusal like a host without Docker (best-effort paths already handle that). - Add a stubSharedRunner helper and use it in the re-up test (shared stack reported unreachable, so RunUp takes the stubbed per-instance overlay path) and in the refcount test. - Stub sharedGrafanaURL in the CLI TestObservabilityStatus_TextOff, which was running `docker compose port` against the shared project.
Pick up curated Splice 0.9.0 memory floors (#363) so TestSpliceMemoryFloors_NeverBelowDockerGate passes in CI.
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.
Why
TestRunUp_InheritsOptInProfilesOnReupre-ups an instance whose stored profiles includeobservability, soRunUpprobes the shared stack throughsharedStackReachable→EnsureSharedStack. The test stubbed the instance compose runner (NewRunner) but not the package varnewSharedRunner. Everygo test ./internal/localnet/...therefore ran a realdocker compose upand leftcanton-devkit-observability-prometheusand-grafanarunning, with their compose working_dir in the test's deletedt.TempDir().The shared project name is fixed (
canton-devkit-observability), so this goes beyond leaked containers. An unstubbed test can also:DiscoverPort), orStopis-p-only (docker compose -p canton-devkit-observability down --volumes).What
go test(testing.Testing()), the defaultnewSharedRunnernow returns a runner that refusesUp/Stop/DiscoverPort, unlessCANTON_DEVKIT_TEST_ALLOW_SHARED_STACK=1is set (for a future integration test). Callers treat the refusal like a host without Docker. Those paths are already best-effort.TestRunUp_InheritsOptInProfilesOnReup: stubsnewSharedRunnervia a newstubSharedRunner(t, …)helper (restored witht.Cleanup). The stub reports the shared stack as unreachable, soRunUptakes the per-instance overlay path, whichNewRunneralready stubs.TestTeardownSharedStackIfIdle_RefcountGatenow uses the same helper.cli/localnetTestObservabilityStatus_TextOff: stubssharedGrafanaURL. It was runningdocker compose port grafana 3000against the shared project.TestNewSharedRunner_RefusesDockerUnderGoTest. It checks the runner's type before calling any method, so a regressed guard fails the test without running a real teardown.Audit
I temporarily instrumented the default runner to log a stack trace on every call and ran
go test ./.... Only two tests reached it: the two fixed above. Nointernal/ui/handlerstest reachesRegisterInstanceAndEnsureStack/EnsureSharedStack.SetObservabilitydrives the per-instance project, not the shared one, and its tests never take the docker enable path.Test plan
go test ./internal/localnet/... ./internal/ui/...: passes exceptTestSpliceMemoryFloors_NeverBelowDockerGate. That test already fails onmain(splice.RecommendedMemoryFor("0.9.0") = 0) and is unrelated to this change.make test: same single pre-existing failure.make lint(golangci-lint v2.12.2): 0 issues.docker ps -a --filter name=canton-devkit-observabilityshows no containers after the runs (Docker 29.2.1 reachable).