From 3a0e583232fbcdcdcb0f2c7887289b290ee73279 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 14 May 2018 15:47:50 -0700 Subject: [PATCH 1/7] jsonmessage: pass message to aux callback Signed-off-by: Tonis Tiigi Upstream-commit: f784907eae4f2e8bd4d9dea3d45c790c92689f3d Component: engine --- components/engine/pkg/jsonmessage/jsonmessage.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/engine/pkg/jsonmessage/jsonmessage.go b/components/engine/pkg/jsonmessage/jsonmessage.go index b9f40d3ef1..7e5c95b58b 100644 --- a/components/engine/pkg/jsonmessage/jsonmessage.go +++ b/components/engine/pkg/jsonmessage/jsonmessage.go @@ -245,7 +245,7 @@ func (jm *JSONMessage) Display(out io.Writer, termInfo termInfo) error { // DisplayJSONMessagesStream displays a json message stream from `in` to `out`, `isTerminal` // describes if `out` is a terminal. If this is the case, it will print `\n` at the end of // each line and move the cursor while displaying. -func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, isTerminal bool, auxCallback func(*json.RawMessage)) error { +func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, isTerminal bool, auxCallback func(JSONMessage)) error { var ( dec = json.NewDecoder(in) ids = make(map[string]int) @@ -277,7 +277,7 @@ func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, if jm.Aux != nil { if auxCallback != nil { - auxCallback(jm.Aux) + auxCallback(jm) } continue } @@ -330,6 +330,6 @@ type stream interface { } // DisplayJSONMessagesToStream prints json messages to the output stream -func DisplayJSONMessagesToStream(in io.Reader, stream stream, auxCallback func(*json.RawMessage)) error { +func DisplayJSONMessagesToStream(in io.Reader, stream stream, auxCallback func(JSONMessage)) error { return DisplayJSONMessagesStream(in, stream, stream.FD(), stream.IsTerminal(), auxCallback) } From 8373fcb573d89591447c9a2b9767b174fff69dde Mon Sep 17 00:00:00 2001 From: emanb29 Date: Sun, 29 Apr 2018 21:14:23 -0700 Subject: [PATCH 2/7] Describe IP field of Port definition Signed-off-by: Ethan Bell Signed-off-by: Sebastiaan van Stijn Upstream-commit: 13e0b2651082878f8f17669df3f97ab252a9e095 Component: engine --- components/engine/api/swagger.yaml | 1 + components/engine/api/types/port.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/engine/api/swagger.yaml b/components/engine/api/swagger.yaml index 2124a816b1..cf7043d336 100644 --- a/components/engine/api/swagger.yaml +++ b/components/engine/api/swagger.yaml @@ -155,6 +155,7 @@ definitions: IP: type: "string" format: "ip-address" + description: "Host IP address that the container's port is mapped to" PrivatePort: type: "integer" format: "uint16" diff --git a/components/engine/api/types/port.go b/components/engine/api/types/port.go index ad52d46d56..d91234744c 100644 --- a/components/engine/api/types/port.go +++ b/components/engine/api/types/port.go @@ -7,7 +7,7 @@ package types // swagger:model Port type Port struct { - // IP + // Host IP address that the container's port is mapped to IP string `json:"IP,omitempty"` // Port on the container From a24b673f22dbb0956fe4d353d44355c4df2644ac Mon Sep 17 00:00:00 2001 From: Anda Xu Date: Fri, 4 May 2018 14:15:00 -0700 Subject: [PATCH 3/7] fix and skip some tests based on API version Signed-off-by: Anda Xu Co-authored-by: Anda Xu Co-authored-by: Tibor Vass Upstream-commit: e440831802a500b28ecf16c2627a294dc31dfeb9 Component: engine --- .../integration-cli/docker_api_build_test.go | 3 +- .../docker_api_containers_test.go | 73 +++++++++++++++---- .../integration-cli/docker_api_create_test.go | 31 ++++++-- .../docker_api_exec_resize_test.go | 7 +- .../integration-cli/docker_api_exec_test.go | 21 ++++-- .../docker_api_ipcmode_test.go | 4 +- .../integration-cli/docker_api_logs_test.go | 1 + .../docker_api_network_test.go | 42 +++++++++-- .../engine/integration-cli/docker_api_test.go | 13 +++- .../integration-cli/docker_cli_build_test.go | 4 + .../integration-cli/docker_cli_commit_test.go | 15 ++-- .../docker_cli_inspect_test.go | 2 +- .../integration-cli/docker_cli_links_test.go | 4 +- .../docker_cli_netmode_test.go | 2 +- .../integration-cli/docker_cli_ps_test.go | 11 ++- .../docker_cli_run_unix_test.go | 18 ++--- .../docker_cli_save_load_test.go | 4 +- .../integration-cli/docker_cli_start_test.go | 2 +- .../docker_deprecated_api_v124_test.go | 26 +++++-- .../integration-cli/requirements_test.go | 15 ++++ .../engine/integration/build/build_test.go | 2 + .../engine/integration/container/exec_test.go | 3 + .../integration/container/pause_test.go | 2 + .../integration/container/rename_test.go | 2 + .../integration/container/resize_test.go | 3 + .../engine/integration/container/stop_test.go | 3 +- .../engine/integration/image/commit_test.go | 3 + .../engine/integration/network/delete_test.go | 3 + .../integration/network/service_test.go | 6 ++ .../engine/integration/system/event_test.go | 5 +- .../engine/integration/volume/volume_test.go | 5 +- 31 files changed, 265 insertions(+), 70 deletions(-) diff --git a/components/engine/integration-cli/docker_api_build_test.go b/components/engine/integration-cli/docker_api_build_test.go index e2c4780274..594185f14d 100644 --- a/components/engine/integration-cli/docker_api_build_test.go +++ b/components/engine/integration-cli/docker_api_build_test.go @@ -406,7 +406,8 @@ func (s *DockerSuite) TestBuildAddRemoteNoDecompress(c *check.C) { } func (s *DockerSuite) TestBuildChownOnCopy(c *check.C) { - testRequires(c, DaemonIsLinux) + // new feature added in 1.31 - https://github.com/moby/moby/pull/34263 + testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31")) dockerfile := `FROM busybox RUN echo 'test1:x:1001:1001::/bin:/bin/false' >> /etc/passwd RUN echo 'test1:x:1001:' >> /etc/group diff --git a/components/engine/integration-cli/docker_api_containers_test.go b/components/engine/integration-cli/docker_api_containers_test.go index c2e26bf0ba..f980d87d82 100644 --- a/components/engine/integration-cli/docker_api_containers_test.go +++ b/components/engine/integration-cli/docker_api_containers_test.go @@ -21,6 +21,7 @@ import ( containertypes "github.com/docker/docker/api/types/container" mounttypes "github.com/docker/docker/api/types/mount" networktypes "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" @@ -724,13 +725,23 @@ func (s *DockerSuite) TestContainerAPIVerifyHeader(c *check.C) { // Try with no content-type res, body, err := create("") c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + // todo: we need to figure out a better way to compare between dockerd versions + // comparing between daemon API version is not precise. + if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } else { + c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK) + } body.Close() // Try with wrong content-type res, body, err = create("application/xml") c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } else { + c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK) + } body.Close() // now application/json @@ -756,7 +767,11 @@ func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *check.C) { res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } else { + c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK) + } b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) @@ -776,7 +791,11 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *check.C) res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } else { + c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK) + } b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) @@ -796,7 +815,11 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *check.C) { res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } else { + c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK) + } b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) @@ -816,7 +839,11 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *check.C res, body, err := request.Post("/containers/create", request.RawString(config), request.JSON) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } else { + c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK) + } b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) @@ -901,7 +928,11 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *check.C) { b, err2 := request.ReadBody(body) c.Assert(err2, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } else { + c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK) + } c.Assert(string(b), checker.Contains, "Minimum memory limit allowed is 4MB") } @@ -1089,7 +1120,11 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *check.C) { res, body, err := request.Post("/v1.23/containers/"+name+"/copy", request.JSONBody(postData)) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } else { + c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK) + } b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) c.Assert(string(b), checker.Matches, "Path cannot be empty\n") @@ -1106,8 +1141,11 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *check.C) res, body, err := request.Post("/v1.23/containers/"+name+"/copy", request.JSONBody(postData)) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusNotFound) - + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + } else { + c.Assert(res.StatusCode, checker.Equals, http.StatusNotFound) + } b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) c.Assert(string(b), checker.Matches, "Could not find the file /notexist in container "+name+"\n") @@ -1563,7 +1601,11 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted( containerJSON, err := cli.ContainerInspect(context.Background(), container.ID) c.Assert(err, check.IsNil) - c.Assert(containerJSON.HostConfig.MemorySwappiness, check.IsNil) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.31") { + c.Assert(*containerJSON.HostConfig.MemorySwappiness, check.Equals, int64(-1)) + } else { + c.Assert(containerJSON.HostConfig.MemorySwappiness, check.IsNil) + } } // check validation is done daemon side and not only in cli @@ -1910,8 +1952,13 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) { } var selinuxSharedLabel string - if runtime.GOOS == "linux" { - selinuxSharedLabel = "z" + // this test label was added after a bug fix in 1.32, thus add requirements min API >= 1.32 + // for the sake of making test pass in earlier versions + // bug fixed in https://github.com/moby/moby/pull/34684 + if !versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + if runtime.GOOS == "linux" { + selinuxSharedLabel = "z" + } } cases := []testCase{ diff --git a/components/engine/integration-cli/docker_api_create_test.go b/components/engine/integration-cli/docker_api_create_test.go index 0e5a1307e6..8c7fff477e 100644 --- a/components/engine/integration-cli/docker_api_create_test.go +++ b/components/engine/integration-cli/docker_api_create_test.go @@ -6,6 +6,7 @@ import ( "time" "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/internal/test/request" "github.com/go-check/check" @@ -25,7 +26,11 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) { res, body, err := request.Post("/containers/create?name="+name, request.JSONBody(config)) c.Assert(err, check.IsNil) - c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, check.Equals, http.StatusInternalServerError) + } else { + c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + } buf, err := request.ReadBody(body) c.Assert(err, checker.IsNil) @@ -49,7 +54,11 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) { buf, err = request.ReadBody(body) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, check.Equals, http.StatusInternalServerError) + } else { + c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + } c.Assert(getErrorMessage(c, buf), checker.Contains, expected) // test invalid Timeout in Healthcheck: less than 1ms @@ -64,7 +73,11 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) { } res, body, err = request.Post("/containers/create?name="+name, request.JSONBody(config)) c.Assert(err, check.IsNil) - c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, check.Equals, http.StatusInternalServerError) + } else { + c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + } buf, err = request.ReadBody(body) c.Assert(err, checker.IsNil) @@ -84,7 +97,11 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) { } res, body, err = request.Post("/containers/create?name="+name, request.JSONBody(config)) c.Assert(err, check.IsNil) - c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, check.Equals, http.StatusInternalServerError) + } else { + c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + } buf, err = request.ReadBody(body) c.Assert(err, checker.IsNil) @@ -105,7 +122,11 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) { } res, body, err = request.Post("/containers/create?name="+name, request.JSONBody(config)) c.Assert(err, check.IsNil) - c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, check.Equals, http.StatusInternalServerError) + } else { + c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest) + } buf, err = request.ReadBody(body) c.Assert(err, checker.IsNil) diff --git a/components/engine/integration-cli/docker_api_exec_resize_test.go b/components/engine/integration-cli/docker_api_exec_resize_test.go index 37a266a277..c561d60f56 100644 --- a/components/engine/integration-cli/docker_api_exec_resize_test.go +++ b/components/engine/integration-cli/docker_api_exec_resize_test.go @@ -9,6 +9,7 @@ import ( "strings" "sync" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/internal/test/request" "github.com/go-check/check" @@ -22,7 +23,11 @@ func (s *DockerSuite) TestExecResizeAPIHeightWidthNoInt(c *check.C) { endpoint := "/exec/" + cleanedContainerID + "/resize?h=foo&w=bar" res, _, err := request.Post(endpoint) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + } else { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } } // Part of #14845 diff --git a/components/engine/integration-cli/docker_api_exec_test.go b/components/engine/integration-cli/docker_api_exec_test.go index dc12c460e7..118f9971a7 100644 --- a/components/engine/integration-cli/docker_api_exec_test.go +++ b/components/engine/integration-cli/docker_api_exec_test.go @@ -14,6 +14,7 @@ import ( "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/internal/test/request" @@ -27,8 +28,11 @@ func (s *DockerSuite) TestExecAPICreateNoCmd(c *check.C) { res, body, err := request.Post(fmt.Sprintf("/containers/%s/exec", name), request.JSONBody(map[string]interface{}{"Cmd": nil})) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) - + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + } else { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) @@ -47,8 +51,11 @@ func (s *DockerSuite) TestExecAPICreateNoValidContentType(c *check.C) { res, body, err := request.Post(fmt.Sprintf("/containers/%s/exec", name), request.RawContent(ioutil.NopCloser(jsonData)), request.ContentType("test/plain")) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) - + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + } else { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) @@ -191,7 +198,11 @@ func (s *DockerSuite) TestExecAPIStartInvalidCommand(c *check.C) { dockerCmd(c, "run", "-d", "-t", "--name", name, "busybox", "/bin/sh") id := createExecCmd(c, name, "invalid") - startExec(c, id, http.StatusBadRequest) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + startExec(c, id, http.StatusNotFound) + } else { + startExec(c, id, http.StatusBadRequest) + } waitForExec(c, id) var inspectJSON struct{ ExecIDs []string } diff --git a/components/engine/integration-cli/docker_api_ipcmode_test.go b/components/engine/integration-cli/docker_api_ipcmode_test.go index 832fe658de..886ff88d20 100644 --- a/components/engine/integration-cli/docker_api_ipcmode_test.go +++ b/components/engine/integration-cli/docker_api_ipcmode_test.go @@ -88,7 +88,7 @@ func testIpcNonePrivateShareable(c *check.C, mode string, mustBeMounted bool, mu * /dev/shm mount inside the container. */ func (s *DockerSuite) TestAPIIpcModeNone(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.32")) testIpcNonePrivateShareable(c, "none", false, false) } @@ -173,7 +173,7 @@ func (s *DockerSuite) TestAPIIpcModeShareableAndContainer(c *check.C) { * --ipc container:ID can NOT use IPC of another private container. */ func (s *DockerSuite) TestAPIIpcModePrivateAndContainer(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.32")) testIpcContainer(s, c, "private", false) } diff --git a/components/engine/integration-cli/docker_api_logs_test.go b/components/engine/integration-cli/docker_api_logs_test.go index bf5f8ab4ba..e809b46c2f 100644 --- a/components/engine/integration-cli/docker_api_logs_test.go +++ b/components/engine/integration-cli/docker_api_logs_test.go @@ -149,6 +149,7 @@ func (s *DockerSuite) TestLogsAPIUntilFutureFollow(c *check.C) { } func (s *DockerSuite) TestLogsAPIUntil(c *check.C) { + testRequires(c, MinimumAPIVersion("1.34")) name := "logsuntil" dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; sleep 1; done") diff --git a/components/engine/integration-cli/docker_api_network_test.go b/components/engine/integration-cli/docker_api_network_test.go index 21418306ec..c159c80a0a 100644 --- a/components/engine/integration-cli/docker_api_network_test.go +++ b/components/engine/integration-cli/docker_api_network_test.go @@ -11,6 +11,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/internal/test/request" "github.com/go-check/check" @@ -64,7 +65,18 @@ func (s *DockerSuite) TestAPINetworkCreateCheckDuplicate(c *check.C) { c.Assert(isNetworkAvailable(c, name), checker.Equals, true) // Creating another network with same name and CheckDuplicate must fail - createNetwork(c, configOnCheck, http.StatusConflict) + isOlderAPI := versions.LessThan(testEnv.DaemonAPIVersion(), "1.34") + expectedStatus := http.StatusConflict + if isOlderAPI { + // In the early test code it uses bool value to represent + // whether createNetwork() is expected to fail or not. + // Therefore, we use negation to handle the same logic after + // the code was changed in https://github.com/moby/moby/pull/35030 + // -http.StatusCreated will also be checked as NOT equal to + // http.StatusCreated in createNetwork() function. + expectedStatus = -http.StatusCreated + } + createNetwork(c, configOnCheck, expectedStatus) // Creating another network with same name and not CheckDuplicate must succeed createNetwork(c, configNotCheck, http.StatusCreated) @@ -202,7 +214,11 @@ func (s *DockerSuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *check.C) { IPAM: ipam1, }, } - createNetwork(c, config1, http.StatusForbidden) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + createNetwork(c, config1, http.StatusInternalServerError) + } else { + createNetwork(c, config1, http.StatusForbidden) + } c.Assert(isNetworkAvailable(c, "test1"), checker.Equals, false) ipam2 := &network.IPAM{ @@ -239,7 +255,7 @@ func (s *DockerSuite) TestAPINetworkIPAMMultipleBridgeNetworks(c *check.C) { } func (s *DockerSuite) TestAPICreateDeletePredefinedNetworks(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, SwarmInactive) createDeletePredefinedNetwork(c, "bridge") createDeletePredefinedNetwork(c, "none") createDeletePredefinedNetwork(c, "host") @@ -253,7 +269,17 @@ func createDeletePredefinedNetwork(c *check.C, name string) { CheckDuplicate: true, }, } - createNetwork(c, config, http.StatusForbidden) + expectedStatus := http.StatusForbidden + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.34") { + // In the early test code it uses bool value to represent + // whether createNetwork() is expected to fail or not. + // Therefore, we use negation to handle the same logic after + // the code was changed in https://github.com/moby/moby/pull/35030 + // -http.StatusCreated will also be checked as NOT equal to + // http.StatusCreated in createNetwork() function. + expectedStatus = -http.StatusCreated + } + createNetwork(c, config, expectedStatus) deleteNetwork(c, name, false) } @@ -320,9 +346,13 @@ func createNetwork(c *check.C, config types.NetworkCreateRequest, expectedStatus c.Assert(err, checker.IsNil) defer resp.Body.Close() - c.Assert(resp.StatusCode, checker.Equals, expectedStatusCode) + if expectedStatusCode >= 0 { + c.Assert(resp.StatusCode, checker.Equals, expectedStatusCode) + } else { + c.Assert(resp.StatusCode, checker.Not(checker.Equals), -expectedStatusCode) + } - if expectedStatusCode == http.StatusCreated { + if expectedStatusCode == http.StatusCreated || expectedStatusCode < 0 { var nr types.NetworkCreateResponse err = json.NewDecoder(body).Decode(&nr) c.Assert(err, checker.IsNil) diff --git a/components/engine/integration-cli/docker_api_test.go b/components/engine/integration-cli/docker_api_test.go index 1dcaa1c4cf..5b7e3e97f9 100644 --- a/components/engine/integration-cli/docker_api_test.go +++ b/components/engine/integration-cli/docker_api_test.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/docker/docker/api" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/internal/test/request" "github.com/go-check/check" @@ -59,7 +60,11 @@ func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *check.C) { func (s *DockerSuite) TestAPIErrorJSON(c *check.C) { httpResp, body, err := request.Post("/containers/create", request.JSONBody(struct{}{})) c.Assert(err, checker.IsNil) - c.Assert(httpResp.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(httpResp.StatusCode, checker.Equals, http.StatusInternalServerError) + } else { + c.Assert(httpResp.StatusCode, checker.Equals, http.StatusBadRequest) + } c.Assert(httpResp.Header.Get("Content-Type"), checker.Equals, "application/json") b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) @@ -72,7 +77,11 @@ func (s *DockerSuite) TestAPIErrorPlainText(c *check.C) { testRequires(c, DaemonIsLinux) httpResp, body, err := request.Post("/v1.23/containers/create", request.JSONBody(struct{}{})) c.Assert(err, checker.IsNil) - c.Assert(httpResp.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(httpResp.StatusCode, checker.Equals, http.StatusInternalServerError) + } else { + c.Assert(httpResp.StatusCode, checker.Equals, http.StatusBadRequest) + } c.Assert(httpResp.Header.Get("Content-Type"), checker.Contains, "text/plain") b, err := request.ReadBody(body) c.Assert(err, checker.IsNil) diff --git a/components/engine/integration-cli/docker_cli_build_test.go b/components/engine/integration-cli/docker_cli_build_test.go index 2ed5e44d8f..e4edc8e642 100644 --- a/components/engine/integration-cli/docker_cli_build_test.go +++ b/components/engine/integration-cli/docker_cli_build_test.go @@ -5953,6 +5953,10 @@ func (s *DockerSuite) TestBuildMulitStageResetScratch(c *check.C) { } func (s *DockerSuite) TestBuildIntermediateTarget(c *check.C) { + //todo: need to be removed after 18.06 release + if strings.Contains(testEnv.DaemonInfo.ServerVersion, "18.05.0") { + c.Skip(fmt.Sprintf("Bug fixed in 18.06 or higher.Skipping it for %s", testEnv.DaemonInfo.ServerVersion)) + } dockerfile := ` FROM busybox AS build-env CMD ["/dev"] diff --git a/components/engine/integration-cli/docker_cli_commit_test.go b/components/engine/integration-cli/docker_cli_commit_test.go index b0f21cef50..79c5f73156 100644 --- a/components/engine/integration-cli/docker_cli_commit_test.go +++ b/components/engine/integration-cli/docker_cli_commit_test.go @@ -3,6 +3,7 @@ package main import ( "strings" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/go-check/check" @@ -121,12 +122,14 @@ func (s *DockerSuite) TestCommitChange(c *check.C) { "test", "test-commit") imageID = strings.TrimSpace(imageID) - // The ordering here is due to `PATH` being overridden from the container's - // ENV. On windows, the container doesn't have a `PATH` ENV variable so - // the ordering is the same as the cli. - expectedEnv := "[PATH=/foo DEBUG=true test=1]" - if testEnv.OSType == "windows" { - expectedEnv = "[DEBUG=true test=1 PATH=/foo]" + expectedEnv := "[DEBUG=true test=1 PATH=/foo]" + // bug fixed in 1.36, add min APi >= 1.36 requirement + // PR record https://github.com/moby/moby/pull/35582 + if versions.GreaterThan(testEnv.DaemonAPIVersion(), "1.35") && testEnv.OSType != "windows" { + // The ordering here is due to `PATH` being overridden from the container's + // ENV. On windows, the container doesn't have a `PATH` ENV variable so + // the ordering is the same as the cli. + expectedEnv = "[PATH=/foo DEBUG=true test=1]" } prefix, slash := getPrefixAndSlashFromDaemonPlatform() diff --git a/components/engine/integration-cli/docker_cli_inspect_test.go b/components/engine/integration-cli/docker_cli_inspect_test.go index bf2ee71e95..247721e616 100644 --- a/components/engine/integration-cli/docker_cli_inspect_test.go +++ b/components/engine/integration-cli/docker_cli_inspect_test.go @@ -463,5 +463,5 @@ func (s *DockerSuite) TestInspectInvalidReference(c *check.C) { // This test should work on both Windows and Linux out, _, err := dockerCmdWithError("inspect", "FooBar") c.Assert(err, checker.NotNil) - c.Assert(out, checker.Contains, "no such image: FooBar") + c.Assert(out, checker.Contains, "invalid reference format: repository name must be lowercase") } diff --git a/components/engine/integration-cli/docker_cli_links_test.go b/components/engine/integration-cli/docker_cli_links_test.go index 0b4f30cfe9..17b25d7994 100644 --- a/components/engine/integration-cli/docker_cli_links_test.go +++ b/components/engine/integration-cli/docker_cli_links_test.go @@ -28,7 +28,9 @@ func (s *DockerSuite) TestLinksInvalidContainerTarget(c *check.C) { // an invalid container target should produce an error c.Assert(err, checker.NotNil, check.Commentf("out: %s", out)) // an invalid container target should produce an error - c.Assert(out, checker.Contains, "could not get container") + // note: convert the output to lowercase first as the error string + // capitalization was changed after API version 1.32 + c.Assert(strings.ToLower(out), checker.Contains, "could not get container") } func (s *DockerSuite) TestLinksPingLinkedContainers(c *check.C) { diff --git a/components/engine/integration-cli/docker_cli_netmode_test.go b/components/engine/integration-cli/docker_cli_netmode_test.go index 2b134d4de1..76f9898d88 100644 --- a/components/engine/integration-cli/docker_cli_netmode_test.go +++ b/components/engine/integration-cli/docker_cli_netmode_test.go @@ -46,7 +46,7 @@ func (s *DockerSuite) TestNetHostname(c *check.C) { c.Assert(out, checker.Contains, runconfig.ErrConflictNetworkHostname.Error()) out, _ = dockerCmdWithFail(c, "run", "--net=container", "busybox", "ps") - c.Assert(out, checker.Contains, "Invalid network mode: invalid container format container:") + c.Assert(out, checker.Contains, "invalid container format container:") out, _ = dockerCmdWithFail(c, "run", "--net=weird", "busybox", "ps") c.Assert(strings.ToLower(out), checker.Contains, "not found") diff --git a/components/engine/integration-cli/docker_cli_ps_test.go b/components/engine/integration-cli/docker_cli_ps_test.go index 509015d6bd..fea51dd0bd 100644 --- a/components/engine/integration-cli/docker_cli_ps_test.go +++ b/components/engine/integration-cli/docker_cli_ps_test.go @@ -7,6 +7,7 @@ import ( "strings" "time" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/integration-cli/cli" "github.com/docker/docker/integration-cli/cli/build" @@ -200,11 +201,14 @@ func (s *DockerSuite) TestPsListContainersFilterStatus(c *check.C) { c.Assert(RemoveOutputForExistingElements(containerOut, existingContainers), checker.Equals, secondID) result := cli.Docker(cli.Args("ps", "-a", "-q", "--filter=status=rubbish"), cli.WithTimeout(time.Second*60)) + err := "Invalid filter 'status=rubbish'" + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + err = "Unrecognised filter value for status: rubbish" + } result.Assert(c, icmd.Expected{ ExitCode: 1, - Err: "Invalid filter 'status=rubbish'", + Err: err, }) - // Windows doesn't support pausing of containers if testEnv.OSType != "windows" { // pause running container @@ -848,8 +852,7 @@ func (s *DockerSuite) TestPsListContainersFilterPorts(c *check.C) { } func (s *DockerSuite) TestPsNotShowLinknamesOfDeletedContainer(c *check.C) { - testRequires(c, DaemonIsLinux) - + testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31")) existingContainers := ExistingContainerNames(c) dockerCmd(c, "create", "--name=aaa", "busybox", "top") diff --git a/components/engine/integration-cli/docker_cli_run_unix_test.go b/components/engine/integration-cli/docker_cli_run_unix_test.go index d817bc3b22..5987276407 100644 --- a/components/engine/integration-cli/docker_cli_run_unix_test.go +++ b/components/engine/integration-cli/docker_cli_run_unix_test.go @@ -1165,7 +1165,7 @@ func (s *DockerSuite) TestLegacyRunNoNewPrivSetuid(c *check.C) { } func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChown(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, SameHostDaemon) ensureSyscallTest(c) // test that a root user has default capability CAP_CHOWN @@ -1183,7 +1183,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChown(c *check.C) { } func (s *DockerSuite) TestUserNoEffectiveCapabilitiesDacOverride(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, SameHostDaemon) ensureSyscallTest(c) // test that a root user has default capability CAP_DAC_OVERRIDE @@ -1196,7 +1196,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesDacOverride(c *check.C) { } func (s *DockerSuite) TestUserNoEffectiveCapabilitiesFowner(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, SameHostDaemon) ensureSyscallTest(c) // test that a root user has default capability CAP_FOWNER @@ -1212,7 +1212,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesFowner(c *check.C) { // TODO CAP_KILL func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetuid(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, SameHostDaemon) ensureSyscallTest(c) // test that a root user has default capability CAP_SETUID @@ -1230,7 +1230,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetuid(c *check.C) { } func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetgid(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, SameHostDaemon) ensureSyscallTest(c) // test that a root user has default capability CAP_SETGID @@ -1250,7 +1250,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesSetgid(c *check.C) { // TODO CAP_SETPCAP func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetBindService(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, SameHostDaemon) ensureSyscallTest(c) // test that a root user has default capability CAP_NET_BIND_SERVICE @@ -1268,7 +1268,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetBindService(c *check.C) } func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetRaw(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, SameHostDaemon) ensureSyscallTest(c) // test that a root user has default capability CAP_NET_RAW @@ -1286,7 +1286,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesNetRaw(c *check.C) { } func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChroot(c *check.C) { - testRequires(c, DaemonIsLinux) + testRequires(c, DaemonIsLinux, SameHostDaemon) ensureSyscallTest(c) // test that a root user has default capability CAP_SYS_CHROOT @@ -1304,7 +1304,7 @@ func (s *DockerSuite) TestUserNoEffectiveCapabilitiesChroot(c *check.C) { } func (s *DockerSuite) TestUserNoEffectiveCapabilitiesMknod(c *check.C) { - testRequires(c, DaemonIsLinux, NotUserNamespace) + testRequires(c, DaemonIsLinux, NotUserNamespace, SameHostDaemon) ensureSyscallTest(c) // test that a root user has default capability CAP_MKNOD diff --git a/components/engine/integration-cli/docker_cli_save_load_test.go b/components/engine/integration-cli/docker_cli_save_load_test.go index d7cbc84752..3077c0b46d 100644 --- a/components/engine/integration-cli/docker_cli_save_load_test.go +++ b/components/engine/integration-cli/docker_cli_save_load_test.go @@ -330,7 +330,9 @@ func listTar(f io.Reader) ([]string, error) { // The layer.tar file is actually zero bytes, no padding or anything else. // See issue: 18170 func (s *DockerSuite) TestLoadZeroSizeLayer(c *check.C) { - testRequires(c, DaemonIsLinux) + // this will definitely not work if using remote daemon + // very weird test + testRequires(c, DaemonIsLinux, SameHostDaemon) dockerCmd(c, "load", "-i", "testdata/emptyLayer.tar") } diff --git a/components/engine/integration-cli/docker_cli_start_test.go b/components/engine/integration-cli/docker_cli_start_test.go index 13c1d8ef2f..98f7beaea9 100644 --- a/components/engine/integration-cli/docker_cli_start_test.go +++ b/components/engine/integration-cli/docker_cli_start_test.go @@ -103,7 +103,7 @@ func (s *DockerSuite) TestStartPausedContainer(c *check.C) { // an error should have been shown that you cannot start paused container c.Assert(err, checker.NotNil, check.Commentf("out: %s", out)) // an error should have been shown that you cannot start paused container - c.Assert(out, checker.Contains, "cannot start a paused container, try unpause instead") + c.Assert(strings.ToLower(out), checker.Contains, "cannot start a paused container, try unpause instead") } func (s *DockerSuite) TestStartMultipleContainers(c *check.C) { diff --git a/components/engine/integration-cli/docker_deprecated_api_v124_test.go b/components/engine/integration-cli/docker_deprecated_api_v124_test.go index 0f3f99b438..ffb06da40f 100644 --- a/components/engine/integration-cli/docker_deprecated_api_v124_test.go +++ b/components/engine/integration-cli/docker_deprecated_api_v124_test.go @@ -7,6 +7,7 @@ import ( "net/http" "strings" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration-cli/checker" "github.com/docker/docker/internal/test/request" "github.com/go-check/check" @@ -24,12 +25,15 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartHostConfig(c *check.C) { } res, body, err := request.Post("/containers/"+name+"/start", request.JSONBody(config)) c.Assert(err, checker.IsNil) - - buf, err := request.ReadBody(body) - c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) - c.Assert(string(buf), checker.Contains, "was deprecated since API v1.22") + if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") { + // assertions below won't work before 1.32 + buf, err := request.ReadBody(body) + c.Assert(err, checker.IsNil) + + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + c.Assert(string(buf), checker.Contains, "was deprecated since API v1.22") + } } func (s *DockerSuite) TestDeprecatedContainerAPIStartVolumeBinds(c *check.C) { @@ -88,7 +92,11 @@ func (s *DockerSuite) TestDeprecatedContainerAPIStartDupVolumeBinds(c *check.C) buf, err := request.ReadBody(body) c.Assert(err, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + } else { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } c.Assert(string(buf), checker.Contains, "Duplicate mount point", check.Commentf("Expected failure due to duplicate bind mounts to same path, instead got: %q with error: %v", string(buf), err)) } @@ -161,7 +169,11 @@ func (s *DockerSuite) TestDeprecatedStartWithTooLowMemoryLimit(c *check.C) { c.Assert(err, checker.IsNil) b, err2 := request.ReadBody(body) c.Assert(err2, checker.IsNil) - c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + if versions.LessThan(testEnv.DaemonAPIVersion(), "1.32") { + c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError) + } else { + c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest) + } c.Assert(string(b), checker.Contains, "Minimum memory limit allowed is 4MB") } diff --git a/components/engine/integration-cli/requirements_test.go b/components/engine/integration-cli/requirements_test.go index 3ae24b204c..9b08a63b0e 100644 --- a/components/engine/integration-cli/requirements_test.go +++ b/components/engine/integration-cli/requirements_test.go @@ -12,6 +12,8 @@ import ( "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/client" "github.com/docker/docker/integration-cli/requirement" "github.com/docker/docker/internal/test/registry" @@ -40,6 +42,12 @@ func DaemonIsLinux() bool { return testEnv.OSType == "linux" } +func MinimumAPIVersion(version string) func() bool { + return func() bool { + return versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), version) + } +} + func OnlyDefaultNetworks() bool { cli, err := client.NewEnvClient() if err != nil { @@ -109,6 +117,9 @@ func Network() bool { } func Apparmor() bool { + if strings.HasPrefix(testEnv.DaemonInfo.OperatingSystem, "SUSE Linux Enterprise Server ") { + return false + } buf, err := ioutil.ReadFile("/sys/module/apparmor/parameters/enabled") return err == nil && len(buf) > 1 && buf[0] == 'Y' } @@ -193,6 +204,10 @@ func RegistryHosting() bool { return err == nil } +func SwarmInactive() bool { + return testEnv.DaemonInfo.Swarm.LocalNodeState == swarm.LocalNodeStateInactive +} + // testRequires checks if the environment satisfies the requirements // for the test to run or skips the tests. func testRequires(c requirement.SkipT, requirements ...requirement.Test) { diff --git a/components/engine/integration/build/build_test.go b/components/engine/integration/build/build_test.go index 880c0197a4..52c03b4734 100644 --- a/components/engine/integration/build/build_test.go +++ b/components/engine/integration/build/build_test.go @@ -136,6 +136,7 @@ func buildContainerIdsFilter(buildOutput io.Reader) (filters.Args, error) { } func TestBuildMultiStageParentConfig(t *testing.T) { + skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.35"), "broken in earlier versions") dockerfile := ` FROM busybox AS stage0 ENV WHO=parent @@ -204,6 +205,7 @@ func TestBuildWithEmptyLayers(t *testing.T) { // multiple subsequent stages // #35652 func TestBuildMultiStageOnBuild(t *testing.T) { + skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.33"), "broken in earlier versions") defer setupTest(t)() // test both metadata and layer based commands as they may be implemented differently dockerfile := `FROM busybox AS stage1 diff --git a/components/engine/integration/container/exec_test.go b/components/engine/integration/container/exec_test.go index 790f3fe3da..e1750d9414 100644 --- a/components/engine/integration/container/exec_test.go +++ b/components/engine/integration/container/exec_test.go @@ -7,13 +7,16 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/strslice" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/internal/test/request" "github.com/gotestyourself/gotestyourself/assert" is "github.com/gotestyourself/gotestyourself/assert/cmp" + "github.com/gotestyourself/gotestyourself/skip" ) func TestExec(t *testing.T) { + skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.35"), "broken in earlier versions") defer setupTest(t)() ctx := context.Background() client := request.NewAPIClient(t) diff --git a/components/engine/integration/container/pause_test.go b/components/engine/integration/container/pause_test.go index 449b623957..e6ecbbc0b5 100644 --- a/components/engine/integration/container/pause_test.go +++ b/components/engine/integration/container/pause_test.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/internal/test/request" "github.com/docker/docker/internal/testutil" @@ -66,6 +67,7 @@ func TestPauseFailsOnWindowsServerContainers(t *testing.T) { func TestPauseStopPausedContainer(t *testing.T) { skip.If(t, testEnv.DaemonInfo.OSType != "linux") + skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.31"), "broken in earlier versions") defer setupTest(t)() client := request.NewAPIClient(t) diff --git a/components/engine/integration/container/rename_test.go b/components/engine/integration/container/rename_test.go index d35e6aa683..4496b980b7 100644 --- a/components/engine/integration/container/rename_test.go +++ b/components/engine/integration/container/rename_test.go @@ -8,6 +8,7 @@ import ( "github.com/docker/docker/api/types" containertypes "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/internal/test/request" "github.com/docker/docker/internal/testutil" @@ -23,6 +24,7 @@ import ( // and then deleting and recreating the source container linked to the new target. // This checks that "rename" updates source container correctly and doesn't set it to null. func TestRenameLinkedContainer(t *testing.T) { + skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.32"), "broken in earlier versions") defer setupTest(t)() ctx := context.Background() client := request.NewAPIClient(t) diff --git a/components/engine/integration/container/resize_test.go b/components/engine/integration/container/resize_test.go index e5d5db2df6..892a5c1765 100644 --- a/components/engine/integration/container/resize_test.go +++ b/components/engine/integration/container/resize_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/internal/test/request" req "github.com/docker/docker/internal/test/request" @@ -14,6 +15,7 @@ import ( "github.com/gotestyourself/gotestyourself/assert" is "github.com/gotestyourself/gotestyourself/assert/cmp" "github.com/gotestyourself/gotestyourself/poll" + "github.com/gotestyourself/gotestyourself/skip" ) func TestResize(t *testing.T) { @@ -33,6 +35,7 @@ func TestResize(t *testing.T) { } func TestResizeWithInvalidSize(t *testing.T) { + skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.32"), "broken in earlier versions") defer setupTest(t)() client := request.NewAPIClient(t) ctx := context.Background() diff --git a/components/engine/integration/container/stop_test.go b/components/engine/integration/container/stop_test.go index 5cb970ba58..c22a0302f6 100644 --- a/components/engine/integration/container/stop_test.go +++ b/components/engine/integration/container/stop_test.go @@ -43,7 +43,8 @@ func TestStopContainerWithRestartPolicyAlways(t *testing.T) { } func TestDeleteDevicemapper(t *testing.T) { - skip.IfCondition(t, testEnv.DaemonInfo.Driver != "devicemapper") + skip.If(t, testEnv.DaemonInfo.Driver != "devicemapper") + skip.If(t, testEnv.IsRemoteDaemon, "cannot start daemon on remote test run") defer setupTest(t)() client := request.NewAPIClient(t) diff --git a/components/engine/integration/image/commit_test.go b/components/engine/integration/image/commit_test.go index ea62c6257a..eb0b4e6b5d 100644 --- a/components/engine/integration/image/commit_test.go +++ b/components/engine/integration/image/commit_test.go @@ -5,13 +5,16 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/internal/test/request" "github.com/gotestyourself/gotestyourself/assert" is "github.com/gotestyourself/gotestyourself/assert/cmp" + "github.com/gotestyourself/gotestyourself/skip" ) func TestCommitInheritsEnv(t *testing.T) { + skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.36"), "broken in earlier versions") defer setupTest(t)() client := request.NewAPIClient(t) ctx := context.Background() diff --git a/components/engine/integration/network/delete_test.go b/components/engine/integration/network/delete_test.go index 49a237f71e..f937da5274 100644 --- a/components/engine/integration/network/delete_test.go +++ b/components/engine/integration/network/delete_test.go @@ -5,9 +5,11 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/internal/test/request" "github.com/gotestyourself/gotestyourself/assert" is "github.com/gotestyourself/gotestyourself/assert/cmp" + "github.com/gotestyourself/gotestyourself/skip" ) func containsNetwork(nws []types.NetworkResource, nw types.NetworkCreateResponse) bool { @@ -48,6 +50,7 @@ func createAmbiguousNetworks(t *testing.T) (types.NetworkCreateResponse, types.N // equal to another network's ID exists, the Network with the given // ID is removed, and not the network with the given name. func TestDockerNetworkDeletePreferID(t *testing.T) { + skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.34"), "broken in earlier versions") defer setupTest(t)() client := request.NewAPIClient(t) ctx := context.Background() diff --git a/components/engine/integration/network/service_test.go b/components/engine/integration/network/service_test.go index b856a9e38a..2ae1897c6d 100644 --- a/components/engine/integration/network/service_test.go +++ b/components/engine/integration/network/service_test.go @@ -13,6 +13,7 @@ import ( "github.com/gotestyourself/gotestyourself/assert" "github.com/gotestyourself/gotestyourself/icmd" "github.com/gotestyourself/gotestyourself/poll" + "github.com/gotestyourself/gotestyourself/skip" ) // delInterface removes given network interface @@ -23,6 +24,7 @@ func delInterface(t *testing.T, ifName string) { } func TestDaemonRestartWithLiveRestore(t *testing.T) { + skip.If(t, testEnv.IsRemoteDaemon()) d := daemon.New(t) defer d.Stop(t) d.Start(t) @@ -42,6 +44,7 @@ func TestDaemonRestartWithLiveRestore(t *testing.T) { func TestDaemonDefaultNetworkPools(t *testing.T) { // Remove docker0 bridge and the start daemon defining the predefined address pools + skip.If(t, testEnv.IsRemoteDaemon()) defaultNetworkBridge := "docker0" delInterface(t, defaultNetworkBridge) d := daemon.New(t) @@ -86,6 +89,7 @@ func TestDaemonDefaultNetworkPools(t *testing.T) { } func TestDaemonRestartWithExistingNetwork(t *testing.T) { + skip.If(t, testEnv.IsRemoteDaemon()) defaultNetworkBridge := "docker0" d := daemon.New(t) d.Start(t) @@ -119,6 +123,7 @@ func TestDaemonRestartWithExistingNetwork(t *testing.T) { } func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) { + skip.If(t, testEnv.IsRemoteDaemon()) defaultNetworkBridge := "docker0" d := daemon.New(t) d.Start(t) @@ -174,6 +179,7 @@ func TestDaemonRestartWithExistingNetworkWithDefaultPoolRange(t *testing.T) { } func TestDaemonWithBipAndDefaultNetworkPool(t *testing.T) { + skip.If(t, testEnv.IsRemoteDaemon()) defaultNetworkBridge := "docker0" d := daemon.New(t) defer d.Stop(t) diff --git a/components/engine/integration/system/event_test.go b/components/engine/integration/system/event_test.go index 9156edf4f2..b1966fe6ce 100644 --- a/components/engine/integration/system/event_test.go +++ b/components/engine/integration/system/event_test.go @@ -13,15 +13,18 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/strslice" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration/internal/container" "github.com/docker/docker/internal/test/request" req "github.com/docker/docker/internal/test/request" "github.com/docker/docker/pkg/jsonmessage" "github.com/gotestyourself/gotestyourself/assert" is "github.com/gotestyourself/gotestyourself/assert/cmp" + "github.com/gotestyourself/gotestyourself/skip" ) -func TestEvents(t *testing.T) { +func TestEventsExecDie(t *testing.T) { + skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.36"), "broken in earlier versions") defer setupTest(t)() ctx := context.Background() client := request.NewAPIClient(t) diff --git a/components/engine/integration/volume/volume_test.go b/components/engine/integration/volume/volume_test.go index 36822bb447..d7014ec3ac 100644 --- a/components/engine/integration/volume/volume_test.go +++ b/components/engine/integration/volume/volume_test.go @@ -54,9 +54,9 @@ func TestVolumesRemove(t *testing.T) { client := request.NewAPIClient(t) ctx := context.Background() - prefix, _ := getPrefixAndSlashFromDaemonPlatform() + prefix, slash := getPrefixAndSlashFromDaemonPlatform() - id := container.Create(t, ctx, client, container.WithVolume(prefix+"foo")) + id := container.Create(t, ctx, client, container.WithVolume(prefix+slash+"foo")) c, err := client.ContainerInspect(ctx, id) assert.NilError(t, err) @@ -75,6 +75,7 @@ func TestVolumesRemove(t *testing.T) { } func TestVolumesInspect(t *testing.T) { + skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") defer setupTest(t)() client := request.NewAPIClient(t) ctx := context.Background() From 9e6796b6521a459640d40fac07d3da74e7a951a3 Mon Sep 17 00:00:00 2001 From: weipeng Date: Wed, 16 May 2018 09:15:43 +0800 Subject: [PATCH 4/7] Fix typos Signed-off-by: weipeng Upstream-commit: f781ec45b5c1745279f0429c2b7f19c793efcb85 Component: engine --- components/engine/client/ping_test.go | 2 +- components/engine/client/service_create.go | 2 +- components/engine/daemon/daemon_linux_test.go | 2 +- components/engine/daemon/graphdriver/lcow/lcow.go | 2 +- components/engine/reports/2017-06-05.md | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/engine/client/ping_test.go b/components/engine/client/ping_test.go index 785dfc00fb..a26a136e3e 100644 --- a/components/engine/client/ping_test.go +++ b/components/engine/client/ping_test.go @@ -14,7 +14,7 @@ import ( // TestPingFail tests that when a server sends a non-successful response that we // can still grab API details, when set. -// Some of this is just excercising the code paths to make sure there are no +// Some of this is just exercising the code paths to make sure there are no // panics. func TestPingFail(t *testing.T) { var withHeader bool diff --git a/components/engine/client/service_create.go b/components/engine/client/service_create.go index 871460c7b6..8d08271689 100644 --- a/components/engine/client/service_create.go +++ b/components/engine/client/service_create.go @@ -136,7 +136,7 @@ func imageWithDigestString(image string, dgst digest.Digest) string { // imageWithTagString takes an image string, and returns a tagged image // string, adding a 'latest' tag if one was not provided. It returns an -// emptry string if a canonical reference was provided +// empty string if a canonical reference was provided func imageWithTagString(image string) string { namedRef, err := reference.ParseNormalizedNamed(image) if err == nil { diff --git a/components/engine/daemon/daemon_linux_test.go b/components/engine/daemon/daemon_linux_test.go index c6699ed1e1..3bbbc814c6 100644 --- a/components/engine/daemon/daemon_linux_test.go +++ b/components/engine/daemon/daemon_linux_test.go @@ -116,7 +116,7 @@ func TestNotCleanupMounts(t *testing.T) { } // TestTmpfsDevShmSizeOverride checks that user-specified /dev/tmpfs mount -// size is not overriden by the default shmsize (that should only be used +// size is not overridden by the default shmsize (that should only be used // for default /dev/shm (as in "shareable" and "private" ipc modes). // https://github.com/moby/moby/issues/35271 func TestTmpfsDevShmSizeOverride(t *testing.T) { diff --git a/components/engine/daemon/graphdriver/lcow/lcow.go b/components/engine/daemon/graphdriver/lcow/lcow.go index 9cc06201e0..649beccdc6 100644 --- a/components/engine/daemon/graphdriver/lcow/lcow.go +++ b/components/engine/daemon/graphdriver/lcow/lcow.go @@ -411,7 +411,7 @@ func (d *Driver) terminateServiceVM(id, context string, force bool) (err error) svm.signalStopFinished(err) }() - // Now it's possible that the serivce VM failed to start and now we are trying to terminate it. + // Now it's possible that the service VM failed to start and now we are trying to terminate it. // In this case, we will relay the error to the goroutines waiting for this vm to stop. if err := svm.getStartError(); err != nil { logrus.Debugf("lcowdriver: terminateservicevm: %s had failed to start up: %s", id, err) diff --git a/components/engine/reports/2017-06-05.md b/components/engine/reports/2017-06-05.md index 8e2cc3c458..63679ed033 100644 --- a/components/engine/reports/2017-06-05.md +++ b/components/engine/reports/2017-06-05.md @@ -4,7 +4,7 @@ A daily meeting is hosted on [slack](https://dockercommunity.slack.com) every business day at 9am PST on the channel `#moby-project`. Lots of discussion happened during this meeting to kickstart the project, but now that we have the forums, we see less activity there. -We are discussing the future of this meeting [here](https://forums.mobyproject.org/t/of-standups-future), we will possibily move the meeting +We are discussing the future of this meeting [here](https://forums.mobyproject.org/t/of-standups-future), we will possibility move the meeting to weekly. ## Topics discussed last week @@ -33,4 +33,4 @@ The builder dev report can be found [here](builder/2017-06-05.md) ### LinuxKit -The LinuxKit dev report can be found [here](https://github.com/linuxkit/linuxkit/blob/master/reports/2017-06-03.md) \ No newline at end of file +The LinuxKit dev report can be found [here](https://github.com/linuxkit/linuxkit/blob/master/reports/2017-06-03.md) From 42dc03897a64ee3333614c0e78660d8290ddb311 Mon Sep 17 00:00:00 2001 From: Dennis Chen Date: Wed, 16 May 2018 09:21:55 +0800 Subject: [PATCH 5/7] Fix flaky test case of `TestExecInteractiveStdinClose` This issue has been reported by issue #36877. The purpose of this test case is for the regression test of #12546, so we only need to make sure the essential of the testing is still in the way to check that while not disturbed by some testing noises, which is exactly what this PR want to do. Signed-off-by: Dennis Chen Upstream-commit: 96abf9f59ebd350cc9a70034b4d30279e6ae04e4 Component: engine --- .../engine/integration-cli/docker_cli_exec_unix_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/engine/integration-cli/docker_cli_exec_unix_test.go b/components/engine/integration-cli/docker_cli_exec_unix_test.go index 5d8efc70d0..6608a7b704 100644 --- a/components/engine/integration-cli/docker_cli_exec_unix_test.go +++ b/components/engine/integration-cli/docker_cli_exec_unix_test.go @@ -33,7 +33,9 @@ func (s *DockerSuite) TestExecInteractiveStdinClose(c *check.C) { select { case err := <-ch: c.Assert(err, checker.IsNil) - output := b.String() + bs := b.Bytes() + bs = bytes.Trim(bs, "\x00") + output := string(bs[:]) c.Assert(strings.TrimSpace(output), checker.Equals, "hello") case <-time.After(5 * time.Second): c.Fatal("timed out running docker exec") From 422bb44235f25e1fccbf2676739c2dbc3d557e44 Mon Sep 17 00:00:00 2001 From: Mathieu Champlon Date: Tue, 15 May 2018 15:12:30 +0200 Subject: [PATCH 6/7] Make client underlying HTTP client accessible Signed-off-by: Mathieu Champlon Upstream-commit: 5a84124739a809bcdb5830fd385440027ddd910f Component: engine --- components/engine/client/client.go | 5 +++++ components/engine/client/interface.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/components/engine/client/client.go b/components/engine/client/client.go index b8428128bb..b874b3b522 100644 --- a/components/engine/client/client.go +++ b/components/engine/client/client.go @@ -356,6 +356,11 @@ func (cli *Client) DaemonHost() string { return cli.host } +// HTTPClient returns a copy of the HTTP client bound to the server +func (cli *Client) HTTPClient() *http.Client { + return &*cli.client +} + // ParseHostURL parses a url string, validates the string is a host url, and // returns the parsed URL func ParseHostURL(host string) (*url.URL, error) { diff --git a/components/engine/client/interface.go b/components/engine/client/interface.go index 8ab25591c0..0487a0b9f3 100644 --- a/components/engine/client/interface.go +++ b/components/engine/client/interface.go @@ -4,6 +4,7 @@ import ( "context" "io" "net" + "net/http" "time" "github.com/docker/docker/api/types" @@ -33,6 +34,7 @@ type CommonAPIClient interface { VolumeAPIClient ClientVersion() string DaemonHost() string + HTTPClient() *http.Client ServerVersion(ctx context.Context) (types.Version, error) NegotiateAPIVersion(ctx context.Context) NegotiateAPIVersionPing(types.Ping) From 7d44629ea2c739e7803acc77b84ee8dd2a8c4746 Mon Sep 17 00:00:00 2001 From: chenyuzhu Date: Wed, 16 May 2018 09:06:43 +0800 Subject: [PATCH 7/7] Fix typos Signed-off-by: chenyuzhu Upstream-commit: 5ac0d2f0b83e65f49b490e9d20c7a5b0e65f8e55 Component: engine --- components/engine/pkg/fileutils/fileutils.go | 2 +- components/engine/pkg/namesgenerator/names-generator.go | 2 +- components/engine/pkg/stdcopy/stdcopy_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/engine/pkg/fileutils/fileutils.go b/components/engine/pkg/fileutils/fileutils.go index 88e0f2834b..28cad499aa 100644 --- a/components/engine/pkg/fileutils/fileutils.go +++ b/components/engine/pkg/fileutils/fileutils.go @@ -13,7 +13,7 @@ import ( "github.com/sirupsen/logrus" ) -// PatternMatcher allows checking paths agaist a list of patterns +// PatternMatcher allows checking paths against a list of patterns type PatternMatcher struct { patterns []*Pattern exclusions bool diff --git a/components/engine/pkg/namesgenerator/names-generator.go b/components/engine/pkg/namesgenerator/names-generator.go index d1da8539bd..5c3395aaaa 100644 --- a/components/engine/pkg/namesgenerator/names-generator.go +++ b/components/engine/pkg/namesgenerator/names-generator.go @@ -198,7 +198,7 @@ var ( // Asima Chatterjee was an indian organic chemist noted for her research on vinca alkaloids, development of drugs for treatment of epilepsy and malaria - https://en.wikipedia.org/wiki/Asima_Chatterjee "chatterjee", - // Pafnuty Chebyshev - Russian mathematitian. He is known fo his works on probability, statistics, mechanics, analytical geometry and number theory https://en.wikipedia.org/wiki/Pafnuty_Chebyshev + // Pafnuty Chebyshev - Russian mathematician. He is known fo his works on probability, statistics, mechanics, analytical geometry and number theory https://en.wikipedia.org/wiki/Pafnuty_Chebyshev "chebyshev", //Claude Shannon - The father of information theory and founder of digital circuit design theory. (https://en.wikipedia.org/wiki/Claude_Shannon) diff --git a/components/engine/pkg/stdcopy/stdcopy_test.go b/components/engine/pkg/stdcopy/stdcopy_test.go index 2ec0c320d7..63edb855e5 100644 --- a/components/engine/pkg/stdcopy/stdcopy_test.go +++ b/components/engine/pkg/stdcopy/stdcopy_test.go @@ -23,7 +23,7 @@ func TestWriteWithUninitializedStdWriter(t *testing.T) { } n, err := writer.Write([]byte("Something here")) if n != 0 || err == nil { - t.Fatalf("Should fail when given an uncomplete or uninitialized StdWriter") + t.Fatalf("Should fail when given an incomplete or uninitialized StdWriter") } }