@@ -28,6 +28,7 @@ var mountTests = integration.TestFuncs(
28
28
testMountTmpfsSize ,
29
29
testMountDuplicate ,
30
30
testCacheMountUser ,
31
+ testCacheMountParallel ,
31
32
)
32
33
33
34
func init () {
@@ -536,3 +537,43 @@ COPY --from=base /combined.txt /
536
537
test ("foo\n " )
537
538
test ("updated\n " )
538
539
}
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