mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Move ChunkedEncoding from integration
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
a242ceaa09
commit
7c574b9e9d
1 changed files with 52 additions and 0 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/httputil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -1150,3 +1151,54 @@ func (s *DockerSuite) TestContainerApiDeleteRemoveVolume(c *check.C) {
|
||||||
c.Fatalf("expected to get ErrNotExist error, got %v", err)
|
c.Fatalf("expected to get ErrNotExist error, got %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regression test for https://github.com/docker/docker/issues/6231
|
||||||
|
func (s *DockerSuite) TestContainersApiChunkedEncoding(c *check.C) {
|
||||||
|
out, _ := dockerCmd(c, "create", "-v", "/foo", "busybox", "true")
|
||||||
|
id := strings.TrimSpace(out)
|
||||||
|
|
||||||
|
conn, err := sockConn(time.Duration(10 * time.Second))
|
||||||
|
if err != nil {
|
||||||
|
c.Fatal(err)
|
||||||
|
}
|
||||||
|
client := httputil.NewClientConn(conn, nil)
|
||||||
|
defer client.Close()
|
||||||
|
|
||||||
|
bindCfg := strings.NewReader(`{"Binds": ["/tmp:/foo"]}`)
|
||||||
|
req, err := http.NewRequest("POST", "/containers/"+id+"/start", bindCfg)
|
||||||
|
if err != nil {
|
||||||
|
c.Fatal(err)
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
if err != nil {
|
||||||
|
c.Fatalf("error starting container with chunked encoding: %v", err)
|
||||||
|
}
|
||||||
|
resp.Body.Close()
|
||||||
|
if resp.StatusCode != 204 {
|
||||||
|
c.Fatalf("expected status code 204, got %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
out, err = inspectFieldJSON(id, "HostConfig.Binds")
|
||||||
|
if err != nil {
|
||||||
|
c.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var binds []string
|
||||||
|
if err := json.NewDecoder(strings.NewReader(out)).Decode(&binds); err != nil {
|
||||||
|
c.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(binds) != 1 {
|
||||||
|
c.Fatalf("got unexpected binds: %v", binds)
|
||||||
|
}
|
||||||
|
|
||||||
|
expected := "/tmp:/foo"
|
||||||
|
if binds[0] != expected {
|
||||||
|
c.Fatalf("got incorrect bind spec, wanted %s, got: %s", expected, binds[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue