mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Update api tests to use container.Run/Create in helper package
This fix is a sync up with 36266 so that relevant api tests use the newly added container.Run/Create in helper package Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
parent
95ce998c10
commit
9fcd2a0510
7 changed files with 68 additions and 148 deletions
|
@ -6,9 +6,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
|
||||||
"github.com/docker/docker/api/types/network"
|
|
||||||
"github.com/docker/docker/api/types/strslice"
|
"github.com/docker/docker/api/types/strslice"
|
||||||
|
"github.com/docker/docker/integration/internal/container"
|
||||||
"github.com/docker/docker/integration/internal/request"
|
"github.com/docker/docker/integration/internal/request"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -18,22 +17,12 @@ func TestExec(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
client := request.NewAPIClient(t)
|
client := request.NewAPIClient(t)
|
||||||
|
|
||||||
container, err := client.ContainerCreate(ctx,
|
cID := container.Run(t, ctx, client, func(c *container.TestContainerConfig) {
|
||||||
&container.Config{
|
c.Config.Tty = true
|
||||||
Image: "busybox",
|
c.Config.WorkingDir = "/root"
|
||||||
Tty: true,
|
})
|
||||||
WorkingDir: "/root",
|
|
||||||
Cmd: strslice.StrSlice([]string{"top"}),
|
|
||||||
},
|
|
||||||
&container.HostConfig{},
|
|
||||||
&network.NetworkingConfig{},
|
|
||||||
"foo",
|
|
||||||
)
|
|
||||||
require.NoError(t, err)
|
|
||||||
err = client.ContainerStart(ctx, container.ID, types.ContainerStartOptions{})
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
id, err := client.ContainerExecCreate(ctx, container.ID,
|
id, err := client.ContainerExecCreate(ctx, cID,
|
||||||
types.ExecConfig{
|
types.ExecConfig{
|
||||||
WorkingDir: "/tmp",
|
WorkingDir: "/tmp",
|
||||||
Env: strslice.StrSlice([]string{"FOO=BAR"}),
|
Env: strslice.StrSlice([]string{"FOO=BAR"}),
|
||||||
|
|
|
@ -6,13 +6,11 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
containertypes "github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/network"
|
|
||||||
"github.com/docker/docker/api/types/strslice"
|
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
|
"github.com/docker/docker/integration/internal/container"
|
||||||
"github.com/docker/docker/integration/internal/request"
|
"github.com/docker/docker/integration/internal/request"
|
||||||
"github.com/gotestyourself/gotestyourself/poll"
|
"github.com/gotestyourself/gotestyourself/poll"
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestHealthCheckWorkdir verifies that health-checks inherit the containers'
|
// TestHealthCheckWorkdir verifies that health-checks inherit the containers'
|
||||||
|
@ -22,27 +20,17 @@ func TestHealthCheckWorkdir(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
client := request.NewAPIClient(t)
|
client := request.NewAPIClient(t)
|
||||||
|
|
||||||
c, err := client.ContainerCreate(ctx,
|
cID := container.Run(t, ctx, client, func(c *container.TestContainerConfig) {
|
||||||
&container.Config{
|
c.Config.Tty = true
|
||||||
Image: "busybox",
|
c.Config.WorkingDir = "/foo"
|
||||||
Tty: true,
|
c.Config.Healthcheck = &containertypes.HealthConfig{
|
||||||
WorkingDir: "/foo",
|
Test: []string{"CMD-SHELL", "if [ \"$PWD\" = \"/foo\" ]; then exit 0; else exit 1; fi;"},
|
||||||
Cmd: strslice.StrSlice([]string{"top"}),
|
Interval: 50 * time.Millisecond,
|
||||||
Healthcheck: &container.HealthConfig{
|
Retries: 3,
|
||||||
Test: []string{"CMD-SHELL", "if [ \"$PWD\" = \"/foo\" ]; then exit 0; else exit 1; fi;"},
|
}
|
||||||
Interval: 50 * time.Millisecond,
|
})
|
||||||
Retries: 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
&container.HostConfig{},
|
|
||||||
&network.NetworkingConfig{},
|
|
||||||
"healthtest",
|
|
||||||
)
|
|
||||||
require.NoError(t, err)
|
|
||||||
err = client.ContainerStart(ctx, c.ID, types.ContainerStartOptions{})
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
poll.WaitOn(t, pollForHealthStatus(ctx, client, c.ID, types.Healthy), poll.WithDelay(100*time.Millisecond))
|
poll.WaitOn(t, pollForHealthStatus(ctx, client, cID, types.Healthy), poll.WithDelay(100*time.Millisecond))
|
||||||
}
|
}
|
||||||
|
|
||||||
func pollForHealthStatus(ctx context.Context, client client.APIClient, containerID string, healthStatus string) func(log poll.LogT) poll.Result {
|
func pollForHealthStatus(ctx context.Context, client client.APIClient, containerID string, healthStatus string) func(log poll.LogT) poll.Result {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/integration/internal/container"
|
||||||
"github.com/docker/docker/integration/internal/request"
|
"github.com/docker/docker/integration/internal/request"
|
||||||
"github.com/docker/docker/pkg/stdcopy"
|
"github.com/docker/docker/pkg/stdcopy"
|
||||||
"github.com/gotestyourself/gotestyourself/poll"
|
"github.com/gotestyourself/gotestyourself/poll"
|
||||||
|
@ -28,24 +28,13 @@ func TestLinksEtcHostsContentMatch(t *testing.T) {
|
||||||
client := request.NewAPIClient(t)
|
client := request.NewAPIClient(t)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
c, err := client.ContainerCreate(ctx,
|
cID := container.Run(t, ctx, client, container.WithCmd("cat", "/etc/hosts"), func(c *container.TestContainerConfig) {
|
||||||
&container.Config{
|
c.HostConfig.NetworkMode = "host"
|
||||||
Image: "busybox",
|
})
|
||||||
Cmd: []string{"cat", "/etc/hosts"},
|
|
||||||
},
|
|
||||||
&container.HostConfig{
|
|
||||||
NetworkMode: "host",
|
|
||||||
},
|
|
||||||
nil,
|
|
||||||
"")
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
err = client.ContainerStart(ctx, c.ID, types.ContainerStartOptions{})
|
poll.WaitOn(t, containerIsStopped(ctx, client, cID), poll.WithDelay(100*time.Millisecond))
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
poll.WaitOn(t, containerIsStopped(ctx, client, c.ID), poll.WithDelay(100*time.Millisecond))
|
body, err := client.ContainerLogs(ctx, cID, types.ContainerLogsOptions{
|
||||||
|
|
||||||
body, err := client.ContainerLogs(ctx, c.ID, types.ContainerLogsOptions{
|
|
||||||
ShowStdout: true,
|
ShowStdout: true,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -12,8 +12,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/integration/internal/container"
|
||||||
"github.com/docker/docker/api/types/network"
|
|
||||||
"github.com/docker/docker/integration/internal/request"
|
"github.com/docker/docker/integration/internal/request"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/gotestyourself/gotestyourself/poll"
|
"github.com/gotestyourself/gotestyourself/poll"
|
||||||
|
@ -67,25 +66,15 @@ func TestNetworkLoopbackNat(t *testing.T) {
|
||||||
|
|
||||||
client := request.NewAPIClient(t)
|
client := request.NewAPIClient(t)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
c, err := client.ContainerCreate(ctx,
|
|
||||||
&container.Config{
|
|
||||||
Image: "busybox",
|
|
||||||
Cmd: []string{"sh", "-c", fmt.Sprintf("stty raw && nc -w 5 %s 8080", endpoint.String())},
|
|
||||||
Tty: true,
|
|
||||||
},
|
|
||||||
&container.HostConfig{
|
|
||||||
NetworkMode: "container:server",
|
|
||||||
},
|
|
||||||
nil,
|
|
||||||
"")
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
err = client.ContainerStart(ctx, c.ID, types.ContainerStartOptions{})
|
cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", fmt.Sprintf("stty raw && nc -w 5 %s 8080", endpoint.String())), func(c *container.TestContainerConfig) {
|
||||||
require.NoError(t, err)
|
c.Config.Tty = true
|
||||||
|
c.HostConfig.NetworkMode = "container:server"
|
||||||
|
})
|
||||||
|
|
||||||
poll.WaitOn(t, containerIsStopped(ctx, client, c.ID), poll.WithDelay(100*time.Millisecond))
|
poll.WaitOn(t, containerIsStopped(ctx, client, cID), poll.WithDelay(100*time.Millisecond))
|
||||||
|
|
||||||
body, err := client.ContainerLogs(ctx, c.ID, types.ContainerLogsOptions{
|
body, err := client.ContainerLogs(ctx, cID, types.ContainerLogsOptions{
|
||||||
ShowStdout: true,
|
ShowStdout: true,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -102,34 +91,22 @@ func startServerContainer(t *testing.T, msg string, port int) string {
|
||||||
client := request.NewAPIClient(t)
|
client := request.NewAPIClient(t)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
c, err := client.ContainerCreate(ctx,
|
cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", fmt.Sprintf("echo %q | nc -lp %d", msg, port)), func(c *container.TestContainerConfig) {
|
||||||
&container.Config{
|
c.Config.ExposedPorts = map[nat.Port]struct{}{
|
||||||
Image: "busybox",
|
nat.Port(fmt.Sprintf("%d/tcp", port)): {},
|
||||||
Cmd: []string{"sh", "-c", fmt.Sprintf("echo %q | nc -lp %d", msg, port)},
|
}
|
||||||
ExposedPorts: map[nat.Port]struct{}{
|
c.HostConfig.PortBindings = nat.PortMap{
|
||||||
nat.Port(fmt.Sprintf("%d/tcp", port)): {},
|
nat.Port(fmt.Sprintf("%d/tcp", port)): []nat.PortBinding{
|
||||||
},
|
{
|
||||||
},
|
HostPort: fmt.Sprintf("%d", port),
|
||||||
&container.HostConfig{
|
|
||||||
PortBindings: nat.PortMap{
|
|
||||||
nat.Port(fmt.Sprintf("%d/tcp", port)): []nat.PortBinding{
|
|
||||||
{
|
|
||||||
HostPort: fmt.Sprintf("%d", port),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
&network.NetworkingConfig{},
|
})
|
||||||
"server",
|
|
||||||
)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
err = client.ContainerStart(ctx, c.ID, types.ContainerStartOptions{})
|
poll.WaitOn(t, containerIsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond))
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
poll.WaitOn(t, containerIsInState(ctx, client, c.ID, "running"), poll.WithDelay(100*time.Millisecond))
|
return cID
|
||||||
|
|
||||||
return c.ID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getExternalAddress(t *testing.T) net.IP {
|
func getExternalAddress(t *testing.T) net.IP {
|
||||||
|
|
|
@ -8,8 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/integration/internal/container"
|
||||||
"github.com/docker/docker/api/types/network"
|
|
||||||
"github.com/docker/docker/integration/internal/request"
|
"github.com/docker/docker/integration/internal/request"
|
||||||
"github.com/gotestyourself/gotestyourself/poll"
|
"github.com/gotestyourself/gotestyourself/poll"
|
||||||
"github.com/gotestyourself/gotestyourself/skip"
|
"github.com/gotestyourself/gotestyourself/skip"
|
||||||
|
@ -27,23 +26,11 @@ func TestStats(t *testing.T) {
|
||||||
info, err := client.Info(ctx)
|
info, err := client.Info(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
c, err := client.ContainerCreate(ctx,
|
cID := container.Run(t, ctx, client)
|
||||||
&container.Config{
|
|
||||||
Cmd: []string{"top"},
|
|
||||||
Image: "busybox",
|
|
||||||
},
|
|
||||||
&container.HostConfig{},
|
|
||||||
&network.NetworkingConfig{},
|
|
||||||
"",
|
|
||||||
)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
err = client.ContainerStart(ctx, c.ID, types.ContainerStartOptions{})
|
poll.WaitOn(t, containerIsInState(ctx, client, cID, "running"), poll.WithDelay(100*time.Millisecond))
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
poll.WaitOn(t, containerIsInState(ctx, client, c.ID, "running"), poll.WithDelay(100*time.Millisecond))
|
resp, err := client.ContainerStats(ctx, cID, false)
|
||||||
|
|
||||||
resp, err := client.ContainerStats(context.Background(), c.ID, false)
|
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
|
||||||
eventtypes "github.com/docker/docker/api/types/events"
|
eventtypes "github.com/docker/docker/api/types/events"
|
||||||
networktypes "github.com/docker/docker/api/types/network"
|
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
|
"github.com/docker/docker/integration/internal/container"
|
||||||
"github.com/docker/docker/integration/internal/request"
|
"github.com/docker/docker/integration/internal/request"
|
||||||
"github.com/docker/docker/internal/test/environment"
|
"github.com/docker/docker/internal/test/environment"
|
||||||
"github.com/docker/docker/pkg/authorization"
|
"github.com/docker/docker/pkg/authorization"
|
||||||
|
@ -91,17 +90,15 @@ func TestAuthZPluginAllowRequest(t *testing.T) {
|
||||||
client, err := d.NewClient()
|
client, err := d.NewClient()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
// Ensure command successful
|
ctx := context.Background()
|
||||||
createResponse, err := client.ContainerCreate(context.Background(), &container.Config{Cmd: []string{"top"}, Image: "busybox"}, &container.HostConfig{}, &networktypes.NetworkingConfig{}, "")
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
err = client.ContainerStart(context.Background(), createResponse.ID, types.ContainerStartOptions{})
|
// Ensure command successful
|
||||||
require.Nil(t, err)
|
cID := container.Run(t, ctx, client)
|
||||||
|
|
||||||
assertURIRecorded(t, ctrl.requestsURIs, "/containers/create")
|
assertURIRecorded(t, ctrl.requestsURIs, "/containers/create")
|
||||||
assertURIRecorded(t, ctrl.requestsURIs, fmt.Sprintf("/containers/%s/start", createResponse.ID))
|
assertURIRecorded(t, ctrl.requestsURIs, fmt.Sprintf("/containers/%s/start", cID))
|
||||||
|
|
||||||
_, err = client.ServerVersion(context.Background())
|
_, err = client.ServerVersion(ctx)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
require.Equal(t, 1, ctrl.versionReqCount)
|
require.Equal(t, 1, ctrl.versionReqCount)
|
||||||
require.Equal(t, 1, ctrl.versionResCount)
|
require.Equal(t, 1, ctrl.versionResCount)
|
||||||
|
@ -213,19 +210,17 @@ func TestAuthZPluginAllowEventStream(t *testing.T) {
|
||||||
client, err := d.NewClient()
|
client, err := d.NewClient()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
startTime := strconv.FormatInt(systemTime(t, client, testEnv).Unix(), 10)
|
startTime := strconv.FormatInt(systemTime(t, client, testEnv).Unix(), 10)
|
||||||
events, errs, cancel := systemEventsSince(client, startTime)
|
events, errs, cancel := systemEventsSince(client, startTime)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// Create a container and wait for the creation events
|
// Create a container and wait for the creation events
|
||||||
createResponse, err := client.ContainerCreate(context.Background(), &container.Config{Cmd: []string{"top"}, Image: "busybox"}, &container.HostConfig{}, &networktypes.NetworkingConfig{}, "")
|
cID := container.Run(t, ctx, client)
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
err = client.ContainerStart(context.Background(), createResponse.ID, types.ContainerStartOptions{})
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
c, err := client.ContainerInspect(context.Background(), createResponse.ID)
|
c, err := client.ContainerInspect(ctx, cID)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
if c.State.Running {
|
if c.State.Running {
|
||||||
break
|
break
|
||||||
|
@ -241,7 +236,7 @@ func TestAuthZPluginAllowEventStream(t *testing.T) {
|
||||||
for !created && !started {
|
for !created && !started {
|
||||||
select {
|
select {
|
||||||
case event := <-events:
|
case event := <-events:
|
||||||
if event.Type == eventtypes.ContainerEventType && event.Actor.ID == createResponse.ID {
|
if event.Type == eventtypes.ContainerEventType && event.Actor.ID == cID {
|
||||||
if event.Action == "create" {
|
if event.Action == "create" {
|
||||||
created = true
|
created = true
|
||||||
}
|
}
|
||||||
|
@ -264,7 +259,7 @@ func TestAuthZPluginAllowEventStream(t *testing.T) {
|
||||||
// authorization plugin
|
// authorization plugin
|
||||||
assertURIRecorded(t, ctrl.requestsURIs, "/events")
|
assertURIRecorded(t, ctrl.requestsURIs, "/events")
|
||||||
assertURIRecorded(t, ctrl.requestsURIs, "/containers/create")
|
assertURIRecorded(t, ctrl.requestsURIs, "/containers/create")
|
||||||
assertURIRecorded(t, ctrl.requestsURIs, fmt.Sprintf("/containers/%s/start", createResponse.ID))
|
assertURIRecorded(t, ctrl.requestsURIs, fmt.Sprintf("/containers/%s/start", cID))
|
||||||
}
|
}
|
||||||
|
|
||||||
func systemTime(t *testing.T, client client.APIClient, testEnv *environment.Execution) time.Time {
|
func systemTime(t *testing.T, client client.APIClient, testEnv *environment.Execution) time.Time {
|
||||||
|
@ -347,6 +342,8 @@ func TestAuthZPluginEnsureLoadImportWorking(t *testing.T) {
|
||||||
client, err := d.NewClient()
|
client, err := d.NewClient()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
tmp, err := ioutil.TempDir("", "test-authz-load-import")
|
tmp, err := ioutil.TempDir("", "test-authz-load-import")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
defer os.RemoveAll(tmp)
|
defer os.RemoveAll(tmp)
|
||||||
|
@ -360,13 +357,9 @@ func TestAuthZPluginEnsureLoadImportWorking(t *testing.T) {
|
||||||
|
|
||||||
exportedImagePath := filepath.Join(tmp, "export.tar")
|
exportedImagePath := filepath.Join(tmp, "export.tar")
|
||||||
|
|
||||||
createResponse, err := client.ContainerCreate(context.Background(), &container.Config{Cmd: []string{}, Image: "busybox"}, &container.HostConfig{}, &networktypes.NetworkingConfig{}, "")
|
cID := container.Run(t, ctx, client)
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
err = client.ContainerStart(context.Background(), createResponse.ID, types.ContainerStartOptions{})
|
responseReader, err := client.ContainerExport(context.Background(), cID)
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
responseReader, err := client.ContainerExport(context.Background(), createResponse.ID)
|
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
defer responseReader.Close()
|
defer responseReader.Close()
|
||||||
file, err := os.Create(exportedImagePath)
|
file, err := os.Create(exportedImagePath)
|
||||||
|
|
|
@ -11,11 +11,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/container"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
networktypes "github.com/docker/docker/api/types/network"
|
|
||||||
volumetypes "github.com/docker/docker/api/types/volume"
|
volumetypes "github.com/docker/docker/api/types/volume"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
|
"github.com/docker/docker/integration/internal/container"
|
||||||
"github.com/docker/docker/integration/internal/requirement"
|
"github.com/docker/docker/integration/internal/requirement"
|
||||||
"github.com/gotestyourself/gotestyourself/skip"
|
"github.com/gotestyourself/gotestyourself/skip"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -47,6 +46,8 @@ func TestAuthZPluginV2AllowNonVolumeRequest(t *testing.T) {
|
||||||
client, err := d.NewClient()
|
client, err := d.NewClient()
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
// Install authz plugin
|
// Install authz plugin
|
||||||
err = pluginInstallGrantAllPermissions(client, authzPluginNameWithTag)
|
err = pluginInstallGrantAllPermissions(client, authzPluginNameWithTag)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
@ -56,13 +57,9 @@ func TestAuthZPluginV2AllowNonVolumeRequest(t *testing.T) {
|
||||||
d.LoadBusybox(t)
|
d.LoadBusybox(t)
|
||||||
|
|
||||||
// Ensure docker run command and accompanying docker ps are successful
|
// Ensure docker run command and accompanying docker ps are successful
|
||||||
createResponse, err := client.ContainerCreate(context.Background(), &container.Config{Cmd: []string{"top"}, Image: "busybox"}, &container.HostConfig{}, &networktypes.NetworkingConfig{}, "")
|
cID := container.Run(t, ctx, client)
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
err = client.ContainerStart(context.Background(), createResponse.ID, types.ContainerStartOptions{})
|
_, err = client.ContainerInspect(ctx, cID)
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
_, err = client.ContainerInspect(context.Background(), createResponse.ID)
|
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue