Skip to content

Commit 12f0d32

Browse files
authored
test(artifact): run internal/artifact tests in parallel (#1328)
Runs 197 isolated `internal/artifact` top-level tests in parallel to shorten an I/O-bound CI package. Five tests that change process-wide state or measure process-wide allocations remain serial, and subtests are unchanged. The change only affects test scheduling, not assertions or fixtures. Parallelism uses more memory and can become slower at very high concurrency because the fixtures compete for filesystem writes. Co-authored-by: Matthew Jacobs <mjacobs@users.noreply.github.com>
1 parent 37ca8a6 commit 12f0d32

17 files changed

Lines changed: 399 additions & 0 deletions

internal/artifact/canonical_json_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
)
1010

1111
func TestCanonicalJSONSortsStructAndMapKeys(t *testing.T) {
12+
t.Parallel()
13+
1214
type inner struct {
1315
Zeta string `json:"zeta"`
1416
Alpha string `json:"alpha"`
@@ -30,6 +32,8 @@ func TestCanonicalJSONSortsStructAndMapKeys(t *testing.T) {
3032
}
3133

3234
func TestCanonicalJSONPreservesSliceOrder(t *testing.T) {
35+
t.Parallel()
36+
3337
v := struct {
3438
Items []string `json:"items"`
3539
}{Items: []string{"z", "a", "m"}}
@@ -40,6 +44,8 @@ func TestCanonicalJSONPreservesSliceOrder(t *testing.T) {
4044
}
4145

4246
func TestCanonicalJSONRecanonicalizesRawMessage(t *testing.T) {
47+
t.Parallel()
48+
4349
type wrapper struct {
4450
Value json.RawMessage `json:"value"`
4551
}
@@ -51,6 +57,8 @@ func TestCanonicalJSONRecanonicalizesRawMessage(t *testing.T) {
5157
}
5258

5359
func TestCanonicalJSONRejectsTrailingRawMessageContent(t *testing.T) {
60+
t.Parallel()
61+
5462
type wrapper struct {
5563
Value json.RawMessage `json:"value"`
5664
}
@@ -77,6 +85,8 @@ func TestCanonicalJSONRejectsTrailingRawMessageContent(t *testing.T) {
7785
}
7886

7987
func TestCanonicalJSONEmptyRawMessageEncodesAsNull(t *testing.T) {
88+
t.Parallel()
89+
8090
type wrapper struct {
8191
Value json.RawMessage `json:"value"`
8292
}
@@ -87,6 +97,8 @@ func TestCanonicalJSONEmptyRawMessageEncodesAsNull(t *testing.T) {
8797
}
8898

8999
func TestCanonicalJSONPreservesLargeNumberPrecision(t *testing.T) {
100+
t.Parallel()
101+
90102
type wrapper struct {
91103
Value json.RawMessage `json:"value"`
92104
}
@@ -100,6 +112,8 @@ func TestCanonicalJSONPreservesLargeNumberPrecision(t *testing.T) {
100112
}
101113

102114
func TestCanonicalJSONNilPointerAndInterfaceEncodeAsNull(t *testing.T) {
115+
t.Parallel()
116+
103117
var nilPointer *int
104118
data, err := canonicalJSON(nilPointer)
105119
require.NoError(t, err)
@@ -112,6 +126,8 @@ func TestCanonicalJSONNilPointerAndInterfaceEncodeAsNull(t *testing.T) {
112126
}
113127

114128
func TestCanonicalJSONDereferencesPopulatedPointerFields(t *testing.T) {
129+
t.Parallel()
130+
115131
name := "Fixture"
116132
v := struct {
117133
Name *string `json:"name"`
@@ -123,6 +139,8 @@ func TestCanonicalJSONDereferencesPopulatedPointerFields(t *testing.T) {
123139
}
124140

125141
func TestCanonicalJSONOmitsEmptyFieldsAndKeepsZeroValuesWithoutTag(t *testing.T) {
142+
t.Parallel()
143+
126144
type v struct {
127145
Kept int `json:"kept"`
128146
Skipped string `json:"skipped,omitempty"`
@@ -135,6 +153,8 @@ func TestCanonicalJSONOmitsEmptyFieldsAndKeepsZeroValuesWithoutTag(t *testing.T)
135153
}
136154

137155
func TestCanonicalJSONRejectsNonStringMapKeys(t *testing.T) {
156+
t.Parallel()
157+
138158
v := map[int]string{1: "a"}
139159

140160
_, err := canonicalJSON(v)
@@ -143,6 +163,8 @@ func TestCanonicalJSONRejectsNonStringMapKeys(t *testing.T) {
143163
}
144164

145165
func TestCanonicalJSONRejectsUnsupportedKind(t *testing.T) {
166+
t.Parallel()
167+
146168
v := struct {
147169
Ch chan int `json:"ch"`
148170
}{Ch: make(chan int)}

internal/artifact/export_checkpoint_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
)
1616

1717
func TestCheckpointFloorBootstrapsFromLiveAndQuarantinedNodes(t *testing.T) {
18+
t.Parallel()
19+
1820
_, store := newTestDocbankStore(t, docbank.Config{})
1921
database := testDB(t)
2022
origin := contractOrigin
@@ -47,6 +49,8 @@ func TestCheckpointFloorBootstrapsFromLiveAndQuarantinedNodes(t *testing.T) {
4749
}
4850

4951
func TestCheckpointFloorTraversesStoreOnlyBeforeBootstrap(t *testing.T) {
52+
t.Parallel()
53+
5054
database := testDB(t)
5155
store := &countingCheckpointFloorStore{floor: 40}
5256

@@ -75,6 +79,8 @@ func (s *countingCheckpointFloorStore) checkpointFloor(context.Context, string)
7579
}
7680

7781
func TestExportCheckpointBootstrapStreamsLargeSessionMap(t *testing.T) {
82+
t.Parallel()
83+
7884
sessions := make(map[string]string, 2000)
7985
for i := range 2000 {
8086
sessions[fmt.Sprintf("%s~session-%04d", contractOrigin, i)] = strings64("a")
@@ -95,6 +101,8 @@ func TestExportCheckpointBootstrapStreamsLargeSessionMap(t *testing.T) {
95101
}
96102

97103
func TestExportCheckpointBootstrapSkipsNoncanonicalJSON(t *testing.T) {
104+
t.Parallel()
105+
98106
tests := []struct {
99107
name string
100108
body string
@@ -132,6 +140,8 @@ func TestExportCheckpointBootstrapSkipsNoncanonicalJSON(t *testing.T) {
132140
}
133141

134142
func TestExportCheckpointBootstrapSkipsMalformedCheckpointBeforeEOF(t *testing.T) {
143+
t.Parallel()
144+
135145
database := testExportDB(t)
136146
store := newTestArtifactStore(t)
137147
body := append([]byte(`{"unexpected":`), deterministicDocbankBytes(1<<20)...)
@@ -153,6 +163,8 @@ func TestExportCheckpointBootstrapSkipsMalformedCheckpointBeforeEOF(t *testing.T
153163
}
154164

155165
func TestExportCheckpointBootstrapDefersOnlyValidFutureCheckpoint(t *testing.T) {
166+
t.Parallel()
167+
156168
tests := []struct {
157169
name string
158170
body string
@@ -291,6 +303,8 @@ func strings64(ch string) string {
291303
}
292304

293305
func TestDecodeSegmentRejectsAggregateNestedLimitsWithSmallLimits(t *testing.T) {
306+
t.Parallel()
307+
294308
tests := []struct {
295309
name string
296310
records []segmentMessage
@@ -334,6 +348,8 @@ func TestDecodeSegmentRejectsAggregateNestedLimitsWithSmallLimits(t *testing.T)
334348
}
335349

336350
func TestDecodeSegmentAcceptsCanonicalTrailingNewlineAndEmptySession(t *testing.T) {
351+
t.Parallel()
352+
337353
record := nestedSegmentData(t, segmentMessage{})
338354
tests := []struct {
339355
name string

internal/artifact/export_limits_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ func assertFinalizedExportRejection(
9292
}
9393

9494
func TestExportClassifiesBoundedLoadLimit(t *testing.T) {
95+
t.Parallel()
96+
9597
ctx := t.Context()
9698
database := testExportDB(t)
9799
store := newTestArtifactStore(t)
@@ -113,6 +115,8 @@ func TestExportClassifiesBoundedLoadLimit(t *testing.T) {
113115
}
114116

115117
func TestExportRejectsNativeSessionIDsImporterCannotRepresent(t *testing.T) {
118+
t.Parallel()
119+
116120
tests := []struct {
117121
name string
118122
sessionID string
@@ -153,6 +157,8 @@ func TestExportRejectsNativeSessionIDsImporterCannotRepresent(t *testing.T) {
153157
}
154158

155159
func TestExportRejectsNestedAmplificationBeforePublication(t *testing.T) {
160+
t.Parallel()
161+
156162
tests := []struct {
157163
name string
158164
message db.Message
@@ -200,6 +206,8 @@ func TestExportRejectsNestedAmplificationBeforePublication(t *testing.T) {
200206
}
201207

202208
func TestExportChunksOnAggregateNestedLimitsWithSmallLimits(t *testing.T) {
209+
t.Parallel()
210+
203211
tests := []struct {
204212
name string
205213
resultEvents []db.ToolResultEvent
@@ -265,6 +273,8 @@ func TestExportChunksOnAggregateNestedLimitsWithSmallLimits(t *testing.T) {
265273
}
266274

267275
func TestExportRejectsMessageThatCannotFitNestedSegmentLimits(t *testing.T) {
276+
t.Parallel()
277+
268278
tests := []struct {
269279
name string
270280
message db.Message
@@ -322,6 +332,8 @@ func TestExportRejectsMessageThatCannotFitNestedSegmentLimits(t *testing.T) {
322332
}
323333

324334
func TestExportRejectsSessionNestedLimitsBeforeWritingWithSmallLimits(t *testing.T) {
335+
t.Parallel()
336+
325337
tests := []struct {
326338
name string
327339
configure func(*artifactLimits)
@@ -376,6 +388,8 @@ func TestExportRejectsSessionNestedLimitsBeforeWritingWithSmallLimits(t *testing
376388
}
377389

378390
func TestExportChunksOnMessageRecordLimit(t *testing.T) {
391+
t.Parallel()
392+
379393
ctx := context.Background()
380394
database := testExportDB(t)
381395
store := newTestArtifactStore(t)
@@ -396,6 +410,8 @@ func TestExportChunksOnMessageRecordLimit(t *testing.T) {
396410
}
397411

398412
func TestExportRejectsOversizedGeneratedManifestBeforePublication(t *testing.T) {
413+
t.Parallel()
414+
399415
ctx := context.Background()
400416
database := testExportDB(t)
401417
store := newTestArtifactStore(t)
@@ -415,6 +431,8 @@ func TestExportRejectsOversizedGeneratedManifestBeforePublication(t *testing.T)
415431
}
416432

417433
func TestExportRejectsSessionMessageAmplificationBeforePublication(t *testing.T) {
434+
t.Parallel()
435+
418436
ctx := context.Background()
419437
database := testExportDB(t)
420438
store := newTestArtifactStore(t)
@@ -436,6 +454,8 @@ func TestExportRejectsSessionMessageAmplificationBeforePublication(t *testing.T)
436454
}
437455

438456
func TestExportRejectsUsageEventAmplificationBeforePublication(t *testing.T) {
457+
t.Parallel()
458+
439459
ctx := context.Background()
440460
database := testExportDB(t)
441461
store := newTestArtifactStore(t)
@@ -461,6 +481,8 @@ func TestExportRejectsUsageEventAmplificationBeforePublication(t *testing.T) {
461481
}
462482

463483
func TestExportSessionRejectsAggregateLimitsBeforeWritingWithSmallLimits(t *testing.T) {
484+
t.Parallel()
485+
464486
tests := []struct {
465487
name string
466488
configure func(*artifactLimits)
@@ -509,6 +531,8 @@ func TestExportSessionRejectsAggregateLimitsBeforeWritingWithSmallLimits(t *test
509531
}
510532

511533
func TestExportChunksLargeMultiMessageSessionInOrder(t *testing.T) {
534+
t.Parallel()
535+
512536
ctx := context.Background()
513537
database := testExportDB(t)
514538
store := newTestArtifactStore(t)
@@ -542,6 +566,8 @@ func TestExportChunksLargeMultiMessageSessionInOrder(t *testing.T) {
542566
}
543567

544568
func TestExportRejectsSingleEncodedRecordAboveReadableLimit(t *testing.T) {
569+
t.Parallel()
570+
545571
ctx := context.Background()
546572
database := testExportDB(t)
547573
store := newTestArtifactStore(t)
@@ -567,6 +593,8 @@ func TestExportRejectsSingleEncodedRecordAboveReadableLimit(t *testing.T) {
567593
}
568594

569595
func TestExportPreservesSmallSingleSegmentHash(t *testing.T) {
596+
t.Parallel()
597+
570598
ctx := context.Background()
571599
database := testExportDB(t)
572600
store := newTestArtifactStore(t)

0 commit comments

Comments
 (0)