Skip to content

Commit a9d073e

Browse files
authored
Enable more parallel tests (#2572)
1 parent 8e63917 commit a9d073e

9 files changed

+55
-6
lines changed

internal/mode/static/config_updater_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
)
1717

1818
func TestUpdateControlPlane(t *testing.T) {
19+
t.Parallel()
1920
debugLogCfg := &ngfAPI.NginxGateway{
2021
Spec: ngfAPI.NginxGatewaySpec{
2122
Logging: &ngfAPI.Logging{
@@ -72,6 +73,7 @@ func TestUpdateControlPlane(t *testing.T) {
7273

7374
for _, test := range tests {
7475
t.Run(test.name, func(t *testing.T) {
76+
t.Parallel()
7577
g := NewWithT(t)
7678

7779
fakeLogSetter := &staticfakes.FakeLogLevelSetter{
@@ -118,6 +120,7 @@ func TestValidateLogLevel(t *testing.T) {
118120

119121
for _, level := range validLevels {
120122
t.Run(fmt.Sprintf("valid level %q", level), func(t *testing.T) {
123+
t.Parallel()
121124
g := NewWithT(t)
122125

123126
g.Expect(validateLogLevel(level)).To(Succeed())

internal/mode/static/state/graph/backend_refs_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func getModifiedRef(mod func(ref gatewayv1.BackendRef) gatewayv1.BackendRef) gat
3737
}
3838

3939
func TestValidateRouteBackendRef(t *testing.T) {
40+
t.Parallel()
4041
tests := []struct {
4142
expectedCondition conditions.Condition
4243
name string
@@ -85,6 +86,7 @@ func TestValidateRouteBackendRef(t *testing.T) {
8586

8687
for _, test := range tests {
8788
t.Run(test.name, func(t *testing.T) {
89+
t.Parallel()
8890
g := NewWithT(t)
8991
alwaysTrueRefGrantResolver := func(_ toResource) bool { return true }
9092

@@ -97,6 +99,7 @@ func TestValidateRouteBackendRef(t *testing.T) {
9799
}
98100

99101
func TestValidateBackendRef(t *testing.T) {
102+
t.Parallel()
100103
alwaysFalseRefGrantResolver := func(_ toResource) bool { return false }
101104
alwaysTrueRefGrantResolver := func(_ toResource) bool { return true }
102105

@@ -204,6 +207,7 @@ func TestValidateBackendRef(t *testing.T) {
204207

205208
for _, test := range tests {
206209
t.Run(test.name, func(t *testing.T) {
210+
t.Parallel()
207211
g := NewWithT(t)
208212

209213
valid, cond := validateBackendRef(test.ref, "test", test.refGrantResolver, field.NewPath("test"))
@@ -215,6 +219,7 @@ func TestValidateBackendRef(t *testing.T) {
215219
}
216220

217221
func TestValidateWeight(t *testing.T) {
222+
t.Parallel()
218223
validWeights := []int32{0, 1, 1000000}
219224
invalidWeights := []int32{-1, 1000001}
220225

@@ -231,6 +236,7 @@ func TestValidateWeight(t *testing.T) {
231236
}
232237

233238
func TestGetIPFamilyAndPortFromRef(t *testing.T) {
239+
t.Parallel()
234240
svc1 := &v1.Service{
235241
ObjectMeta: metav1.ObjectMeta{
236242
Name: "service1",
@@ -301,6 +307,7 @@ func TestGetIPFamilyAndPortFromRef(t *testing.T) {
301307

302308
for _, test := range tests {
303309
t.Run(test.name, func(t *testing.T) {
310+
t.Parallel()
304311
g := NewWithT(t)
305312

306313
svcIPFamily, servicePort, err := getIPFamilyAndPortFromRef(test.ref, test.svcNsName, services, refPath)
@@ -313,6 +320,7 @@ func TestGetIPFamilyAndPortFromRef(t *testing.T) {
313320
}
314321

315322
func TestVerifyIPFamily(t *testing.T) {
323+
t.Parallel()
316324
test := []struct {
317325
name string
318326
expErr error
@@ -377,6 +385,7 @@ func TestVerifyIPFamily(t *testing.T) {
377385

378386
for _, test := range test {
379387
t.Run(test.name, func(t *testing.T) {
388+
t.Parallel()
380389
g := NewWithT(t)
381390
err := verifyIPFamily(test.npCfg, test.svcIPFamily)
382391
if test.expErr != nil {
@@ -748,6 +757,7 @@ func TestAddBackendRefsToRulesTest(t *testing.T) {
748757
}
749758

750759
func TestCreateBackend(t *testing.T) {
760+
t.Parallel()
751761
createService := func(name string) *v1.Service {
752762
return &v1.Service{
753763
ObjectMeta: metav1.ObjectMeta{
@@ -1007,6 +1017,7 @@ func TestCreateBackend(t *testing.T) {
10071017

10081018
for _, test := range tests {
10091019
t.Run(test.name, func(t *testing.T) {
1020+
t.Parallel()
10101021
g := NewWithT(t)
10111022

10121023
alwaysTrueRefGrantResolver := func(_ toResource) bool { return true }
@@ -1035,6 +1046,7 @@ func TestCreateBackend(t *testing.T) {
10351046
}
10361047

10371048
func TestGetServicePort(t *testing.T) {
1049+
t.Parallel()
10381050
svc := &v1.Service{
10391051
Spec: v1.ServiceSpec{
10401052
Ports: []v1.ServicePort{
@@ -1065,6 +1077,7 @@ func TestGetServicePort(t *testing.T) {
10651077
}
10661078

10671079
func TestValidateBackendTLSPolicyMatchingAllBackends(t *testing.T) {
1080+
t.Parallel()
10681081
getBtp := func(name, caCertName string) *BackendTLSPolicy {
10691082
return &BackendTLSPolicy{
10701083
Source: &v1alpha3.BackendTLSPolicy{
@@ -1156,6 +1169,7 @@ func TestValidateBackendTLSPolicyMatchingAllBackends(t *testing.T) {
11561169

11571170
for _, test := range tests {
11581171
t.Run(test.name, func(t *testing.T) {
1172+
t.Parallel()
11591173
g := NewWithT(t)
11601174

11611175
cond := validateBackendTLSPolicyMatchingAllBackends(test.backendRefs)
@@ -1166,6 +1180,7 @@ func TestValidateBackendTLSPolicyMatchingAllBackends(t *testing.T) {
11661180
}
11671181

11681182
func TestFindBackendTLSPolicyForService(t *testing.T) {
1183+
t.Parallel()
11691184
oldCreationTimestamp := metav1.Now()
11701185
newCreationTimestamp := metav1.Now()
11711186
getBtp := func(name string, timestamp metav1.Time) *BackendTLSPolicy {
@@ -1231,6 +1246,7 @@ func TestFindBackendTLSPolicyForService(t *testing.T) {
12311246

12321247
for _, test := range tests {
12331248
t.Run(test.name, func(t *testing.T) {
1249+
t.Parallel()
12341250
g := NewWithT(t)
12351251

12361252
btp, err := findBackendTLSPolicyForService(test.backendTLSPolicies, ref.Namespace, string(ref.Name), "test")
@@ -1242,6 +1258,7 @@ func TestFindBackendTLSPolicyForService(t *testing.T) {
12421258
}
12431259

12441260
func TestGetRefGrantFromResourceForRoute(t *testing.T) {
1261+
t.Parallel()
12451262
tests := []struct {
12461263
name string
12471264
routeType RouteType
@@ -1264,13 +1281,15 @@ func TestGetRefGrantFromResourceForRoute(t *testing.T) {
12641281

12651282
for _, test := range tests {
12661283
t.Run(test.name, func(t *testing.T) {
1284+
t.Parallel()
12671285
g := NewWithT(t)
12681286
g.Expect(getRefGrantFromResourceForRoute(test.routeType, test.ns)).To(Equal(test.expFromResource))
12691287
})
12701288
}
12711289
}
12721290

12731291
func TestGetRefGrantFromResourceForRoute_Panics(t *testing.T) {
1292+
t.Parallel()
12741293
g := NewWithT(t)
12751294

12761295
get := func() {

internal/mode/static/state/graph/backend_tls_policy_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
)
1717

1818
func TestProcessBackendTLSPoliciesEmpty(t *testing.T) {
19+
t.Parallel()
1920
backendTLSPolicies := map[types.NamespacedName]*v1alpha3.BackendTLSPolicy{
2021
{Namespace: "test", Name: "tls-policy"}: {
2122
ObjectMeta: metav1.ObjectMeta{
@@ -71,6 +72,7 @@ func TestProcessBackendTLSPoliciesEmpty(t *testing.T) {
7172

7273
for _, test := range tests {
7374
t.Run(test.name, func(t *testing.T) {
75+
t.Parallel()
7476
g := NewWithT(t)
7577

7678
processed := processBackendTLSPolicies(test.backendTLSPolicies, nil, "test", test.gateway)

internal/mode/static/state/graph/configmaps_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ UdxohGqleWFMQ3UNLOvc9Fk+q72ryg==
8888
)
8989

9090
func TestValidateCA(t *testing.T) {
91+
t.Parallel()
9192
base64Data := make([]byte, base64.StdEncoding.EncodedLen(len(caBlock)))
9293
base64.StdEncoding.Encode(base64Data, []byte(caBlock))
9394

@@ -120,6 +121,7 @@ func TestValidateCA(t *testing.T) {
120121

121122
for _, test := range tests {
122123
t.Run(test.name, func(t *testing.T) {
124+
t.Parallel()
123125
g := NewWithT(t)
124126

125127
err := validateCA(test.data)

internal/mode/static/state/graph/gateway_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
)
1919

2020
func TestProcessedGatewaysGetAllNsNames(t *testing.T) {
21+
t.Parallel()
2122
winner := &v1.Gateway{
2223
ObjectMeta: metav1.ObjectMeta{
2324
Namespace: "test",
@@ -58,6 +59,7 @@ func TestProcessedGatewaysGetAllNsNames(t *testing.T) {
5859

5960
for _, test := range tests {
6061
t.Run(test.name, func(t *testing.T) {
62+
t.Parallel()
6163
g := NewWithT(t)
6264
result := test.gws.GetAllNsNames()
6365
g.Expect(result).To(Equal(test.expected))
@@ -66,6 +68,7 @@ func TestProcessedGatewaysGetAllNsNames(t *testing.T) {
6668
}
6769

6870
func TestProcessGateways(t *testing.T) {
71+
t.Parallel()
6972
const gcName = "test-gc"
7073

7174
winner := &v1.Gateway{
@@ -133,6 +136,7 @@ func TestProcessGateways(t *testing.T) {
133136

134137
for _, test := range tests {
135138
t.Run(test.name, func(t *testing.T) {
139+
t.Parallel()
136140
g := NewWithT(t)
137141
result := processGateways(test.gws, gcName)
138142
g.Expect(helpers.Diff(test.expected, result)).To(BeEmpty())

internal/mode/static/state/graph/graph_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ func TestIsReferenced(t *testing.T) {
11821182
}
11831183

11841184
func TestIsNGFPolicyRelevant(t *testing.T) {
1185+
t.Parallel()
11851186
policyGVK := schema.GroupVersionKind{Kind: "MyKind"}
11861187
existingPolicyNsName := types.NamespacedName{Namespace: "test", Name: "pol"}
11871188

@@ -1324,6 +1325,7 @@ func TestIsNGFPolicyRelevant(t *testing.T) {
13241325

13251326
for _, test := range tests {
13261327
t.Run(test.name, func(t *testing.T) {
1328+
t.Parallel()
13271329
g := NewWithT(t)
13281330

13291331
relevant := test.graph.IsNGFPolicyRelevant(test.policy, policyGVK, test.nsname)
@@ -1333,6 +1335,7 @@ func TestIsNGFPolicyRelevant(t *testing.T) {
13331335
}
13341336

13351337
func TestIsNGFPolicyRelevantPanics(t *testing.T) {
1338+
t.Parallel()
13361339
g := NewWithT(t)
13371340
graph := &Graph{}
13381341
nsname := types.NamespacedName{Namespace: "test", Name: "pol"}

internal/mode/static/state/graph/reference_grant_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
func TestReferenceGrantResolver(t *testing.T) {
1515
t.Parallel()
16-
1716
gwNs := "gw-ns"
1817
secretNsName := types.NamespacedName{Namespace: "test", Name: "certificate"}
1918

@@ -164,7 +163,6 @@ func TestReferenceGrantResolver(t *testing.T) {
164163
for _, test := range tests {
165164
t.Run(test.msg, func(t *testing.T) {
166165
t.Parallel()
167-
168166
g := NewWithT(t)
169167

170168
g.Expect(resolver.refAllowed(test.to, test.from)).To(Equal(test.allowed))
@@ -174,7 +172,6 @@ func TestReferenceGrantResolver(t *testing.T) {
174172

175173
func TestToSecret(t *testing.T) {
176174
t.Parallel()
177-
178175
ref := toSecret(types.NamespacedName{Namespace: "ns", Name: "secret"})
179176

180177
exp := toResource{
@@ -189,7 +186,6 @@ func TestToSecret(t *testing.T) {
189186

190187
func TestToService(t *testing.T) {
191188
t.Parallel()
192-
193189
ref := toService(types.NamespacedName{Namespace: "ns", Name: "service"})
194190

195191
exp := toResource{
@@ -204,7 +200,6 @@ func TestToService(t *testing.T) {
204200

205201
func TestFromGateway(t *testing.T) {
206202
t.Parallel()
207-
208203
ref := fromGateway("ns")
209204

210205
exp := fromResource{
@@ -219,7 +214,6 @@ func TestFromGateway(t *testing.T) {
219214

220215
func TestFromHTTPRoute(t *testing.T) {
221216
t.Parallel()
222-
223217
ref := fromHTTPRoute("ns")
224218

225219
exp := fromResource{

0 commit comments

Comments
 (0)