mirror of
https://github.com/docker/compose.git
synced 2026-11-17 13:45:39 +00:00
test(compose): bound the unsupported-condition wait, compare the deadline class
Review follow-ups of the removal of waitDependencies' timeout parameter: the unsupported-condition test lost the 2s bound the parameter gave it, so a regression that waits would hang instead of failing; and the test comparing a timeout that expires during the inspection with one that expires between polls now also compares whether they are a deadline. Also reword the comment of execWaitCondition, which still said that waitDependencies threads a timeout through its waits. Part of #14081 Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
43f30d52d7
commit
27fbcae131
2 changed files with 13 additions and 11 deletions
|
|
@ -220,16 +220,14 @@ func (exec *planExecutor) resolveContainerSummary(op Operation) (container.Summa
|
|||
// warning, not a plan failure — matching waitDependencies' own
|
||||
// optional-dependency handling.
|
||||
//
|
||||
// Unlike waitDependencies, this has no timeout of its own to apply here --
|
||||
// ctx is used exactly as given, already wrapped (or not) by executeNode's
|
||||
// OpWaitCondition dispatch in executor.go. origCtx is ctx as it stood right
|
||||
// before that wrap, passed through unchanged to waitDependency, which needs
|
||||
// it to tell its own wait timeout apart from an inherited deadline (see its
|
||||
// doc comment). upDetached (up.go) is the caller that needs a timeout here
|
||||
// at all: planExecutor.waitTimeout gives this node its own fresh per-wait
|
||||
// window, the same thing start()'s own WaitTimeout already threads through
|
||||
// every waitDependencies call -- without also bounding unrelated Create or
|
||||
// Start work the way wrapping the whole plan's ctx would.
|
||||
// This applies no timeout of its own -- ctx is used exactly as given,
|
||||
// already wrapped (or not) by executeNode's OpWaitCondition dispatch in
|
||||
// executor.go. origCtx is ctx as it stood right before that wrap, passed
|
||||
// through unchanged to waitDependency, which needs it to tell its own wait
|
||||
// timeout apart from an inherited deadline (see its doc comment).
|
||||
// planExecutor.waitTimeout (set by upDetached and start) is what gives this
|
||||
// node its own fresh per-wait window, without also bounding unrelated Create
|
||||
// or Start work the way wrapping the whole plan's ctx would.
|
||||
func (exec *planExecutor) execWaitCondition(ctx, origCtx context.Context, op Operation) error {
|
||||
s := exec.compose
|
||||
exec.containersMu.Lock()
|
||||
|
|
|
|||
|
|
@ -927,7 +927,10 @@ func TestWaitDependencyDeadline(t *testing.T) {
|
|||
unsupportedDeps := types.DependsOnConfig{
|
||||
"db": {Condition: "some_future_condition", Required: true},
|
||||
}
|
||||
err := tested.(*composeService).waitDependencies(t.Context(), &project, "app", unsupportedDeps, containers)
|
||||
// the bound makes a regression that waits fail instead of hanging
|
||||
ctx, cancel := context.WithTimeout(t.Context(), 2*time.Second)
|
||||
defer cancel()
|
||||
err := tested.(*composeService).waitDependencies(ctx, &project, "app", unsupportedDeps, containers)
|
||||
assert.NilError(t, err)
|
||||
|
||||
var messages []string
|
||||
|
|
@ -1147,6 +1150,7 @@ func TestOptionalDependencyInspectFailure(t *testing.T) {
|
|||
// the same end, whatever the instant the timeout expired at
|
||||
assert.Equal(t, duringInspect == nil, betweenPolls == nil)
|
||||
assert.Equal(t, errors.Is(duringInspect, errWaitTimeout), errors.Is(betweenPolls, errWaitTimeout))
|
||||
assert.Equal(t, errors.Is(duringInspect, context.DeadlineExceeded), errors.Is(betweenPolls, context.DeadlineExceeded))
|
||||
if required {
|
||||
assert.Assert(t, errors.Is(duringInspect, errWaitTimeout), "got %v", duringInspect)
|
||||
assert.ErrorIs(t, duringInspect, context.DeadlineExceeded)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue