Skip to content

Commit 365598b

Browse files
committed
integration: split feature compat check for subtests
Signed-off-by: CrazyMax <[email protected]>
1 parent 7f6cae2 commit 365598b

File tree

1 file changed

+70
-20
lines changed

1 file changed

+70
-20
lines changed

client/client_test.go

Lines changed: 70 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,6 @@ func testSecurityModeErrors(t *testing.T, sb integration.Sandbox) {
974974
}
975975

976976
func testFrontendImageNaming(t *testing.T, sb integration.Sandbox) {
977-
integration.CheckFeatureCompat(t, sb, integration.FeatureOCIExporter, integration.FeatureDirectPush)
978977
requiresLinux(t)
979978
c, err := New(sb.Context(), sb.Address())
980979
require.NoError(t, err)
@@ -1083,12 +1082,15 @@ func testFrontendImageNaming(t *testing.T, sb integration.Sandbox) {
10831082

10841083
switch exp {
10851084
case ExporterOCI:
1085+
integration.CheckFeatureCompat(t, sb, integration.FeatureOCIExporter)
10861086
t.Skip("oci exporter does not support named images")
10871087
case ExporterDocker:
1088+
integration.CheckFeatureCompat(t, sb, integration.FeatureOCIExporter)
10881089
outW, err := os.Create(out)
10891090
require.NoError(t, err)
10901091
so.Exports[0].Output = fixedWriteCloser(outW)
10911092
case ExporterImage:
1093+
integration.CheckFeatureCompat(t, sb, integration.FeatureDirectPush)
10921094
imageName = registry + "/" + imageName
10931095
so.Exports[0].Attrs["push"] = "true"
10941096
}
@@ -3747,7 +3749,11 @@ func testBuildPushAndValidate(t *testing.T, sb integration.Sandbox) {
37473749
}
37483750

37493751
func testStargzLazyRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
3750-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendRegistry)
3752+
integration.CheckFeatureCompat(t, sb,
3753+
integration.FeatureCacheExport,
3754+
integration.FeatureCacheBackendRegistry,
3755+
integration.FeatureOCIExporter,
3756+
)
37513757
requiresLinux(t)
37523758
cdAddress := sb.ContainerdAddress()
37533759
if cdAddress == "" || sb.Snapshotter() != "stargz" {
@@ -3807,6 +3813,7 @@ func testStargzLazyRegistryCacheImportExport(t *testing.T, sb integration.Sandbo
38073813

38083814
// clear all local state out
38093815
ensurePruneAll(t, c, sb)
3816+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheImport, integration.FeatureDirectPush)
38103817

38113818
// stargz layers should be lazy even for executing something on them
38123819
def, err = baseDef.
@@ -4456,12 +4463,7 @@ func testZstdLocalCacheExport(t *testing.T, sb integration.Sandbox) {
44564463
}
44574464

44584465
func testCacheExportIgnoreError(t *testing.T, sb integration.Sandbox) {
4459-
integration.CheckFeatureCompat(t, sb,
4460-
integration.FeatureCacheExport,
4461-
integration.FeatureCacheBackendS3,
4462-
integration.FeatureCacheBackendLocal,
4463-
integration.FeatureCacheBackendRegistry,
4464-
)
4466+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport)
44654467
c, err := New(sb.Context(), sb.Address())
44664468
require.NoError(t, err)
44674469
defer c.Close()
@@ -4544,12 +4546,21 @@ func testCacheExportIgnoreError(t *testing.T, sb integration.Sandbox) {
45444546
for _, ignoreError := range ignoreErrorValues {
45454547
ignoreErrStr := strconv.FormatBool(ignoreError)
45464548
for n, test := range tests {
4549+
n := n
45474550
require.Equal(t, 1, len(test.Exports))
45484551
require.Equal(t, 1, len(test.CacheExports))
45494552
require.NotEmpty(t, test.CacheExports[0].Attrs)
45504553
test.CacheExports[0].Attrs["ignore-error"] = ignoreErrStr
45514554
testName := fmt.Sprintf("%s-%s", n, ignoreErrStr)
45524555
t.Run(testName, func(t *testing.T) {
4556+
switch n {
4557+
case "local-ignore-error":
4558+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheBackendLocal)
4559+
case "registry-ignore-error":
4560+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheBackendRegistry)
4561+
case "s3-ignore-error":
4562+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheBackendS3)
4563+
}
45534564
_, err = c.Solve(sb.Context(), def, SolveOpt{
45544565
Exports: test.Exports,
45554566
CacheExports: test.CacheExports,
@@ -4568,7 +4579,11 @@ func testCacheExportIgnoreError(t *testing.T, sb integration.Sandbox) {
45684579
}
45694580

45704581
func testUncompressedLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
4571-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendLocal)
4582+
integration.CheckFeatureCompat(t, sb,
4583+
integration.FeatureCacheExport,
4584+
integration.FeatureCacheImport,
4585+
integration.FeatureCacheBackendLocal,
4586+
)
45724587
dir := t.TempDir()
45734588
im := CacheOptionsEntry{
45744589
Type: "local",
@@ -4588,7 +4603,11 @@ func testUncompressedLocalCacheImportExport(t *testing.T, sb integration.Sandbox
45884603
}
45894604

45904605
func testUncompressedRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
4591-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendRegistry)
4606+
integration.CheckFeatureCompat(t, sb,
4607+
integration.FeatureCacheExport,
4608+
integration.FeatureCacheImport,
4609+
integration.FeatureCacheBackendRegistry,
4610+
)
45924611
registry, err := sb.NewRegistry()
45934612
if errors.Is(err, integration.ErrRequirements) {
45944613
t.Skip(err.Error())
@@ -4613,7 +4632,11 @@ func testUncompressedRegistryCacheImportExport(t *testing.T, sb integration.Sand
46134632
}
46144633

46154634
func testZstdLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
4616-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendLocal)
4635+
integration.CheckFeatureCompat(t, sb,
4636+
integration.FeatureCacheExport,
4637+
integration.FeatureCacheImport,
4638+
integration.FeatureCacheBackendLocal,
4639+
)
46174640
dir := t.TempDir()
46184641
im := CacheOptionsEntry{
46194642
Type: "local",
@@ -4634,7 +4657,11 @@ func testZstdLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
46344657
}
46354658

46364659
func testZstdRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
4637-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendRegistry)
4660+
integration.CheckFeatureCompat(t, sb,
4661+
integration.FeatureCacheExport,
4662+
integration.FeatureCacheImport,
4663+
integration.FeatureCacheBackendRegistry,
4664+
)
46384665
registry, err := sb.NewRegistry()
46394666
if errors.Is(err, integration.ErrRequirements) {
46404667
t.Skip(err.Error())
@@ -4722,7 +4749,11 @@ func testBasicCacheImportExport(t *testing.T, sb integration.Sandbox, cacheOptio
47224749
}
47234750

47244751
func testBasicRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
4725-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendRegistry)
4752+
integration.CheckFeatureCompat(t, sb,
4753+
integration.FeatureCacheExport,
4754+
integration.FeatureCacheImport,
4755+
integration.FeatureCacheBackendRegistry,
4756+
)
47264757
registry, err := sb.NewRegistry()
47274758
if errors.Is(err, integration.ErrRequirements) {
47284759
t.Skip(err.Error())
@@ -4739,7 +4770,11 @@ func testBasicRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
47394770
}
47404771

47414772
func testMultipleRegistryCacheImportExport(t *testing.T, sb integration.Sandbox) {
4742-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendRegistry)
4773+
integration.CheckFeatureCompat(t, sb,
4774+
integration.FeatureCacheExport,
4775+
integration.FeatureCacheImport,
4776+
integration.FeatureCacheBackendRegistry,
4777+
)
47434778
registry, err := sb.NewRegistry()
47444779
if errors.Is(err, integration.ErrRequirements) {
47454780
t.Skip(err.Error())
@@ -4762,7 +4797,11 @@ func testMultipleRegistryCacheImportExport(t *testing.T, sb integration.Sandbox)
47624797
}
47634798

47644799
func testBasicLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
4765-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendLocal)
4800+
integration.CheckFeatureCompat(t, sb,
4801+
integration.FeatureCacheExport,
4802+
integration.FeatureCacheImport,
4803+
integration.FeatureCacheBackendLocal,
4804+
)
47664805
dir := t.TempDir()
47674806
im := CacheOptionsEntry{
47684807
Type: "local",
@@ -4780,7 +4819,11 @@ func testBasicLocalCacheImportExport(t *testing.T, sb integration.Sandbox) {
47804819
}
47814820

47824821
func testBasicS3CacheImportExport(t *testing.T, sb integration.Sandbox) {
4783-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendS3)
4822+
integration.CheckFeatureCompat(t, sb,
4823+
integration.FeatureCacheExport,
4824+
integration.FeatureCacheImport,
4825+
integration.FeatureCacheBackendS3,
4826+
)
47844827

47854828
opts := integration.MinioOpts{
47864829
Region: "us-east-1",
@@ -4818,7 +4861,11 @@ func testBasicS3CacheImportExport(t *testing.T, sb integration.Sandbox) {
48184861
}
48194862

48204863
func testBasicAzblobCacheImportExport(t *testing.T, sb integration.Sandbox) {
4821-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendAzblob)
4864+
integration.CheckFeatureCompat(t, sb,
4865+
integration.FeatureCacheExport,
4866+
integration.FeatureCacheImport,
4867+
integration.FeatureCacheBackendAzblob,
4868+
)
48224869

48234870
opts := integration.AzuriteOpts{
48244871
AccountName: "azblobcacheaccount",
@@ -4854,9 +4901,7 @@ func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
48544901
integration.CheckFeatureCompat(t, sb,
48554902
integration.FeatureDirectPush,
48564903
integration.FeatureCacheExport,
4857-
integration.FeatureCacheImport,
48584904
integration.FeatureCacheBackendInline,
4859-
integration.FeatureCacheBackendRegistry,
48604905
)
48614906
requiresLinux(t)
48624907
registry, err := sb.NewRegistry()
@@ -4909,6 +4954,7 @@ func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
49094954
require.NoError(t, err)
49104955

49114956
ensurePruneAll(t, c, sb)
4957+
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheImport, integration.FeatureCacheBackendRegistry)
49124958

49134959
resp, err = c.Solve(sb.Context(), def, SolveOpt{
49144960
// specifying inline cache exporter is needed for reproducing containerimage.digest
@@ -5017,7 +5063,11 @@ func testBasicInlineCacheImportExport(t *testing.T, sb integration.Sandbox) {
50175063
}
50185064

50195065
func testBasicGhaCacheImportExport(t *testing.T, sb integration.Sandbox) {
5020-
integration.CheckFeatureCompat(t, sb, integration.FeatureCacheExport, integration.FeatureCacheImport, integration.FeatureCacheBackendGha)
5066+
integration.CheckFeatureCompat(t, sb,
5067+
integration.FeatureCacheExport,
5068+
integration.FeatureCacheImport,
5069+
integration.FeatureCacheBackendGha,
5070+
)
50215071
runtimeToken := os.Getenv("ACTIONS_RUNTIME_TOKEN")
50225072
cacheURL := os.Getenv("ACTIONS_CACHE_URL")
50235073
if runtimeToken == "" || cacheURL == "" {

0 commit comments

Comments
 (0)