Browse code

Fixes for dnephin review

Signed-off-by: Christopher Crone <christopher.crone@docker.com>

Christopher Crone authored on 2017/09/12 21:53:20
Showing 17 changed files
... ...
@@ -1,3 +1,4 @@
1
+## Step 1: Build tests
1 2
 FROM golang:1.8.3-alpine3.6 as builder
2 3
 
3 4
 RUN apk add --update \
... ...
@@ -11,26 +12,31 @@ RUN apk add --update \
11 11
 RUN mkdir -p /go/src/github.com/docker/docker/
12 12
 WORKDIR /go/src/github.com/docker/docker/
13 13
 
14
-COPY contrib contrib
14
+# Generate frozen images
15
+COPY contrib/download-frozen-image-v2.sh contrib/download-frozen-image-v2.sh
15 16
 RUN contrib/download-frozen-image-v2.sh /output/docker-frozen-images \
16 17
   buildpack-deps:jessie@sha256:85b379ec16065e4fe4127eb1c5fb1bcc03c559bd36dbb2e22ff496de55925fa6 \
17 18
   busybox:latest@sha256:32f093055929dbc23dec4d03e09dfe971f5973a9ca5cf059cbfb644c206aa83f \
18 19
   debian:jessie@sha256:72f784399fd2719b4cb4e16ef8e369a39dc67f53d978cd3e2e7bf4e502c7b793 \
19 20
   hello-world:latest@sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
20 21
 
21
-ARG DOCKER_GITCOMMIT
22
+# Download Docker CLI binary
23
+COPY hack/dockerfile hack/dockerfile
24
+RUN hack/dockerfile/install-binaries.sh dockercli
22 25
 
26
+# Set tag and add sources
27
+ARG DOCKER_GITCOMMIT
23 28
 ENV DOCKER_GITCOMMIT=$DOCKER_GITCOMMIT
24
-
25
-# integration-cli tests are frozen to 17.06
26
-# Newer CLI tests can be found in the docker/cli repository
27
-RUN curl https://download.docker.com/linux/static/stable/x86_64/docker-17.06.2-ce.tgz | tar  xzf - -C /output
28
-
29 29
 ADD . .
30 30
 
31
+# Build DockerSuite.TestBuild* dependency
32
+RUN CGO_ENABLED=0 go build -o /output/httpserver github.com/docker/docker/contrib/httpserver
33
+
34
+# Build the integration tests and copy the resulting binaries to /output/tests
31 35
 RUN hack/make.sh build-integration-test-binary
32 36
 RUN mkdir -p /output/tests && find . -name test.main -exec cp --parents '{}' /output/tests \;
33 37
 
38
+## Step 2: Generate testing image
34 39
 FROM alpine:3.6 as runner
35 40
 
36 41
 # GNU tar is used for generating the emptyfs image
... ...
@@ -47,15 +53,17 @@ RUN apk add --update \
47 47
 # Add an unprivileged user to be used for tests which need it
48 48
 RUN addgroup docker && adduser -D -G docker unprivilegeduser -s /bin/ash
49 49
 
50
-ENV DOCKER_E2E=1 DOCKER_REMOTE_DAEMON=1 DOCKER_INTEGRATION_DAEMON_DEST=/
50
+COPY contrib/httpserver/Dockerfile /tests/contrib/httpserver/Dockerfile
51
+COPY contrib/syscall-test /tests/contrib/syscall-test
52
+COPY hack/test/e2e-run.sh /run.sh
53
+COPY hack/make/.ensure-emptyfs /ensure-emptyfs.sh
54
+COPY integration-cli/fixtures /tests/integration-cli/fixtures
51 55
 
52
-COPY --from=builder /output/docker/docker /usr/bin/docker
53 56
 COPY --from=builder /output/docker-frozen-images /docker-frozen-images
57
+COPY --from=builder /output/httpserver /tests/contrib/httpserver/httpserver
54 58
 COPY --from=builder /output/tests /tests
59
+COPY --from=builder /usr/local/bin/docker /usr/bin/docker
55 60
 
