Skip to content

Commit

Permalink
Clean more build utils in integration cli
Browse files Browse the repository at this point in the history
- Remove deprecated buildImage* functions
- Rename buildImageNew to buildImage
- Use *check.C in fakeContext* setup and in getIdByName

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
  • Loading branch information
vdemeester committed Jan 17, 2017
1 parent 8c76519 commit c10f6ef
Show file tree
Hide file tree
Showing 28 changed files with 587 additions and 1,194 deletions.
1 change: 1 addition & 0 deletions integration-cli/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ func WaitInspectWithArgs(dockerBinary, name, expr, expected string, timeout time
}

// BuildImageCmdWithHost create a build command with the specified arguments.
// Deprecated
// FIXME(vdemeester) move this away
func BuildImageCmdWithHost(dockerBinary, name, dockerfile, host string, useCache bool, buildFlags ...string) *exec.Cmd {
args := []string{}
Expand Down
21 changes: 7 additions & 14 deletions integration-cli/docker_api_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ COPY * /tmp/
RUN find / -xdev -name ba*
RUN find /tmp/`
}
server, err := fakeStorage(map[string]string{"testD": testD})
c.Assert(err, checker.IsNil)
server := fakeStorage(c, map[string]string{"testD": testD})
defer server.Close()

res, body, err := request.SockRequestRaw("POST", "/build?dockerfile=baz&remote="+server.URL()+"/testD", nil, "application/json", daemonHost())
Expand Down Expand Up @@ -66,11 +65,9 @@ func (s *DockerSuite) TestBuildAPIRemoteTarballContext(c *check.C) {
// failed to close tar archive
c.Assert(tw.Close(), checker.IsNil)

server, err := fakeBinaryStorage(map[string]*bytes.Buffer{
server := fakeBinaryStorage(c, map[string]*bytes.Buffer{
"testT.tar": buffer,
})
c.Assert(err, checker.IsNil)

defer server.Close()

res, b, err := request.SockRequestRaw("POST", "/build?remote="+server.URL()+"/testT.tar", nil, "application/tar", daemonHost())
Expand Down Expand Up @@ -115,12 +112,11 @@ RUN echo 'right'
// failed to close tar archive
c.Assert(tw.Close(), checker.IsNil)

server, err := fakeBinaryStorage(map[string]*bytes.Buffer{
server := fakeBinaryStorage(c, map[string]*bytes.Buffer{
"testT.tar": buffer,
})
c.Assert(err, checker.IsNil)

defer server.Close()

url := "/build?dockerfile=custom&remote=" + server.URL() + "/testT.tar"
res, body, err := request.SockRequestRaw("POST", url, nil, "application/tar", daemonHost())
c.Assert(err, checker.IsNil)
Expand All @@ -135,11 +131,10 @@ RUN echo 'right'
}

func (s *DockerSuite) TestBuildAPILowerDockerfile(c *check.C) {
git, err := newFakeGit("repo", map[string]string{
git := newFakeGit(c, "repo", map[string]string{
"dockerfile": `FROM busybox
RUN echo from dockerfile`,
}, false)
c.Assert(err, checker.IsNil)
defer git.Close()

res, body, err := request.SockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json", daemonHost())
Expand All @@ -154,13 +149,12 @@ RUN echo from dockerfile`,
}

func (s *DockerSuite) TestBuildAPIBuildGitWithF(c *check.C) {
git, err := newFakeGit("repo", map[string]string{
git := newFakeGit(c, "repo", map[string]string{
"baz": `FROM busybox
RUN echo from baz`,
"Dockerfile": `FROM busybox
RUN echo from Dockerfile`,
}, false)
c.Assert(err, checker.IsNil)
defer git.Close()

// Make sure it tries to 'dockerfile' query param value
Expand All @@ -177,13 +171,12 @@ RUN echo from Dockerfile`,

func (s *DockerSuite) TestBuildAPIDoubleDockerfile(c *check.C) {
testRequires(c, UnixCli) // dockerfile overwrites Dockerfile on Windows
git, err := newFakeGit("repo", map[string]string{
git := newFakeGit(c, "repo", map[string]string{
"Dockerfile": `FROM busybox
RUN echo from Dockerfile`,
"dockerfile": `FROM busybox
RUN echo from dockerfile`,
}, false)
c.Assert(err, checker.IsNil)
defer git.Close()

// Make sure it tries to 'dockerfile' query param value
Expand Down
7 changes: 3 additions & 4 deletions integration-cli/docker_api_containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1766,19 +1766,18 @@ func (s *DockerSuite) TestContainersAPICreateMountsCreate(c *check.C) {
destPath := prefix + slash + "foo"

var (
err error
testImg string
)
if testEnv.DaemonPlatform() != "windows" {
testImg, err = buildImage("test-mount-config", `
testImg = "test-mount-config"
buildImageSuccessfully(c, testImg, withDockerfile(`
FROM busybox
RUN mkdir `+destPath+` && touch `+destPath+slash+`bar
CMD cat `+destPath+slash+`bar
`, true)
`))
} else {
testImg = "busybox"
}
c.Assert(err, checker.IsNil)

type testCase struct {
cfg mounttypes.Mount
Expand Down
16 changes: 6 additions & 10 deletions integration-cli/docker_api_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ func (s *DockerSuite) TestAPIImagesSaveAndLoad(c *check.C) {
// TODO Windows to Windows CI: Investigate further why this test fails.
testRequires(c, Network)
testRequires(c, DaemonIsLinux)
out, err := buildImage("saveandload", "FROM busybox\nENV FOO bar", false)
c.Assert(err, checker.IsNil)
id := strings.TrimSpace(out)
buildImageSuccessfully(c, "saveandload", withDockerfile("FROM busybox\nENV FOO bar"))
id := getIDByName(c, "saveandload")

res, body, err := request.SockRequestRaw("GET", "/images/"+id+"/get", nil, "", daemonHost())
c.Assert(err, checker.IsNil)
Expand All @@ -77,9 +76,8 @@ func (s *DockerSuite) TestAPIImagesDelete(c *check.C) {
testRequires(c, Network)
}
name := "test-api-images-delete"
out, err := buildImage(name, "FROM busybox\nENV FOO bar", false)
c.Assert(err, checker.IsNil)
id := strings.TrimSpace(out)
buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nENV FOO bar"))
id := getIDByName(c, name)

dockerCmd(c, "tag", name, "test:tag1")

Expand All @@ -101,10 +99,8 @@ func (s *DockerSuite) TestAPIImagesHistory(c *check.C) {
testRequires(c, Network)
}
name := "test-api-images-history"
out, err := buildImage(name, "FROM busybox\nENV FOO bar", false)
c.Assert(err, checker.IsNil)

id := strings.TrimSpace(out)
buildImageSuccessfully(c, name, withDockerfile("FROM busybox\nENV FOO bar"))
id := getIDByName(c, name)

status, body, err := request.SockRequest("GET", "/images/"+id+"/history", nil, daemonHost())
c.Assert(err, checker.IsNil)
Expand Down
Loading

0 comments on commit c10f6ef

Please sign in to comment.