MCPcopy
hub / github.com/docker/compose / TestWaitPreStart_RaceNilErrorAndResult

Function TestWaitPreStart_RaceNilErrorAndResult

pkg/compose/pre_start_test.go:344–353  ·  view source on GitHub ↗

TestWaitPreStart_RaceNilErrorAndResult stress-tests the scheduler outcome when ContainerWait closes a successful stream cleanly: Result has the exit code and Error sends nil at the same instant. Either branch of the outer select must end on the Result-based success, with no spurious failure.

(t *testing.T)

Source from the content-addressed store, hash-verified

342// code and Error sends nil at the same instant. Either branch of the outer
343// select must end on the Result-based success, with no spurious failure.
344func TestWaitPreStart_RaceNilErrorAndResult(t *testing.T) {
345 for i := 0; i < 100; i++ {
346 resultC := make(chan container.WaitResponse, 1)
347 errC := make(chan error, 1)
348 resultC <- container.WaitResponse{StatusCode: 0}
349 errC <- nil
350 waitRes := client.ContainerWaitResult{Result: resultC, Error: errC}
351 assert.NilError(t, waitPreStart(t.Context(), "web", 0, waitRes))
352 }
353}
354
355// TestWaitPreStart_RaceRealErrorAndResult stress-tests the opposite scenario:
356// a real transport error on Error races with a stale Result. The Error must

Callers

nothing calls this directly

Calls 1

waitPreStartFunction · 0.85

Tested by

no test coverage detected