56
-COPY contrib /tests/contrib
57
-COPY hack/make/.ensure-emptyfs /ensure-emptyfs.sh
58
-COPY integration-cli/fixtures /tests/integration-cli/fixtures
59
-COPY internal/e2e/run.sh /run.sh
61
+ENV DOCKER_E2E=1 DOCKER_REMOTE_DAEMON=1 DOCKER_INTEGRATION_DAEMON_DEST=/
60 62
 
61 63
 ENTRYPOINT ["/run.sh"]
62 64
new file mode 100755
... ...
@@ -0,0 +1,15 @@
0
+#!/usr/bin/env bash
1
+set -e
2
+
3
+export DOCKER_ENGINE_GOARCH=${DOCKER_ENGINE_GOARCH:-amd64}
4
+
5
+echo "Ensure emptyfs image is loaded"
6
+bash /ensure-emptyfs.sh
7
+
8
+echo "Run integration/container tests"
9
+cd /tests/integration/container
10
+./test.main -test.v
11
+
12
+echo "Run integration-cli DockerSuite tests"
13
+cd /tests/integration-cli
14
+./test.main -test.v -check.v -check.f DockerSuite
... ...
@@ -39,27 +39,34 @@ func ensureHTTPServerImage(t testingT) {
39 39
 		goarch = "amd64"
40 40
 	}
41 41
 
42
-	goCmd, lookErr := exec.LookPath("go")
42
+	cpCmd, lookErr := exec.LookPath("cp")
43 43
 	if lookErr != nil {
44 44
 		t.Fatalf("could not build http server: %v", lookErr)
45 45
 	}
46 46
 
