Skip to content

Commit 2ac3239

Browse files
authored
Run tests in internal/framework in parallel (2) (#2367)
1 parent e9b626b commit 2ac3239

10 files changed

+39
-3
lines changed

internal/framework/controller/controller_suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
)
99

1010
func TestControllers(t *testing.T) {
11+
t.Parallel()
1112
RegisterFailHandler(Fail)
1213
RunSpecs(t, "Controller Suite")
1314
}

internal/framework/controller/filter/filter_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
)
99

1010
func TestCreateSingleResourceFilter(t *testing.T) {
11+
t.Parallel()
1112
targetNsName := types.NamespacedName{Namespace: "test", Name: "resource"}
1213

1314
g := NewWithT(t)
@@ -50,7 +51,9 @@ func TestCreateSingleResourceFilter(t *testing.T) {
5051
}
5152

5253
for _, test := range tests {
54+
test := test
5355
t.Run(test.name, func(t *testing.T) {
56+
t.Parallel()
5457
g := NewWithT(t)
5558
shouldProcess, msg := filter(test.nsname)
5659
g.Expect(shouldProcess).To(Equal(test.expectedShouldProcess))

internal/framework/controller/index/endpointslice_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
)
1212

1313
func TestServiceNameIndexFunc(t *testing.T) {
14+
t.Parallel()
1415
testcases := []struct {
1516
msg string
1617
obj client.Object
@@ -42,13 +43,19 @@ func TestServiceNameIndexFunc(t *testing.T) {
4243
}
4344

4445
for _, tc := range testcases {
45-
g := NewWithT(t)
46-
output := ServiceNameIndexFunc(tc.obj)
47-
g.Expect(output).To(Equal(tc.expOutput))
46+
tc := tc
47+
t.Run(tc.msg, func(t *testing.T) {
48+
t.Parallel()
49+
g := NewWithT(t)
50+
51+
output := ServiceNameIndexFunc(tc.obj)
52+
g.Expect(output).To(Equal(tc.expOutput))
53+
})
4854
}
4955
}
5056

5157
func TestServiceNameIndexFuncPanics(t *testing.T) {
58+
t.Parallel()
5259
defer func() {
5360
g := NewWithT(t)
5461
g.Expect(recover()).ToNot(BeNil())

internal/framework/controller/predicate/annotation_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
)
1111

1212
func TestAnnotationPredicate_Create(t *testing.T) {
13+
t.Parallel()
1314
annotation := "test"
1415

1516
tests := []struct {
@@ -58,7 +59,9 @@ func TestAnnotationPredicate_Create(t *testing.T) {
5859
p := AnnotationPredicate{Annotation: annotation}
5960

6061
for _, test := range tests {
62+
test := test
6163
t.Run(test.name, func(t *testing.T) {
64+
t.Parallel()
6265
g := NewWithT(t)
6366
update := p.Create(test.event)
6467
g.Expect(update).To(Equal(test.expUpdate))
@@ -67,6 +70,7 @@ func TestAnnotationPredicate_Create(t *testing.T) {
6770
}
6871

6972
func TestAnnotationPredicate_Update(t *testing.T) {
73+
t.Parallel()
7074
annotation := "test"
7175

7276
tests := []struct {
@@ -211,7 +215,9 @@ func TestAnnotationPredicate_Update(t *testing.T) {
211215
p := AnnotationPredicate{Annotation: annotation}
212216

213217
for _, test := range tests {
218+
test := test
214219
t.Run(test.name, func(t *testing.T) {
220+
t.Parallel()
215221
g := NewWithT(t)
216222
update := p.Update(test.event)
217223
g.Expect(update).To(Equal(test.expUpdate))

internal/framework/controller/predicate/gatewayclass_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
)
1010

1111
func TestGatewayClassPredicate(t *testing.T) {
12+
t.Parallel()
1213
g := NewWithT(t)
1314

1415
p := GatewayClassPredicate{ControllerName: "nginx-ctlr"}

internal/framework/controller/predicate/service_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
)
1414

1515
func TestServicePortsChangedPredicate_Update(t *testing.T) {
16+
t.Parallel()
1617
testcases := []struct {
1718
objectOld client.Object
1819
objectNew client.Object
@@ -227,7 +228,9 @@ func TestServicePortsChangedPredicate_Update(t *testing.T) {
227228
p := ServicePortsChangedPredicate{}
228229

229230
for _, tc := range testcases {
231+
tc := tc
230232
t.Run(tc.msg, func(t *testing.T) {
233+
t.Parallel()
231234
g := NewWithT(t)
232235
update := p.Update(event.UpdateEvent{
233236
ObjectOld: tc.objectOld,
@@ -240,6 +243,7 @@ func TestServicePortsChangedPredicate_Update(t *testing.T) {
240243
}
241244

242245
func TestServicePortsChangedPredicate(t *testing.T) {
246+
t.Parallel()
243247
g := NewWithT(t)
244248

245249
p := GatewayServicePredicate{}
@@ -250,6 +254,7 @@ func TestServicePortsChangedPredicate(t *testing.T) {
250254
}
251255

252256
func TestGatewayServicePredicate_Update(t *testing.T) {
257+
t.Parallel()
253258
testcases := []struct {
254259
objectOld client.Object
255260
objectNew client.Object
@@ -440,7 +445,9 @@ func TestGatewayServicePredicate_Update(t *testing.T) {
440445
p := GatewayServicePredicate{NSName: types.NamespacedName{Namespace: "nginx-gateway", Name: "nginx"}}
441446

442447
for _, tc := range testcases {
448+
tc := tc
443449
t.Run(tc.msg, func(t *testing.T) {
450+
t.Parallel()
444451
g := NewWithT(t)
445452
update := p.Update(event.UpdateEvent{
446453
ObjectOld: tc.objectOld,
@@ -453,6 +460,7 @@ func TestGatewayServicePredicate_Update(t *testing.T) {
453460
}
454461

455462
func TestGatewayServicePredicate(t *testing.T) {
463+
t.Parallel()
456464
g := NewWithT(t)
457465

458466
p := GatewayServicePredicate{}

internal/framework/controller/register_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
)
2828

2929
func TestRegister(t *testing.T) {
30+
t.Parallel()
3031
type fakes struct {
3132
mgr *controllerfakes.FakeManager
3233
indexer *controllerfakes.FakeFieldIndexer
@@ -120,7 +121,9 @@ func TestRegister(t *testing.T) {
120121
}
121122

122123
for _, test := range tests {
124+
test := test
123125
t.Run(test.msg, func(t *testing.T) {
126+
t.Parallel()
124127
g := NewWithT(t)
125128

126129
newReconciler := func(c controller.ReconcilerConfig) *controller.Reconciler {

internal/framework/status/conditions_test.go

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

1111
func TestConditionsEqual(t *testing.T) {
12+
t.Parallel()
1213
getDefaultConds := func() []v1.Condition {
1314
return []v1.Condition{
1415
{
@@ -110,7 +111,9 @@ func TestConditionsEqual(t *testing.T) {
110111
}
111112

112113
for _, test := range tests {
114+
test := test
113115
t.Run(test.name, func(t *testing.T) {
116+
t.Parallel()
114117
g := NewWithT(t)
115118
equal := ConditionsEqual(test.prevConds, test.curConds)
116119
g.Expect(equal).To(Equal(test.expEqual))

internal/framework/status/status_suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
)
99

1010
func TestStatus(t *testing.T) {
11+
t.Parallel()
1112
RegisterFailHandler(Fail)
1213
RunSpecs(t, "Status Suite")
1314
}

internal/framework/status/updater_retry_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
)
2020

2121
func TestNewRetryUpdateFunc(t *testing.T) {
22+
t.Parallel()
2223
tests := []struct {
2324
getReturns error
2425
updateReturns error
@@ -70,7 +71,9 @@ func TestNewRetryUpdateFunc(t *testing.T) {
7071
}
7172

7273
for _, test := range tests {
74+
test := test
7375
t.Run(test.name, func(t *testing.T) {
76+
t.Parallel()
7477
g := NewWithT(t)
7578

7679
fakeStatusUpdater := &statusfakes.FakeK8sUpdater{}

0 commit comments

Comments
 (0)