Browse code

Add TestBuildWCOWSandboxSize integration test

This test validates that `RUN` and `COPY` both target a read-write
sandbox on Windows that is configured according to the daemon's
`storage-opts` setting.

Sadly, this is a slow test, so we need to bump the timeout to 60 minutes
from the default of 10 minutes.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>

Paul "TBBle" Hampson authored on 2020/11/05 18:39:40
Showing 2 changed files
... ...
@@ -363,7 +363,7 @@ Function Run-IntegrationTests() {
363 363
         $pinfo.FileName = "gotestsum.exe"
364 364
         $pinfo.WorkingDirectory = "$($PWD.Path)"
365 365
         $pinfo.UseShellExecute = $false
366
-        $pinfo.Arguments = "--format=standard-verbose --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- $env:INTEGRATION_TESTFLAGS"
366
+        $pinfo.Arguments = "--format=standard-verbose --jsonfile=$jsonFilePath --junitfile=$xmlFilePath -- -test.timeout=60m $env:INTEGRATION_TESTFLAGS"
367 367
         $p = New-Object System.Diagnostics.Process
368 368
         $p.StartInfo = $pinfo
369 369
         $p.Start() | Out-Null
... ...
@@ -523,6 +523,46 @@ RUN for g in $(seq 0 8); do dd if=/dev/urandom of=rnd bs=1K count=1 seek=$((1024
523 523
 	assert.Check(t, is.Contains(out.String(), "Successfully built"))
524 524
 }
525 525
 
526
+func TestBuildWCOWSandboxSize(t *testing.T) {
527
+	skip.If(t, testEnv.DaemonInfo.OSType != "windows", "only Windows has sandbox size control")
528
+	ctx := context.TODO()
529
+	defer setupTest(t)()
530
+
531
+	dockerfile := `FROM busybox AS intermediate
532
+WORKDIR C:\\stuff
533
+# Create and delete a 21GB file
534
+RUN fsutil file createnew C:\\stuff\\bigfile_0.txt 22548578304 && del bigfile_0.txt
535
+# Create three 7GB files
536
+RUN fsutil file createnew C:\\stuff\\bigfile_1.txt 7516192768
537
+RUN fsutil file createnew C:\\stuff\\bigfile_2.txt 7516192768
538
+RUN fsutil file createnew C:\\stuff\\bigfile_3.txt 7516192768
539
+# Copy that 21GB of data out into a new target
540
+FROM busybox
541
+COPY --from=intermediate C:\\stuff C:\\stuff
542
+`
543
+
544
+	buf := bytes.NewBuffer(nil)
545
+	w := tar.NewWriter(buf)
546
+	writeTarRecord(t, w, "Dockerfile", dockerfile)
547
+	err := w.Close()
548
+	assert.NilError(t, err)
549
+
550
+	apiclient := testEnv.APIClient()
551
+	resp, err := apiclient.ImageBuild(ctx,
552
+		buf,
553
+		types.ImageBuildOptions{
554
+			Remove:      true,
555
+			ForceRemove: true,
556
+		})
557
+
558
+	out := bytes.NewBuffer(nil)
559
+	assert.NilError(t, err)
560
+	_, err = io.Copy(out, resp.Body)
561
+	resp.Body.Close()
562
+	assert.NilError(t, err)
563
+	assert.Check(t, is.Contains(out.String(), "Successfully built"))
564
+}
565
+
526 566
 func TestBuildWithEmptyDockerfile(t *testing.T) {
527 567
 	skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.40"), "broken in earlier versions")
528 568
 	ctx := context.TODO()