Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func TestIntegration(t *testing.T) {
testCacheMountNoCache,
testExporterTargetExists,
testTarExporterWithSocket,
testMultipleRegistryCacheImportExport,
}, mirrors)

integration.Run(t, []integration.Test{
Expand Down Expand Up @@ -1658,7 +1659,7 @@ func testBuildPushAndValidate(t *testing.T, sb integration.Sandbox) {
require.False(t, ok)
}

func testBasicCacheImportExport(t *testing.T, sb integration.Sandbox, cacheOptionsEntryImport, cacheOptionsEntryExport CacheOptionsEntry) {
func testBasicCacheImportExport(t *testing.T, sb integration.Sandbox, cacheOptionsEntryImport, cacheOptionsEntryExport []CacheOptionsEntry) {
requiresLinux(t)
c, err := New(context.TODO(), sb.Address())
require.NoError(t, err)
Expand Down Expand Up @@ -1688,9 +1689,7 @@ func testBasicCacheImportExport(t *testing.T, sb integration.Sandbox, cacheOptio
OutputDir: destDir,
},
},
CacheExports: []CacheOptionsEntry{
cacheOptionsEntryExport,
},
CacheExports: cacheOptionsEntryExport,
}, nil)
require.NoError(t, err)

Expand All @@ -1716,9 +1715,7 @@ func testBasicCacheImportExport(t *testing.T, sb integration.Sandbox, cacheOptio
Type: ExporterLocal,
OutputDir: destDir,
}},
CacheImports: []CacheOptionsEntry{
cacheOptionsEntryImport,
},
CacheImports: cacheOptionsEntryImport,
}, nil)
require.NoError(t, err)

Expand All @@ -1744,7 +1741,29 @@ func testBasicRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
"ref": target,
},
}
testBasicCacheImportExport(t, sb, o, o)
testBasicCacheImportExport(t, sb, []CacheOptionsEntry{o}, []CacheOptionsEntry{o})
}

func testMultipleRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
registry, err := sb.NewRegistry()
if errors.Cause(err) == integration.ErrorRequirements {
t.Skip(err.Error())
}
require.NoError(t, err)
target := registry + "/buildkit/testexport:latest"
o := CacheOptionsEntry{
Type: "registry",
Attrs: map[string]string{
"ref": target,
},
}
o2 := CacheOptionsEntry{
Type: "registry",
Attrs: map[string]string{
"ref": target + "notexist",
},
}
testBasicCacheImportExport(t, sb, []CacheOptionsEntry{o, o2}, []CacheOptionsEntry{o})
}

func testBasicLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
Expand All @@ -1763,7 +1782,7 @@ func testBasicLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
"dest": dir,
},
}
testBasicCacheImportExport(t, sb, im, ex)
testBasicCacheImportExport(t, sb, []CacheOptionsEntry{im}, []CacheOptionsEntry{ex})
}

func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
Expand Down
4 changes: 2 additions & 2 deletions solver/llbsolver/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (b *llbBridge) Solve(ctx context.Context, req frontend.SolveRequest) (res *
}
}
if prevCm, ok := b.cms[cmId]; !ok {
func(cmId string) {
func(cmId string, im gw.CacheOptionsEntry) {
cm = newLazyCacheManager(cmId, func() (solver.CacheManager, error) {
var cmNew solver.CacheManager
if err := inVertexContext(b.builder.Context(ctx), "importing cache manifest from "+cmId, "", func(ctx context.Context) error {
Expand All @@ -74,7 +74,7 @@ func (b *llbBridge) Solve(ctx context.Context, req frontend.SolveRequest) (res *
}
return cmNew, nil
})
}(cmId)
}(cmId, im)
b.cms[cmId] = cm
} else {
cm = prevCm
Expand Down