From b3165f5b2d7c1063c2a76a7ed5c2dd18f868276b Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 5 Sep 2018 19:11:04 -0700 Subject: [PATCH] integration/build: add TestBuildHugeFile Add a test case for creating a 8GB file inside a container. Due to a bug in tar-split this was failing in Docker 18.06. The file being created is sparse, so there's not much I/O happening or disk space being used -- meaning the test is fast and does not require a lot of disk space. Signed-off-by: Kir Kolyshkin --- integration/build/build_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/integration/build/build_test.go b/integration/build/build_test.go index 25c5e635bd..9dde5d4557 100644 --- a/integration/build/build_test.go +++ b/integration/build/build_test.go @@ -423,6 +423,38 @@ RUN [ ! -f foo ] assert.Check(t, is.Contains(out.String(), "Successfully built")) } +// #37581 +func TestBuildWithHugeFile(t *testing.T) { + ctx := context.TODO() + defer setupTest(t)() + + dockerfile := `FROM busybox +# create a sparse file with size over 8GB +RUN for g in $(seq 0 8); do dd if=/dev/urandom of=rnd bs=1K count=1 seek=$((1024*1024*g)) status=none; done && \ + ls -la rnd && du -sk rnd` + + buf := bytes.NewBuffer(nil) + w := tar.NewWriter(buf) + writeTarRecord(t, w, "Dockerfile", dockerfile) + err := w.Close() + assert.NilError(t, err) + + apiclient := testEnv.APIClient() + resp, err := apiclient.ImageBuild(ctx, + buf, + types.ImageBuildOptions{ + Remove: true, + ForceRemove: true, + }) + + out := bytes.NewBuffer(nil) + assert.NilError(t, err) + _, err = io.Copy(out, resp.Body) + resp.Body.Close() + assert.NilError(t, err) + assert.Check(t, is.Contains(out.String(), "Successfully built")) +} + func writeTarRecord(t *testing.T, w *tar.Writer, fn, contents string) { err := w.WriteHeader(&tar.Header{ Name: fn,