Skip to content

Commit 9198f36

Browse files
authored
test: parallelize releasepolicy subtests (NVIDIA#2152)
Signed-off-by: Yuan Chen <yuanchen97@gmail.com>
1 parent dbddffb commit 9198f36

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

tests/releasepolicy/release_reverify_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ func TestReleaseReverifyWorkflowShape(t *testing.T) {
248248
// network trouble must be operational and must never look like a missing entry.
249249
// Every case here is one side of that line.
250250
func TestReleaseReverifyClassification(t *testing.T) {
251+
t.Parallel()
251252
script := reverifyClassifierScript(t)
252253

253254
// Every fixture derives from the floor constant. Hardcoding a version here
@@ -668,6 +669,7 @@ func TestReleaseReverifyClassification(t *testing.T) {
668669

669670
for _, tc := range tests {
670671
t.Run(tc.name, func(t *testing.T) {
672+
t.Parallel()
671673
got, code, output := runReverifyClassifier(t, script, tc.opts)
672674
if got != tc.want || code != tc.code {
673675
t.Fatalf("classification = %q (exit %d), want %q (exit %d)\n%s", got, code, tc.want, tc.code, output)
@@ -693,6 +695,7 @@ func TestReleaseReverifyClassification(t *testing.T) {
693695
// misclassifies as a security finding — which is the failure mode this workflow
694696
// exists to prevent, so the tests must not pass without the guards.
695697
func TestReleaseReverifyGuardsAreLoadBearing(t *testing.T) {
698+
t.Parallel()
696699
script := reverifyClassifierScript(t)
697700

698701
tests := []struct {
@@ -827,6 +830,7 @@ func TestReleaseReverifyGuardsAreLoadBearing(t *testing.T) {
827830

828831
for _, tc := range tests {
829832
t.Run(tc.name, func(t *testing.T) {
833+
t.Parallel()
830834
opts := tc.opts
831835
opts.tag = reverifySBOMFloor
832836
if !opts.missingAssetsFile {
@@ -881,6 +885,7 @@ func TestReleaseReverifyGuardsAreLoadBearing(t *testing.T) {
881885
// set unambiguous, and the assertions name the exact subjects rather than
882886
// counting them.
883887
func TestReleaseReverifySBOMLoopIsolatesChildStdin(t *testing.T) {
888+
t.Parallel()
884889
script := reverifyClassifierScript(t)
885890

886891
// Pin the redirect count so a change in form (a different redirection, or a
@@ -926,6 +931,7 @@ func TestReleaseReverifySBOMLoopIsolatesChildStdin(t *testing.T) {
926931

927932
for _, tc := range tests {
928933
t.Run(tc.name, func(t *testing.T) {
934+
t.Parallel()
929935
opts := reverifyOptions{
930936
tag: "v" + version,
931937
assets: assets,
@@ -990,6 +996,7 @@ func verifiedSBOMs(output string) []string {
990996
// did so deliberately. A release that is genuinely missing an SBOM bundle would
991997
// come back clean.
992998
func TestReleaseReverifySBOMFloorOrderingIsGuarded(t *testing.T) {
999+
t.Parallel()
9931000
script := reverifyClassifierScript(t)
9941001

9951002
const from = `newest=""
@@ -1059,6 +1066,7 @@ if [ "${TAG}" = "${SBOM_SIGNING_FLOOR}" ] || [ "${newest}" != "${TAG}" ]; then`
10591066
// same derive-from-the-artifact-under-test flaw that shipped the allowlist bug
10601067
// in NVIDIA/aicr#1982.
10611068
func TestReleaseReverifyMandatorySBOMSetIsDerivedFromTheTag(t *testing.T) {
1069+
t.Parallel()
10621070
script := reverifyClassifierScript(t)
10631071

10641072
derivation := " read -r -a sbom_binaries <<< \"${EXPECTED_SBOM_BINARIES}\"\n" +
@@ -1133,6 +1141,7 @@ func TestReleaseReverifyMandatorySBOMSetIsDerivedFromTheTag(t *testing.T) {
11331141
// is the deliberate divergence from rekor-monitor, whose alert tracks the
11341142
// release-agnostic log and so genuinely clears on any clean run.
11351143
func TestReleaseReverifyAlertCloseIsTagScoped(t *testing.T) {
1144+
t.Parallel()
11361145
doc := loadYAML(t, reverifyWorkflow)
11371146
env := mapValue(t, doc, "env")
11381147
alertTitle := fmt.Sprint(env["ALERT_TITLE"])
@@ -1184,6 +1193,7 @@ func TestReleaseReverifyAlertCloseIsTagScoped(t *testing.T) {
11841193
}
11851194
for _, tc := range tests {
11861195
t.Run(tc.name, func(t *testing.T) {
1196+
t.Parallel()
11871197
closed, output, err := runReverifyCloseStep(t, script, tc.tag, tc.issues)
11881198
if err != nil {
11891199
t.Fatalf("close step failed: %v\n%s", err, output)
@@ -1195,6 +1205,7 @@ func TestReleaseReverifyAlertCloseIsTagScoped(t *testing.T) {
11951205
}
11961206

11971207
t.Run("an unscoped close reopens the bug", func(t *testing.T) {
1208+
t.Parallel()
11981209
// The pre-fix shape: one global alert title, closed by any clean run.
11991210
// Staged with the unscoped title on both sides, which is what the
12001211
// workflow used to create.

tests/releasepolicy/release_scripts_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func TestReleaseScriptsStructure(t *testing.T) {
6767
// mutated registry aliases. Deriving the expected names from the stanza's own
6868
// `signature:` template keeps the two from drifting apart.
6969
func TestReleaseSbomSignaturesAreAllowlisted(t *testing.T) {
70+
t.Parallel()
7071
config := loadYAML(t, ".goreleaser.yaml")
7172

7273
sboms, ok := config["sboms"].([]any)
@@ -201,6 +202,7 @@ func shellReleaseAssetNames(t *testing.T, tag string) []string {
201202
// path as a release artifact whether or not the script writes it, so every
202203
// path that cannot produce a bundle has to exit non-zero.
203204
func TestReleaseSignSbomBehavior(t *testing.T) {
205+
t.Parallel()
204206
tests := []struct {
205207
name string
206208
failures int
@@ -225,6 +227,7 @@ func TestReleaseSignSbomBehavior(t *testing.T) {
225227
}
226228
for _, tc := range tests {
227229
t.Run(tc.name, func(t *testing.T) {
230+
t.Parallel()
228231
dir := t.TempDir()
229232
bin := filepath.Join(dir, "bin")
230233
if err := os.Mkdir(bin, 0o700); err != nil {
@@ -349,6 +352,7 @@ func TestReleaseHomebrewScriptIsMutationLimited(t *testing.T) {
349352
}
350353

351354
func TestReleaseResolverBehavior(t *testing.T) {
355+
t.Parallel()
352356
tests := []struct {
353357
name string
354358
badLabelRef string
@@ -362,6 +366,7 @@ func TestReleaseResolverBehavior(t *testing.T) {
362366
}
363367
for _, tc := range tests {
364368
t.Run(tc.name, func(t *testing.T) {
369+
t.Parallel()
365370
fixture := newReleaseFixture(t)
366371
output := filepath.Join(fixture.dir, "digests.json")
367372
env := fixture.environment()
@@ -390,6 +395,7 @@ func TestReleaseResolverBehavior(t *testing.T) {
390395
}
391396

392397
func TestReleaseRejectsNonCanonicalReleaseTags(t *testing.T) {
398+
t.Parallel()
393399
for _, tag := range []string{
394400
"v01.2.3",
395401
"v1.02.3",
@@ -400,6 +406,7 @@ func TestReleaseRejectsNonCanonicalReleaseTags(t *testing.T) {
400406
"v1.2.3+build.1",
401407
} {
402408
t.Run(tag, func(t *testing.T) {
409+
t.Parallel()
403410
fixture := newReleaseFixture(t)
404411
environment := append(fixture.environment(), "RELEASE_TAG="+tag)
405412
result := runScript(t, environment, ".github/scripts/release-images.sh", "verify-source")
@@ -411,6 +418,7 @@ func TestReleaseRejectsNonCanonicalReleaseTags(t *testing.T) {
411418
}
412419

413420
func TestReleaseTargetRerunPolicy(t *testing.T) {
421+
t.Parallel()
414422
tests := []struct {
415423
name string
416424
releases [][]map[string]any
@@ -541,6 +549,7 @@ func TestReleaseTargetRerunPolicy(t *testing.T) {
541549
}
542550
for _, tc := range tests {
543551
t.Run(tc.name, func(t *testing.T) {
552+
t.Parallel()
544553
fixture := newReleaseFixture(t)
545554
writeJSON(t, fixture.releases, tc.releases)
546555
if tc.assets != nil {
@@ -561,6 +570,7 @@ func TestReleaseTargetRerunPolicy(t *testing.T) {
561570
}
562571

563572
func TestReleasePublishRequiresExactDraftAssetsAndID(t *testing.T) {
573+
t.Parallel()
564574
tests := []struct {
565575
name string
566576
modifyRelease func(map[string]any)
@@ -635,6 +645,7 @@ func TestReleasePublishRequiresExactDraftAssetsAndID(t *testing.T) {
635645
}
636646
for _, tc := range tests {
637647
t.Run(tc.name, func(t *testing.T) {
648+
t.Parallel()
638649
fixture := newReleaseFixture(t)
639650
release := map[string]any{
640651
"id": 42,
@@ -684,6 +695,7 @@ func TestReleasePublishRequiresExactDraftAssetsAndID(t *testing.T) {
684695
}
685696

686697
func TestReleasePreflightRejectsConflictingVersionWithoutMutation(t *testing.T) {
698+
t.Parallel()
687699
fixture := newReleaseFixture(t)
688700
mapPath := filepath.Join(fixture.dir, "digests.json")
689701
writeDigestMap(t, mapPath, fixture.digests)
@@ -702,6 +714,7 @@ func TestReleasePreflightRejectsConflictingVersionWithoutMutation(t *testing.T)
702714
}
703715

704716
func TestReleasePreflightRejectsDuplicateDigestKeysWithoutMutation(t *testing.T) {
717+
t.Parallel()
705718
fixture := newReleaseFixture(t)
706719
encoded, err := json.Marshal(fixture.digests)
707720
if err != nil {
@@ -727,6 +740,7 @@ func TestReleasePreflightRejectsDuplicateDigestKeysWithoutMutation(t *testing.T)
727740
}
728741

729742
func TestReleasePreflightRejectsReleaseKindMismatchWithoutMutation(t *testing.T) {
743+
t.Parallel()
730744
fixture := newStableReleaseFixture(t)
731745
mapPath := filepath.Join(fixture.dir, "digests.json")
732746
writeDigestMap(t, mapPath, fixture.digests)
@@ -742,6 +756,7 @@ func TestReleasePreflightRejectsReleaseKindMismatchWithoutMutation(t *testing.T)
742756
}
743757

744758
func TestReleasePreflightFailureModesHaveNoMutations(t *testing.T) {
759+
t.Parallel()
745760
tests := []struct {
746761
name string
747762
setup func(*testing.T, releaseFixture, map[string]string) []string
@@ -810,6 +825,7 @@ func TestReleasePreflightFailureModesHaveNoMutations(t *testing.T) {
810825
}
811826
for _, tc := range tests {
812827
t.Run(tc.name, func(t *testing.T) {
828+
t.Parallel()
813829
fixture := newReleaseFixture(t)
814830
digests := make(map[string]string, len(fixture.digests))
815831
for key, digest := range fixture.digests {
@@ -835,6 +851,7 @@ func TestReleasePreflightFailureModesHaveNoMutations(t *testing.T) {
835851
}
836852

837853
func TestReleaseStablePreflightFailureModesHaveNoMutations(t *testing.T) {
854+
t.Parallel()
838855
tests := []struct {
839856
name string
840857
setup func(*testing.T, releaseFixture)
@@ -922,6 +939,7 @@ func TestReleaseStablePreflightFailureModesHaveNoMutations(t *testing.T) {
922939
}
923940
for _, tc := range tests {
924941
t.Run(tc.name, func(t *testing.T) {
942+
t.Parallel()
925943
fixture := newStableReleaseFixture(t)
926944
tc.setup(t, fixture)
927945
mapPath := filepath.Join(fixture.dir, "digests.json")
@@ -942,6 +960,7 @@ func TestReleaseStablePreflightFailureModesHaveNoMutations(t *testing.T) {
942960
}
943961

944962
func TestReleasePriorSelectionIgnoresNonStableNames(t *testing.T) {
963+
t.Parallel()
945964
fixture := newStableReleaseFixture(t)
946965
writeJSON(t, fixture.releases, [][]map[string]any{{
947966
{"tag_name": "v1.2.2", "draft": false, "prerelease": false},
@@ -958,6 +977,7 @@ func TestReleasePriorSelectionIgnoresNonStableNames(t *testing.T) {
958977
}
959978

960979
func TestReleasePreflightRejectsMovedCurrentTag(t *testing.T) {
980+
t.Parallel()
961981
fixture := newReleaseFixture(t)
962982
mapPath := filepath.Join(fixture.dir, "digests.json")
963983
writeDigestMap(t, mapPath, fixture.digests)
@@ -973,6 +993,7 @@ func TestReleasePreflightRejectsMovedCurrentTag(t *testing.T) {
973993
}
974994

975995
func TestReleasePromotionRejectsPostPreflightAliasMutationWithoutWrites(t *testing.T) {
996+
t.Parallel()
976997
fixture := newStableReleaseFixture(t)
977998
mapPath := filepath.Join(fixture.dir, "digests.json")
978999
writeDigestMap(t, mapPath, fixture.digests)
@@ -993,6 +1014,7 @@ func TestReleasePromotionRejectsPostPreflightAliasMutationWithoutWrites(t *testi
9931014
}
9941015

9951016
func TestReleasePreflightPaginatesAndPeelsAnnotatedTags(t *testing.T) {
1017+
t.Parallel()
9961018
fixture := newStableReleaseFixture(t)
9971019
mapPath := filepath.Join(fixture.dir, "digests.json")
9981020
writeDigestMap(t, mapPath, fixture.digests)
@@ -1008,7 +1030,9 @@ func TestReleasePreflightPaginatesAndPeelsAnnotatedTags(t *testing.T) {
10081030
}
10091031

10101032
func TestReleaseV0170UnlabeledBootstrapIsExact(t *testing.T) {
1033+
t.Parallel()
10111034
t.Run("pinned core digests accepted", func(t *testing.T) {
1035+
t.Parallel()
10121036
fixture := newV0170BootstrapFixture(t)
10131037
mapPath := filepath.Join(fixture.dir, "digests.json")
10141038
writeDigestMap(t, mapPath, fixture.digests)
@@ -1020,6 +1044,7 @@ func TestReleaseV0170UnlabeledBootstrapIsExact(t *testing.T) {
10201044
})
10211045

10221046
t.Run("other unlabeled core digest rejected", func(t *testing.T) {
1047+
t.Parallel()
10231048
fixture := newV0170BootstrapFixture(t)
10241049
wrong := "sha256:" + strings.Repeat("f", 64)
10251050
appendFile(t, fixture.digestState, releaseImages["aicr"]+":v0.17.0\t"+wrong+"\n")
@@ -1038,6 +1063,7 @@ func TestReleaseV0170UnlabeledBootstrapIsExact(t *testing.T) {
10381063
}
10391064

10401065
func TestReleaseStablePromotionConvergesAndRerunsWithoutMutation(t *testing.T) {
1066+
t.Parallel()
10411067
fixture := newStableReleaseFixture(t)
10421068
mapPath := filepath.Join(fixture.dir, "digests.json")
10431069
writeDigestMap(t, mapPath, fixture.digests)
@@ -1070,6 +1096,7 @@ func TestReleaseStablePromotionConvergesAndRerunsWithoutMutation(t *testing.T) {
10701096
}
10711097

10721098
func TestReleasePromotionDefersLatestUntilEveryVersionIsVerified(t *testing.T) {
1099+
t.Parallel()
10731100
tests := []struct {
10741101
name string
10751102
extraEnv func(releaseFixture) string
@@ -1090,6 +1117,7 @@ func TestReleasePromotionDefersLatestUntilEveryVersionIsVerified(t *testing.T) {
10901117
}
10911118
for _, tc := range tests {
10921119
t.Run(tc.name, func(t *testing.T) {
1120+
t.Parallel()
10931121
fixture := newStableReleaseFixture(t)
10941122
mapPath := filepath.Join(fixture.dir, "digests.json")
10951123
writeDigestMap(t, mapPath, fixture.digests)
@@ -1123,6 +1151,7 @@ func TestReleasePromotionHasExplicitVersionThenLatestPhases(t *testing.T) {
11231151
}
11241152

11251153
func TestReleaseStablePromotionConvergesMixedAliasStates(t *testing.T) {
1154+
t.Parallel()
11261155
fixture := newStableReleaseFixture(t)
11271156
keys := make([]string, 0, len(releaseImages))
11281157
for key := range releaseImages {
@@ -1163,6 +1192,7 @@ func TestReleaseStablePromotionConvergesMixedAliasStates(t *testing.T) {
11631192
}
11641193

11651194
func TestReleasePromotionRejectsTagMovementAfterPreflightWithoutWrites(t *testing.T) {
1195+
t.Parallel()
11661196
fixture := newStableReleaseFixture(t)
11671197
mapPath := filepath.Join(fixture.dir, "digests.json")
11681198
writeDigestMap(t, mapPath, fixture.digests)
@@ -1182,6 +1212,7 @@ func TestReleasePromotionRejectsTagMovementAfterPreflightWithoutWrites(t *testin
11821212
}
11831213

11841214
func TestReleasePromotionPrereleaseWritesOnlyVersionAliases(t *testing.T) {
1215+
t.Parallel()
11851216
fixture := newReleaseFixture(t)
11861217
validated := map[string]any{
11871218
"candidate_tag": fixture.candidateTag,
@@ -1224,6 +1255,7 @@ func TestReleasePromotionPrereleaseWritesOnlyVersionAliases(t *testing.T) {
12241255
}
12251256

12261257
func TestReleaseHomebrewBehavior(t *testing.T) {
1258+
t.Parallel()
12271259
tests := []struct {
12281260
name string
12291261
existingTag string
@@ -1271,6 +1303,7 @@ func TestReleaseHomebrewBehavior(t *testing.T) {
12711303
}
12721304
for _, tc := range tests {
12731305
t.Run(tc.name, func(t *testing.T) {
1306+
t.Parallel()
12741307
dir := t.TempDir()
12751308
bin := filepath.Join(dir, "bin")
12761309
tap := filepath.Join(dir, "tap")
@@ -1334,7 +1367,9 @@ func TestReleaseHomebrewBehavior(t *testing.T) {
13341367
}
13351368

13361369
func TestReleaseNetworkBoundsTerminateBlockedCommands(t *testing.T) {
1370+
t.Parallel()
13371371
t.Run("candidate resolver", func(t *testing.T) {
1372+
t.Parallel()
13381373
fixture := newReleaseFixture(t)
13391374
writeExecutable(t, filepath.Join(fixture.bin, "timeout"), fakeTimeout)
13401375
writeExecutable(t, filepath.Join(fixture.bin, "crane"), blockingCommand)
@@ -1357,6 +1392,7 @@ func TestReleaseNetworkBoundsTerminateBlockedCommands(t *testing.T) {
13571392
})
13581393

13591394
t.Run("Homebrew checksum fetch", func(t *testing.T) {
1395+
t.Parallel()
13601396
dir := t.TempDir()
13611397
bin := filepath.Join(dir, "bin")
13621398
formulaDir := filepath.Join(dir, "tap", "Formula")

0 commit comments

Comments
 (0)