Skip to content

Commit ea7ef87

Browse files
authored
Run tests in parallel (#2537)
1 parent 74724a6 commit ea7ef87

22 files changed

+83
-0
lines changed

internal/mode/provisioner/provisioner_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 TestProvisioner(t *testing.T) {
11+
t.Parallel()
1112
RegisterFailHandler(Fail)
1213
RunSpecs(t, "Provisioner Suite")
1314
}

internal/mode/static/config_updater_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func TestUpdateControlPlane(t *testing.T) {
103103
}
104104

105105
func TestValidateLogLevel(t *testing.T) {
106+
t.Parallel()
106107
validLevels := []ngfAPI.ControllerLogLevel{
107108
ngfAPI.ControllerLogLevelError,
108109
ngfAPI.ControllerLogLevelInfo,
@@ -125,6 +126,7 @@ func TestValidateLogLevel(t *testing.T) {
125126

126127
for _, level := range invalidLevels {
127128
t.Run(fmt.Sprintf("invalid level %q", level), func(t *testing.T) {
129+
t.Parallel()
128130
g := NewWithT(t)
129131

130132
g.Expect(validateLogLevel(level)).ToNot(Succeed())

internal/mode/static/health_test.go

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

99
func TestReadyCheck(t *testing.T) {
10+
t.Parallel()
1011
g := NewWithT(t)
1112
nginxChecker := newNginxConfiguredOnStartChecker()
1213
g.Expect(nginxChecker.readyCheck(nil)).ToNot(Succeed())

internal/mode/static/log_level_setters_test.go

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

1313
func TestMultiLogLevelSetter_SetLevel(t *testing.T) {
14+
t.Parallel()
1415
g := NewWithT(t)
1516

1617
logr1 := &staticfakes.FakeLogLevelSetter{}
@@ -41,6 +42,7 @@ func TestMultiLogLevelSetter_SetLevel(t *testing.T) {
4142
}
4243

4344
func TestZapLogLevelSetter_SetLevel(t *testing.T) {
45+
t.Parallel()
4446
g := NewWithT(t)
4547

4648
zapSetter := newZapLogLevelSetter(zap.NewAtomicLevel())
@@ -58,6 +60,7 @@ func TestZapLogLevelSetter_SetLevel(t *testing.T) {
5860
}
5961

6062
func TestPromLogLevelSetter_SetLevel(t *testing.T) {
63+
t.Parallel()
6164
g := NewWithT(t)
6265

6366
logger, err := newLeveledPrometheusLogger()

internal/mode/static/manager_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
)
2323

2424
func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) {
25+
t.Parallel()
2526
const gcName = "nginx"
2627

2728
partialObjectMetadataList := &metav1.PartialObjectMetadataList{}
@@ -117,6 +118,7 @@ func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) {
117118

118119
for _, test := range tests {
119120
t.Run(test.name, func(t *testing.T) {
121+
t.Parallel()
120122
g := NewWithT(t)
121123

122124
objects, objectLists := prepareFirstEventBatchPreparerArgs(gcName, test.gwNsName, test.experimentalEnabled)
@@ -128,6 +130,7 @@ func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) {
128130
}
129131

130132
func TestGetMetricsOptions(t *testing.T) {
133+
t.Parallel()
131134
tests := []struct {
132135
name string
133136
expectedOptions metricsserver.Options
@@ -166,6 +169,7 @@ func TestGetMetricsOptions(t *testing.T) {
166169

167170
for _, test := range tests {
168171
t.Run(test.name, func(t *testing.T) {
172+
t.Parallel()
169173
g := NewWithT(t)
170174

171175
metricsServerOptions := getMetricsOptions(test.metricsConfig)

internal/mode/static/nginx/file/file_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 TestFile(t *testing.T) {
11+
t.Parallel()
1112
RegisterFailHandler(Fail)
1213
RunSpecs(t, "File Suite")
1314
}

internal/mode/static/nginx/file/folders_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func writeFile(t *testing.T, name string, data []byte) {
2121
}
2222

2323
func TestClearFoldersRemoves(t *testing.T) {
24+
t.Parallel()
2425
g := NewWithT(t)
2526

2627
tempDir := t.TempDir()
@@ -41,6 +42,7 @@ func TestClearFoldersRemoves(t *testing.T) {
4142
}
4243

4344
func TestClearFoldersFails(t *testing.T) {
45+
t.Parallel()
4446
files := []string{"file"}
4547

4648
testErr := errors.New("test error")
@@ -78,6 +80,7 @@ func TestClearFoldersFails(t *testing.T) {
7880

7981
for _, test := range tests {
8082
t.Run(test.name, func(t *testing.T) {
83+
t.Parallel()
8184
g := NewWithT(t)
8285

8386
removedFiles, err := file.ClearFolders(test.fileMgr, files)

internal/mode/static/nginx/runtime/manager_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ var _ = Describe("NGINX Runtime Manager", func() {
223223
})
224224

225225
func TestFindMainProcess(t *testing.T) {
226+
t.Parallel()
226227
readFileFuncGen := func(content []byte) runtime.ReadFileFunc {
227228
return func(name string) ([]byte, error) {
228229
if name != runtime.PidFile {
@@ -311,6 +312,7 @@ func TestFindMainProcess(t *testing.T) {
311312

312313
for _, test := range tests {
313314
t.Run(test.name, func(t *testing.T) {
315+
t.Parallel()
314316
g := NewWithT(t)
315317
p := runtime.NewProcessHandlerImpl(
316318
test.readFile,

internal/mode/static/nginx/runtime/runtime_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 TestRuntime(t *testing.T) {
11+
t.Parallel()
1112
RegisterFailHandler(Fail)
1213
RunSpecs(t, "Runtime Suite")
1314
}

internal/mode/static/nginx/runtime/verify_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func getTestHTTPClient() *http.Client {
3030
}
3131

3232
func TestVerifyClient(t *testing.T) {
33+
t.Parallel()
3334
c := VerifyClient{
3435
client: getTestHTTPClient(),
3536
timeout: 25 * time.Millisecond,
@@ -87,6 +88,7 @@ func TestVerifyClient(t *testing.T) {
8788

8889
for _, test := range tests {
8990
t.Run(test.name, func(t *testing.T) {
91+
t.Parallel()
9092
g := NewWithT(t)
9193

9294
err := c.WaitForCorrectVersion(test.ctx, test.expectedVersion, "/childfile", []byte("1 2 3"), test.readFile)
@@ -101,6 +103,7 @@ func TestVerifyClient(t *testing.T) {
101103
}
102104

103105
func TestEnsureNewNginxWorkers(t *testing.T) {
106+
t.Parallel()
104107
previousContents := []byte("1 2 3")
105108
newContents := []byte("4 5 6")
106109

@@ -163,6 +166,7 @@ func TestEnsureNewNginxWorkers(t *testing.T) {
163166

164167
for _, test := range tests {
165168
t.Run(test.name, func(t *testing.T) {
169+
t.Parallel()
166170
g := NewWithT(t)
167171

168172
err := ensureNewNginxWorkers(

internal/mode/static/sort/sort_test.go

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

1313
func TestLessObjectMeta(t *testing.T) {
14+
t.Parallel()
1415
before := metav1.Now()
1516
later := metav1.NewTime(before.Add(1 * time.Second))
1617

@@ -80,6 +81,7 @@ func TestLessObjectMeta(t *testing.T) {
8081

8182
for _, test := range tests {
8283
t.Run(test.name, func(t *testing.T) {
84+
t.Parallel()
8385
g := NewWithT(t)
8486

8587
result := LessObjectMeta(test.meta1, test.meta2)
@@ -92,6 +94,7 @@ func TestLessObjectMeta(t *testing.T) {
9294
}
9395

9496
func TestLessClientObject(t *testing.T) {
97+
t.Parallel()
9598
before := metav1.Now()
9699
later := metav1.NewTime(before.Add(1 * time.Second))
97100

@@ -177,6 +180,7 @@ func TestLessClientObject(t *testing.T) {
177180

178181
for _, test := range tests {
179182
t.Run(test.name, func(t *testing.T) {
183+
t.Parallel()
180184
g := NewWithT(t)
181185

182186
result := LessClientObject(test.obj1, test.obj2)

internal/mode/static/static_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 TestStatic(t *testing.T) {
11+
t.Parallel()
1112
RegisterFailHandler(Fail)
1213
RunSpecs(t, "Static Suite")
1314
}

internal/mode/static/status/prepare_requests_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ var (
212212
)
213213

214214
func TestBuildHTTPRouteStatuses(t *testing.T) {
215+
t.Parallel()
215216
hrValid := &v1.HTTPRoute{
216217
ObjectMeta: metav1.ObjectMeta{
217218
Namespace: "test",
@@ -291,6 +292,7 @@ func TestBuildHTTPRouteStatuses(t *testing.T) {
291292
}
292293

293294
func TestBuildGRPCRouteStatuses(t *testing.T) {
295+
t.Parallel()
294296
grValid := &v1.GRPCRoute{
295297
ObjectMeta: metav1.ObjectMeta{
296298
Namespace: "test",
@@ -369,6 +371,7 @@ func TestBuildGRPCRouteStatuses(t *testing.T) {
369371
}
370372

371373
func TestBuildTLSRouteStatuses(t *testing.T) {
374+
t.Parallel()
372375
trValid := &v1alpha2.TLSRoute{
373376
ObjectMeta: metav1.ObjectMeta{
374377
Namespace: "test",
@@ -445,6 +448,7 @@ func TestBuildTLSRouteStatuses(t *testing.T) {
445448
}
446449

447450
func TestBuildRouteStatusesNginxErr(t *testing.T) {
451+
t.Parallel()
448452
const gatewayCtlrName = "controller"
449453

450454
hr1 := &v1.HTTPRoute{
@@ -546,6 +550,7 @@ func TestBuildRouteStatusesNginxErr(t *testing.T) {
546550
}
547551

548552
func TestBuildGatewayClassStatuses(t *testing.T) {
553+
t.Parallel()
549554
transitionTime := helpers.PrepareTimeForFakeClient(metav1.Now())
550555

551556
tests := []struct {
@@ -638,6 +643,7 @@ func TestBuildGatewayClassStatuses(t *testing.T) {
638643

639644
for _, test := range tests {
640645
t.Run(test.name, func(t *testing.T) {
646+
t.Parallel()
641647
g := NewWithT(t)
642648

643649
k8sClient := createK8sClientFor(&v1.GatewayClass{})
@@ -676,6 +682,7 @@ func TestBuildGatewayClassStatuses(t *testing.T) {
676682
}
677683

678684
func TestBuildGatewayStatuses(t *testing.T) {
685+
t.Parallel()
679686
createGateway := func() *v1.Gateway {
680687
return &v1.Gateway{
681688
ObjectMeta: metav1.ObjectMeta{
@@ -1131,6 +1138,7 @@ func TestBuildGatewayStatuses(t *testing.T) {
11311138

11321139
for _, test := range tests {
11331140
t.Run(test.name, func(t *testing.T) {
1141+
t.Parallel()
11341142
g := NewWithT(t)
11351143

11361144
k8sClient := createK8sClientFor(&v1.Gateway{})
@@ -1176,6 +1184,7 @@ func TestBuildGatewayStatuses(t *testing.T) {
11761184
}
11771185

11781186
func TestBuildBackendTLSPolicyStatuses(t *testing.T) {
1187+
t.Parallel()
11791188
const gatewayCtlrName = "controller"
11801189

11811190
transitionTime := helpers.PrepareTimeForFakeClient(metav1.Now())
@@ -1357,6 +1366,7 @@ func TestBuildBackendTLSPolicyStatuses(t *testing.T) {
13571366

13581367
for _, test := range tests {
13591368
t.Run(test.name, func(t *testing.T) {
1369+
t.Parallel()
13601370
g := NewWithT(t)
13611371

13621372
k8sClient := createK8sClientFor(&v1alpha3.BackendTLSPolicy{})
@@ -1386,6 +1396,7 @@ func TestBuildBackendTLSPolicyStatuses(t *testing.T) {
13861396
}
13871397

13881398
func TestBuildNginxGatewayStatus(t *testing.T) {
1399+
t.Parallel()
13891400
transitionTime := helpers.PrepareTimeForFakeClient(metav1.Now())
13901401

13911402
tests := []struct {
@@ -1449,6 +1460,7 @@ func TestBuildNginxGatewayStatus(t *testing.T) {
14491460

14501461
for _, test := range tests {
14511462
t.Run(test.name, func(t *testing.T) {
1463+
t.Parallel()
14521464
g := NewWithT(t)
14531465

14541466
k8sClient := createK8sClientFor(&ngfAPI.NginxGateway{})
@@ -1479,6 +1491,7 @@ func TestBuildNginxGatewayStatus(t *testing.T) {
14791491
}
14801492

14811493
func TestBuildNGFPolicyStatuses(t *testing.T) {
1494+
t.Parallel()
14821495
const gatewayCtlrName = "controller"
14831496

14841497
transitionTime := helpers.PrepareTimeForFakeClient(metav1.Now())
@@ -1741,6 +1754,7 @@ func TestBuildNGFPolicyStatuses(t *testing.T) {
17411754

17421755
for _, test := range tests {
17431756
t.Run(test.name, func(t *testing.T) {
1757+
t.Parallel()
17441758
g := NewWithT(t)
17451759

17461760
k8sClient := createK8sClientFor(&ngfAPI.ClientSettingsPolicy{})

0 commit comments

Comments
 (0)