summaryrefslogtreecommitdiff
path: root/integration-cli/docker_api_build_test.go
diff options
context:
space:
mode:
authorSimon Ferquel <simon.ferquel@docker.com>2017-05-22 17:21:17 +0200
committerSimon Ferquel <simon.ferquel@docker.com>2017-09-18 09:48:56 +0200
commit669c0677980b04bcbf871bb7c2d9f07caccfd42b (patch)
treeb130a469adde27f2893b6e946cfefda86950f434 /integration-cli/docker_api_build_test.go
parentc5c0702a4d523071b3e41a13c233b6ec9e261b06 (diff)
downloaddocker-669c0677980b04bcbf871bb7c2d9f07caccfd42b.tar.gz
Introduce a typed command system and 2 phase parse/dispatch build
This is a work base to introduce more features like build time dockerfile optimisations, dependency analysis and parallel build, as well as a first step to go from a dispatch-inline process to a frontend+backend process. Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
Diffstat (limited to 'integration-cli/docker_api_build_test.go')
-rw-r--r--integration-cli/docker_api_build_test.go76
1 files changed, 76 insertions, 0 deletions
diff --git a/integration-cli/docker_api_build_test.go b/integration-cli/docker_api_build_test.go
index 59b451024e..de78da465e 100644
--- a/integration-cli/docker_api_build_test.go
+++ b/integration-cli/docker_api_build_test.go
@@ -438,6 +438,82 @@ func (s *DockerSuite) TestBuildChownOnCopy(c *check.C) {
assert.Contains(c, string(out), "Successfully built")
}
+func (s *DockerSuite) TestBuildCopyCacheOnFileChange(c *check.C) {
+
+ dockerfile := `FROM busybox
+COPY file /file`
+
+ ctx1 := fakecontext.New(c, "",
+ fakecontext.WithDockerfile(dockerfile),
+ fakecontext.WithFile("file", "foo"))
+ ctx2 := fakecontext.New(c, "",
+ fakecontext.WithDockerfile(dockerfile),
+ fakecontext.WithFile("file", "bar"))
+
+ var build = func(ctx *fakecontext.Fake) string {
+ res, body, err := request.Post("/build",
+ request.RawContent(ctx.AsTarReader(c)),
+ request.ContentType("application/x-tar"))
+
+ require.NoError(c, err)
+ assert.Equal(c, http.StatusOK, res.StatusCode)
+
+ out, err := request.ReadBody(body)
+
+ ids := getImageIDsFromBuild(c, out)
+ return ids[len(ids)-1]
+ }
+
+ id1 := build(ctx1)
+ id2 := build(ctx1)
+ id3 := build(ctx2)
+
+ if id1 != id2 {
+ c.Fatal("didn't use the cache")
+ }
+ if id1 == id3 {
+ c.Fatal("COPY With different source file should not share same cache")
+ }
+}
+
+func (s *DockerSuite) TestBuildAddCacheOnFileChange(c *check.C) {
+
+ dockerfile := `FROM busybox
+ADD file /file`
+
+ ctx1 := fakecontext.New(c, "",
+ fakecontext.WithDockerfile(dockerfile),
+ fakecontext.WithFile("file", "foo"))
+ ctx2 := fakecontext.New(c, "",
+ fakecontext.WithDockerfile(dockerfile),
+ fakecontext.WithFile("file", "bar"))
+
+ var build = func(ctx *fakecontext.Fake) string {
+ res, body, err := request.Post("/build",
+ request.RawContent(ctx.AsTarReader(c)),
+ request.ContentType("application/x-tar"))
+
+ require.NoError(c, err)
+ assert.Equal(c, http.StatusOK, res.StatusCode)
+
+ out, err := request.ReadBody(body)
+
+ ids := getImageIDsFromBuild(c, out)
+ return ids[len(ids)-1]
+ }
+
+ id1 := build(ctx1)
+ id2 := build(ctx1)
+ id3 := build(ctx2)
+
+ if id1 != id2 {
+ c.Fatal("didn't use the cache")
+ }
+ if id1 == id3 {
+ c.Fatal("COPY With different source file should not share same cache")
+ }
+}
+
func (s *DockerSuite) TestBuildWithSession(c *check.C) {
testRequires(c, ExperimentalDaemon)