Skip to content

Commit

Permalink
dockerfile: add regression test for parallel cache mounts
Browse files Browse the repository at this point in the history
Checks for mkdir bug that was fixed in runc 1.2.3

Signed-off-by: Tonis Tiigi <[email protected]>
(cherry picked from commit ee0438b)
  • Loading branch information
tonistiigi committed Dec 16, 2024
1 parent 25649b3 commit 6614837
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 6614837

Please sign in to comment.