Skip to content

Commit d4992d5

Browse files
authored
Merge pull request moby#5590 from tonistiigi/dockerfile-parallel-cache-mount-fix
dockerfile: add regression test for parallel cache mounts
2 parents fcf5593 + ee0438b commit d4992d5

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

frontend/dockerfile/dockerfile_mount_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var mountTests = integration.TestFuncs(
2828
testMountTmpfsSize,
2929
testMountDuplicate,
3030
testCacheMountUser,
31+
testCacheMountParallel,
3132
)
3233

3334
func init() {
@@ -536,3 +537,43 @@ COPY --from=base /combined.txt /
536537
test("foo\n")
537538
test("updated\n")
538539
}
540+
541+
// moby/buildkit#5566
542+
func testCacheMountParallel(t *testing.T, sb integration.Sandbox) {
543+
integration.SkipOnPlatform(t, "windows")
544+
f := getFrontend(t, sb)
545+
546+
dockerfile := []byte(`
547+
FROM alpine AS b1
548+
RUN --mount=type=cache,target=/foo/bar --mount=type=cache,target=/foo/bar/baz echo 1
549+
550+
FROM alpine AS b2
551+
RUN --mount=type=cache,target=/foo/bar --mount=type=cache,target=/foo/bar/baz echo 2
552+
553+
FROM scratch
554+
COPY --from=b1 /etc/passwd p1
555+
COPY --from=b2 /etc/passwd p2
556+
`)
557+
558+
dir := integration.Tmpdir(
559+
t,
560+
fstest.CreateFile("Dockerfile", dockerfile, 0600),
561+
)
562+
563+
c, err := client.New(sb.Context(), sb.Address())
564+
require.NoError(t, err)
565+
defer c.Close()
566+
567+
for i := 0; i < 20; i++ {
568+
_, err = f.Solve(sb.Context(), c, client.SolveOpt{
569+
FrontendAttrs: map[string]string{
570+
"no-cache": "",
571+
},
572+
LocalMounts: map[string]fsutil.FS{
573+
dockerui.DefaultLocalNameDockerfile: dir,
574+
dockerui.DefaultLocalNameContext: dir,
575+
},
576+
}, nil)
577+
require.NoError(t, err)
578+
}
579+
}

0 commit comments

Comments
 (0)