Skip to content

Commit e324a64

Browse files
authored
Run tests in internal/mode/static/nginx/config in parallel (2) (#2533)
1 parent 8fb93bb commit e324a64

12 files changed

+106
-13
lines changed

internal/mode/static/nginx/config/base_http_config_test.go

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

1212
func TestExecuteBaseHttp(t *testing.T) {
13+
t.Parallel()
1314
confOn := dataplane.Configuration{
1415
BaseHTTPConfig: dataplane.BaseHTTPConfig{
1516
HTTP2: true,
@@ -42,13 +43,16 @@ func TestExecuteBaseHttp(t *testing.T) {
4243
}
4344

4445
for _, test := range tests {
45-
g := NewWithT(t)
46-
47-
res := executeBaseHTTPConfig(test.conf)
48-
g.Expect(res).To(HaveLen(1))
49-
g.Expect(test.expCount).To(Equal(strings.Count(string(res[0].data), expSubStr)))
50-
g.Expect(strings.Count(string(res[0].data), "map $http_host $gw_api_compliant_host {")).To(Equal(1))
51-
g.Expect(strings.Count(string(res[0].data), "map $http_upgrade $connection_upgrade {")).To(Equal(1))
52-
g.Expect(strings.Count(string(res[0].data), "map $request_uri $request_uri_path {")).To(Equal(1))
46+
t.Run(test.name, func(t *testing.T) {
47+
t.Parallel()
48+
g := NewWithT(t)
49+
50+
res := executeBaseHTTPConfig(test.conf)
51+
g.Expect(res).To(HaveLen(1))
52+
g.Expect(test.expCount).To(Equal(strings.Count(string(res[0].data), expSubStr)))
53+
g.Expect(strings.Count(string(res[0].data), "map $http_host $gw_api_compliant_host {")).To(Equal(1))
54+
g.Expect(strings.Count(string(res[0].data), "map $http_upgrade $connection_upgrade {")).To(Equal(1))
55+
g.Expect(strings.Count(string(res[0].data), "map $request_uri $request_uri_path {")).To(Equal(1))
56+
})
5357
}
5458
}

internal/mode/static/nginx/config/convert_test.go

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

1212
func TestConvertEndpoints(t *testing.T) {
13+
t.Parallel()
1314
endpoints := []resolver.Endpoint{
1415
{
1516
Address: "1.2.3.4",

internal/mode/static/nginx/config/generator_test.go

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

1717
func TestGenerate(t *testing.T) {
18+
t.Parallel()
1819
bg := dataplane.BackendGroup{
1920
Source: types.NamespacedName{Namespace: "test", Name: "hr"},
2021
RuleIdx: 0,

internal/mode/static/nginx/config/maps_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
)
1313

1414
func TestExecuteMaps(t *testing.T) {
15+
t.Parallel()
1516
g := NewWithT(t)
1617
pathRules := []dataplane.PathRule{
1718
{
@@ -97,6 +98,7 @@ func TestExecuteMaps(t *testing.T) {
9798
}
9899

99100
func TestBuildAddHeaderMaps(t *testing.T) {
101+
t.Parallel()
100102
g := NewWithT(t)
101103
pathRules := []dataplane.PathRule{
102104
{
@@ -190,6 +192,7 @@ func TestBuildAddHeaderMaps(t *testing.T) {
190192
}
191193

192194
func TestExecuteStreamMaps(t *testing.T) {
195+
t.Parallel()
193196
g := NewWithT(t)
194197
conf := dataplane.Configuration{
195198
TLSPassthroughServers: []dataplane.Layer4VirtualServer{
@@ -257,6 +260,7 @@ func TestExecuteStreamMaps(t *testing.T) {
257260
}
258261

259262
func TestCreateStreamMaps(t *testing.T) {
263+
t.Parallel()
260264
g := NewWithT(t)
261265
conf := dataplane.Configuration{
262266
TLSPassthroughServers: []dataplane.Layer4VirtualServer{
@@ -371,6 +375,7 @@ func TestCreateStreamMaps(t *testing.T) {
371375
}
372376

373377
func TestCreateStreamMapsWithEmpty(t *testing.T) {
378+
t.Parallel()
374379
g := NewWithT(t)
375380
conf := dataplane.Configuration{
376381
TLSPassthroughServers: nil,

internal/mode/static/nginx/config/servers_test.go

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
)
1919

2020
func TestExecuteServers(t *testing.T) {
21+
t.Parallel()
2122
conf := dataplane.Configuration{
2223
HTTPServers: []dataplane.VirtualServer{
2324
{
@@ -145,6 +146,7 @@ func TestExecuteServers(t *testing.T) {
145146
}
146147

147148
func TestExecuteServers_IPFamily(t *testing.T) {
149+
t.Parallel()
148150
httpServers := []dataplane.VirtualServer{
149151
{
150152
IsDefault: true,
@@ -267,6 +269,7 @@ func TestExecuteServers_IPFamily(t *testing.T) {
267269

268270
for _, test := range tests {
269271
t.Run(test.msg, func(t *testing.T) {
272+
t.Parallel()
270273
g := NewWithT(t)
271274

272275
gen := GeneratorImpl{}
@@ -284,6 +287,7 @@ func TestExecuteServers_IPFamily(t *testing.T) {
284287
}
285288

286289
func TestExecuteServers_RewriteClientIP(t *testing.T) {
290+
t.Parallel()
287291
httpServers := []dataplane.VirtualServer{
288292
{
289293
IsDefault: true,
@@ -383,6 +387,7 @@ func TestExecuteServers_RewriteClientIP(t *testing.T) {
383387

384388
for _, test := range tests {
385389
t.Run(test.msg, func(t *testing.T) {
390+
t.Parallel()
386391
g := NewWithT(t)
387392

388393
gen := GeneratorImpl{}
@@ -400,6 +405,7 @@ func TestExecuteServers_RewriteClientIP(t *testing.T) {
400405
}
401406

402407
func TestExecuteServers_Plus(t *testing.T) {
408+
t.Parallel()
403409
config := dataplane.Configuration{
404410
HTTPServers: []dataplane.VirtualServer{
405411
{
@@ -438,6 +444,7 @@ func TestExecuteServers_Plus(t *testing.T) {
438444
}
439445

440446
func TestExecuteForDefaultServers(t *testing.T) {
447+
t.Parallel()
441448
testcases := []struct {
442449
msg string
443450
httpPorts []int
@@ -506,6 +513,7 @@ func TestExecuteForDefaultServers(t *testing.T) {
506513

507514
for _, tc := range testcases {
508515
t.Run(tc.msg, func(t *testing.T) {
516+
t.Parallel()
509517
g := NewWithT(t)
510518

511519
gen := GeneratorImpl{}
@@ -527,6 +535,7 @@ func TestExecuteForDefaultServers(t *testing.T) {
527535
}
528536

529537
func TestCreateServers(t *testing.T) {
538+
t.Parallel()
530539
const (
531540
sslKeyPairID = "test-keypair"
532541
)
@@ -1498,6 +1507,7 @@ func modifyMatchPairs(matchPairs httpMatchPairs) httpMatchPairs {
14981507
}
14991508

15001509
func TestCreateServersConflicts(t *testing.T) {
1510+
t.Parallel()
15011511
fooGroup := dataplane.BackendGroup{
15021512
Source: types.NamespacedName{Namespace: "test", Name: "route"},
15031513
RuleIdx: 0,
@@ -1671,6 +1681,7 @@ func TestCreateServersConflicts(t *testing.T) {
16711681

16721682
for _, test := range tests {
16731683
t.Run(test.name, func(t *testing.T) {
1684+
t.Parallel()
16741685
httpServers := []dataplane.VirtualServer{
16751686
{
16761687
IsDefault: true,
@@ -1703,6 +1714,7 @@ func TestCreateServersConflicts(t *testing.T) {
17031714
}
17041715

17051716
func TestCreateLocationsRootPath(t *testing.T) {
1717+
t.Parallel()
17061718
hrNsName := types.NamespacedName{Namespace: "test", Name: "route1"}
17071719

17081720
fooGroup := dataplane.BackendGroup{
@@ -1869,6 +1881,7 @@ func TestCreateLocationsRootPath(t *testing.T) {
18691881

18701882
for _, test := range tests {
18711883
t.Run(test.name, func(t *testing.T) {
1884+
t.Parallel()
18721885
g := NewWithT(t)
18731886

18741887
locs, httpMatchPair, grpc := createLocations(&dataplane.VirtualServer{
@@ -1883,6 +1896,7 @@ func TestCreateLocationsRootPath(t *testing.T) {
18831896
}
18841897

18851898
func TestCreateReturnValForRedirectFilter(t *testing.T) {
1899+
t.Parallel()
18861900
const listenerPortCustom = 123
18871901
const listenerPortHTTP = 80
18881902
const listenerPortHTTPS = 443
@@ -2005,6 +2019,7 @@ func TestCreateReturnValForRedirectFilter(t *testing.T) {
20052019

20062020
for _, test := range tests {
20072021
t.Run(test.msg, func(t *testing.T) {
2022+
t.Parallel()
20082023
g := NewWithT(t)
20092024

20102025
result := createReturnValForRedirectFilter(test.filter, test.listenerPort)
@@ -2014,6 +2029,7 @@ func TestCreateReturnValForRedirectFilter(t *testing.T) {
20142029
}
20152030

20162031
func TestCreateRewritesValForRewriteFilter(t *testing.T) {
2032+
t.Parallel()
20172033
tests := []struct {
20182034
filter *dataplane.HTTPURLRewriteFilter
20192035
expected *rewriteConfig
@@ -2131,6 +2147,7 @@ func TestCreateRewritesValForRewriteFilter(t *testing.T) {
21312147

21322148
for _, test := range tests {
21332149
t.Run(test.msg, func(t *testing.T) {
2150+
t.Parallel()
21342151
g := NewWithT(t)
21352152

21362153
result := createRewritesValForRewriteFilter(test.filter, test.path)
@@ -2140,6 +2157,7 @@ func TestCreateRewritesValForRewriteFilter(t *testing.T) {
21402157
}
21412158

21422159
func TestCreateRouteMatch(t *testing.T) {
2160+
t.Parallel()
21432161
testPath := "/internal_loc"
21442162

21452163
testMethodMatch := helpers.GetPointer("PUT")
@@ -2290,6 +2308,7 @@ func TestCreateRouteMatch(t *testing.T) {
22902308
}
22912309
for _, tc := range tests {
22922310
t.Run(tc.msg, func(t *testing.T) {
2311+
t.Parallel()
22932312
g := NewWithT(t)
22942313

22952314
result := createRouteMatch(tc.match, testPath)
@@ -2299,6 +2318,7 @@ func TestCreateRouteMatch(t *testing.T) {
22992318
}
23002319

23012320
func TestCreateQueryParamKeyValString(t *testing.T) {
2321+
t.Parallel()
23022322
g := NewWithT(t)
23032323

23042324
expected := "key=value"
@@ -2325,6 +2345,7 @@ func TestCreateQueryParamKeyValString(t *testing.T) {
23252345
}
23262346

23272347
func TestCreateHeaderKeyValString(t *testing.T) {
2348+
t.Parallel()
23282349
g := NewWithT(t)
23292350

23302351
expected := "kEy:vALUe"
@@ -2340,6 +2361,7 @@ func TestCreateHeaderKeyValString(t *testing.T) {
23402361
}
23412362

23422363
func TestIsPathOnlyMatch(t *testing.T) {
2364+
t.Parallel()
23432365
tests := []struct {
23442366
msg string
23452367
match dataplane.Match
@@ -2385,6 +2407,7 @@ func TestIsPathOnlyMatch(t *testing.T) {
23852407

23862408
for _, tc := range tests {
23872409
t.Run(tc.msg, func(t *testing.T) {
2410+
t.Parallel()
23882411
g := NewWithT(t)
23892412

23902413
result := isPathOnlyMatch(tc.match)
@@ -2394,7 +2417,7 @@ func TestIsPathOnlyMatch(t *testing.T) {
23942417
}
23952418

23962419
func TestCreateProxyPass(t *testing.T) {
2397-
g := NewWithT(t)
2420+
t.Parallel()
23982421

23992422
tests := []struct {
24002423
rewrite *dataplane.HTTPURLRewriteFilter
@@ -2463,12 +2486,17 @@ func TestCreateProxyPass(t *testing.T) {
24632486
}
24642487

24652488
for _, tc := range tests {
2466-
result := createProxyPass(tc.grp, tc.rewrite, generateProtocolString(nil, tc.GRPC), tc.GRPC)
2467-
g.Expect(result).To(Equal(tc.expected))
2489+
t.Run(tc.expected, func(t *testing.T) {
2490+
t.Parallel()
2491+
g := NewWithT(t)
2492+
result := createProxyPass(tc.grp, tc.rewrite, generateProtocolString(nil, tc.GRPC), tc.GRPC)
2493+
g.Expect(result).To(Equal(tc.expected))
2494+
})
24682495
}
24692496
}
24702497

24712498
func TestCreateMatchLocation(t *testing.T) {
2499+
t.Parallel()
24722500
g := NewWithT(t)
24732501

24742502
expectedNoGRPC := http.Location{
@@ -2492,6 +2520,7 @@ func TestCreateMatchLocation(t *testing.T) {
24922520
}
24932521

24942522
func TestGenerateProxySetHeaders(t *testing.T) {
2523+
t.Parallel()
24952524
tests := []struct {
24962525
filters *dataplane.HTTPFilters
24972526
msg string
@@ -2685,6 +2714,7 @@ func TestGenerateProxySetHeaders(t *testing.T) {
26852714

26862715
for _, tc := range tests {
26872716
t.Run(tc.msg, func(t *testing.T) {
2717+
t.Parallel()
26882718
g := NewWithT(t)
26892719

26902720
headers := generateProxySetHeaders(tc.filters, tc.GRPC)
@@ -2694,7 +2724,7 @@ func TestGenerateProxySetHeaders(t *testing.T) {
26942724
}
26952725

26962726
func TestConvertBackendTLSFromGroup(t *testing.T) {
2697-
g := NewWithT(t)
2727+
t.Parallel()
26982728

26992729
tests := []struct {
27002730
expected *http.ProxySSLVerify
@@ -2775,14 +2805,18 @@ func TestConvertBackendTLSFromGroup(t *testing.T) {
27752805
}
27762806

27772807
for _, tc := range tests {
2778-
t.Run(tc.msg, func(_ *testing.T) {
2808+
t.Run(tc.msg, func(t *testing.T) {
2809+
t.Parallel()
2810+
g := NewWithT(t)
2811+
27792812
result := createProxyTLSFromBackends(tc.grp)
27802813
g.Expect(result).To(Equal(tc.expected))
27812814
})
27822815
}
27832816
}
27842817

27852818
func TestGenerateResponseHeaders(t *testing.T) {
2819+
t.Parallel()
27862820
tests := []struct {
27872821
filters *dataplane.HTTPFilters
27882822
msg string
@@ -2842,6 +2876,7 @@ func TestGenerateResponseHeaders(t *testing.T) {
28422876

28432877
for _, tc := range tests {
28442878
t.Run(tc.msg, func(t *testing.T) {
2879+
t.Parallel()
28452880
g := NewWithT(t)
28462881

28472882
headers := generateResponseHeaders(tc.filters)
@@ -2851,6 +2886,7 @@ func TestGenerateResponseHeaders(t *testing.T) {
28512886
}
28522887

28532888
func TestCreateIncludesFromPolicyGenerateResult(t *testing.T) {
2889+
t.Parallel()
28542890
tests := []struct {
28552891
name string
28562892
files []policies.File
@@ -2896,6 +2932,7 @@ func TestCreateIncludesFromPolicyGenerateResult(t *testing.T) {
28962932

28972933
for _, test := range tests {
28982934
t.Run(test.name, func(t *testing.T) {
2935+
t.Parallel()
28992936
g := NewWithT(t)
29002937

29012938
includes := createIncludesFromPolicyGenerateResult(test.files)
@@ -2905,6 +2942,7 @@ func TestCreateIncludesFromPolicyGenerateResult(t *testing.T) {
29052942
}
29062943

29072944
func TestCreateIncludeFileResults(t *testing.T) {
2945+
t.Parallel()
29082946
servers := []http.Server{
29092947
{
29102948
Includes: []http.Include{
@@ -2995,6 +3033,7 @@ func TestCreateIncludeFileResults(t *testing.T) {
29953033
}
29963034

29973035
func TestGetIPFamily(t *testing.T) {
3036+
t.Parallel()
29983037
test := []struct {
29993038
msg string
30003039
baseHTTPConfig dataplane.BaseHTTPConfig
@@ -3019,7 +3058,9 @@ func TestGetIPFamily(t *testing.T) {
30193058

30203059
for _, tc := range test {
30213060
t.Run(tc.msg, func(t *testing.T) {
3061+
t.Parallel()
30223062
g := NewWithT(t)
3063+
30233064
result := getIPFamily(tc.baseHTTPConfig)
30243065
g.Expect(result).To(Equal(tc.expected))
30253066
})

0 commit comments

Comments
 (0)