Skip to content

Commit 19969b9

Browse files
committed
integration: add FeatureCacheBackend* compat
Signed-off-by: CrazyMax <[email protected]>
1 parent e39c44d commit 19969b9

File tree

4 files changed

+84
-51
lines changed

4 files changed

+84
-51
lines changed

client/client_test.go

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func newContainerd(cdAddress string) (*containerd.Client, error) {
245245

246246
// moby/buildkit#1336
247247
func testCacheExportCacheKeyLoop(t *testing.T, sb integration.Sandbox) {
248-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
248+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheBackendLocal)
249249
c, err := New(sb.Context(), sb.Address())
250250
require.NoError(t, err)
251251
defer c.Close()
@@ -3747,7 +3747,7 @@ func testBuildPushAndValidate(t *testing.T, sb integration.Sandbox) {
37473747
}
37483748

37493749
func testStargzLazyRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
3750-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
3750+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendRegistry)
37513751
requiresLinux(t)
37523752
cdAddress := sb.ContainerdAddress()
37533753
if cdAddress == "" || sb.Snapshotter() != "stargz" {
@@ -3945,7 +3945,12 @@ func testStargzLazyRegistryCacheImportExport(t *testing.T, sb integration.Sandbo
39453945
}
39463946

39473947
func testStargzLazyInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
3948-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
3948+
integration.CheckFeatureCompat(t, sb,
3949+
integration.FeatureCacheExport,
3950+
integration.FeatureCacheImport,
3951+
integration.FeatureCacheBackendInline,
3952+
integration.FeatureCacheBackendRegistry,
3953+
)
39493954
requiresLinux(t)
39503955
cdAddress := sb.ContainerdAddress()
39513956
if cdAddress == "" || sb.Snapshotter() != "stargz" {
@@ -4392,7 +4397,7 @@ func testLazyImagePush(t *testing.T, sb integration.Sandbox) {
43924397
}
43934398

43944399
func testZstdLocalCacheExport(t *testing.T, sb integration.Sandbox) {
4395-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4400+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheBackendLocal)
43964401
c, err := New(sb.Context(), sb.Address())
43974402
require.NoError(t, err)
43984403
defer c.Close()
@@ -4451,7 +4456,7 @@ func testZstdLocalCacheExport(t *testing.T, sb integration.Sandbox) {
44514456
}
44524457

44534458
func testCacheExportIgnoreError(t *testing.T, sb integration.Sandbox) {
4454-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4459+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheBackendLocal)
44554460
c, err := New(sb.Context(), sb.Address())
44564461
require.NoError(t, err)
44574462
defer c.Close()
@@ -4558,7 +4563,7 @@ func testCacheExportIgnoreError(t *testing.T, sb integration.Sandbox) {
45584563
}
45594564

45604565
func testUncompressedLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
4561-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4566+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendLocal)
45624567
dir := t.TempDir()
45634568
im := CacheOptionsEntry{
45644569
Type: "local",
@@ -4578,7 +4583,7 @@ func testUncompressedLocalCacheImportExport(t *testing.T, sb integration.Sandbox
45784583
}
45794584

45804585
func testUncompressedRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
4581-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4586+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendRegistry)
45824587
registry, err := sb.NewRegistry()
45834588
if errors.Is(err, integration.ErrRequirements) {
45844589
t.Skip(err.Error())
@@ -4603,7 +4608,7 @@ func testUncompressedRegistryCacheImportExport(t *testing.T, sb integration.Sand
46034608
}
46044609

46054610
func testZstdLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
4606-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4611+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendLocal)
46074612
dir := t.TempDir()
46084613
im := CacheOptionsEntry{
46094614
Type: "local",
@@ -4624,7 +4629,7 @@ func testZstdLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
46244629
}
46254630

46264631
func testZstdRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
4627-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4632+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendRegistry)
46284633
registry, err := sb.NewRegistry()
46294634
if errors.Is(err, integration.ErrRequirements) {
46304635
t.Skip(err.Error())
@@ -4712,7 +4717,7 @@ func testBasicCacheImportExport(t *testing.T, sb integration.Sandbox, cacheOptio
47124717
}
47134718

47144719
func testBasicRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
4715-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4720+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendRegistry)
47164721
registry, err := sb.NewRegistry()
47174722
if errors.Is(err, integration.ErrRequirements) {
47184723
t.Skip(err.Error())
@@ -4729,7 +4734,7 @@ func testBasicRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
47294734
}
47304735

