Browse code

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 <kolyshkin@gmail.com>

Kir Kolyshkin authored on 2018/09/06 11:11:04
Showing 1 changed files
... ...
@@ -423,6 +423,38 @@ RUN [ ! -f foo ]
423 423
 	assert.Check(t, is.Contains(out.String(), "Successfully built"))
424 424
 }
425 425
 
426
+// #37581
427
+func TestBuildWithHugeFile(t *testing.T) {
428
+	ctx := context.TODO()
429
+	defer setupTest(t)()
430
+
431
+	dockerfile := `FROM busybox
432
+# create a sparse file with size over 8GB
433
+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 && \
434
+    ls -la rnd && du -sk rnd`
435
+
436
+	buf := bytes.NewBuffer(nil)
437
+	w := tar.NewWriter(buf)
438
+	writeTarRecord(t, w, "Dockerfile", dockerfile)
439
+	err := w.Close()
440
+	assert.NilError(t, err)
441
+
442
+	apiclient := testEnv.APIClient()
443
+	resp, err := apiclient.ImageBuild(ctx,
444
+		buf,
445
+		types.ImageBuildOptions{
446
+			Remove:      true,
447
+			ForceRemove: true,
448
+		})
449
+
450
+	out := bytes.NewBuffer(nil)
451
+	assert.NilError(t, err)
452
+	_, err = io.Copy(out, resp.Body)
453
+	resp.Body.Close()
454
+	assert.NilError(t, err)
455
+	assert.Check(t, is.Contains(out.String(), "Successfully built"))
456
+}
457
+
426 458
 func writeTarRecord(t *testing.T, w *tar.Writer, fn, contents string) {
427 459
 	err := w.WriteHeader(&tar.Header{
428 460
 		Name:     fn,