Skip to content

Commit

Permalink
Merge pull request #5590 from tonistiigi/dockerfile-parallel-cache-mo…
Browse files Browse the repository at this point in the history
…unt-fix

dockerfile: add regression test for parallel cache mounts
  • Loading branch information
tonistiigi authored Dec 16, 2024
2 parents fcf5593 + ee0438b commit d4992d5
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions frontend/dockerfile/dockerfile_mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var mountTests = integration.TestFuncs(
testMountTmpfsSize,
testMountDuplicate,
testCacheMountUser,
testCacheMountParallel,
)

func init() {
Expand Down Expand Up @@ -536,3 +537,43 @@ COPY --from=base /combined.txt /
test("foo\n")
test("updated\n")
}

// moby/buildkit#5566
func testCacheMountParallel(t *testing.T, sb integration.Sandbox) {
integration.SkipOnPlatform(t, "windows")
f := getFrontend(t, sb)

dockerfile := []byte(`
FROM alpine AS b1
RUN --mount=type=cache,target=/foo/bar --mount=type=cache,target=/foo/bar/baz echo 1
FROM alpine AS b2
RUN --mount=type=cache,target=/foo/bar --mount=type=cache,target=/foo/bar/baz echo 2
FROM scratch
COPY --from=b1 /etc/passwd p1
COPY --from=b2 /etc/passwd p2
`)

dir := integration.Tmpdir(
t,
fstest.CreateFile("Dockerfile", dockerfile, 0600),
)

c, err := client.New(sb.Context(), sb.Address())
require.NoError(t, err)
defer c.Close()

for i := 0; i < 20; i++ {
_, err = f.Solve(sb.Context(), c, client.SolveOpt{
FrontendAttrs: map[string]string{
"no-cache": "",
},
LocalMounts: map[string]fsutil.FS{
dockerui.DefaultLocalNameDockerfile: dir,
dockerui.DefaultLocalNameContext: dir,
},
}, nil)
require.NoError(t, err)
}
}

0 comments on commit d4992d5

Please sign in to comment.