Skip to content

Commit 84418ce

Browse files
authored
Run tests in parallel (#3910)
1 parent c6b0c2a commit 84418ce

File tree

6 files changed

+87
-6
lines changed

6 files changed

+87
-6
lines changed

internal/k8s/configuration_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func createTestConfiguration() *Configuration {
4545
}
4646

4747
func TestAddIngressForRegularIngress(t *testing.T) {
48+
t.Parallel()
4849
configuration := createTestConfiguration()
4950

5051
// no problems are expected for all cases
@@ -216,6 +217,7 @@ func TestAddIngressForRegularIngress(t *testing.T) {
216217
}
217218

218219
func TestAddInvalidIngress(t *testing.T) {
220+
t.Parallel()
219221
configuration := createTestConfiguration()
220222

221223
ing := createTestIngress("ingress", "foo.example.com", "foo.example.com")
@@ -3072,6 +3074,7 @@ func TestChooseObjectMetaWinner(t *testing.T) {
30723074
}
30733075

30743076
func TestSquashResourceChanges(t *testing.T) {
3077+
t.Parallel()
30753078
ingConfig := &IngressConfiguration{
30763079
Ingress: createTestIngress("test", "foo.example.com"),
30773080
}
@@ -3256,6 +3259,7 @@ func (rc *testReferenceChecker) IsReferencedByTransportServer(namespace string,
32563259
}
32573260

32583261
func TestFindResourcesForResourceReference(t *testing.T) {
3262+
t.Parallel()
32593263
regularIng := createTestIngress("regular-ingress", "foo.example.com")
32603264
master := createTestIngressMaster("master-ingress", "bar.example.com")
32613265
minion := createTestIngressMinion("minion-ingress", "bar.example.com", "/")
@@ -3379,6 +3383,7 @@ func TestFindResourcesForResourceReference(t *testing.T) {
33793383
}
33803384

33813385
func TestGetResources(t *testing.T) {
3386+
t.Parallel()
33823387
ing := createTestIngress("ingress", "foo.example.com", "bar.example.com")
33833388
vs := createTestVirtualServer("virtualserver", "qwe.example.com")
33843389
passTS := createTestTLSPassthroughTransportServer("transportserver", "abc.example.com")
@@ -3446,6 +3451,7 @@ func TestGetResources(t *testing.T) {
34463451
}
34473452

34483453
func TestGetTransportServerMetrics(t *testing.T) {
3454+
t.Parallel()
34493455
tsPass := createTestTLSPassthroughTransportServer("transportserver", "abc.example.com")
34503456
tsTCP := createTestTransportServer("transportserver-tcp", "tcp-7777", "TCP")
34513457
tsUDP := createTestTransportServer("transportserver-udp", "udp-7777", "UDP")
@@ -3544,6 +3550,7 @@ func TestGetTransportServerMetrics(t *testing.T) {
35443550
}
35453551

35463552
func TestIsEqualForIngressConfigurations(t *testing.T) {
3553+
t.Parallel()
35473554
regularIng := createTestIngress("regular-ingress", "foo.example.com")
35483555

35493556
ingConfigWithInvalidHost := NewRegularIngressConfiguration(regularIng)
@@ -3638,6 +3645,7 @@ func TestIsEqualForIngressConfigurations(t *testing.T) {
36383645
}
36393646

36403647
func TestIsEqualForVirtualServers(t *testing.T) {
3648+
t.Parallel()
36413649
vs := createTestVirtualServerWithRoutes(
36423650
"virtualserver",
36433651
"foo.example.com",
@@ -3696,6 +3704,7 @@ func TestIsEqualForVirtualServers(t *testing.T) {
36963704
}
36973705

36983706
func TestIsEqualForDifferentResources(t *testing.T) {
3707+
t.Parallel()
36993708
ingConfig := NewRegularIngressConfiguration(createTestIngress("ingress", "foo.example.com"))
37003709
vsConfig := NewVirtualServerConfiguration(createTestVirtualServer("virtualserver", "bar.example.com"), []*conf_v1.VirtualServerRoute{}, []string{})
37013710

@@ -3706,6 +3715,7 @@ func TestIsEqualForDifferentResources(t *testing.T) {
37063715
}
37073716

37083717
func TestCompareConfigurationProblems(t *testing.T) {
3718+
t.Parallel()
37093719
tests := []struct {
37103720
problem1 *ConfigurationProblem
37113721
problem2 *ConfigurationProblem

internal/k8s/controller_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
)
3131

3232
func TestHasCorrectIngressClass(t *testing.T) {
33+
t.Parallel()
3334
ingressClass := "ing-ctrl"
3435
incorrectIngressClass := "gce"
3536
emptyClass := ""
@@ -172,6 +173,7 @@ func deepCopyWithIngressClass(obj interface{}, class string) interface{} {
172173
}
173174

174175
func TestIngressClassForCustomResources(t *testing.T) {
176+
t.Parallel()
175177
ctrl := &LoadBalancerController{
176178
ingressClass: "nginx",
177179
}
@@ -221,6 +223,7 @@ func TestIngressClassForCustomResources(t *testing.T) {
221223
}
222224

223225
func TestComparePorts(t *testing.T) {
226+
t.Parallel()
224227
scenarios := []struct {
225228
sp api_v1.ServicePort
226229
cp api_v1.ContainerPort
@@ -314,6 +317,7 @@ func TestComparePorts(t *testing.T) {
314317
}
315318

316319
func TestFindProbeForPods(t *testing.T) {
320+
t.Parallel()
317321
pods := []*api_v1.Pod{
318322
{
319323
Spec: api_v1.PodSpec{
@@ -404,6 +408,7 @@ func TestFindProbeForPods(t *testing.T) {
404408
}
405409

406410
func TestGetServicePortForIngressPort(t *testing.T) {
411+
t.Parallel()
407412
fakeClient := fake.NewSimpleClientset()
408413
cnf := configs.NewConfigurator(&nginx.LocalManager{}, &configs.StaticConfigParams{}, &configs.ConfigParams{}, &version1.TemplateExecutor{}, &version2.TemplateExecutor{}, false, false, nil, false, nil, false)
409414
lbc := LoadBalancerController{
@@ -462,6 +467,7 @@ func TestGetServicePortForIngressPort(t *testing.T) {
462467
}
463468

464469
func TestFormatWarningsMessages(t *testing.T) {
470+
t.Parallel()
465471
warnings := []string{"Test warning", "Test warning 2"}
466472

467473
expected := "Test warning; Test warning 2"
@@ -473,6 +479,7 @@ func TestFormatWarningsMessages(t *testing.T) {
473479
}
474480

475481
func TestGetEndpointsFromEndpointSlices_DuplicateEndpointsInOneEndpointSlice(t *testing.T) {
482+
t.Parallel()
476483
endpointPort := int32(8080)
477484

478485
lbc := LoadBalancerController{
@@ -561,6 +568,7 @@ func TestGetEndpointsFromEndpointSlices_DuplicateEndpointsInOneEndpointSlice(t *
561568
}
562569

563570
func TestGetEndpointsFromEndpointSlices_TwoDifferentEndpointsInOnEndpointSlice(t *testing.T) {
571+
t.Parallel()
564572
endpointPort := int32(8080)
565573

566574
lbc := LoadBalancerController{
@@ -651,6 +659,7 @@ func TestGetEndpointsFromEndpointSlices_TwoDifferentEndpointsInOnEndpointSlice(t
651659
}
652660

653661
func TestGetEndpointsFromEndpointSlices_DuplicateEndpointsAcrossTwoEndpointSlices(t *testing.T) {
662+
t.Parallel()
654663
endpointPort := int32(8080)
655664

656665
lbc := LoadBalancerController{
@@ -770,6 +779,7 @@ func TestGetEndpointsFromEndpointSlices_DuplicateEndpointsAcrossTwoEndpointSlice
770779
}
771780

772781
func TestGetEndpointsFromEndpointSlices_TwoDifferentEndpointsInOnEndpointSliceOneEndpointNotReady(t *testing.T) {
782+
t.Parallel()
773783
endpointPort := int32(8080)
774784

775785
lbc := LoadBalancerController{
@@ -858,6 +868,7 @@ func TestGetEndpointsFromEndpointSlices_TwoDifferentEndpointsInOnEndpointSliceOn
858868
}
859869

860870
func TestGetEndpointsFromEndpointSlices_TwoDifferentEndpointsAcrossTwoEndpointSlicesOneEndpointNotReady(t *testing.T) {
871+
t.Parallel()
861872
endpointPort := int32(8080)
862873

863874
lbc := LoadBalancerController{
@@ -956,6 +967,7 @@ func TestGetEndpointsFromEndpointSlices_TwoDifferentEndpointsAcrossTwoEndpointSl
956967
}
957968

958969
func TestGetEndpointsFromEndpointSlices_ErrorsOnInvalidTargetPort(t *testing.T) {
970+
t.Parallel()
959971
endpointPort := int32(8080)
960972

961973
lbc := LoadBalancerController{
@@ -1027,6 +1039,7 @@ func TestGetEndpointsFromEndpointSlices_ErrorsOnInvalidTargetPort(t *testing.T)
10271039
}
10281040

10291041
func TestGetEndpointsFromEndpointSlices_ErrorsOnNoEndpointSlicesFound(t *testing.T) {
1042+
t.Parallel()
10301043
lbc := LoadBalancerController{
10311044
isNginxPlus: true,
10321045
}
@@ -1076,6 +1089,7 @@ func TestGetEndpointsFromEndpointSlices_ErrorsOnNoEndpointSlicesFound(t *testing
10761089
}
10771090

10781091
func TestGetEndpointSlicesBySubselectedPods_FindOnePodInOneEndpointSlice(t *testing.T) {
1092+
t.Parallel()
10791093
endpointPort := int32(8080)
10801094
endpointReady := true
10811095
boolPointer := func(b bool) *bool { return &b }
@@ -1148,6 +1162,7 @@ func TestGetEndpointSlicesBySubselectedPods_FindOnePodInOneEndpointSlice(t *test
11481162
}
11491163

11501164
func TestGetEndpointSlicesBySubselectedPods_FindOnePodInTwoEndpointSlicesWithDuplicateEndpoints(t *testing.T) {
1165+
t.Parallel()
11511166
endpointPort := int32(8080)
11521167
endpointReady := true
11531168
boolPointer := func(b bool) *bool { return &b }
@@ -1237,6 +1252,7 @@ func TestGetEndpointSlicesBySubselectedPods_FindOnePodInTwoEndpointSlicesWithDup
12371252
}
12381253

12391254
func TestGetEndpointSlicesBySubselectedPods_FindTwoPodsInOneEndpointSlice(t *testing.T) {
1255+
t.Parallel()
12401256
endpointPort := int32(8080)
12411257
endpointReady := true
12421258
boolPointer := func(b bool) *bool { return &b }
@@ -1338,6 +1354,7 @@ func TestGetEndpointSlicesBySubselectedPods_FindTwoPodsInOneEndpointSlice(t *tes
13381354
}
13391355

13401356
func TestGetEndpointSlicesBySubselectedPods_FindTwoPodsInTwoEndpointSlices(t *testing.T) {
1357+
t.Parallel()
13411358
endpointPort := int32(8080)
13421359
endpointReady := true
13431360
boolPointer := func(b bool) *bool { return &b }
@@ -1448,6 +1465,7 @@ func TestGetEndpointSlicesBySubselectedPods_FindTwoPodsInTwoEndpointSlices(t *te
14481465
}
14491466

14501467
func TestGetEndpointSlicesBySubselectedPods_FindOnePodEndpointInOneEndpointSliceWithOneEndpointNotReady(t *testing.T) {
1468+
t.Parallel()
14511469
endpointPort := int32(8080)
14521470
endpointReadyTrue := true
14531471
endpointReadyFalse := false
@@ -1543,6 +1561,7 @@ func TestGetEndpointSlicesBySubselectedPods_FindOnePodEndpointInOneEndpointSlice
15431561
}
15441562

15451563
func TestGetEndpointSlicesBySubselectedPods_FindOnePodEndpointInTwoEndpointSlicesWithOneEndpointNotReady(t *testing.T) {
1564+
t.Parallel()
15461565
endpointPort := int32(8080)
15471566
endpointReadyTrue := true
15481567
endpointReadyFalse := false
@@ -1647,6 +1666,7 @@ func TestGetEndpointSlicesBySubselectedPods_FindOnePodEndpointInTwoEndpointSlice
16471666
}
16481667

16491668
func TestGetEndpointSlicesBySubselectedPods_FindNoPods(t *testing.T) {
1669+
t.Parallel()
16501670
endpointPort := int32(8080)
16511671
endpointReady := true
16521672
boolPointer := func(b bool) *bool { return &b }
@@ -1711,6 +1731,7 @@ func TestGetEndpointSlicesBySubselectedPods_FindNoPods(t *testing.T) {
17111731
}
17121732

17131733
func TestGetEndpointSlicesBySubselectedPods_TargetPortMismatch(t *testing.T) {
1734+
t.Parallel()
17141735
endpointPort := int32(8080)
17151736

17161737
boolPointer := func(b bool) *bool { return &b }
@@ -1788,6 +1809,7 @@ func unorderedEqual(got, want []podEndpoint) bool {
17881809
}
17891810

17901811
func TestGetStatusFromEventTitle(t *testing.T) {
1812+
t.Parallel()
17911813
tests := []struct {
17921814
eventTitle string
17931815
expected string
@@ -1847,6 +1869,7 @@ func TestGetStatusFromEventTitle(t *testing.T) {
18471869
}
18481870

18491871
func TestGetPolicies(t *testing.T) {
1872+
t.Parallel()
18501873
validPolicy := &conf_v1.Policy{
18511874
ObjectMeta: meta_v1.ObjectMeta{
18521875
Name: "valid-policy",
@@ -1946,6 +1969,7 @@ func TestGetPolicies(t *testing.T) {
19461969
}
19471970

19481971
func TestCreatePolicyMap(t *testing.T) {
1972+
t.Parallel()
19491973
policies := []*conf_v1.Policy{
19501974
{
19511975
ObjectMeta: meta_v1.ObjectMeta{
@@ -2001,6 +2025,7 @@ func TestCreatePolicyMap(t *testing.T) {
20012025
}
20022026

20032027
func TestGetPodOwnerTypeAndName(t *testing.T) {
2028+
t.Parallel()
20042029
tests := []struct {
20052030
desc string
20062031
expType string
@@ -2144,6 +2169,7 @@ func (t *testResource) String() string {
21442169
}
21452170

21462171
func TestRemoveDuplicateResources(t *testing.T) {
2172+
t.Parallel()
21472173
tests := []struct {
21482174
resources []Resource
21492175
expected []Resource
@@ -2182,6 +2208,7 @@ func TestRemoveDuplicateResources(t *testing.T) {
21822208
}
21832209

21842210
func TestFindPoliciesForSecret(t *testing.T) {
2211+
t.Parallel()
21852212
jwtPol1 := &conf_v1.Policy{
21862213
ObjectMeta: meta_v1.ObjectMeta{
21872214
Name: "jwt-policy",
@@ -2398,6 +2425,7 @@ func errorComparer(e1, e2 error) bool {
23982425
}
23992426

24002427
func TestAddJWTSecrets(t *testing.T) {
2428+
t.Parallel()
24012429
invalidErr := errors.New("invalid")
24022430
validJWKSecret := &api_v1.Secret{
24032431
ObjectMeta: meta_v1.ObjectMeta{
@@ -2542,6 +2570,7 @@ func TestAddJWTSecrets(t *testing.T) {
25422570
}
25432571

25442572
func TestAddBasicSecrets(t *testing.T) {
2573+
t.Parallel()
25452574
invalidErr := errors.New("invalid")
25462575
validBasicSecret := &api_v1.Secret{
25472576
ObjectMeta: meta_v1.ObjectMeta{
@@ -2666,6 +2695,7 @@ func TestAddBasicSecrets(t *testing.T) {
26662695
}
26672696

26682697
func TestAddIngressMTLSSecret(t *testing.T) {
2698+
t.Parallel()
26692699
invalidErr := errors.New("invalid")
26702700
validSecret := &api_v1.Secret{
26712701
ObjectMeta: meta_v1.ObjectMeta{
@@ -2788,6 +2818,7 @@ func TestAddIngressMTLSSecret(t *testing.T) {
27882818
}
27892819

27902820
func TestAddEgressMTLSSecrets(t *testing.T) {
2821+
t.Parallel()
27912822
invalidErr := errors.New("invalid")
27922823
validMTLSSecret := &api_v1.Secret{
27932824
ObjectMeta: meta_v1.ObjectMeta{
@@ -3005,6 +3036,7 @@ func TestAddEgressMTLSSecrets(t *testing.T) {
30053036
}
30063037

30073038
func TestAddOidcSecret(t *testing.T) {
3039+
t.Parallel()
30083040
invalidErr := errors.New("invalid")
30093041
validSecret := &api_v1.Secret{
30103042
ObjectMeta: meta_v1.ObjectMeta{
@@ -3128,6 +3160,7 @@ func TestAddOidcSecret(t *testing.T) {
31283160
}
31293161

31303162
func TestAddWAFPolicyRefs(t *testing.T) {
3163+
t.Parallel()
31313164
apPol := &unstructured.Unstructured{
31323165
Object: map[string]interface{}{
31333166
"metadata": map[string]interface{}{
@@ -3358,6 +3391,7 @@ func TestAddWAFPolicyRefs(t *testing.T) {
33583391
}
33593392

33603393
func TestGetWAFPoliciesForAppProtectPolicy(t *testing.T) {
3394+
t.Parallel()
33613395
apPol := &conf_v1.Policy{
33623396
Spec: conf_v1.PolicySpec{
33633397
WAF: &conf_v1.WAF{
@@ -3435,6 +3469,7 @@ func TestGetWAFPoliciesForAppProtectPolicy(t *testing.T) {
34353469
}
34363470

34373471
func TestGetWAFPoliciesForAppProtectLogConf(t *testing.T) {
3472+
t.Parallel()
34383473
logConf := &conf_v1.Policy{
34393474
Spec: conf_v1.PolicySpec{
34403475
WAF: &conf_v1.WAF{
@@ -3541,6 +3576,7 @@ func TestGetWAFPoliciesForAppProtectLogConf(t *testing.T) {
35413576
}
35423577

35433578
func TestPreSyncSecrets(t *testing.T) {
3579+
t.Parallel()
35443580
secretLister := &cache.FakeCustomStore{
35453581
ListFunc: func() []interface{} {
35463582
return []interface{}{

internal/k8s/handlers_test.go

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

1212
func TestHasServicePortChanges(t *testing.T) {
13+
t.Parallel()
1314
cases := []struct {
1415
a []v1.ServicePort
1516
b []v1.ServicePort
@@ -158,6 +159,7 @@ func TestHasServicePortChanges(t *testing.T) {
158159
}
159160

160161
func TestAreResourcesDifferent(t *testing.T) {
162+
t.Parallel()
161163
tests := []struct {
162164
oldR, newR *unstructured.Unstructured
163165
expected bool

0 commit comments

Comments
 (0)