|
@@ -8,7 +8,6 @@ import (
|
|
"io"
|
|
"io"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"net/http"
|
|
- "net/http/httputil"
|
|
|
|
"net/url"
|
|
"net/url"
|
|
"os"
|
|
"os"
|
|
"path/filepath"
|
|
"path/filepath"
|
|
@@ -22,6 +21,7 @@ import (
|
|
mounttypes "github.com/docker/docker/api/types/mount"
|
|
mounttypes "github.com/docker/docker/api/types/mount"
|
|
networktypes "github.com/docker/docker/api/types/network"
|
|
networktypes "github.com/docker/docker/api/types/network"
|
|
"github.com/docker/docker/integration-cli/checker"
|
|
"github.com/docker/docker/integration-cli/checker"
|
|
|
|
+ "github.com/docker/docker/integration-cli/request"
|
|
"github.com/docker/docker/pkg/ioutils"
|
|
"github.com/docker/docker/pkg/ioutils"
|
|
"github.com/docker/docker/pkg/mount"
|
|
"github.com/docker/docker/pkg/mount"
|
|
"github.com/docker/docker/pkg/stringid"
|
|
"github.com/docker/docker/pkg/stringid"
|
|
@@ -37,7 +37,7 @@ func (s *DockerSuite) TestContainerAPIGetAll(c *check.C) {
|
|
name := "getall"
|
|
name := "getall"
|
|
dockerCmd(c, "run", "--name", name, "busybox", "true")
|
|
dockerCmd(c, "run", "--name", name, "busybox", "true")
|
|
|
|
|
|
- status, body, err := sockRequest("GET", "/containers/json?all=1", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("GET", "/containers/json?all=1", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -57,7 +57,7 @@ func (s *DockerSuite) TestContainerAPIGetAll(c *check.C) {
|
|
func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *check.C) {
|
|
func (s *DockerSuite) TestContainerAPIGetJSONNoFieldsOmitted(c *check.C) {
|
|
dockerCmd(c, "run", "busybox", "true")
|
|
dockerCmd(c, "run", "busybox", "true")
|
|
|
|
|
|
- status, body, err := sockRequest("GET", "/containers/json?all=1", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("GET", "/containers/json?all=1", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -98,7 +98,7 @@ func (s *DockerSuite) TestContainerAPIPsOmitFields(c *check.C) {
|
|
port := 80
|
|
port := 80
|
|
runSleepingContainer(c, "--name", name, "--expose", strconv.Itoa(port))
|
|
runSleepingContainer(c, "--name", name, "--expose", strconv.Itoa(port))
|
|
|
|
|
|
- status, body, err := sockRequest("GET", "/containers/json?all=1", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("GET", "/containers/json?all=1", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -130,7 +130,7 @@ func (s *DockerSuite) TestContainerAPIGetExport(c *check.C) {
|
|
name := "exportcontainer"
|
|
name := "exportcontainer"
|
|
dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test")
|
|
dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test")
|
|
|
|
|
|
- status, body, err := sockRequest("GET", "/containers/"+name+"/export", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("GET", "/containers/"+name+"/export", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -154,7 +154,7 @@ func (s *DockerSuite) TestContainerAPIGetChanges(c *check.C) {
|
|
name := "changescontainer"
|
|
name := "changescontainer"
|
|
dockerCmd(c, "run", "--name", name, "busybox", "rm", "/etc/passwd")
|
|
dockerCmd(c, "run", "--name", name, "busybox", "rm", "/etc/passwd")
|
|
|
|
|
|
- status, body, err := sockRequest("GET", "/containers/"+name+"/changes", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("GET", "/containers/"+name+"/changes", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -187,7 +187,7 @@ func (s *DockerSuite) TestGetContainerStats(c *check.C) {
|
|
}
|
|
}
|
|
bc := make(chan b, 1)
|
|
bc := make(chan b, 1)
|
|
go func() {
|
|
go func() {
|
|
- status, body, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("GET", "/containers/"+name+"/stats", nil, daemonHost())
|
|
bc <- b{status, body, err}
|
|
bc <- b{status, body, err}
|
|
}()
|
|
}()
|
|
|
|
|
|
@@ -218,7 +218,7 @@ func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) {
|
|
buf := &testutil.ChannelBuffer{make(chan []byte, 1)}
|
|
buf := &testutil.ChannelBuffer{make(chan []byte, 1)}
|
|
defer buf.Close()
|
|
defer buf.Close()
|
|
|
|
|
|
- _, body, err := sockRequestRaw("GET", "/containers/"+id+"/stats?stream=1", nil, "application/json")
|
|
|
|
|
|
+ _, body, err := request.SockRequestRaw("GET", "/containers/"+id+"/stats?stream=1", nil, "application/json", daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
defer body.Close()
|
|
defer body.Close()
|
|
|
|
|
|
@@ -257,7 +257,7 @@ func (s *DockerSuite) TestGetContainerStatsStream(c *check.C) {
|
|
}
|
|
}
|
|
bc := make(chan b, 1)
|
|
bc := make(chan b, 1)
|
|
go func() {
|
|
go func() {
|
|
- status, body, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("GET", "/containers/"+name+"/stats", nil, daemonHost())
|
|
bc <- b{status, body, err}
|
|
bc <- b{status, body, err}
|
|
}()
|
|
}()
|
|
|
|
|
|
@@ -293,7 +293,7 @@ func (s *DockerSuite) TestGetContainerStatsNoStream(c *check.C) {
|
|
}
|
|
}
|
|
bc := make(chan b, 1)
|
|
bc := make(chan b, 1)
|
|
go func() {
|
|
go func() {
|
|
- status, body, err := sockRequest("GET", "/containers/"+name+"/stats?stream=0", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("GET", "/containers/"+name+"/stats?stream=0", nil, daemonHost())
|
|
bc <- b{status, body, err}
|
|
bc <- b{status, body, err}
|
|
}()
|
|
}()
|
|
|
|
|
|
@@ -329,7 +329,7 @@ func (s *DockerSuite) TestGetStoppedContainerStats(c *check.C) {
|
|
// We expect an immediate response, but if it's not immediate, the test would hang, so put it in a goroutine
|
|
// We expect an immediate response, but if it's not immediate, the test would hang, so put it in a goroutine
|
|
// below we'll check this on a timeout.
|
|
// below we'll check this on a timeout.
|
|
go func() {
|
|
go func() {
|
|
- resp, body, err := sockRequestRaw("GET", "/containers/"+name+"/stats", nil, "")
|
|
|
|
|
|
+ resp, body, err := request.SockRequestRaw("GET", "/containers/"+name+"/stats", nil, "", daemonHost())
|
|
body.Close()
|
|
body.Close()
|
|
chResp <- stats{resp.StatusCode, err}
|
|
chResp <- stats{resp.StatusCode, err}
|
|
}()
|
|
}()
|
|
@@ -350,7 +350,7 @@ func (s *DockerSuite) TestContainerAPIPause(c *check.C) {
|
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "sleep", "30")
|
|
out, _ := dockerCmd(c, "run", "-d", "busybox", "sleep", "30")
|
|
ContainerID := strings.TrimSpace(out)
|
|
ContainerID := strings.TrimSpace(out)
|
|
|
|
|
|
- status, _, err := sockRequest("POST", "/containers/"+ContainerID+"/pause", nil)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("POST", "/containers/"+ContainerID+"/pause", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
|
|
|
|
@@ -361,7 +361,7 @@ func (s *DockerSuite) TestContainerAPIPause(c *check.C) {
|
|
c.Fatalf("there should be one paused container and not %d", len(pausedContainers))
|
|
c.Fatalf("there should be one paused container and not %d", len(pausedContainers))
|
|
}
|
|
}
|
|
|
|
|
|
- status, _, err = sockRequest("POST", "/containers/"+ContainerID+"/unpause", nil)
|
|
|
|
|
|
+ status, _, err = request.SockRequest("POST", "/containers/"+ContainerID+"/unpause", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
|
|
|
|
@@ -381,7 +381,7 @@ func (s *DockerSuite) TestContainerAPITop(c *check.C) {
|
|
Processes [][]string
|
|
Processes [][]string
|
|
}
|
|
}
|
|
var top topResp
|
|
var top topResp
|
|
- status, b, err := sockRequest("GET", "/containers/"+id+"/top?ps_args=aux", nil)
|
|
|
|
|
|
+ status, b, err := request.SockRequest("GET", "/containers/"+id+"/top?ps_args=aux", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(json.Unmarshal(b, &top), checker.IsNil)
|
|
c.Assert(json.Unmarshal(b, &top), checker.IsNil)
|
|
@@ -406,7 +406,7 @@ func (s *DockerSuite) TestContainerAPITopWindows(c *check.C) {
|
|
Processes [][]string
|
|
Processes [][]string
|
|
}
|
|
}
|
|
var top topResp
|
|
var top topResp
|
|
- status, b, err := sockRequest("GET", "/containers/"+id+"/top", nil)
|
|
|
|
|
|
+ status, b, err := request.SockRequest("GET", "/containers/"+id+"/top", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(json.Unmarshal(b, &top), checker.IsNil)
|
|
c.Assert(json.Unmarshal(b, &top), checker.IsNil)
|
|
@@ -434,7 +434,7 @@ func (s *DockerSuite) TestContainerAPICommit(c *check.C) {
|
|
dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test")
|
|
dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test")
|
|
|
|
|
|
name := "testcontainerapicommit"
|
|
name := "testcontainerapicommit"
|
|
- status, b, err := sockRequest("POST", "/commit?repo="+name+"&testtag=tag&container="+cName, nil)
|
|
|
|
|
|
+ status, b, err := request.SockRequest("POST", "/commit?repo="+name+"&testtag=tag&container="+cName, nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
|
|
|
|
@@ -460,7 +460,7 @@ func (s *DockerSuite) TestContainerAPICommitWithLabelInConfig(c *check.C) {
|
|
}
|
|
}
|
|
|
|
|
|
name := "testcontainerapicommitwithconfig"
|
|
name := "testcontainerapicommitwithconfig"
|
|
- status, b, err := sockRequest("POST", "/commit?repo="+name+"&container="+cName, config)
|
|
|
|
|
|
+ status, b, err := request.SockRequest("POST", "/commit?repo="+name+"&container="+cName, config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
|
|
|
|
@@ -502,7 +502,7 @@ func (s *DockerSuite) TestContainerAPIBadPort(c *check.C) {
|
|
jsonData := bytes.NewBuffer(nil)
|
|
jsonData := bytes.NewBuffer(nil)
|
|
json.NewEncoder(jsonData).Encode(config)
|
|
json.NewEncoder(jsonData).Encode(config)
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(getErrorMessage(c, body), checker.Equals, `invalid port specification: "aa80"`, check.Commentf("Incorrect error msg: %s", body))
|
|
c.Assert(getErrorMessage(c, body), checker.Equals, `invalid port specification: "aa80"`, check.Commentf("Incorrect error msg: %s", body))
|
|
@@ -514,7 +514,7 @@ func (s *DockerSuite) TestContainerAPICreate(c *check.C) {
|
|
"Cmd": []string{"/bin/sh", "-c", "touch /test && ls /test"},
|
|
"Cmd": []string{"/bin/sh", "-c", "touch /test && ls /test"},
|
|
}
|
|
}
|
|
|
|
|
|
- status, b, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, b, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
|
|
|
|
@@ -531,7 +531,7 @@ func (s *DockerSuite) TestContainerAPICreate(c *check.C) {
|
|
func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *check.C) {
|
|
func (s *DockerSuite) TestContainerAPICreateEmptyConfig(c *check.C) {
|
|
config := map[string]interface{}{}
|
|
config := map[string]interface{}{}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
|
|
|
|
@@ -552,7 +552,7 @@ func (s *DockerSuite) TestContainerAPICreateMultipleNetworksConfig(c *check.C) {
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusBadRequest)
|
|
c.Assert(status, checker.Equals, http.StatusBadRequest)
|
|
msg := getErrorMessage(c, body)
|
|
msg := getErrorMessage(c, body)
|
|
@@ -570,14 +570,14 @@ func (s *DockerSuite) TestContainerAPICreateWithHostName(c *check.C) {
|
|
"Hostname": hostName,
|
|
"Hostname": hostName,
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
|
|
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
c.Assert(json.Unmarshal(body, &container), checker.IsNil)
|
|
c.Assert(json.Unmarshal(body, &container), checker.IsNil)
|
|
|
|
|
|
- status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil)
|
|
|
|
|
|
+ status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -593,14 +593,14 @@ func (s *DockerSuite) TestContainerAPICreateWithDomainName(c *check.C) {
|
|
"Domainname": domainName,
|
|
"Domainname": domainName,
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
|
|
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
c.Assert(json.Unmarshal(body, &container), checker.IsNil)
|
|
c.Assert(json.Unmarshal(body, &container), checker.IsNil)
|
|
|
|
|
|
- status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil)
|
|
|
|
|
|
+ status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -628,14 +628,14 @@ func UtilCreateNetworkMode(c *check.C, networkMode string) {
|
|
"HostConfig": map[string]interface{}{"NetworkMode": networkMode},
|
|
"HostConfig": map[string]interface{}{"NetworkMode": networkMode},
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
|
|
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
c.Assert(json.Unmarshal(body, &container), checker.IsNil)
|
|
c.Assert(json.Unmarshal(body, &container), checker.IsNil)
|
|
|
|
|
|
- status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil)
|
|
|
|
|
|
+ status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -653,14 +653,14 @@ func (s *DockerSuite) TestContainerAPICreateWithCpuSharesCpuset(c *check.C) {
|
|
"CpusetCpus": "0",
|
|
"CpusetCpus": "0",
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
|
|
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
c.Assert(json.Unmarshal(body, &container), checker.IsNil)
|
|
c.Assert(json.Unmarshal(body, &container), checker.IsNil)
|
|
|
|
|
|
- status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil)
|
|
|
|
|
|
+ status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -683,7 +683,7 @@ func (s *DockerSuite) TestContainerAPIVerifyHeader(c *check.C) {
|
|
create := func(ct string) (*http.Response, io.ReadCloser, error) {
|
|
create := func(ct string) (*http.Response, io.ReadCloser, error) {
|
|
jsonData := bytes.NewBuffer(nil)
|
|
jsonData := bytes.NewBuffer(nil)
|
|
c.Assert(json.NewEncoder(jsonData).Encode(config), checker.IsNil)
|
|
c.Assert(json.NewEncoder(jsonData).Encode(config), checker.IsNil)
|
|
- return sockRequestRaw("POST", "/containers/create", jsonData, ct)
|
|
|
|
|
|
+ return request.SockRequestRaw("POST", "/containers/create", jsonData, ct, daemonHost())
|
|
}
|
|
}
|
|
|
|
|
|
// Try with no content-type
|
|
// Try with no content-type
|
|
@@ -719,7 +719,7 @@ func (s *DockerSuite) TestContainerAPIInvalidPortSyntax(c *check.C) {
|
|
}
|
|
}
|
|
}`
|
|
}`
|
|
|
|
|
|
- res, body, err := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json")
|
|
|
|
|
|
+ res, body, err := request.SockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json", daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError)
|
|
|
|
|
|
@@ -739,7 +739,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyInvalidPolicyName(c *check.C)
|
|
}
|
|
}
|
|
}`
|
|
}`
|
|
|
|
|
|
- res, body, err := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json")
|
|
|
|
|
|
+ res, body, err := request.SockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json", daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError)
|
|
|
|
|
|
@@ -759,7 +759,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyRetryMismatch(c *check.C) {
|
|
}
|
|
}
|
|
}`
|
|
}`
|
|
|
|
|
|
- res, body, err := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json")
|
|
|
|
|
|
+ res, body, err := request.SockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json", daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError)
|
|
|
|
|
|
@@ -779,7 +779,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyNegativeRetryCount(c *check.C
|
|
}
|
|
}
|
|
}`
|
|
}`
|
|
|
|
|
|
- res, body, err := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json")
|
|
|
|
|
|
+ res, body, err := request.SockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json", daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusInternalServerError)
|
|
|
|
|
|
@@ -799,7 +799,7 @@ func (s *DockerSuite) TestContainerAPIRestartPolicyDefaultRetryCount(c *check.C)
|
|
}
|
|
}
|
|
}`
|
|
}`
|
|
|
|
|
|
- res, _, err := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json")
|
|
|
|
|
|
+ res, _, err := request.SockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json", daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusCreated)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusCreated)
|
|
}
|
|
}
|
|
@@ -830,7 +830,7 @@ func (s *DockerSuite) TestContainerAPIPostCreateNull(c *check.C) {
|
|
"NetworkDisabled":false,
|
|
"NetworkDisabled":false,
|
|
"OnBuild":null}`
|
|
"OnBuild":null}`
|
|
|
|
|
|
- res, body, err := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json")
|
|
|
|
|
|
+ res, body, err := request.SockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json", daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusCreated)
|
|
c.Assert(res.StatusCode, checker.Equals, http.StatusCreated)
|
|
|
|
|
|
@@ -861,7 +861,7 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *check.C) {
|
|
"Memory": 524287
|
|
"Memory": 524287
|
|
}`
|
|
}`
|
|
|
|
|
|
- res, body, err := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json")
|
|
|
|
|
|
+ res, body, err := request.SockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json", daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
b, err2 := testutil.ReadBody(body)
|
|
b, err2 := testutil.ReadBody(body)
|
|
c.Assert(err2, checker.IsNil)
|
|
c.Assert(err2, checker.IsNil)
|
|
@@ -875,7 +875,7 @@ func (s *DockerSuite) TestContainerAPIRename(c *check.C) {
|
|
|
|
|
|
containerID := strings.TrimSpace(out)
|
|
containerID := strings.TrimSpace(out)
|
|
newName := "TestContainerAPIRenameNew"
|
|
newName := "TestContainerAPIRenameNew"
|
|
- statusCode, _, err := sockRequest("POST", "/containers/"+containerID+"/rename?name="+newName, nil)
|
|
|
|
|
|
+ statusCode, _, err := request.SockRequest("POST", "/containers/"+containerID+"/rename?name="+newName, nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
// 204 No Content is expected, not 200
|
|
// 204 No Content is expected, not 200
|
|
c.Assert(statusCode, checker.Equals, http.StatusNoContent)
|
|
c.Assert(statusCode, checker.Equals, http.StatusNoContent)
|
|
@@ -888,7 +888,7 @@ func (s *DockerSuite) TestContainerAPIKill(c *check.C) {
|
|
name := "test-api-kill"
|
|
name := "test-api-kill"
|
|
runSleepingContainer(c, "-i", "--name", name)
|
|
runSleepingContainer(c, "-i", "--name", name)
|
|
|
|
|
|
- status, _, err := sockRequest("POST", "/containers/"+name+"/kill", nil)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("POST", "/containers/"+name+"/kill", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
|
|
|
|
@@ -900,7 +900,7 @@ func (s *DockerSuite) TestContainerAPIRestart(c *check.C) {
|
|
name := "test-api-restart"
|
|
name := "test-api-restart"
|
|
runSleepingContainer(c, "-di", "--name", name)
|
|
runSleepingContainer(c, "-di", "--name", name)
|
|
|
|
|
|
- status, _, err := sockRequest("POST", "/containers/"+name+"/restart?t=1", nil)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("POST", "/containers/"+name+"/restart?t=1", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil)
|
|
c.Assert(waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil)
|
|
@@ -912,7 +912,7 @@ func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *check.C) {
|
|
id := strings.TrimSpace(out)
|
|
id := strings.TrimSpace(out)
|
|
c.Assert(waitRun(id), checker.IsNil)
|
|
c.Assert(waitRun(id), checker.IsNil)
|
|
|
|
|
|
- status, _, err := sockRequest("POST", "/containers/"+name+"/restart", nil)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("POST", "/containers/"+name+"/restart", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil)
|
|
c.Assert(waitInspect(name, "{{ .State.Restarting }} {{ .State.Running }}", "false true", 15*time.Second), checker.IsNil)
|
|
@@ -926,16 +926,16 @@ func (s *DockerSuite) TestContainerAPIStart(c *check.C) {
|
|
"OpenStdin": true,
|
|
"OpenStdin": true,
|
|
}
|
|
}
|
|
|
|
|
|
- status, _, err := sockRequest("POST", "/containers/create?name="+name, config)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
|
|
|
|
- status, _, err = sockRequest("POST", "/containers/"+name+"/start", nil)
|
|
|
|
|
|
+ status, _, err = request.SockRequest("POST", "/containers/"+name+"/start", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
|
|
|
|
// second call to start should give 304
|
|
// second call to start should give 304
|
|
- status, _, err = sockRequest("POST", "/containers/"+name+"/start", nil)
|
|
|
|
|
|
+ status, _, err = request.SockRequest("POST", "/containers/"+name+"/start", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
// TODO(tibor): figure out why this doesn't work on windows
|
|
// TODO(tibor): figure out why this doesn't work on windows
|
|
@@ -948,13 +948,13 @@ func (s *DockerSuite) TestContainerAPIStop(c *check.C) {
|
|
name := "test-api-stop"
|
|
name := "test-api-stop"
|
|
runSleepingContainer(c, "-i", "--name", name)
|
|
runSleepingContainer(c, "-i", "--name", name)
|
|
|
|
|
|
- status, _, err := sockRequest("POST", "/containers/"+name+"/stop?t=30", nil)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("POST", "/containers/"+name+"/stop?t=30", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil)
|
|
c.Assert(waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil)
|
|
|
|
|
|
// second call to start should give 304
|
|
// second call to start should give 304
|
|
- status, _, err = sockRequest("POST", "/containers/"+name+"/stop?t=30", nil)
|
|
|
|
|
|
+ status, _, err = request.SockRequest("POST", "/containers/"+name+"/stop?t=30", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNotModified)
|
|
c.Assert(status, checker.Equals, http.StatusNotModified)
|
|
}
|
|
}
|
|
@@ -968,7 +968,7 @@ func (s *DockerSuite) TestContainerAPIWait(c *check.C) {
|
|
}
|
|
}
|
|
dockerCmd(c, "run", "--name", name, "busybox", sleepCmd, "2")
|
|
dockerCmd(c, "run", "--name", name, "busybox", sleepCmd, "2")
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/"+name+"/wait", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/"+name+"/wait", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil)
|
|
c.Assert(waitInspect(name, "{{ .State.Running }}", "false", 60*time.Second), checker.IsNil)
|
|
@@ -986,7 +986,7 @@ func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *check.C) {
|
|
Resource: "/test.txt",
|
|
Resource: "/test.txt",
|
|
}
|
|
}
|
|
|
|
|
|
- status, _, err := sockRequest("POST", "/containers/"+name+"/copy", postData)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("POST", "/containers/"+name+"/copy", postData, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNotFound)
|
|
c.Assert(status, checker.Equals, http.StatusNotFound)
|
|
}
|
|
}
|
|
@@ -1000,7 +1000,7 @@ func (s *DockerSuite) TestContainerAPICopyPre124(c *check.C) {
|
|
Resource: "/test.txt",
|
|
Resource: "/test.txt",
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/v1.23/containers/"+name+"/copy", postData)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/v1.23/containers/"+name+"/copy", postData, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -1030,7 +1030,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPr124(c *check.C) {
|
|
Resource: "",
|
|
Resource: "",
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/v1.23/containers/"+name+"/copy", postData)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/v1.23/containers/"+name+"/copy", postData, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(string(body), checker.Matches, "Path cannot be empty\n")
|
|
c.Assert(string(body), checker.Matches, "Path cannot be empty\n")
|
|
@@ -1045,7 +1045,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *check.C)
|
|
Resource: "/notexist",
|
|
Resource: "/notexist",
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/v1.23/containers/"+name+"/copy", postData)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/v1.23/containers/"+name+"/copy", postData, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(string(body), checker.Matches, "Could not find the file /notexist in container "+name+"\n")
|
|
c.Assert(string(body), checker.Matches, "Could not find the file /notexist in container "+name+"\n")
|
|
@@ -1057,7 +1057,7 @@ func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *check.C) {
|
|
Resource: "/something",
|
|
Resource: "/something",
|
|
}
|
|
}
|
|
|
|
|
|
- status, _, err := sockRequest("POST", "/v1.23/containers/notexists/copy", postData)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("POST", "/v1.23/containers/notexists/copy", postData, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNotFound)
|
|
c.Assert(status, checker.Equals, http.StatusNotFound)
|
|
}
|
|
}
|
|
@@ -1070,13 +1070,13 @@ func (s *DockerSuite) TestContainerAPIDelete(c *check.C) {
|
|
|
|
|
|
dockerCmd(c, "stop", id)
|
|
dockerCmd(c, "stop", id)
|
|
|
|
|
|
- status, _, err := sockRequest("DELETE", "/containers/"+id, nil)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("DELETE", "/containers/"+id, nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *check.C) {
|
|
func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *check.C) {
|
|
- status, body, err := sockRequest("DELETE", "/containers/doesnotexist", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("DELETE", "/containers/doesnotexist", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNotFound)
|
|
c.Assert(status, checker.Equals, http.StatusNotFound)
|
|
c.Assert(getErrorMessage(c, body), checker.Matches, "No such container: doesnotexist")
|
|
c.Assert(getErrorMessage(c, body), checker.Matches, "No such container: doesnotexist")
|
|
@@ -1088,7 +1088,7 @@ func (s *DockerSuite) TestContainerAPIDeleteForce(c *check.C) {
|
|
id := strings.TrimSpace(out)
|
|
id := strings.TrimSpace(out)
|
|
c.Assert(waitRun(id), checker.IsNil)
|
|
c.Assert(waitRun(id), checker.IsNil)
|
|
|
|
|
|
- status, _, err := sockRequest("DELETE", "/containers/"+id+"?force=1", nil)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("DELETE", "/containers/"+id+"?force=1", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
}
|
|
}
|
|
@@ -1109,7 +1109,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *check.C) {
|
|
links := inspectFieldJSON(c, id2, "HostConfig.Links")
|
|
links := inspectFieldJSON(c, id2, "HostConfig.Links")
|
|
c.Assert(links, checker.Equals, "[\"/tlink1:/tlink2/tlink1\"]", check.Commentf("expected to have links between containers"))
|
|
c.Assert(links, checker.Equals, "[\"/tlink1:/tlink2/tlink1\"]", check.Commentf("expected to have links between containers"))
|
|
|
|
|
|
- status, b, err := sockRequest("DELETE", "/containers/tlink2/tlink1?link=1", nil)
|
|
|
|
|
|
+ status, b, err := request.SockRequest("DELETE", "/containers/tlink2/tlink1?link=1", nil, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusNoContent, check.Commentf(string(b)))
|
|
c.Assert(status, check.Equals, http.StatusNoContent, check.Commentf(string(b)))
|
|
|
|
|
|
@@ -1123,7 +1123,7 @@ func (s *DockerSuite) TestContainerAPIDeleteConflict(c *check.C) {
|
|
id := strings.TrimSpace(out)
|
|
id := strings.TrimSpace(out)
|
|
c.Assert(waitRun(id), checker.IsNil)
|
|
c.Assert(waitRun(id), checker.IsNil)
|
|
|
|
|
|
- status, _, err := sockRequest("DELETE", "/containers/"+id, nil)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("DELETE", "/containers/"+id, nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusConflict)
|
|
c.Assert(status, checker.Equals, http.StatusConflict)
|
|
}
|
|
}
|
|
@@ -1145,7 +1145,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) {
|
|
_, err = os.Stat(source)
|
|
_, err = os.Stat(source)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
- status, _, err := sockRequest("DELETE", "/containers/"+id+"?v=1&force=1", nil)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("DELETE", "/containers/"+id+"?v=1&force=1", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
_, err = os.Stat(source)
|
|
_, err = os.Stat(source)
|
|
@@ -1154,30 +1154,21 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) {
|
|
|
|
|
|
// Regression test for https://github.com/docker/docker/issues/6231
|
|
// Regression test for https://github.com/docker/docker/issues/6231
|
|
func (s *DockerSuite) TestContainerAPIChunkedEncoding(c *check.C) {
|
|
func (s *DockerSuite) TestContainerAPIChunkedEncoding(c *check.C) {
|
|
- conn, err := sockConn(time.Duration(10*time.Second), "")
|
|
|
|
- c.Assert(err, checker.IsNil)
|
|
|
|
- client := httputil.NewClientConn(conn, nil)
|
|
|
|
- defer client.Close()
|
|
|
|
|
|
|
|
config := map[string]interface{}{
|
|
config := map[string]interface{}{
|
|
"Image": "busybox",
|
|
"Image": "busybox",
|
|
"Cmd": append([]string{"/bin/sh", "-c"}, sleepCommandForDaemonPlatform()...),
|
|
"Cmd": append([]string{"/bin/sh", "-c"}, sleepCommandForDaemonPlatform()...),
|
|
"OpenStdin": true,
|
|
"OpenStdin": true,
|
|
}
|
|
}
|
|
- b, err := json.Marshal(config)
|
|
|
|
- c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
- req, err := http.NewRequest("POST", "/containers/create", bytes.NewBuffer(b))
|
|
|
|
- c.Assert(err, checker.IsNil)
|
|
|
|
- req.Header.Set("Content-Type", "application/json")
|
|
|
|
- // This is a cheat to make the http request do chunked encoding
|
|
|
|
- // Otherwise (just setting the Content-Encoding to chunked) net/http will overwrite
|
|
|
|
- // https://golang.org/src/pkg/net/http/request.go?s=11980:12172
|
|
|
|
- req.ContentLength = -1
|
|
|
|
-
|
|
|
|
- resp, err := client.Do(req)
|
|
|
|
|
|
+ resp, _, err := request.Post(daemonHost(), "/containers/create", request.JSONBody(config), func(req *http.Request) error {
|
|
|
|
+ // This is a cheat to make the http request do chunked encoding
|
|
|
|
+ // Otherwise (just setting the Content-Encoding to chunked) net/http will overwrite
|
|
|
|
+ // https://golang.org/src/pkg/net/http/request.go?s=11980:12172
|
|
|
|
+ req.ContentLength = -1
|
|
|
|
+ return nil
|
|
|
|
+ })
|
|
c.Assert(err, checker.IsNil, check.Commentf("error creating container with chunked encoding"))
|
|
c.Assert(err, checker.IsNil, check.Commentf("error creating container with chunked encoding"))
|
|
- resp.Body.Close()
|
|
|
|
c.Assert(resp.StatusCode, checker.Equals, http.StatusCreated)
|
|
c.Assert(resp.StatusCode, checker.Equals, http.StatusCreated)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1187,7 +1178,7 @@ func (s *DockerSuite) TestContainerAPIPostContainerStop(c *check.C) {
|
|
containerID := strings.TrimSpace(out)
|
|
containerID := strings.TrimSpace(out)
|
|
c.Assert(waitRun(containerID), checker.IsNil)
|
|
c.Assert(waitRun(containerID), checker.IsNil)
|
|
|
|
|
|
- statusCode, _, err := sockRequest("POST", "/containers/"+containerID+"/stop", nil)
|
|
|
|
|
|
+ statusCode, _, err := request.SockRequest("POST", "/containers/"+containerID+"/stop", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
// 204 No Content is expected, not 200
|
|
// 204 No Content is expected, not 200
|
|
c.Assert(statusCode, checker.Equals, http.StatusNoContent)
|
|
c.Assert(statusCode, checker.Equals, http.StatusNoContent)
|
|
@@ -1201,7 +1192,7 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *c
|
|
Entrypoint string
|
|
Entrypoint string
|
|
Cmd []string
|
|
Cmd []string
|
|
}{"busybox", "echo", []string{"hello", "world"}}
|
|
}{"busybox", "echo", []string{"hello", "world"}}
|
|
- _, _, err := sockRequest("POST", "/containers/create?name=echotest", config)
|
|
|
|
|
|
+ _, _, err := request.SockRequest("POST", "/containers/create?name=echotest", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
out, _ := dockerCmd(c, "start", "-a", "echotest")
|
|
out, _ := dockerCmd(c, "start", "-a", "echotest")
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "hello world")
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "hello world")
|
|
@@ -1211,7 +1202,7 @@ func (s *DockerSuite) TestPostContainerAPICreateWithStringOrSliceEntrypoint(c *c
|
|
Entrypoint []string
|
|
Entrypoint []string
|
|
Cmd []string
|
|
Cmd []string
|
|
}{"busybox", []string{"echo"}, []string{"hello", "world"}}
|
|
}{"busybox", []string{"echo"}, []string{"hello", "world"}}
|
|
- _, _, err = sockRequest("POST", "/containers/create?name=echotest2", config2)
|
|
|
|
|
|
+ _, _, err = request.SockRequest("POST", "/containers/create?name=echotest2", config2, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
out, _ = dockerCmd(c, "start", "-a", "echotest2")
|
|
out, _ = dockerCmd(c, "start", "-a", "echotest2")
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "hello world")
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "hello world")
|
|
@@ -1224,7 +1215,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *check.C) {
|
|
Entrypoint string
|
|
Entrypoint string
|
|
Cmd string
|
|
Cmd string
|
|
}{"busybox", "echo", "hello world"}
|
|
}{"busybox", "echo", "hello world"}
|
|
- _, _, err := sockRequest("POST", "/containers/create?name=echotest", config)
|
|
|
|
|
|
+ _, _, err := request.SockRequest("POST", "/containers/create?name=echotest", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
out, _ := dockerCmd(c, "start", "-a", "echotest")
|
|
out, _ := dockerCmd(c, "start", "-a", "echotest")
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "hello world")
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "hello world")
|
|
@@ -1233,7 +1224,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCmd(c *check.C) {
|
|
Image string
|
|
Image string
|
|
Cmd []string
|
|
Cmd []string
|
|
}{"busybox", []string{"echo", "hello", "world"}}
|
|
}{"busybox", []string{"echo", "hello", "world"}}
|
|
- _, _, err = sockRequest("POST", "/containers/create?name=echotest2", config2)
|
|
|
|
|
|
+ _, _, err = request.SockRequest("POST", "/containers/create?name=echotest2", config2, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
out, _ = dockerCmd(c, "start", "-a", "echotest2")
|
|
out, _ = dockerCmd(c, "start", "-a", "echotest2")
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "hello world")
|
|
c.Assert(strings.TrimSpace(out), checker.Equals, "hello world")
|
|
@@ -1248,7 +1239,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *che
|
|
CapAdd string
|
|
CapAdd string
|
|
CapDrop string
|
|
CapDrop string
|
|
}{"busybox", "NET_ADMIN", "SYS_ADMIN"}
|
|
}{"busybox", "NET_ADMIN", "SYS_ADMIN"}
|
|
- status, _, err := sockRequest("POST", "/containers/create?name=capaddtest0", config)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("POST", "/containers/create?name=capaddtest0", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
|
|
|
|
@@ -1257,7 +1248,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *che
|
|
CapAdd []string
|
|
CapAdd []string
|
|
CapDrop []string
|
|
CapDrop []string
|
|
}{"busybox", []string{"NET_ADMIN", "SYS_ADMIN"}, []string{"SETGID"}}
|
|
}{"busybox", []string{"NET_ADMIN", "SYS_ADMIN"}, []string{"SETGID"}}
|
|
- status, _, err = sockRequest("POST", "/containers/create?name=capaddtest1", config2)
|
|
|
|
|
|
+ status, _, err = request.SockRequest("POST", "/containers/create?name=capaddtest1", config2, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
}
|
|
}
|
|
@@ -1268,7 +1259,7 @@ func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *check.C) {
|
|
config := struct {
|
|
config := struct {
|
|
Image string
|
|
Image string
|
|
}{"busybox"}
|
|
}{"busybox"}
|
|
- status, _, err := sockRequest("POST", "/v1.18/containers/create", config)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("POST", "/v1.18/containers/create", config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
}
|
|
}
|
|
@@ -1300,7 +1291,7 @@ func (s *DockerSuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRootfs(
|
|
query.Set("path", "/vol2/symlinkToAbsDir")
|
|
query.Set("path", "/vol2/symlinkToAbsDir")
|
|
urlPath := fmt.Sprintf("/v1.20/containers/%s/archive?%s", cID, query.Encode())
|
|
urlPath := fmt.Sprintf("/v1.20/containers/%s/archive?%s", cID, query.Encode())
|
|
|
|
|
|
- statusCode, body, err := sockRequest("PUT", urlPath, nil)
|
|
|
|
|
|
+ statusCode, body, err := request.SockRequest("PUT", urlPath, nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
if !isCpCannotCopyReadOnly(fmt.Errorf(string(body))) {
|
|
if !isCpCannotCopyReadOnly(fmt.Errorf(string(body))) {
|
|
@@ -1309,7 +1300,7 @@ func (s *DockerSuite) TestPutContainerArchiveErrSymlinkInVolumeToReadOnlyRootfs(
|
|
}
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestContainerAPIGetContainersJSONEmpty(c *check.C) {
|
|
func (s *DockerSuite) TestContainerAPIGetContainersJSONEmpty(c *check.C) {
|
|
- status, body, err := sockRequest("GET", "/containers/json?all=1", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("GET", "/containers/json?all=1", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(status, checker.Equals, http.StatusOK)
|
|
c.Assert(string(body), checker.Equals, "[]\n")
|
|
c.Assert(string(body), checker.Equals, "[]\n")
|
|
@@ -1324,7 +1315,7 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *check.C)
|
|
CpusetCpus string
|
|
CpusetCpus string
|
|
}{"busybox", "1-42,,"}
|
|
}{"busybox", "1-42,,"}
|
|
name := "wrong-cpuset-cpus"
|
|
name := "wrong-cpuset-cpus"
|
|
- status, body, err := sockRequest("POST", "/containers/create?name="+name, c1)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create?name="+name, c1, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
expected := "Invalid value 1-42,, for cpuset cpus"
|
|
expected := "Invalid value 1-42,, for cpuset cpus"
|
|
@@ -1335,7 +1326,7 @@ func (s *DockerSuite) TestPostContainersCreateWithWrongCpusetValues(c *check.C)
|
|
CpusetMems string
|
|
CpusetMems string
|
|
}{"busybox", "42-3,1--"}
|
|
}{"busybox", "42-3,1--"}
|
|
name = "wrong-cpuset-mems"
|
|
name = "wrong-cpuset-mems"
|
|
- status, body, err = sockRequest("POST", "/containers/create?name="+name, c2)
|
|
|
|
|
|
+ status, body, err = request.SockRequest("POST", "/containers/create?name="+name, c2, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
c.Assert(status, checker.Equals, http.StatusInternalServerError)
|
|
expected = "Invalid value 42-3,1-- for cpuset mems"
|
|
expected = "Invalid value 42-3,1-- for cpuset mems"
|
|
@@ -1350,7 +1341,7 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeNegative(c *check.C) {
|
|
"HostConfig": map[string]interface{}{"ShmSize": -1},
|
|
"HostConfig": map[string]interface{}{"ShmSize": -1},
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
|
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
|
c.Assert(getErrorMessage(c, body), checker.Contains, "SHM size can not be less than 0")
|
|
c.Assert(getErrorMessage(c, body), checker.Contains, "SHM size can not be less than 0")
|
|
@@ -1365,14 +1356,14 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *check.
|
|
"Cmd": "mount",
|
|
"Cmd": "mount",
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusCreated)
|
|
c.Assert(status, check.Equals, http.StatusCreated)
|
|
|
|
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
c.Assert(json.Unmarshal(body, &container), check.IsNil)
|
|
c.Assert(json.Unmarshal(body, &container), check.IsNil)
|
|
|
|
|
|
- status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil)
|
|
|
|
|
|
+ status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusOK)
|
|
c.Assert(status, check.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -1397,14 +1388,14 @@ func (s *DockerSuite) TestPostContainersCreateShmSizeOmitted(c *check.C) {
|
|
"Cmd": "mount",
|
|
"Cmd": "mount",
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusCreated)
|
|
c.Assert(status, check.Equals, http.StatusCreated)
|
|
|
|
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
c.Assert(json.Unmarshal(body, &container), check.IsNil)
|
|
c.Assert(json.Unmarshal(body, &container), check.IsNil)
|
|
|
|
|
|
- status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil)
|
|
|
|
|
|
+ status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusOK)
|
|
c.Assert(status, check.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -1429,14 +1420,14 @@ func (s *DockerSuite) TestPostContainersCreateWithShmSize(c *check.C) {
|
|
"HostConfig": map[string]interface{}{"ShmSize": 1073741824},
|
|
"HostConfig": map[string]interface{}{"ShmSize": 1073741824},
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusCreated)
|
|
c.Assert(status, check.Equals, http.StatusCreated)
|
|
|
|
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
c.Assert(json.Unmarshal(body, &container), check.IsNil)
|
|
c.Assert(json.Unmarshal(body, &container), check.IsNil)
|
|
|
|
|
|
- status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil)
|
|
|
|
|
|
+ status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusOK)
|
|
c.Assert(status, check.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -1459,14 +1450,14 @@ func (s *DockerSuite) TestPostContainersCreateMemorySwappinessHostConfigOmitted(
|
|
"Image": "busybox",
|
|
"Image": "busybox",
|
|
}
|
|
}
|
|
|
|
|
|
- status, body, err := sockRequest("POST", "/containers/create", config)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("POST", "/containers/create", config, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusCreated)
|
|
c.Assert(status, check.Equals, http.StatusCreated)
|
|
|
|
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
var container containertypes.ContainerCreateCreatedBody
|
|
c.Assert(json.Unmarshal(body, &container), check.IsNil)
|
|
c.Assert(json.Unmarshal(body, &container), check.IsNil)
|
|
|
|
|
|
- status, body, err = sockRequest("GET", "/containers/"+container.ID+"/json", nil)
|
|
|
|
|
|
+ status, body, err = request.SockRequest("GET", "/containers/"+container.ID+"/json", nil, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusOK)
|
|
c.Assert(status, check.Equals, http.StatusOK)
|
|
|
|
|
|
@@ -1486,7 +1477,7 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *che
|
|
OomScoreAdj int
|
|
OomScoreAdj int
|
|
}{"busybox", 1001}
|
|
}{"busybox", 1001}
|
|
name := "oomscoreadj-over"
|
|
name := "oomscoreadj-over"
|
|
- status, b, err := sockRequest("POST", "/containers/create?name="+name, config)
|
|
|
|
|
|
+ status, b, err := request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
|
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
|
|
|
|
|
@@ -1501,7 +1492,7 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *che
|
|
OomScoreAdj int
|
|
OomScoreAdj int
|
|
}{"busybox", -1001}
|
|
}{"busybox", -1001}
|
|
name = "oomscoreadj-low"
|
|
name = "oomscoreadj-low"
|
|
- status, b, err = sockRequest("POST", "/containers/create?name="+name, config)
|
|
|
|
|
|
+ status, b, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost())
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(err, check.IsNil)
|
|
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
|
c.Assert(status, check.Equals, http.StatusInternalServerError)
|
|
expected = "Invalid value -1001, range for oom score adj is [-1000, 1000]"
|
|
expected = "Invalid value -1001, range for oom score adj is [-1000, 1000]"
|
|
@@ -1513,7 +1504,7 @@ func (s *DockerSuite) TestPostContainersCreateWithOomScoreAdjInvalidRange(c *che
|
|
|
|
|
|
// test case for #22210 where an empty container name caused panic.
|
|
// test case for #22210 where an empty container name caused panic.
|
|
func (s *DockerSuite) TestContainerAPIDeleteWithEmptyName(c *check.C) {
|
|
func (s *DockerSuite) TestContainerAPIDeleteWithEmptyName(c *check.C) {
|
|
- status, out, err := sockRequest("DELETE", "/containers/", nil)
|
|
|
|
|
|
+ status, out, err := request.SockRequest("DELETE", "/containers/", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusBadRequest)
|
|
c.Assert(status, checker.Equals, http.StatusBadRequest)
|
|
c.Assert(string(out), checker.Contains, "No container name or ID supplied")
|
|
c.Assert(string(out), checker.Contains, "No container name or ID supplied")
|
|
@@ -1530,11 +1521,11 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *check.C) {
|
|
"NetworkDisabled": true,
|
|
"NetworkDisabled": true,
|
|
}
|
|
}
|
|
|
|
|
|
- status, _, err := sockRequest("POST", "/containers/create?name="+name, config)
|
|
|
|
|
|
+ status, _, err := request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
c.Assert(status, checker.Equals, http.StatusCreated)
|
|
|
|
|
|
- status, _, err = sockRequest("POST", "/containers/"+name+"/start", nil)
|
|
|
|
|
|
+ status, _, err = request.SockRequest("POST", "/containers/"+name+"/start", nil, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
c.Assert(status, checker.Equals, http.StatusNoContent)
|
|
|
|
|
|
@@ -1547,7 +1538,7 @@ func (s *DockerSuite) TestContainerAPIStatsWithNetworkDisabled(c *check.C) {
|
|
}
|
|
}
|
|
bc := make(chan b, 1)
|
|
bc := make(chan b, 1)
|
|
go func() {
|
|
go func() {
|
|
- status, body, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
|
|
|
|
|
|
+ status, body, err := request.SockRequest("GET", "/containers/"+name+"/stats", nil, daemonHost())
|
|
bc <- b{status, body, err}
|
|
bc <- b{status, body, err}
|
|
}()
|
|
}()
|
|
|
|
|
|
@@ -1755,7 +1746,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) {
|
|
|
|
|
|
for i, x := range cases {
|
|
for i, x := range cases {
|
|
c.Logf("case %d", i)
|
|
c.Logf("case %d", i)
|
|
- status, b, err := sockRequest("POST", "/containers/create", x.config)
|
|
|
|
|
|
+ status, b, err := request.SockRequest("POST", "/containers/create", x.config, daemonHost())
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(status, checker.Equals, x.status, check.Commentf("%s\n%v", string(b), cases[i].config))
|
|
c.Assert(status, checker.Equals, x.status, check.Commentf("%s\n%v", string(b), cases[i].config))
|
|
if len(x.msg) > 0 {
|
|
if len(x.msg) > 0 {
|
|
@@ -1780,7 +1771,7 @@ func (s *DockerSuite) TestContainerAPICreateMountsBindRead(c *check.C) {
|
|
"Cmd": []string{"/bin/sh", "-c", "cat /foo/bar"},
|
|
"Cmd": []string{"/bin/sh", "-c", "cat /foo/bar"},
|
|
"HostConfig": map[string]interface{}{"Mounts": []map[string]interface{}{{"Type": "bind", "Source": tmpDir, "Target": destPath}}},
|
|
"HostConfig": map[string]interface{}{"Mounts": []map[string]interface{}{{"Type": "bind", "Source": tmpDir, "Target": destPath}}},
|
|
}
|
|
}
|
|
- status, resp, err := sockRequest("POST", "/containers/create?name=test", data)
|
|
|
|
|
|
+ status, resp, err := request.SockRequest("POST", "/containers/create?name=test", data, daemonHost())
|
|
c.Assert(err, checker.IsNil, check.Commentf(string(resp)))
|
|
c.Assert(err, checker.IsNil, check.Commentf(string(resp)))
|
|
c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(resp)))
|
|
c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(resp)))
|
|
|
|
|
|
@@ -1868,7 +1859,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) {
|
|
}
|
|
}
|
|
for i, x := range cases {
|
|
for i, x := range cases {
|
|
c.Logf("case %d - config: %v", i, x.cfg)
|
|
c.Logf("case %d - config: %v", i, x.cfg)
|
|
- status, data, err := sockRequest("POST", "/containers/create", wrapper{containertypes.Config{Image: testImg}, containertypes.HostConfig{Mounts: []mounttypes.Mount{x.cfg}}})
|
|
|
|
|
|
+ status, data, err := request.SockRequest("POST", "/containers/create", wrapper{containertypes.Config{Image: testImg}, containertypes.HostConfig{Mounts: []mounttypes.Mount{x.cfg}}}, daemonHost())
|
|
c.Assert(err, checker.IsNil, check.Commentf(string(data)))
|
|
c.Assert(err, checker.IsNil, check.Commentf(string(data)))
|
|
c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(data)))
|
|
c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(data)))
|
|
|
|
|
|
@@ -1950,7 +1941,7 @@ func (s *DockerSuite) TestContainersAPICreateMountsTmpfs(c *check.C) {
|
|
fmt.Sprintf("mount | grep 'tmpfs on %s'", target)},
|
|
fmt.Sprintf("mount | grep 'tmpfs on %s'", target)},
|
|
"HostConfig": map[string]interface{}{"Mounts": []map[string]interface{}{x.cfg}},
|
|
"HostConfig": map[string]interface{}{"Mounts": []map[string]interface{}{x.cfg}},
|
|
}
|
|
}
|
|
- status, resp, err := sockRequest("POST", "/containers/create?name="+cName, data)
|
|
|
|
|
|
+ status, resp, err := request.SockRequest("POST", "/containers/create?name="+cName, data, daemonHost())
|
|
c.Assert(err, checker.IsNil, check.Commentf(string(resp)))
|
|
c.Assert(err, checker.IsNil, check.Commentf(string(resp)))
|
|
c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(resp)))
|
|
c.Assert(status, checker.Equals, http.StatusCreated, check.Commentf(string(resp)))
|
|
out, _ := dockerCmd(c, "start", "-a", cName)
|
|
out, _ := dockerCmd(c, "start", "-a", cName)
|