47
-	cmd := exec.Command(goCmd, "build", "-o", filepath.Join(tmp, "httpserver"), "github.com/docker/docker/contrib/httpserver")
48
-	cmd.Env = append(os.Environ(), []string{
49
-		"CGO_ENABLED=0",
50
-		"GOOS=" + goos,
51
-		"GOARCH=" + goarch,
52
-	}...)
53
-	var out []byte
54
-	if out, err = cmd.CombinedOutput(); err != nil {
55
-		t.Fatalf("could not build http server: %s", string(out))
56
-	}
47
+	if _, err = os.Stat("../contrib/httpserver/httpserver"); os.IsNotExist(err) {
48
+		goCmd, lookErr := exec.LookPath("go")
49
+		if lookErr != nil {
50
+			t.Fatalf("could not build http server: %v", lookErr)
51
+		}
57 52
 
58
-	cpCmd, lookErr := exec.LookPath("cp")
59
-	if lookErr != nil {
60
-		t.Fatalf("could not build http server: %v", lookErr)
53
+		cmd := exec.Command(goCmd, "build", "-o", filepath.Join(tmp, "httpserver"), "github.com/docker/docker/contrib/httpserver")
54
+		cmd.Env = append(os.Environ(), []string{
55
+			"CGO_ENABLED=0",
56
+			"GOOS=" + goos,
57
+			"GOARCH=" + goarch,
58
+		}...)
59
+		var out []byte
60
+		if out, err = cmd.CombinedOutput(); err != nil {
61
+			t.Fatalf("could not build http server: %s", string(out))
62
+		}
63
+	} else {
64
+		if out, err := exec.Command(cpCmd, "../contrib/httpserver/httpserver", filepath.Join(tmp, "httpserver")).CombinedOutput(); err != nil {
65
+			t.Fatalf("could not copy http server: %v", string(out))
66
+		}
61 67
 	}
62
-	if out, err = exec.Command(cpCmd, "../contrib/httpserver/Dockerfile", filepath.Join(tmp, "Dockerfile")).CombinedOutput(); err != nil {
68
+
69
+	if out, err := exec.Command(cpCmd, "../contrib/httpserver/Dockerfile", filepath.Join(tmp, "Dockerfile")).CombinedOutput(); err != nil {
63 70
 		t.Fatalf("could not build http server: %v", string(out))
64 71
 	}
65 72
 
... ...
@@ -27,8 +27,7 @@ import (
27 27
 )
28 28
 
29 29
 func (s *DockerSuite) TestBuildAPIDockerFileRemote(c *check.C) {
30
-	// E2E: Requires built httpserver.
31
-	testRequires(c, NotUserNamespace, NotE2E)
30
+	testRequires(c, NotUserNamespace)
32 31
 
33 32
 	var testD string
34 33
 	if testEnv.DaemonPlatform() == "windows" {
... ...
@@ -59,9 +58,6 @@ RUN find /tmp/`
59 59
 }
60 60
 
61 61
 func (s *DockerSuite) TestBuildAPIRemoteTarballContext(c *check.C) {
62
-	// E2E: Requires built httpserver.
63
-	testRequires(c, NotE2E)
64
-
65 62
 	buffer := new(bytes.Buffer)
66 63
 	tw := tar.NewWriter(buffer)
67 64
 	defer tw.Close()
... ...
@@ -93,9 +89,6 @@ func (s *DockerSuite) TestBuildAPIRemoteTarballContext(c *check.C) {
93 93
 }
94 94
 
95 95
 func (s *DockerSuite) TestBuildAPIRemoteTarballContextWithCustomDockerfile(c *check.C) {
96
-	// E2E: Requires built httpserver.
97
-	testRequires(c, NotE2E)
98
-
99 96
 	buffer := new(bytes.Buffer)
100 97
 	tw := tar.NewWriter(buffer)
101 98
 	defer tw.Close()
... ...
@@ -150,8 +143,6 @@ RUN echo 'right'
150 150
 }
151 151
 
152 152
 func (s *DockerSuite) TestBuildAPILowerDockerfile(c *check.C) {
153
-	// E2E: Requires built httpserver.
154
-	testRequires(c, NotE2E)
155 153
 	git := fakegit.New(c, "repo", map[string]string{
156 154
 		"dockerfile": `FROM busybox
157 155
 RUN echo from dockerfile`,
... ...
@@ -170,9 +161,6 @@ RUN echo from dockerfile`,
170 170
 }
171 171
 
172 172
 func (s *DockerSuite) TestBuildAPIBuildGitWithF(c *check.C) {
173
-	// E2E: Test requires go and contrib source.
174
-	testRequires(c, NotE2E)
175
-
176 173
 	git := fakegit.New(c, "repo", map[string]string{
177 174
 		"baz": `FROM busybox
178 175
 RUN echo from baz`,
... ...
@@ -194,8 +182,7 @@ RUN echo from Dockerfile`,
194 194
 }
195 195
 
196 196
 func (s *DockerSuite) TestBuildAPIDoubleDockerfile(c *check.C) {
197
-	// E2E: Requires built httpserver.
198
-	testRequires(c, UnixCli, NotE2E) // dockerfile overwrites Dockerfile on Windows
197
+	testRequires(c, UnixCli) // dockerfile overwrites Dockerfile on Windows
199 198
 	git := fakegit.New(c, "repo", map[string]string{
200 199
 		"Dockerfile": `FROM busybox
201 200
 RUN echo from Dockerfile`,
... ...
@@ -380,9 +367,6 @@ func (s *DockerRegistrySuite) TestBuildCopyFromForcePull(c *check.C) {
380 380
 }
381 381
 
382 382
 func (s *DockerSuite) TestBuildAddRemoteNoDecompress(c *check.C) {
383
-	// E2E: Requires built httpserver.
384
-	testRequires(c, NotE2E)
385
-
386 383
 	buffer := new(bytes.Buffer)
387 384
 	tw := tar.NewWriter(buffer)
388 385
 	dt := []byte("contents")
... ...
@@ -1372,7 +1372,7 @@ func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *check.C) {
1372 1372
 		Image: "busybox",
1373 1373
 	}
1374 1374
 
1375
-	cli, err := NewEnvClientWithVersion("v1.18")
1375
+	cli, err := request.NewEnvClientWithVersion("v1.18")
1376 1376
 
1377 1377
 	_, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "")
1378 1378
 	c.Assert(err, checker.IsNil)
... ...
@@ -180,7 +180,7 @@ func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *check.C) {
180 180
 		Labels      map[string]string
181 181
 	}
182 182
 
183
-	cli, err = NewEnvClientWithVersion("v1.24")
183
+	cli, err = request.NewEnvClientWithVersion("v1.24")
184 184
 	c.Assert(err, checker.IsNil)
185 185
 	defer cli.Close()
186 186
 
... ...
@@ -6,6 +6,7 @@ import (
6 6
 	"encoding/json"
7 7
 
8 8
 	"github.com/docker/docker/integration-cli/checker"
9
+	"github.com/docker/docker/integration-cli/request"
9 10
 	"github.com/go-check/check"
10 11
 	"golang.org/x/net/context"
11 12
 )
... ...
@@ -17,7 +18,7 @@ func (s *DockerSuite) TestInspectAPICpusetInConfigPre120(c *check.C) {
17 17
 
18 18
 	name := "cpusetinconfig-pre120"
19 19
 	dockerCmd(c, "run", "--name", name, "--cpuset-cpus", "0", "busybox", "true")
20
-	cli, err := NewEnvClientWithVersion("v1.19")
20
+	cli, err := request.NewEnvClientWithVersion("v1.19")
21 21
 	c.Assert(err, checker.IsNil)
22 22
 	defer cli.Close()
23 23
 	_, body, err := cli.ContainerInspectWithRaw(context.Background(), name, false)
... ...
@@ -4,7 +4,6 @@ package main
4 4
 
5 5
 import (
6 6
 	"fmt"
7
-	"strings"
8 7
 
9 8
 	"github.com/docker/docker/integration-cli/checker"
10 9
 	"github.com/docker/docker/integration-cli/daemon"
... ...
@@ -48,8 +47,6 @@ func (s *DockerAuthzV2Suite) TearDownTest(c *check.C) {
48 48
 func (s *DockerAuthzV2Suite) TestAuthZPluginAllowNonVolumeRequest(c *check.C) {
49 49
 	testRequires(c, DaemonIsLinux, IsAmd64, Network)
50 50
 
51
-	existingContainers := ExistingContainerIDs(c)
52
-
53 51
 	// Install authz plugin
54 52
 	_, err := s.d.Cmd("plugin", "install", "--grant-all-permissions", authzPluginNameWithTag)
55 53
 	c.Assert(err, checker.IsNil)
... ...
@@ -68,14 +65,8 @@ func (s *DockerAuthzV2Suite) TestAuthZPluginAllowNonVolumeRequest(c *check.C) {
68 68
 	}()
69 69
 
70 70
 	// Ensure docker run command and accompanying docker ps are successful
71
-	out, err := s.d.Cmd("run", "-d", "busybox", "top")
72
-	c.Assert(err, check.IsNil)
73
-
74
-	id := strings.TrimSpace(out)
75
-
76
-	out, err = s.d.Cmd("ps")
71
+	_, err = s.d.Cmd("run", "-d", "busybox", "top")
77 72
 	c.Assert(err, check.IsNil)
78
-	c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{id}), check.Equals, true)
79 73
 }
80 74
 
81 75
 func (s *DockerAuthzV2Suite) TestAuthZPluginDisable(c *check.C) {
... ...
@@ -204,8 +204,6 @@ func (s *DockerAuthzSuite) TearDownSuite(c *check.C) {
204 204
 }
205 205
 
206 206
 func (s *DockerAuthzSuite) TestAuthZPluginAllowRequest(c *check.C) {
207
-	existingContainers := ExistingContainerIDs(c)
208
-
209 207
 	// start the daemon and load busybox, --net=none build fails otherwise
210 208
 	// cause it needs to pull busybox
211 209
 	s.d.Start(c, "--authorization-plugin="+testAuthZPlugin)
... ...
@@ -220,12 +218,6 @@ func (s *DockerAuthzSuite) TestAuthZPluginAllowRequest(c *check.C) {
220 220
 	id := strings.TrimSpace(out)
221 221
 	assertURIRecorded(c, s.ctrl.requestsURIs, "/containers/create")
222 222
 	assertURIRecorded(c, s.ctrl.requestsURIs, fmt.Sprintf("/containers/%s/start", id))
223
-
224
-	out, err = s.d.Cmd("ps")
225
-	c.Assert(err, check.IsNil)
226
-	c.Assert(assertContainerList(RemoveOutputForExistingElements(out, existingContainers), []string{id}), check.Equals, true)
227
-	c.Assert(s.ctrl.psRequestCnt, check.Equals, 1)
228
-	c.Assert(s.ctrl.psResponseCnt, check.Equals, 1)
229 223
 }
230 224
 
231 225
 func (s *DockerAuthzSuite) TestAuthZPluginTls(c *check.C) {
... ...
@@ -368,8 +368,7 @@ ONBUILD ENTRYPOINT ["echo"]`))
368 368
 }
369 369
 
370 370
 func (s *DockerSuite) TestBuildCacheAdd(c *check.C) {
371
-	// E2E: Requires built httpserver.
372
-	testRequires(c, DaemonIsLinux, NotE2E) // Windows doesn't have httpserver image yet
371
+	testRequires(c, DaemonIsLinux) // Windows doesn't have httpserver image yet
373 372
 	name := "testbuildtwoimageswithadd"
374 373
 	server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{
375 374
 		"robots.txt": "hello",
... ...
@@ -389,9 +388,6 @@ func (s *DockerSuite) TestBuildCacheAdd(c *check.C) {
389 389
 }
390 390
 
391 391
 func (s *DockerSuite) TestBuildLastModified(c *check.C) {
392
-	// E2E: Requires built httpserver.
393
-	testRequires(c, NotE2E)
394
-
395 392
 	// Temporary fix for #30890. TODO @jhowardmsft figure out what
396 393
 	// has changed in the master busybox image.
397 394
 	testRequires(c, DaemonIsLinux)
... ...
@@ -521,8 +517,7 @@ RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio'
521 521
 }
522 522
 
523 523
 func (s *DockerSuite) TestBuildCopyAddMultipleFiles(c *check.C) {
524
-	// E2E: Requires built httpserver.
525
-	testRequires(c, DaemonIsLinux, NotE2E) // Linux specific test
524
+	testRequires(c, DaemonIsLinux) // Linux specific test
526 525
 	server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{
527 526
 		"robots.txt": "hello",
528 527
 	}))
... ...
@@ -637,9 +632,6 @@ RUN find "test6" "C:/test dir/test_file6"`
637 637
 }
638 638
 
639 639
 func (s *DockerSuite) TestBuildCopyWildcard(c *check.C) {
640
-	// E2E: Requires built httpserver.
641
-	testRequires(c, NotE2E)
642
-
643 640
 	name := "testcopywildcard"
644 641
 	server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{
645 642
 		"robots.txt": "hello",
... ...
@@ -1935,9 +1927,6 @@ func (s *DockerSuite) TestBuildAddCurrentDirWithoutCache(c *check.C) {
1935 1935
 }
1936 1936
 
1937 1937
 func (s *DockerSuite) TestBuildAddRemoteFileWithAndWithoutCache(c *check.C) {
1938
-	// E2E: Requires built httpserver.
1939
-	testRequires(c, NotE2E)
1940
-
1941 1938
 	name := "testbuildaddremotefilewithcache"
1942 1939
 	server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{
1943 1940
 		"baz": "hello",
... ...
@@ -1963,9 +1952,6 @@ func (s *DockerSuite) TestBuildAddRemoteFileWithAndWithoutCache(c *check.C) {
1963 1963
 }
1964 1964
 
1965 1965
 func (s *DockerSuite) TestBuildAddRemoteFileMTime(c *check.C) {
1966
-	// E2E: Requires built httpserver.
1967
-	testRequires(c, NotE2E)
1968
-
1969 1966
 	name := "testbuildaddremotefilemtime"
1970 1967
 	name2 := name + "2"
1971 1968
 	name3 := name + "3"
... ...
@@ -2009,9 +1995,6 @@ func (s *DockerSuite) TestBuildAddRemoteFileMTime(c *check.C) {
2009 2009
 
2010 2010
 // FIXME(vdemeester) this really seems to test the same thing as before (combined)
2011 2011
 func (s *DockerSuite) TestBuildAddLocalAndRemoteFilesWithAndWithoutCache(c *check.C) {
2012
-	// E2E: Requires built httpserver.
2013
-	testRequires(c, NotE2E)
2014
-
2015 2012
 	name := "testbuildaddlocalandremotefilewithcache"
2016 2013
 	server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{
2017 2014
 		"baz": "hello",
... ...
@@ -3112,9 +3095,6 @@ func (s *DockerSuite) TestBuildFromGitWithF(c *check.C) {
3112 3112
 }
3113 3113
 
3114 3114
 func (s *DockerSuite) TestBuildFromRemoteTarball(c *check.C) {
3115
-	// E2E: Requires built httpserver.
3116
-	testRequires(c, NotE2E)
3117
-
3118 3115
 	name := "testbuildfromremotetarball"
3119 3116
 
3120 3117
 	buffer := new(bytes.Buffer)
... ...
@@ -3781,9 +3761,6 @@ func (s *DockerSuite) TestBuildFromMixedcaseDockerfile(c *check.C) {
3781 3781
 }
3782 3782
 
3783 3783
 func (s *DockerSuite) TestBuildFromURLWithF(c *check.C) {
3784
-	// E2E: Requires built httpserver.
3785
-	testRequires(c, NotE2E)
3786
-
3787 3784
 	server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{"baz": `FROM busybox
3788 3785
 RUN echo from baz
3789 3786
 COPY * /tmp/
... ...
@@ -39,7 +39,7 @@ func getHealth(c *check.C, name string) *types.Health {
39 39
 func (s *DockerSuite) TestHealth(c *check.C) {
40 40
 	testRequires(c, DaemonIsLinux) // busybox doesn't work on Windows
41 41
 
42
-	existingContainers := ExistingContainerNames(c)
42
+	existingContainers := ExistingContainerIDs(c)
43 43
 
44 44
 	imageName := "testhealth"
45 45
 	buildImageSuccessfully(c, imageName, build.WithDockerfile(`FROM busybox
... ...
@@ -51,10 +51,10 @@ func (s *DockerSuite) TestHealth(c *check.C) {
51 51
 
52 52
 	// No health status before starting
53 53
 	name := "test_health"
54
-	dockerCmd(c, "create", "--name", name, imageName)
55
-	out, _ := dockerCmd(c, "ps", "-a", "--format={{.Status}}")
54
+	cid, _ := dockerCmd(c, "create", "--name", name, imageName)
55
+	out, _ := dockerCmd(c, "ps", "-a", "--format={{.ID}} {{.Status}}")
56 56
 	out = RemoveOutputForExistingElements(out, existingContainers)
57
-	c.Check(out, checker.Equals, "Created\n")
57
+	c.Check(out, checker.Equals, cid[:12]+" Created\n")
58 58
 
59 59
 	// Inspect the options
60 60
 	out, _ = dockerCmd(c, "inspect",
... ...
@@ -6,6 +6,7 @@ import (
6 6
 
7 7
 	"github.com/docker/docker/integration-cli/checker"
8 8
 	"github.com/docker/docker/integration-cli/cli"
9
+	"github.com/docker/docker/integration-cli/request"
9 10
 	"github.com/go-check/check"
10 11
 	"github.com/gotestyourself/gotestyourself/icmd"
11 12
 	"golang.org/x/net/context"
... ...
@@ -129,7 +130,7 @@ func (s *DockerSuite) TestKillStoppedContainerAPIPre120(c *check.C) {
129 129
 	testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
130 130
 	runSleepingContainer(c, "--name", "docker-kill-test-api", "-d")
131 131
 	dockerCmd(c, "stop", "docker-kill-test-api")
132
-	cli, err := NewEnvClientWithVersion("v1.19")
132
+	cli, err := request.NewEnvClientWithVersion("v1.19")
133 133
 	c.Assert(err, check.IsNil)
134 134
 	defer cli.Close()
135 135
 	err = cli.ContainerKill(context.Background(), "docker-kill-test-api", "SIGKILL")
... ...
@@ -149,6 +149,7 @@ func (s *DockerSuite) TestPortList(c *check.C) {
149 149
 
150 150
 	out, _ = dockerCmd(c, "port", ID)
151 151
 
152
+	// Running this test multiple times causes the TCP port to increment.
152 153
 	err = assertPortRange(c, out, []int{8000, 8080}, []int{8000, 8080})
153 154
 	// Port list is not correct
154 155
 	c.Assert(err, checker.IsNil)
... ...
@@ -372,7 +372,7 @@ func waitInspectWithArgs(name, expr, expected string, timeout time.Duration, arg
372 372
 }
373 373
 
374 374
 func getInspectBody(c *check.C, version, id string) []byte {
375
-	cli, err := NewEnvClientWithVersion(version)
375
+	cli, err := request.NewEnvClientWithVersion(version)
376 376
 	c.Assert(err, check.IsNil)
377 377
 	defer cli.Close()
378 378
 	_, body, err := cli.ContainerInspectWithRaw(context.Background(), id, false)
... ...
@@ -18,6 +18,7 @@ import (
18 18
 	"time"
19 19
 
20 20
 	"github.com/docker/docker/api"
21
+	"github.com/docker/docker/api/types"
21 22
 	dclient "github.com/docker/docker/client"
22 23
 	"github.com/docker/docker/opts"
23 24
 	"github.com/docker/docker/pkg/ioutils"
... ...
@@ -323,3 +324,14 @@ func DaemonHost() string {
323 323
 	}
324 324
 	return daemonURLStr
325 325
 }
326
+
327
+// NewEnvClientWithVersion returns a docker client with a specified version.
328
+// See: github.com/docker/docker/client `NewEnvClient()`
329
+func NewEnvClientWithVersion(version string) (*dclient.Client, error) {
330
+	cli, err := dclient.NewEnvClient()
331
+	if err != nil {
332
+		return nil, err
333
+	}
334
+	cli.NegotiateAPIVersionPing(types.Ping{APIVersion: version})
335
+	return cli, nil
336
+}
... ...
@@ -7,8 +7,6 @@ import (
7 7
 	"path/filepath"
8 8
 	"strings"
9 9
 
10
-	"github.com/docker/docker/api/types"
11
-	"github.com/docker/docker/client"
12 10
 	"github.com/docker/docker/pkg/parsers/kernel"
13 11
 	"github.com/docker/docker/pkg/stringutils"
14 12
 	"github.com/go-check/check"
... ...
@@ -185,17 +183,6 @@ func RemoveOutputForExistingElements(output string, existing []string) string {
185 185
 	return strings.Join(res, "\n")
186 186
 }
187 187
 
188
-// NewEnvClientWithVersion returns a docker client with a specified version.
189
-// See: github.com/docker/docker/client `NewEnvClient()`
190
-func NewEnvClientWithVersion(version string) (*client.Client, error) {
191
-	cli, err := client.NewEnvClient()
192
-	if err != nil {
193
-		return nil, err
194
-	}
195
-	cli.NegotiateAPIVersionPing(types.Ping{APIVersion: version})
196
-	return cli, nil
197
-}
198
-
199 188
 // GetKernelVersion gets the current kernel version.
200 189
 func GetKernelVersion() *kernel.VersionInfo {
201 190
 	v, _ := kernel.ParseRelease(testEnv.DaemonInfo.KernelVersion)
... ...
@@ -205,9 +192,5 @@ func GetKernelVersion() *kernel.VersionInfo {
205 205
 // CheckKernelVersion checks if current kernel is newer than (or equal to)
206 206
 // the given version.
207 207
 func CheckKernelVersion(k, major, minor int) bool {
208
-	v := GetKernelVersion()
209
-	if kernel.CompareKernelVersion(*v, kernel.VersionInfo{Kernel: k, Major: major, Minor: minor}) < 0 {
210
-		return false
211
-	}
212
-	return true
208
+	return kernel.CompareKernelVersion(*GetKernelVersion(), kernel.VersionInfo{Kernel: k, Major: major, Minor: minor}) > 0
213 209
 }
214 210
deleted file mode 100755
... ...
@@ -1,13 +0,0 @@
1
-#!/usr/bin/env bash
2
-set -e
3
-
4
-echo "Ensure emptyfs image is loaded"
5
-bash /ensure-emptyfs.sh
6
-
7
-echo "Run integration/container tests"
8
-cd /tests/integration/container
9
-./test.main -test.v
10
-
11
-echo "Run integration-cli DockerSuite tests"
12
-cd /tests/integration-cli
13
-./test.main -test.v -check.v -check.f DockerSuite