2018-02-05 16:05:59 -05:00
|
|
|
package container // import "github.com/docker/docker/integration/container"
|
2018-01-02 23:55:33 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2018-02-10 18:01:37 -05:00
|
|
|
"github.com/docker/docker/integration/internal/container"
|
2020-02-07 08:39:24 -05:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
"gotest.tools/v3/poll"
|
2018-01-02 23:55:33 -05:00
|
|
|
)
|
|
|
|
|
2018-01-29 18:36:45 -05:00
|
|
|
func TestStopContainerWithRestartPolicyAlways(t *testing.T) {
|
|
|
|
defer setupTest(t)()
|
2019-01-02 08:16:25 -05:00
|
|
|
client := testEnv.APIClient()
|
2018-01-29 18:36:45 -05:00
|
|
|
ctx := context.Background()
|
|
|
|
|
2018-03-21 17:47:49 -04:00
|
|
|
names := []string{"verifyRestart1-" + t.Name(), "verifyRestart2-" + t.Name()}
|
2018-01-29 18:36:45 -05:00
|
|
|
for _, name := range names {
|
2019-06-06 07:15:31 -04:00
|
|
|
container.Run(ctx, t, client,
|
2019-02-14 19:03:26 -05:00
|
|
|
container.WithName(name),
|
|
|
|
container.WithCmd("false"),
|
|
|
|
container.WithRestartPolicy("always"),
|
|
|
|
)
|
2018-01-29 18:36:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, name := range names {
|
2018-02-22 05:30:51 -05:00
|
|
|
poll.WaitOn(t, container.IsInState(ctx, client, name, "running", "restarting"), poll.WithDelay(100*time.Millisecond))
|
2018-01-29 18:36:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, name := range names {
|
|
|
|
err := client.ContainerStop(ctx, name, nil)
|
2018-03-13 15:28:34 -04:00
|
|
|
assert.NilError(t, err)
|
2018-01-29 18:36:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, name := range names {
|
2018-02-22 05:30:51 -05:00
|
|
|
poll.WaitOn(t, container.IsStopped(ctx, client, name), poll.WithDelay(100*time.Millisecond))
|
2018-01-29 18:36:45 -05:00
|
|
|
}
|
|
|
|
}
|