github.com/rumpl/bof@v23.0.0-rc.2+incompatible/integration/container/stop_test.go (about) 1 package container // import "github.com/docker/docker/integration/container" 2 3 import ( 4 "context" 5 "testing" 6 "time" 7 8 containertypes "github.com/docker/docker/api/types/container" 9 "github.com/docker/docker/integration/internal/container" 10 "gotest.tools/v3/assert" 11 "gotest.tools/v3/poll" 12 ) 13 14 func TestStopContainerWithRestartPolicyAlways(t *testing.T) { 15 defer setupTest(t)() 16 client := testEnv.APIClient() 17 ctx := context.Background() 18 19 names := []string{"verifyRestart1-" + t.Name(), "verifyRestart2-" + t.Name()} 20 for _, name := range names { 21 container.Run(ctx, t, client, 22 container.WithName(name), 23 container.WithCmd("false"), 24 container.WithRestartPolicy("always"), 25 ) 26 } 27 28 for _, name := range names { 29 poll.WaitOn(t, container.IsInState(ctx, client, name, "running", "restarting"), poll.WithDelay(100*time.Millisecond)) 30 } 31 32 for _, name := range names { 33 err := client.ContainerStop(ctx, name, containertypes.StopOptions{}) 34 assert.NilError(t, err) 35 } 36 37 for _, name := range names { 38 poll.WaitOn(t, container.IsStopped(ctx, client, name), poll.WithDelay(100*time.Millisecond)) 39 } 40 }