47314736
func testMultipleRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
4732-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4737+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendRegistry)
47334738
registry, err := sb.NewRegistry()
47344739
if errors.Is(err, integration.ErrRequirements) {
47354740
t.Skip(err.Error())
@@ -4752,7 +4757,7 @@ func testMultipleRegistryCacheImportExport(t *testing.T, sb integration.Sandbox)
47524757
}
47534758

47544759
func testBasicLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
4755-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4760+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendLocal)
47564761
dir := t.TempDir()
47574762
im := CacheOptionsEntry{
47584763
Type: "local",
@@ -4770,7 +4775,7 @@ func testBasicLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
47704775
}
47714776

47724777
func testBasicS3CacheImportExport(t *testing.T, sb integration.Sandbox) {
4773-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4778+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendS3)
47744779

47754780
opts := integration.MinioOpts{
47764781
Region: "us-east-1",
@@ -4808,7 +4813,7 @@ func testBasicS3CacheImportExport(t *testing.T, sb integration.Sandbox) {
48084813
}
48094814

48104815
func testBasicAzblobCacheImportExport(t *testing.T, sb integration.Sandbox) {
4811-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4816+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendAzblob)
48124817

48134818
opts := integration.AzuriteOpts{
48144819
AccountName: "azblobcacheaccount",
@@ -4841,7 +4846,13 @@ func testBasicAzblobCacheImportExport(t *testing.T, sb integration.Sandbox) {
48414846
}
48424847

48434848
func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
4844-
integration.CheckFeatureCompat(t, sb, integration.FeatureDirectPush, integration.FeatureCacheImport)
4849+
integration.CheckFeatureCompat(t, sb,
4850+
integration.FeatureDirectPush,
4851+
integration.FeatureCacheExport,
4852+
integration.FeatureCacheImport,
4853+
integration.FeatureCacheBackendInline,
4854+
integration.FeatureCacheBackendRegistry,
4855+
)
48454856
requiresLinux(t)
48464857
registry, err := sb.NewRegistry()
48474858
if errors.Is(err, integration.ErrRequirements) {
@@ -5001,7 +5012,7 @@ func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
50015012
}
50025013

50035014
func testBasicGhaCacheImportExport(t *testing.T, sb integration.Sandbox) {
5004-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
5015+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendGha)
50055016
runtimeToken := os.Getenv("ACTIONS_RUNTIME_TOKEN")
50065017
cacheURL := os.Getenv("ACTIONS_CACHE_URL")
50075018
if runtimeToken == "" || cacheURL == "" {

frontend/dockerfile/dockerfile_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ RUN [ "$(cat testfile)" == "contents0" ]
420420
}
421421

422422
func testExportCacheLoop(t *testing.T, sb integration.Sandbox) {
423-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
423+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendLocal)
424424
f := getFrontend(t, sb)
425425

426426
dockerfile := []byte(`
@@ -3949,7 +3949,12 @@ ONBUILD RUN mkdir -p /out && echo -n 11 >> /out/foo
39493949
}
39503950

39513951
func testCacheMultiPlatformImportExport(t *testing.T, sb integration.Sandbox) {
3952-
integration.CheckFeatureCompat(t, sb, integration.FeatureDirectPush)
3952+
integration.CheckFeatureCompat(t, sb,
3953+
integration.FeatureDirectPush,
3954+
integration.FeatureCacheExport,
3955+
integration.FeatureCacheBackendInline,
3956+
integration.FeatureCacheBackendRegistry,
3957+
)
39533958
f := getFrontend(t, sb)
39543959

39553960
registry, err := sb.NewRegistry()
@@ -4072,7 +4077,7 @@ COPY --from=base arch /
40724077
}
40734078

40744079
func testCacheImportExport(t *testing.T, sb integration.Sandbox) {
4075-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
4080+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheBackendLocal)
40764081
f := getFrontend(t, sb)
40774082

40784083
registry, err := sb.NewRegistry()

util/testutil/integration/dockerd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ func InitDockerdWorker() {
2525
unsupported: []string{
2626
FeatureCacheExport,
2727
FeatureCacheImport,
28+
FeatureCacheBackendAzblob,
29+
FeatureCacheBackendGha,
30+
FeatureCacheBackendLocal,
31+
FeatureCacheBackendRegistry,
32+
FeatureCacheBackendS3,
2833
FeatureDirectPush,
2934
FeatureImageExporter,
3035
FeatureMultiCacheExport,

util/testutil/integration/sandbox.go

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -284,41 +284,53 @@ func printLogs(logs map[string]*bytes.Buffer, f func(args ...interface{})) {
284284
}
285285

286286
const (
287-
FeatureCacheExport = "cache_export"
288-
FeatureCacheImport = "cache_import"
289-
FeatureDirectPush = "direct_push"
290-
FeatureFrontendOutline = "frontend_outline"
291-
FeatureFrontendTargets = "frontend_targets"
292-
FeatureImageExporter = "image_exporter"
293-
FeatureInfo = "info"
294-
FeatureMultiCacheExport = "multi_cache_export"
295-
FeatureMultiPlatform = "multi_platform"
296-
FeatureOCIExporter = "oci_exporter"
297-
FeatureOCILayout = "oci_layout"
298-
FeatureProvenance = "provenance"
299-
FeatureSBOM = "sbom"
300-
FeatureSecurityMode = "security_mode"
301-
FeatureSourceDateEpoch = "source_date_epoch"
302-
FeatureCNINetwork = "cni_network"
287+
FeatureCacheExport = "cache_export"
288+
FeatureCacheImport = "cache_import"
289+
FeatureCacheBackendAzblob = "cache_backend_azblob"
290+
FeatureCacheBackendGha = "cache_backend_gha"
291+
FeatureCacheBackendInline = "cache_backend_inline"
292+
FeatureCacheBackendLocal = "cache_backend_local"
293+
FeatureCacheBackendRegistry = "cache_backend_registry"
294+
FeatureCacheBackendS3 = "cache_backend_s3"
295+
FeatureDirectPush = "direct_push"
296+
FeatureFrontendOutline = "frontend_outline"
297+
FeatureFrontendTargets = "frontend_targets"
298+
FeatureImageExporter = "image_exporter"
299+
FeatureInfo = "info"
300+
FeatureMultiCacheExport = "multi_cache_export"
301+
FeatureMultiPlatform = "multi_platform"
302+
FeatureOCIExporter = "oci_exporter"
303+
FeatureOCILayout = "oci_layout"
304+
FeatureProvenance = "provenance"
305+
FeatureSBOM = "sbom"
306+
FeatureSecurityMode = "security_mode"
307+
FeatureSourceDateEpoch = "source_date_epoch"
308+
FeatureCNINetwork = "cni_network"
303309
)
304310

305311
var features = map[string]struct{}{
306-
FeatureCacheExport: {},
307-
FeatureCacheImport: {},
308-
FeatureDirectPush: {},
309-
FeatureFrontendOutline: {},
310-
FeatureFrontendTargets: {},
311-
FeatureImageExporter: {},
312-
FeatureInfo: {},
313-
FeatureMultiCacheExport: {},
314-
FeatureMultiPlatform: {},
315-
FeatureOCIExporter: {},
316-
FeatureOCILayout: {},
317-
FeatureProvenance: {},
318-
FeatureSBOM: {},
319-
FeatureSecurityMode: {},
320-
FeatureSourceDateEpoch: {},
321-
FeatureCNINetwork: {},
312+
FeatureCacheExport: {},
313+
FeatureCacheImport: {},
314+
FeatureCacheBackendAzblob: {},
315+
FeatureCacheBackendGha: {},
316+
FeatureCacheBackendInline: {},
317+
FeatureCacheBackendLocal: {},
318+
FeatureCacheBackendRegistry: {},
319+
FeatureCacheBackendS3: {},
320+
FeatureDirectPush: {},
321+
FeatureFrontendOutline: {},
322+
FeatureFrontendTargets: {},
323+
FeatureImageExporter: {},
324+
FeatureInfo: {},
325+
FeatureMultiCacheExport: {},
326+
FeatureMultiPlatform: {},
327+
FeatureOCIExporter: {},
328+
FeatureOCILayout: {},
329+
FeatureProvenance: {},
330+
FeatureSBOM: {},
331+
FeatureSecurityMode: {},
332+
FeatureSourceDateEpoch: {},
333+
FeatureCNINetwork: {},
322334
}
323335

324336
func CheckFeatureCompat(t *testing.T, sb Sandbox, reason ...string) {

0 commit comments

Comments
 (0)