Skip to content

Commit c87ec97

Browse files
authored
Run tests in internal/mode/static/nginx/config in parallel (1) (#2493)
1 parent 5e24265 commit c87ec97

File tree

10 files changed

+51
-7
lines changed

10 files changed

+51
-7
lines changed

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

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

1515
func TestGenerate(t *testing.T) {
16+
t.Parallel()
1617
maxSize := helpers.GetPointer[ngfAPI.Size]("10m")
1718
bodyTimeout := helpers.GetPointer[ngfAPI.Duration]("600ms")
1819
keepaliveRequests := helpers.GetPointer[int32](900)
@@ -149,9 +150,9 @@ func TestGenerate(t *testing.T) {
149150
},
150151
}
151152

152-
g := NewWithT(t)
153-
154-
checkResults := func(resFiles policies.GenerateResultFiles, expStrings []string) {
153+
checkResults := func(t *testing.T, resFiles policies.GenerateResultFiles, expStrings []string) {
154+
t.Helper()
155+
g := NewWithT(t)
155156
g.Expect(resFiles).To(HaveLen(1))
156157

157158
for _, str := range expStrings {
@@ -160,22 +161,24 @@ func TestGenerate(t *testing.T) {
160161
}
161162

162163
for _, test := range tests {
163-
t.Run(test.name, func(_ *testing.T) {
164+
t.Run(test.name, func(t *testing.T) {
165+
t.Parallel()
164166
generator := clientsettings.NewGenerator()
165167

166168
resFiles := generator.GenerateForServer([]policies.Policy{test.policy}, http.Server{})
167-
checkResults(resFiles, test.expStrings)
169+
checkResults(t, resFiles, test.expStrings)
168170

169171
resFiles = generator.GenerateForLocation([]policies.Policy{test.policy}, http.Location{})
170-
checkResults(resFiles, test.expStrings)
172+
checkResults(t, resFiles, test.expStrings)
171173

172174
resFiles = generator.GenerateForInternalLocation([]policies.Policy{test.policy})
173-
checkResults(resFiles, test.expStrings)
175+
checkResults(t, resFiles, test.expStrings)
174176
})
175177
}
176178
}
177179

178180
func TestGenerateNoPolicies(t *testing.T) {
181+
t.Parallel()
179182
g := NewWithT(t)
180183

181184
generator := clientsettings.NewGenerator()

internal/mode/static/nginx/config/policies/clientsettings/validator_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func createModifiedPolicy(mod policyModFunc) *ngfAPI.ClientSettingsPolicy {
5353
}
5454

5555
func TestValidator_Validate(t *testing.T) {
56+
t.Parallel()
5657
tests := []struct {
5758
name string
5859
policy *ngfAPI.ClientSettingsPolicy
@@ -133,6 +134,7 @@ func TestValidator_Validate(t *testing.T) {
133134

134135
for _, test := range tests {
135136
t.Run(test.name, func(t *testing.T) {
137+
t.Parallel()
136138
g := NewWithT(t)
137139

138140
conds := v.Validate(test.policy, nil)
@@ -142,6 +144,7 @@ func TestValidator_Validate(t *testing.T) {
142144
}
143145

144146
func TestValidator_ValidatePanics(t *testing.T) {
147+
t.Parallel()
145148
v := clientsettings.NewValidator(nil)
146149

147150
validate := func() {
@@ -154,6 +157,7 @@ func TestValidator_ValidatePanics(t *testing.T) {
154157
}
155158

156159
func TestValidator_Conflicts(t *testing.T) {
160+
t.Parallel()
157161
tests := []struct {
158162
polA *ngfAPI.ClientSettingsPolicy
159163
polB *ngfAPI.ClientSettingsPolicy
@@ -256,6 +260,7 @@ func TestValidator_Conflicts(t *testing.T) {
256260

257261
for _, test := range tests {
258262
t.Run(test.name, func(t *testing.T) {
263+
t.Parallel()
259264
g := NewWithT(t)
260265

261266
g.Expect(v.Conflicts(test.polA, test.polB)).To(Equal(test.conflicts))
@@ -264,6 +269,7 @@ func TestValidator_Conflicts(t *testing.T) {
264269
}
265270

266271
func TestValidator_ConflictsPanics(t *testing.T) {
272+
t.Parallel()
267273
v := clientsettings.NewValidator(nil)
268274

269275
conflicts := func() {

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

Lines changed: 3 additions & 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
ratio := helpers.GetPointer[int32](25)
1920
zeroRatio := helpers.GetPointer[int32](0)
2021
context := helpers.GetPointer[ngfAPI.TraceContext](ngfAPI.TraceContextExtract)
@@ -242,6 +243,7 @@ func TestGenerate(t *testing.T) {
242243

243244
for _, test := range tests {
244245
t.Run(test.name, func(t *testing.T) {
246+
t.Parallel()
245247
g := NewWithT(t)
246248

247249
generator := observability.NewGenerator(test.telemetryConf)
@@ -280,6 +282,7 @@ func TestGenerate(t *testing.T) {
280282
}
281283

282284
func TestGenerateNoPolicies(t *testing.T) {
285+
t.Parallel()
283286
g := NewWithT(t)
284287

285288
generator := observability.NewGenerator(dataplane.Telemetry{})

internal/mode/static/nginx/config/policies/observability/validator_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func createModifiedPolicy(mod policyModFunc) *ngfAPI.ObservabilityPolicy {
5252
}
5353

5454
func TestValidator_Validate(t *testing.T) {
55+
t.Parallel()
5556
globalSettings := &policies.GlobalSettings{
5657
NginxProxyValid: true,
5758
TelemetryEnabled: true,
@@ -185,6 +186,7 @@ func TestValidator_Validate(t *testing.T) {
185186

186187
for _, test := range tests {
187188
t.Run(test.name, func(t *testing.T) {
189+
t.Parallel()
188190
g := NewWithT(t)
189191

190192
conds := v.Validate(test.policy, test.globalSettings)
@@ -194,6 +196,7 @@ func TestValidator_Validate(t *testing.T) {
194196
}
195197

196198
func TestValidator_ValidatePanics(t *testing.T) {
199+
t.Parallel()
197200
v := observability.NewValidator(nil)
198201

199202
validate := func() {
@@ -206,6 +209,7 @@ func TestValidator_ValidatePanics(t *testing.T) {
206209
}
207210

208211
func TestValidator_Conflicts(t *testing.T) {
212+
t.Parallel()
209213
tests := []struct {
210214
polA *ngfAPI.ObservabilityPolicy
211215
polB *ngfAPI.ObservabilityPolicy
@@ -244,6 +248,7 @@ func TestValidator_Conflicts(t *testing.T) {
244248

245249
for _, test := range tests {
246250
t.Run(test.name, func(t *testing.T) {
251+
t.Parallel()
247252
g := NewWithT(t)
248253

249254
g.Expect(v.Conflicts(test.polA, test.polB)).To(Equal(test.conflicts))
@@ -252,6 +257,7 @@ func TestValidator_Conflicts(t *testing.T) {
252257
}
253258

254259
func TestValidator_ConflictsPanics(t *testing.T) {
260+
t.Parallel()
255261
v := observability.NewValidator(nil)
256262

257263
conflicts := func() {

internal/mode/static/nginx/config/policies/policies_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 TestPolicies(t *testing.T) {
11+
t.Parallel()
1112
RegisterFailHandler(Fail)
1213
RunSpecs(t, "Policies Suite")
1314
}

internal/mode/static/nginx/config/validation/common_test.go

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

88
func TestValidateEscapedString(t *testing.T) {
9+
t.Parallel()
910
validator := func(value string) error { return validateEscapedString(value, []string{"example"}) }
1011

1112
testValidValuesForSimpleValidator(
@@ -25,6 +26,7 @@ func TestValidateEscapedString(t *testing.T) {
2526
}
2627

2728
func TestValidateEscapedStringNoVarExpansion(t *testing.T) {
29+
t.Parallel()
2830
validator := func(value string) error { return validateEscapedStringNoVarExpansion(value, []string{"example"}) }
2931

3032
testValidValuesForSimpleValidator(
@@ -45,6 +47,7 @@ func TestValidateEscapedStringNoVarExpansion(t *testing.T) {
4547
}
4648

4749
func TestValidateValidHeaderName(t *testing.T) {
50+
t.Parallel()
4851
validator := func(value string) error { return validateHeaderName(value) }
4952

5053
testValidValuesForSimpleValidator(

internal/mode/static/nginx/config/validation/framework_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func testInvalidValuesForSupportedValuesValidator[T configValue](
7979
}
8080

8181
func TestValidateInSupportedValues(t *testing.T) {
82+
t.Parallel()
8283
supportedValues := map[string]struct{}{
8384
"value1": {},
8485
"value2": {},
@@ -105,6 +106,7 @@ func TestValidateInSupportedValues(t *testing.T) {
105106
}
106107

107108
func TestValidateNoUnsupportedValues(t *testing.T) {
109+
t.Parallel()
108110
unsupportedValues := map[string]struct{}{
109111
"badvalue1": {},
110112
"badvalue2": {},
@@ -133,6 +135,7 @@ func TestValidateNoUnsupportedValues(t *testing.T) {
133135
}
134136

135137
func TestGetSortedKeysAsString(t *testing.T) {
138+
t.Parallel()
136139
values := map[string]struct{}{
137140
"value3": {},
138141
"value1": {},

internal/mode/static/nginx/config/validation/generic_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package validation
33
import "testing"
44

55
func TestGenericValidator_ValidateEscapedStringNoVarExpansion(t *testing.T) {
6+
t.Parallel()
67
validator := GenericValidator{}
78

89
testValidValuesForSimpleValidator(
@@ -24,6 +25,7 @@ func TestGenericValidator_ValidateEscapedStringNoVarExpansion(t *testing.T) {
2425
}
2526

2627
func TestValidateServiceName(t *testing.T) {
28+
t.Parallel()
2729
validator := GenericValidator{}
2830

2931
testValidValuesForSimpleValidator(
@@ -45,6 +47,7 @@ func TestValidateServiceName(t *testing.T) {
4547
}
4648

4749
func TestValidateNginxDuration(t *testing.T) {
50+
t.Parallel()
4851
validator := GenericValidator{}
4952

5053
testValidValuesForSimpleValidator(
@@ -65,6 +68,7 @@ func TestValidateNginxDuration(t *testing.T) {
6568
}
6669

6770
func TestValidateNginxSize(t *testing.T) {
71+
t.Parallel()
6872
validator := GenericValidator{}
6973

7074
testValidValuesForSimpleValidator(
@@ -86,6 +90,7 @@ func TestValidateNginxSize(t *testing.T) {
8690
}
8791

8892
func TestValidateEndpoint(t *testing.T) {
93+
t.Parallel()
8994
validator := GenericValidator{}
9095

9196
testValidValuesForSimpleValidator(

internal/mode/static/nginx/config/validation/http_filters_test.go

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

88
func TestValidateRedirectScheme(t *testing.T) {
9+
t.Parallel()
910
validator := HTTPRedirectValidator{}
1011

1112
testValidValuesForSupportedValuesValidator(
@@ -24,6 +25,7 @@ func TestValidateRedirectScheme(t *testing.T) {
2425
}
2526

2627
func TestValidateRedirectPort(t *testing.T) {
28+
t.Parallel()
2729
validator := HTTPRedirectValidator{}
2830

2931
testValidValuesForSimpleValidator(
@@ -35,6 +37,7 @@ func TestValidateRedirectPort(t *testing.T) {
3537
}
3638

3739
func TestValidateRedirectStatusCode(t *testing.T) {
40+
t.Parallel()
3841
validator := HTTPRedirectValidator{}
3942

4043
testValidValuesForSupportedValuesValidator(
@@ -52,6 +55,7 @@ func TestValidateRedirectStatusCode(t *testing.T) {
5255
}
5356

5457
func TestValidateHostname(t *testing.T) {
58+
t.Parallel()
5559
validator := HTTPRedirectValidator{}
5660

5761
testValidValuesForSimpleValidator(
@@ -68,6 +72,7 @@ func TestValidateHostname(t *testing.T) {
6872
}
6973

7074
func TestValidateRewritePath(t *testing.T) {
75+
t.Parallel()
7176
validator := HTTPURLRewriteValidator{}
7277

7378
testValidValuesForSimpleValidator(
@@ -89,6 +94,7 @@ func TestValidateRewritePath(t *testing.T) {
8994
}
9095

9196
func TestValidateFilterHeaderName(t *testing.T) {
97+
t.Parallel()
9298
validator := HTTPHeaderValidator{}
9399

94100
testValidValuesForSimpleValidator(
@@ -102,6 +108,7 @@ func TestValidateFilterHeaderName(t *testing.T) {
102108
}
103109

104110
func TestValidateFilterHeaderValue(t *testing.T) {
111+
t.Parallel()
105112
validator := HTTPHeaderValidator{}
106113

107114
testValidValuesForSimpleValidator(

internal/mode/static/nginx/config/validation/http_njs_match_test.go

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

77
func TestValidatePathInMatch(t *testing.T) {
8+
t.Parallel()
89
validator := HTTPNJSMatchValidator{}
910

1011
testValidValuesForSimpleValidator(
@@ -28,6 +29,7 @@ func TestValidatePathInMatch(t *testing.T) {
2829
}
2930

3031
func TestValidateHeaderNameInMatch(t *testing.T) {
32+
t.Parallel()
3133
validator := HTTPNJSMatchValidator{}
3234

3335
testValidValuesForSimpleValidator(
@@ -50,6 +52,7 @@ func TestValidateHeaderNameInMatch(t *testing.T) {
5052
}
5153

5254
func TestValidateHeaderValueInMatch(t *testing.T) {
55+
t.Parallel()
5356
validator := HTTPNJSMatchValidator{}
5457

5558
testValidValuesForSimpleValidator(
@@ -70,6 +73,7 @@ func TestValidateHeaderValueInMatch(t *testing.T) {
7073
}
7174

7275
func TestValidateQueryParamNameInMatch(t *testing.T) {
76+
t.Parallel()
7377
validator := HTTPNJSMatchValidator{}
7478

7579
testValidValuesForSimpleValidator(
@@ -85,6 +89,7 @@ func TestValidateQueryParamNameInMatch(t *testing.T) {
8589
}
8690

8791
func TestValidateQueryParamValueInMatch(t *testing.T) {
92+
t.Parallel()
8893
validator := HTTPNJSMatchValidator{}
8994

9095
testValidValuesForSimpleValidator(
@@ -100,6 +105,7 @@ func TestValidateQueryParamValueInMatch(t *testing.T) {
100105
}
101106

102107
func TestValidateMethodInMatch(t *testing.T) {
108+
t.Parallel()
103109
validator := HTTPNJSMatchValidator{}
104110

105111
testValidValuesForSupportedValuesValidator(
@@ -123,6 +129,7 @@ func TestValidateMethodInMatch(t *testing.T) {
123129
}
124130

125131
func TestValidateCommonMatchPart(t *testing.T) {
132+
t.Parallel()
126133
testValidValuesForSimpleValidator(
127134
t,
128135
validateCommonNJSMatchPart,

0 commit comments

Comments
 (0)