integration: add/use WithRestartPolicy
NOTE TestUpdateRestartPolicy is left as is as otherwise it will decrease its readability. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> (cherry picked from commit f664df01d1836686c7a8a917e9da81d56c758d74) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 2c546aace40872169b03e18f07294d3fbfa3d452 Component: engine
This commit is contained in:
committed by
Sebastiaan van Stijn
parent
9659d7a8ac
commit
51a09b5116
@@ -5,7 +5,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
containertypes "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/integration/internal/container"
|
||||
"github.com/docker/docker/internal/test/request"
|
||||
@@ -96,12 +95,11 @@ func TestKillWithStopSignalAndRestartPolicies(t *testing.T) {
|
||||
tc := tc
|
||||
t.Run(tc.doc, func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
id := container.Run(t, ctx, client, func(c *container.TestContainerConfig) {
|
||||
c.Config.StopSignal = tc.stopsignal
|
||||
c.HostConfig.RestartPolicy = containertypes.RestartPolicy{
|
||||
Name: "always",
|
||||
}
|
||||
})
|
||||
id := container.Run(t, ctx, client,
|
||||
container.WithRestartPolicy("always"),
|
||||
func(c *container.TestContainerConfig) {
|
||||
c.Config.StopSignal = tc.stopsignal
|
||||
})
|
||||
err := client.ContainerKill(ctx, id, "TERM")
|
||||
assert.NilError(t, err)
|
||||
|
||||
|
||||
@@ -17,9 +17,11 @@ func TestStopContainerWithRestartPolicyAlways(t *testing.T) {
|
||||
|
||||
names := []string{"verifyRestart1-" + t.Name(), "verifyRestart2-" + t.Name()}
|
||||
for _, name := range names {
|
||||
container.Run(t, ctx, client, container.WithName(name), container.WithCmd("false"), func(c *container.TestContainerConfig) {
|
||||
c.HostConfig.RestartPolicy.Name = "always"
|
||||
})
|
||||
container.Run(t, ctx, client,
|
||||
container.WithName(name),
|
||||
container.WithCmd("false"),
|
||||
container.WithRestartPolicy("always"),
|
||||
)
|
||||
}
|
||||
|
||||
for _, name := range names {
|
||||
|
||||
@@ -129,6 +129,13 @@ func WithAutoRemove(c *TestContainerConfig) {
|
||||
c.HostConfig.AutoRemove = true
|
||||
}
|
||||
|
||||
// WithRestartPolicy sets container's restart policy
|
||||
func WithRestartPolicy(policy string) func(c *TestContainerConfig) {
|
||||
return func(c *TestContainerConfig) {
|
||||
c.HostConfig.RestartPolicy.Name = policy
|
||||
}
|
||||
}
|
||||
|
||||
// WithUser sets the user
|
||||
func WithUser(user string) func(c *TestContainerConfig) {
|
||||
return func(c *TestContainerConfig) {
|
||||
|
||||
Reference in New Issue
Block a user