Repository navigation
test(compose): lock the behaviors of the start path now carried by the plan engine - #14403
Conversation
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
Lower-confidence findings (not posted inline)
- [low] pkg/compose/executor_start_test.go:544 — bareStartNode helper function is missing t.Helper() (confidence: weak 31/100)
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
docker-agent
left a comment
There was a problem hiding this comment.
This review covers only the commits since 09d7231bfdd7.
Assessment: 🟢 APPROVE
The single-hunk change to pkg/compose/up_phases_test.go is correct and complete. It resolves the open review thread (PRRT_kwDOAOWUd86wuKdX) about the goroutine potentially calling t.Error after test completion:
- Buffered channel of capacity 1 (
make(chan error, 1)) guarantees the goroutine can always send without blocking, even if the test goroutine has already exited viaruntime.Goexit()(timeout path). - Goroutine sends exactly once unconditionally —
writeErr <- writeStdcopyFrame(...)— so<-writeErrin the test goroutine never blocks forever on the happy path. - Timeout path is safe:
t.Fatalfcallsruntime.Goexit(), which skips the deferred<-writeErrreceive; the buffered channel absorbs the goroutine's eventual send with no leak and no panic. - Normal path:
assert.NilError(t, <-writeErr)is reached afterrunInteractiveUpreturns, correctly propagating any write failure back to the test goroutine.
No new bugs introduced.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
glours
left a comment
There was a problem hiding this comment.
Needs a rebase: pkg/compose/monitor_test.go:989 calls labelFilter, which 7f7247c renamed to naming.LabelFilter (now on main). No textual conflict, so GitHub shows it mergeable, but pkg/compose no longer compiles once merged. Fix: naming.LabelFilter(api.ProjectLabel, ...) — internal/naming is already imported in that file. With that one-liner, go test -race -shuffle=on ./pkg/compose/ passes.
Three tests don't pin what they claim — mutation survivors outside the six listed in the description, see inline:
watch.gorebuild:createAndStart→createScale:applyReplicasdroppedmonitor.go:315: the start-eventIsRelayguard dropped
Nits, no inline:
inspectOf(dependency_wait_test.go:843) andinspectResultOf(start_test.go:313) are two near-identical builders added by this PR; one with an extra parameter would do.dependency_wait_test.go:967: the doc comment ofTestWaitDependenciesReportsTheWaitsays a hook runner of the service is excluded, but the fixture has no container carryingapi.HookLabel. Add one or trim the comment.executor_start_test.go:2303/:2308: thectrsmap is written, never read.- The description says "no sleeps": true for
start_test.go(synctest), but theuptests rely on real 50–100ms timers. "No new sleeps" would be accurate.
The monitor ends with the application it follows: pin that its initial listing and its event subscription are scoped to the project's own containers (no one-offs, no hook runners without a config hash), and that a provider's relay, which never terminates, is not waited for, whether it is there at the start or created later. Part of docker#14081. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
… order Pin what compose start does around its plan: the --wait verification (ready or not, timeout message, one-shot services satisfied by their completion), the project rebuilt from the project's non-one-off containers when no compose file is given, only the selected services started, and the replicas started in numeric order. Part of docker#14081. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Pin which dependencies are worth a wait (shouldWaitForDependency), how each container state reads for service_healthy and service_completed_successfully (required and optional, dry-run), the Waiting/Healthy rows of a wait outside a plan, and that the end of a wait's context wins over a ready tick. Add the plan shapes for a wait following its dependency's start, a project of scale: 0 services, and the Start phase covering every service of the project (the current behavior of scale, whose change would be a decision of its own). Part of docker#14081. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Pin that every ContainerStart holds startMx, that the start, pre_start, post_start and hook-runner nodes do nothing once the context is canceled, that a failure relays untouched down a replica's chain, that the node bookkeeping records cancellations as failures, that the phase returns the originating error, that an invalid plan is refused, that a concurrency cap cannot deadlock the node goroutines, that Starting is reported when the container starts (not during pre_start), that the hook runner targets the lowest-numbered replica, and that stop timeouts reach the daemon in whole seconds. Part of docker#14081. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Extend the interactive-up daemon fake and pin the behaviors mutation checks of the interactive-up switchover found unlocked: the monitor's Services scope, a Start-phase error while terminated, the cleanup when attaching fails, signal handling starting only after the Create phase, late starters stopped after the teardown sweep, hook logs reaching the session, the wait timeout translation, --exit-code-from and the Running events. Add the wiring of detached up (with its --wait verification), scale, the rebuild of watch and the dependencies of run onto the plan. Part of docker#14081. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Pin that restart waits for a restart:true dependency to hold its condition again before restarting its dependent, and that its timeout reaches the daemon in whole seconds. Part of docker#14081. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Close the started channel before the start event is emitted, so that a late starter stopped in reaction to it always finds the container started, and close both ends of the pipe the hook logs test hands to the session. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
A relay is also started, and onContainerStart adds a watched container to the set on its own: send the start event too, so that dropping its IsRelay guard is caught (a relay restarted after having been created before the monitor subscribed would be waited for forever). Also use naming.LabelFilter, which labelFilter became on main. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
The watch rebuild test recorded every touch alike, so a create alone satisfied it: record the starts apart and require them for the rebuilt service and the one depending on it. Scale asked for the project's default replica count, which made applying the requested count invisible: ask for 2 and count the calls. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Merge inspectOf into inspectResultOf (extra healthcheck parameter), add a container carrying the hook label to the wait fixture the comment talks about, and drop the executor test map that was written and never read. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
953588b to
88c5fe2
Compare
|
Thanks for the review. Rebased on main (
Still open, as noted in the thread: |
…of a rebuild The rebuild forces the recreation of the service it rebuilds and leaves the providers alone, and the test passed without either option. Give it an up to date container of the rebuilt service, expected to be removed and created anyway, and a provider-backed service depending on it, whose provider must not run. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
…channel Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
This review covers only the commits pushed since
88c5fe21b1aa.
The single changed file (pkg/compose/up_signal_test.go) correctly fixes all three previously-reported goroutine-calls-t.Error issues. Each goroutine now reports errors through a buffered channel (capacity 1) that is drained on the test goroutine after h.up(t) returns.
The two speculative concerns raised during analysis — that a non-blocking select { default: } drain could race with the goroutine — were verified and dismissed: the only code path that would send to killErr is syscall.Kill(os.Getpid(), SIGINT) failing, which is practically impossible when a process self-kills. On both the normal path (Kill succeeds, no send) and the timeout path (goroutine exits via t.Context().Done(), no send), the channel is always empty when the drain runs. The pattern is sound.
What this PR does, in one sentence
Locks, with tests only, the behaviors of the old imperative start path that the plan engine now carries, so that #14081 can be closed.
Context
The convergence of the start phase into the plan engine (#14081) replaced the imperative start path step by step. Each step was checked against the old behavior, but mostly by hand and by mutation testing in the PRs themselves. Mutating the production code afterwards showed that many of those behaviors were not pinned by any test: of 167 mutations applied to
pkg/compose, 61 survived the test suite ofmain.What the PR brings
depends_ongate and its health/exit conditions, the executor's guarantees,compose start, the monitor's scope, interactive and detachedup, hooks,restart, and the wiring ofscale,watchrebuild andrun.Start.Servicesin the monitor, the tolerance of the Start phase's error once terminated, the cleanup when the daemon time cannot be read, andsignal.Notifyordering.scalekeeps restarting every stopped container of the project, as it does today; a test pins that current behavior, and the comment says that changing it is a decision of its own.Guardrails: no production code changes, tests are deterministic (
synctestfor the start path timers, no new sleeps), and the new ones were run with-raceand shuffling.The six mutations still alive are the failure-path cleanups of the interactive
up(attach or daemon-time failure, which the deferred cancel makes unobservable), the precedence of a dependency error over "no container to start", and wait nodes being reported as aborted. Observing them would need production hooks, which is out of scope here.Closes #14081
🤖 Generated with Claude Code