1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #38473 from thaJeztah/use_testenv_client

Integration: use testenv.APIClient()
This commit is contained in:
Sebastiaan van Stijn 2019-01-03 22:21:54 +01:00 committed by GitHub
commit 2b7e084dc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 91 additions and 118 deletions

View file

@ -15,7 +15,6 @@ import (
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/internal/test/fakecontext" "github.com/docker/docker/internal/test/fakecontext"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/jsonmessage"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
@ -25,7 +24,7 @@ import (
func TestBuildWithRemoveAndForceRemove(t *testing.T) { func TestBuildWithRemoveAndForceRemove(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME") skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
defer setupTest(t)() defer setupTest(t)()
t.Parallel()
cases := []struct { cases := []struct {
name string name string
dockerfile string dockerfile string
@ -89,7 +88,7 @@ func TestBuildWithRemoveAndForceRemove(t *testing.T) {
}, },
} }
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
for _, c := range cases { for _, c := range cases {
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {

View file

@ -24,7 +24,7 @@ import (
func TestCreateFailsWhenIdentifierDoesNotExist(t *testing.T) { func TestCreateFailsWhenIdentifierDoesNotExist(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
testCases := []struct { testCases := []struct {
doc string doc string
@ -65,7 +65,7 @@ func TestCreateFailsWhenIdentifierDoesNotExist(t *testing.T) {
func TestCreateWithInvalidEnv(t *testing.T) { func TestCreateWithInvalidEnv(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
testCases := []struct { testCases := []struct {
env string env string
@ -108,7 +108,7 @@ func TestCreateTmpfsMountsTarget(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType == "windows") skip.If(t, testEnv.DaemonInfo.OSType == "windows")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
testCases := []struct { testCases := []struct {
target string target string
@ -150,7 +150,7 @@ func TestCreateWithCustomMaskedPaths(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType != "linux") skip.If(t, testEnv.DaemonInfo.OSType != "linux")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
testCases := []struct { testCases := []struct {
@ -229,7 +229,7 @@ func TestCreateWithCustomReadonlyPaths(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType != "linux") skip.If(t, testEnv.DaemonInfo.OSType != "linux")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
testCases := []struct { testCases := []struct {

View file

@ -7,7 +7,6 @@ import (
containertypes "github.com/docker/docker/api/types/container" containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/archive" "github.com/docker/docker/pkg/archive"
"gotest.tools/assert" "gotest.tools/assert"
"gotest.tools/poll" "gotest.tools/poll"
@ -17,7 +16,7 @@ import (
func TestDiff(t *testing.T) { func TestDiff(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "FIXME") skip.If(t, testEnv.OSType == "windows", "FIXME")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", `mkdir /foo; echo xyzzy > /foo/bar`)) cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", `mkdir /foo; echo xyzzy > /foo/bar`))

View file

@ -10,7 +10,6 @@ import (
"github.com/docker/docker/api/types/strslice" "github.com/docker/docker/api/types/strslice"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/skip" "gotest.tools/skip"
@ -22,7 +21,7 @@ func TestExecWithCloseStdin(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
// run top with detached mode // run top with detached mode
cID := container.Run(t, ctx, client) cID := container.Run(t, ctx, client)
@ -89,7 +88,7 @@ func TestExec(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "FIXME. Probably needs to wait for container to be in running state.") skip.If(t, testEnv.OSType == "windows", "FIXME. Probably needs to wait for container to be in running state.")
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
cID := container.Run(t, ctx, client, container.WithTty(true), container.WithWorkingDir("/root")) cID := container.Run(t, ctx, client, container.WithTty(true), container.WithWorkingDir("/root"))

View file

@ -10,7 +10,6 @@ import (
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/daemon" "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/jsonmessage"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
@ -23,7 +22,7 @@ func TestExportContainerAndImportImage(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType == "windows") skip.If(t, testEnv.DaemonInfo.OSType == "windows")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client, container.WithCmd("true")) cID := container.Run(t, ctx, client, container.WithCmd("true"))

View file

@ -9,7 +9,6 @@ import (
containertypes "github.com/docker/docker/api/types/container" containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/poll" "gotest.tools/poll"
"gotest.tools/skip" "gotest.tools/skip"
) )
@ -20,7 +19,7 @@ func TestHealthCheckWorkdir(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "FIXME") skip.If(t, testEnv.OSType == "windows", "FIXME")
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
cID := container.Run(t, ctx, client, container.WithTty(true), container.WithWorkingDir("/foo"), func(c *container.TestContainerConfig) { cID := container.Run(t, ctx, client, container.WithTty(true), container.WithWorkingDir("/foo"), func(c *container.TestContainerConfig) {
c.Config.Healthcheck = &containertypes.HealthConfig{ c.Config.Healthcheck = &containertypes.HealthConfig{

View file

@ -13,7 +13,6 @@ import (
containertypes "github.com/docker/docker/api/types/container" containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/daemon" "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/fs" "gotest.tools/fs"
@ -61,7 +60,7 @@ func testIpcNonePrivateShareable(t *testing.T, mode string, mustBeMounted bool,
hostCfg := containertypes.HostConfig{ hostCfg := containertypes.HostConfig{
IpcMode: containertypes.IpcMode(mode), IpcMode: containertypes.IpcMode(mode),
} }
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
resp, err := client.ContainerCreate(ctx, &cfg, &hostCfg, nil, "") resp, err := client.ContainerCreate(ctx, &cfg, &hostCfg, nil, "")
@ -132,7 +131,7 @@ func testIpcContainer(t *testing.T, donorMode string, mustWork bool) {
IpcMode: containertypes.IpcMode(donorMode), IpcMode: containertypes.IpcMode(donorMode),
} }
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
// create and start the "donor" container // create and start the "donor" container
resp, err := client.ContainerCreate(ctx, &cfg, &hostCfg, nil, "") resp, err := client.ContainerCreate(ctx, &cfg, &hostCfg, nil, "")

View file

@ -17,7 +17,7 @@ import (
func TestKillContainerInvalidSignal(t *testing.T) { func TestKillContainerInvalidSignal(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
id := container.Run(t, ctx, client) id := container.Run(t, ctx, client)
@ -33,7 +33,7 @@ func TestKillContainerInvalidSignal(t *testing.T) {
func TestKillContainer(t *testing.T) { func TestKillContainer(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "TODO Windows: FIXME. No SIGWINCH") skip.If(t, testEnv.OSType == "windows", "TODO Windows: FIXME. No SIGWINCH")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
testCases := []struct { testCases := []struct {
doc string doc string
@ -73,7 +73,7 @@ func TestKillContainer(t *testing.T) {
func TestKillWithStopSignalAndRestartPolicies(t *testing.T) { func TestKillWithStopSignalAndRestartPolicies(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "Windows only supports 1.25 or later") skip.If(t, testEnv.OSType == "windows", "Windows only supports 1.25 or later")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
testCases := []struct { testCases := []struct {
doc string doc string
@ -114,7 +114,7 @@ func TestKillStoppedContainer(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "Windows only supports 1.25 or later") skip.If(t, testEnv.OSType == "windows", "Windows only supports 1.25 or later")
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
id := container.Create(t, ctx, client) id := container.Create(t, ctx, client)
err := client.ContainerKill(ctx, id, "SIGKILL") err := client.ContainerKill(ctx, id, "SIGKILL")
assert.Assert(t, is.ErrorContains(err, "")) assert.Assert(t, is.ErrorContains(err, ""))
@ -154,7 +154,7 @@ func TestInspectOomKilledTrue(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", "x=a; while true; do x=$x$x$x$x; done"), func(c *container.TestContainerConfig) { cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", "x=a; while true; do x=$x$x$x$x; done"), func(c *container.TestContainerConfig) {
c.HostConfig.Resources.Memory = 32 * 1024 * 1024 c.HostConfig.Resources.Memory = 32 * 1024 * 1024
@ -172,7 +172,7 @@ func TestInspectOomKilledFalse(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", "echo hello world")) cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", "echo hello world"))

View file

@ -9,7 +9,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/skip" "gotest.tools/skip"
@ -22,7 +21,7 @@ func TestLinksEtcHostsContentMatch(t *testing.T) {
skip.If(t, os.IsNotExist(err)) skip.If(t, os.IsNotExist(err))
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client, container.WithNetworkMode("host")) cID := container.Run(t, ctx, client, container.WithNetworkMode("host"))
@ -38,7 +37,7 @@ func TestLinksContainerNames(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType == "windows") skip.If(t, testEnv.DaemonInfo.OSType == "windows")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
containerA := "first_" + t.Name() containerA := "first_" + t.Name()

View file

@ -7,7 +7,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/stdcopy"
"gotest.tools/assert" "gotest.tools/assert"
"gotest.tools/skip" "gotest.tools/skip"
@ -19,7 +18,7 @@ func TestLogsFollowTailEmpty(t *testing.T) {
// FIXME(vdemeester) fails on a e2e run on linux... // FIXME(vdemeester) fails on a e2e run on linux...
skip.If(t, testEnv.IsRemoteDaemon()) skip.If(t, testEnv.IsRemoteDaemon())
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
id := container.Run(t, ctx, client, container.WithCmd("sleep", "100000")) id := container.Run(t, ctx, client, container.WithCmd("sleep", "100000"))

View file

@ -14,7 +14,6 @@ import (
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/mount"
"github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/system"
"gotest.tools/assert" "gotest.tools/assert"
@ -87,9 +86,9 @@ func TestContainerNetworkMountsNoChown(t *testing.T) {
func TestMountDaemonRoot(t *testing.T) { func TestMountDaemonRoot(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType == "windows" || testEnv.IsRemoteDaemon()) skip.If(t, testEnv.DaemonInfo.OSType == "windows" || testEnv.IsRemoteDaemon())
t.Parallel()
client := request.NewAPIClient(t) defer setupTest(t)()
client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
info, err := client.Info(ctx) info, err := client.Info(ctx)
if err != nil { if err != nil {
@ -255,7 +254,7 @@ func TestContainerBindMountNonRecursive(t *testing.T) {
nonRecursiveVerifier := []string{"test", "!", "-f", "/foo/mnt/file"} nonRecursiveVerifier := []string{"test", "!", "-f", "/foo/mnt/file"}
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
containers := []string{ containers := []string{
container.Run(t, ctx, client, container.WithMount(implicit), container.WithCmd(recursiveVerifier...)), container.Run(t, ctx, client, container.WithMount(implicit), container.WithCmd(recursiveVerifier...)),
container.Run(t, ctx, client, container.WithMount(recursive), container.WithCmd(recursiveVerifier...)), container.Run(t, ctx, client, container.WithMount(recursive), container.WithCmd(recursiveVerifier...)),

View file

@ -13,7 +13,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"github.com/docker/go-connections/nat" "github.com/docker/go-connections/nat"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
@ -22,6 +21,7 @@ import (
) )
func TestNetworkNat(t *testing.T) { func TestNetworkNat(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "FIXME")
skip.If(t, testEnv.IsRemoteDaemon()) skip.If(t, testEnv.IsRemoteDaemon())
defer setupTest(t)() defer setupTest(t)()
@ -58,6 +58,7 @@ func TestNetworkLocalhostTCPNat(t *testing.T) {
} }
func TestNetworkLoopbackNat(t *testing.T) { func TestNetworkLoopbackNat(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "FIXME")
skip.If(t, testEnv.IsRemoteDaemon()) skip.If(t, testEnv.IsRemoteDaemon())
defer setupTest(t)() defer setupTest(t)()
@ -67,7 +68,7 @@ func TestNetworkLoopbackNat(t *testing.T) {
endpoint := getExternalAddress(t) endpoint := getExternalAddress(t)
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", fmt.Sprintf("stty raw && nc -w 5 %s 8080", endpoint.String())), container.WithTty(true), container.WithNetworkMode("container:"+serverContainerID)) cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", fmt.Sprintf("stty raw && nc -w 5 %s 8080", endpoint.String())), container.WithTty(true), container.WithNetworkMode("container:"+serverContainerID))
@ -88,7 +89,8 @@ func TestNetworkLoopbackNat(t *testing.T) {
} }
func startServerContainer(t *testing.T, msg string, port int) string { func startServerContainer(t *testing.T, msg string, port int) string {
client := request.NewAPIClient(t) t.Helper()
client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client, container.WithName("server-"+t.Name()), container.WithCmd("sh", "-c", fmt.Sprintf("echo %q | nc -lp %d", msg, port)), container.WithExposedPorts(fmt.Sprintf("%d/tcp", port)), func(c *container.TestContainerConfig) { cID := container.Run(t, ctx, client, container.WithName("server-"+t.Name()), container.WithCmd("sh", "-c", fmt.Sprintf("echo %q | nc -lp %d", msg, port)), container.WithExposedPorts(fmt.Sprintf("%d/tcp", port)), func(c *container.TestContainerConfig) {
@ -107,7 +109,7 @@ func startServerContainer(t *testing.T, msg string, port int) string {
} }
func getExternalAddress(t *testing.T) net.IP { func getExternalAddress(t *testing.T) net.IP {
skip.If(t, testEnv.OSType == "windows", "FIXME") t.Helper()
iface, err := net.InterfaceByName("eth0") iface, err := net.InterfaceByName("eth0")
skip.If(t, err != nil, "Test not running with `make test-integration`. Interface eth0 not found: %s", err) skip.If(t, err != nil, "Test not running with `make test-integration`. Interface eth0 not found: %s", err)

View file

@ -22,7 +22,7 @@ func TestPause(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType == "windows" && testEnv.DaemonInfo.Isolation == "process") skip.If(t, testEnv.DaemonInfo.OSType == "windows" && testEnv.DaemonInfo.Isolation == "process")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client) cID := container.Run(t, ctx, client)
@ -54,7 +54,7 @@ func TestPauseFailsOnWindowsServerContainers(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType != "windows" || testEnv.DaemonInfo.Isolation != "process") skip.If(t, testEnv.DaemonInfo.OSType != "windows" || testEnv.DaemonInfo.Isolation != "process")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client) cID := container.Run(t, ctx, client)
@ -68,7 +68,7 @@ func TestPauseStopPausedContainer(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType == "windows") skip.If(t, testEnv.DaemonInfo.OSType == "windows")
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.31"), "broken in earlier versions") skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.31"), "broken in earlier versions")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client) cID := container.Run(t, ctx, client)

View file

@ -7,14 +7,13 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
) )
func TestPsFilter(t *testing.T) { func TestPsFilter(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
prev := container.Create(t, ctx, client) prev := container.Create(t, ctx, client)

View file

@ -9,7 +9,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/fs" "gotest.tools/fs"
@ -30,7 +29,7 @@ func TestRemoveContainerWithRemovedVolume(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
@ -56,7 +55,7 @@ func TestRemoveContainerWithRemovedVolume(t *testing.T) {
func TestRemoveContainerWithVolume(t *testing.T) { func TestRemoveContainerWithVolume(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
@ -81,7 +80,7 @@ func TestRemoveContainerWithVolume(t *testing.T) {
func TestRemoveContainerRunning(t *testing.T) { func TestRemoveContainerRunning(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
cID := container.Run(t, ctx, client) cID := container.Run(t, ctx, client)
@ -92,7 +91,7 @@ func TestRemoveContainerRunning(t *testing.T) {
func TestRemoveContainerForceRemoveRunning(t *testing.T) { func TestRemoveContainerForceRemoveRunning(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
cID := container.Run(t, ctx, client) cID := container.Run(t, ctx, client)
@ -105,7 +104,7 @@ func TestRemoveContainerForceRemoveRunning(t *testing.T) {
func TestRemoveInvalidContainer(t *testing.T) { func TestRemoveInvalidContainer(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
err := client.ContainerRemove(ctx, "unknown", types.ContainerRemoveOptions{}) err := client.ContainerRemove(ctx, "unknown", types.ContainerRemoveOptions{})
assert.Check(t, is.ErrorContains(err, "No such container")) assert.Check(t, is.ErrorContains(err, "No such container"))

View file

@ -10,7 +10,6 @@ import (
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/pkg/stringid" "github.com/docker/docker/pkg/stringid"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
@ -27,7 +26,7 @@ func TestRenameLinkedContainer(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "FIXME") skip.If(t, testEnv.OSType == "windows", "FIXME")
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
aName := "a0" + t.Name() aName := "a0" + t.Name()
bName := "b0" + t.Name() bName := "b0" + t.Name()
@ -52,7 +51,7 @@ func TestRenameLinkedContainer(t *testing.T) {
func TestRenameStoppedContainer(t *testing.T) { func TestRenameStoppedContainer(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
oldName := "first_name" + t.Name() oldName := "first_name" + t.Name()
cID := container.Run(t, ctx, client, container.WithName(oldName), container.WithCmd("sh")) cID := container.Run(t, ctx, client, container.WithName(oldName), container.WithCmd("sh"))
@ -74,7 +73,7 @@ func TestRenameStoppedContainer(t *testing.T) {
func TestRenameRunningContainerAndReuse(t *testing.T) { func TestRenameRunningContainerAndReuse(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
oldName := "first_name" + t.Name() oldName := "first_name" + t.Name()
cID := container.Run(t, ctx, client, container.WithName(oldName)) cID := container.Run(t, ctx, client, container.WithName(oldName))
@ -102,7 +101,7 @@ func TestRenameRunningContainerAndReuse(t *testing.T) {
func TestRenameInvalidName(t *testing.T) { func TestRenameInvalidName(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
oldName := "first_name" + t.Name() oldName := "first_name" + t.Name()
cID := container.Run(t, ctx, client, container.WithName(oldName)) cID := container.Run(t, ctx, client, container.WithName(oldName))
@ -127,7 +126,7 @@ func TestRenameAnonymousContainer(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "FIXME") skip.If(t, testEnv.OSType == "windows", "FIXME")
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
networkName := "network1" + t.Name() networkName := "network1" + t.Name()
_, err := client.NetworkCreate(ctx, networkName, types.NetworkCreate{}) _, err := client.NetworkCreate(ctx, networkName, types.NetworkCreate{})
@ -173,7 +172,7 @@ func TestRenameAnonymousContainer(t *testing.T) {
func TestRenameContainerWithSameName(t *testing.T) { func TestRenameContainerWithSameName(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
oldName := "old" + t.Name() oldName := "old" + t.Name()
cID := container.Run(t, ctx, client, container.WithName(oldName)) cID := container.Run(t, ctx, client, container.WithName(oldName))
@ -196,7 +195,7 @@ func TestRenameContainerWithLinkedContainer(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
db1Name := "db1" + t.Name() db1Name := "db1" + t.Name()
db1ID := container.Run(t, ctx, client, container.WithName(db1Name)) db1ID := container.Run(t, ctx, client, container.WithName(db1Name))

View file

@ -9,7 +9,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
req "github.com/docker/docker/internal/test/request" req "github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
@ -20,7 +19,7 @@ import (
func TestResize(t *testing.T) { func TestResize(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "FIXME") skip.If(t, testEnv.OSType == "windows", "FIXME")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client) cID := container.Run(t, ctx, client)
@ -38,7 +37,7 @@ func TestResizeWithInvalidSize(t *testing.T) {
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.32"), "broken in earlier versions") skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.32"), "broken in earlier versions")
skip.If(t, testEnv.OSType == "windows", "FIXME") skip.If(t, testEnv.OSType == "windows", "FIXME")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client) cID := container.Run(t, ctx, client)
@ -53,7 +52,7 @@ func TestResizeWithInvalidSize(t *testing.T) {
func TestResizeWhenContainerNotStarted(t *testing.T) { func TestResizeWhenContainerNotStarted(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client, container.WithCmd("echo")) cID := container.Run(t, ctx, client, container.WithCmd("echo"))

View file

@ -10,7 +10,6 @@ import (
containertypes "github.com/docker/docker/api/types/container" containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/poll" "gotest.tools/poll"
@ -23,7 +22,7 @@ func TestKernelTCPMemory(t *testing.T) {
skip.If(t, !testEnv.DaemonInfo.KernelMemoryTCP) skip.If(t, !testEnv.DaemonInfo.KernelMemoryTCP)
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
const ( const (
@ -54,7 +53,7 @@ func TestNISDomainname(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType != "linux") skip.If(t, testEnv.DaemonInfo.OSType != "linux")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
const ( const (

View file

@ -9,7 +9,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/poll" "gotest.tools/poll"
@ -20,7 +19,7 @@ func TestStats(t *testing.T) {
skip.If(t, !testEnv.DaemonInfo.MemoryLimit) skip.If(t, !testEnv.DaemonInfo.MemoryLimit)
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
info, err := client.Info(ctx) info, err := client.Info(ctx)

View file

@ -10,7 +10,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
"gotest.tools/icmd" "gotest.tools/icmd"
"gotest.tools/poll" "gotest.tools/poll"
@ -22,7 +21,7 @@ import (
// waiting is not limited (issue #35311). // waiting is not limited (issue #35311).
func TestStopContainerWithTimeout(t *testing.T) { func TestStopContainerWithTimeout(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
testCmd := container.WithCmd("sh", "-c", "sleep 2 && exit 42") testCmd := container.WithCmd("sh", "-c", "sleep 2 && exit 42")
@ -76,7 +75,7 @@ func TestDeleteDevicemapper(t *testing.T) {
skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run") skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
id := container.Run(t, ctx, client, container.WithName("foo-"+t.Name()), container.WithCmd("echo")) id := container.Run(t, ctx, client, container.WithName("foo-"+t.Name()), container.WithCmd("echo"))

View file

@ -6,14 +6,13 @@ import (
"time" "time"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
"gotest.tools/poll" "gotest.tools/poll"
) )
func TestStopContainerWithRestartPolicyAlways(t *testing.T) { func TestStopContainerWithRestartPolicyAlways(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
names := []string{"verifyRestart1-" + t.Name(), "verifyRestart2-" + t.Name()} names := []string{"verifyRestart1-" + t.Name(), "verifyRestart2-" + t.Name()}

View file

@ -7,7 +7,6 @@ import (
"time" "time"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
"gotest.tools/poll" "gotest.tools/poll"
"gotest.tools/skip" "gotest.tools/skip"
@ -19,7 +18,7 @@ import (
func TestStopContainerWithTimeout(t *testing.T) { func TestStopContainerWithTimeout(t *testing.T) {
skip.If(t, testEnv.OSType == "windows") skip.If(t, testEnv.OSType == "windows")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
testCmd := container.WithCmd("sh", "-c", "sleep 2 && exit 42") testCmd := container.WithCmd("sh", "-c", "sleep 2 && exit 42")

View file

@ -9,7 +9,6 @@ import (
containertypes "github.com/docker/docker/api/types/container" containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/poll" "gotest.tools/poll"
@ -22,7 +21,7 @@ func TestUpdateMemory(t *testing.T) {
skip.If(t, !testEnv.DaemonInfo.SwapLimit) skip.If(t, !testEnv.DaemonInfo.SwapLimit)
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client, func(c *container.TestContainerConfig) { cID := container.Run(t, ctx, client, func(c *container.TestContainerConfig) {
@ -67,10 +66,8 @@ func TestUpdateMemory(t *testing.T) {
} }
func TestUpdateCPUQuota(t *testing.T) { func TestUpdateCPUQuota(t *testing.T) {
t.Parallel()
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client) cID := container.Run(t, ctx, client)

View file

@ -7,7 +7,6 @@ import (
containertypes "github.com/docker/docker/api/types/container" containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/poll" "gotest.tools/poll"
@ -15,7 +14,7 @@ import (
func TestUpdateRestartPolicy(t *testing.T) { func TestUpdateRestartPolicy(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", "sleep 1 && false"), func(c *container.TestContainerConfig) { cID := container.Run(t, ctx, client, container.WithCmd("sh", "-c", "sleep 1 && false"), func(c *container.TestContainerConfig) {
@ -48,7 +47,7 @@ func TestUpdateRestartPolicy(t *testing.T) {
func TestUpdateRestartWithAutoRemove(t *testing.T) { func TestUpdateRestartWithAutoRemove(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID := container.Run(t, ctx, client, func(c *container.TestContainerConfig) { cID := container.Run(t, ctx, client, func(c *container.TestContainerConfig) {

View file

@ -7,7 +7,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/skip" "gotest.tools/skip"
@ -17,7 +16,7 @@ func TestCommitInheritsEnv(t *testing.T) {
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.36"), "broken in earlier versions") skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.36"), "broken in earlier versions")
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME") skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
cID1 := container.Create(t, ctx, client) cID1 := container.Create(t, ctx, client)

View file

@ -9,7 +9,6 @@ import (
"testing" "testing"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/internal/testutil" "github.com/docker/docker/internal/testutil"
"gotest.tools/skip" "gotest.tools/skip"
) )
@ -19,7 +18,8 @@ func TestImportExtremelyLargeImageWorks(t *testing.T) {
skip.If(t, runtime.GOARCH == "arm64", "effective test will be time out") skip.If(t, runtime.GOARCH == "arm64", "effective test will be time out")
skip.If(t, testEnv.OSType == "windows", "TODO enable on windows") skip.If(t, testEnv.OSType == "windows", "TODO enable on windows")
client := request.NewAPIClient(t) defer setupTest(t)()
client := testEnv.APIClient()
// Construct an empty tar archive with about 8GB of junk padding at the // Construct an empty tar archive with about 8GB of junk padding at the
// end. This should not cause any crashes (the padding should be mostly // end. This should not cause any crashes (the padding should be mostly

View file

@ -6,7 +6,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
) )
@ -14,7 +13,7 @@ import (
// Regression : #38171 // Regression : #38171
func TestImagesFilterMultiReference(t *testing.T) { func TestImagesFilterMultiReference(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
name := "images_filter_multi_reference" name := "images_filter_multi_reference"

View file

@ -6,7 +6,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/integration/internal/container" "github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/skip" "gotest.tools/skip"
@ -16,7 +15,7 @@ func TestRemoveImageOrphaning(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME") skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME")
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
img := "test-container-orphaning" img := "test-container-orphaning"

View file

@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/docker/docker/internal/test/request"
"github.com/docker/docker/internal/testutil" "github.com/docker/docker/internal/testutil"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
@ -15,7 +14,7 @@ import (
// tagging a named image in a new unprefixed repo should work // tagging a named image in a new unprefixed repo should work
func TestTagUnprefixedRepoByNameOrName(t *testing.T) { func TestTagUnprefixedRepoByNameOrName(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
// By name // By name
@ -33,7 +32,7 @@ func TestTagUnprefixedRepoByNameOrName(t *testing.T) {
// TODO (yongtang): Migrate to unit tests // TODO (yongtang): Migrate to unit tests
func TestTagInvalidReference(t *testing.T) { func TestTagInvalidReference(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
invalidRepos := []string{"fo$z$", "Foo@3cc", "Foo$3", "Foo*3", "Fo^3", "Foo!3", "F)xcz(", "fo%asd", "FOO/bar"} invalidRepos := []string{"fo$z$", "Foo@3cc", "Foo$3", "Foo*3", "Fo^3", "Foo!3", "F)xcz(", "fo%asd", "FOO/bar"}
@ -72,7 +71,7 @@ func TestTagInvalidReference(t *testing.T) {
// ensure we allow the use of valid tags // ensure we allow the use of valid tags
func TestTagValidPrefixedRepo(t *testing.T) { func TestTagValidPrefixedRepo(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
validRepos := []string{"fooo/bar", "fooaa/test", "foooo:t", "HOSTNAME.DOMAIN.COM:443/foo/bar"} validRepos := []string{"fooo/bar", "fooaa/test", "foooo:t", "HOSTNAME.DOMAIN.COM:443/foo/bar"}
@ -86,7 +85,7 @@ func TestTagValidPrefixedRepo(t *testing.T) {
// tag an image with an existed tag name without -f option should work // tag an image with an existed tag name without -f option should work
func TestTagExistedNameWithoutForce(t *testing.T) { func TestTagExistedNameWithoutForce(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
err := client.ImageTag(ctx, "busybox:latest", "busybox:test") err := client.ImageTag(ctx, "busybox:latest", "busybox:test")
@ -98,7 +97,7 @@ func TestTagExistedNameWithoutForce(t *testing.T) {
func TestTagOfficialNames(t *testing.T) { func TestTagOfficialNames(t *testing.T) {
skip.If(t, testEnv.OSType == "windows") skip.If(t, testEnv.OSType == "windows")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
names := []string{ names := []string{
@ -128,7 +127,7 @@ func TestTagOfficialNames(t *testing.T) {
// ensure tags can not match digests // ensure tags can not match digests
func TestTagMatchesDigest(t *testing.T) { func TestTagMatchesDigest(t *testing.T) {
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
digest := "busybox@sha256:abcdef76720241213f5303bda7704ec4c2ef75613173910a56fb1b6e20251507" digest := "busybox@sha256:abcdef76720241213f5303bda7704ec4c2ef75613173910a56fb1b6e20251507"

View file

@ -6,8 +6,8 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/versions"
dclient "github.com/docker/docker/client"
"github.com/docker/docker/integration/internal/network" "github.com/docker/docker/integration/internal/network"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/skip" "gotest.tools/skip"
@ -27,10 +27,7 @@ func containsNetwork(nws []types.NetworkResource, networkID string) bool {
// first network's ID as name. // first network's ID as name.
// //
// After successful creation, properties of all three networks is returned // After successful creation, properties of all three networks is returned
func createAmbiguousNetworks(t *testing.T) (string, string, string) { func createAmbiguousNetworks(t *testing.T, ctx context.Context, client dclient.APIClient) (string, string, string) { // nolint: golint
client := request.NewAPIClient(t)
ctx := context.Background()
testNet := network.CreateNoError(t, ctx, client, "testNet") testNet := network.CreateNoError(t, ctx, client, "testNet")
idPrefixNet := network.CreateNoError(t, ctx, client, testNet[:12]) idPrefixNet := network.CreateNoError(t, ctx, client, testNet[:12])
fullIDNet := network.CreateNoError(t, ctx, client, testNet) fullIDNet := network.CreateNoError(t, ctx, client, testNet)
@ -48,7 +45,7 @@ func createAmbiguousNetworks(t *testing.T) (string, string, string) {
func TestNetworkCreateDelete(t *testing.T) { func TestNetworkCreateDelete(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType != "linux") skip.If(t, testEnv.DaemonInfo.OSType != "linux")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
netName := "testnetwork_" + t.Name() netName := "testnetwork_" + t.Name()
@ -71,9 +68,9 @@ func TestDockerNetworkDeletePreferID(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", skip.If(t, testEnv.OSType == "windows",
"FIXME. Windows doesn't run DinD and uses networks shared between control daemon and daemon under test") "FIXME. Windows doesn't run DinD and uses networks shared between control daemon and daemon under test")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
testNet, idPrefixNet, fullIDNet := createAmbiguousNetworks(t) testNet, idPrefixNet, fullIDNet := createAmbiguousNetworks(t, ctx, client)
// Delete the network using a prefix of the first network's ID as name. // Delete the network using a prefix of the first network's ID as name.
// This should the network name with the id-prefix, not the original network. // This should the network name with the id-prefix, not the original network.

View file

@ -28,7 +28,7 @@ func TestEventsExecDie(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "FIXME. Suspect may need to wait until container is running before exec") skip.If(t, testEnv.OSType == "windows", "FIXME. Suspect may need to wait until container is running before exec")
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
cID := container.Run(t, ctx, client) cID := container.Run(t, ctx, client)
@ -78,7 +78,7 @@ func TestEventsBackwardsCompatible(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "Windows doesn't support back-compat messages") skip.If(t, testEnv.OSType == "windows", "Windows doesn't support back-compat messages")
defer setupTest(t)() defer setupTest(t)()
ctx := context.Background() ctx := context.Background()
client := request.NewAPIClient(t) client := testEnv.APIClient()
since := request.DaemonTime(ctx, t, client, testEnv) since := request.DaemonTime(ctx, t, client, testEnv)
ts := strconv.FormatInt(since.Unix(), 10) ts := strconv.FormatInt(since.Unix(), 10)

View file

@ -7,14 +7,14 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/docker/docker/internal/test/request"
req "github.com/docker/docker/internal/test/request" req "github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
) )
func TestInfoBinaryCommits(t *testing.T) { func TestInfoBinaryCommits(t *testing.T) {
client := request.NewAPIClient(t) defer setupTest(t)()
client := testEnv.APIClient()
info, err := client.Info(context.Background()) info, err := client.Info(context.Background())
assert.NilError(t, err) assert.NilError(t, err)

View file

@ -6,14 +6,14 @@ import (
"testing" "testing"
"github.com/docker/docker/internal/test/daemon" "github.com/docker/docker/internal/test/daemon"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/skip" "gotest.tools/skip"
) )
func TestInfoAPI(t *testing.T) { func TestInfoAPI(t *testing.T) {
client := request.NewAPIClient(t) defer setupTest(t)()
client := testEnv.APIClient()
info, err := client.Info(context.Background()) info, err := client.Info(context.Background())
assert.NilError(t, err) assert.NilError(t, err)

View file

@ -6,7 +6,6 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/integration/internal/requirement" "github.com/docker/docker/integration/internal/requirement"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
"gotest.tools/skip" "gotest.tools/skip"
@ -16,7 +15,8 @@ import (
func TestLoginFailsWithBadCredentials(t *testing.T) { func TestLoginFailsWithBadCredentials(t *testing.T) {
skip.If(t, !requirement.HasHubConnectivity(t)) skip.If(t, !requirement.HasHubConnectivity(t))
client := request.NewAPIClient(t) defer setupTest(t)()
client := testEnv.APIClient()
config := types.AuthConfig{ config := types.AuthConfig{
Username: "no-user", Username: "no-user",

View file

@ -4,13 +4,13 @@ import (
"context" "context"
"testing" "testing"
"github.com/docker/docker/internal/test/request"
"gotest.tools/assert" "gotest.tools/assert"
is "gotest.tools/assert/cmp" is "gotest.tools/assert/cmp"
) )
func TestVersion(t *testing.T) { func TestVersion(t *testing.T) {
client := request.NewAPIClient(t) defer setupTest(t)()
client := testEnv.APIClient()
version, err := client.ServerVersion(context.Background()) version, err := client.ServerVersion(context.Background())
assert.NilError(t, err) assert.NilError(t, err)

View file

@ -22,7 +22,7 @@ import (
func TestVolumesCreateAndList(t *testing.T) { func TestVolumesCreateAndList(t *testing.T) {
skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
name := t.Name() name := t.Name()
@ -52,7 +52,7 @@ func TestVolumesCreateAndList(t *testing.T) {
func TestVolumesRemove(t *testing.T) { func TestVolumesRemove(t *testing.T) {
skip.If(t, testEnv.OSType == "windows", "FIXME") skip.If(t, testEnv.OSType == "windows", "FIXME")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
@ -78,7 +78,7 @@ func TestVolumesRemove(t *testing.T) {
func TestVolumesInspect(t *testing.T) { func TestVolumesInspect(t *testing.T) {
skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
defer setupTest(t)() defer setupTest(t)()
client := request.NewAPIClient(t) client := testEnv.APIClient()
ctx := context.Background() ctx := context.Background()
now := time.Now() now := time.Now()