From e5e87004cf3a5345249ca61ceb50148d79cf0a7e Mon Sep 17 00:00:00 2001 From: Luca Comellini Date: Tue, 4 Jun 2024 14:43:59 -0700 Subject: [PATCH] Run tests in parallel --- .golangci.yml | 2 + cmd/gateway/commands_test.go | 13 +++++ cmd/gateway/validation_test.go | 28 +++++++++++ .../framework/conditions/conditions_test.go | 2 + .../controller/controller_suite_test.go | 1 + .../controller/filter/filter_test.go | 3 ++ .../controller/index/endpointslice_test.go | 2 + .../controller/predicate/annotation_test.go | 6 +++ .../controller/predicate/gatewayclass_test.go | 1 + .../controller/predicate/service_test.go | 8 ++++ .../framework/controller/register_test.go | 3 ++ .../framework/events/events_suite_test.go | 1 + internal/framework/events/events_test.go | 1 + .../framework/gatewayclass/validate_test.go | 3 ++ internal/framework/helpers/helpers_test.go | 6 +++ internal/framework/runnables/cronjob_test.go | 2 + .../framework/runnables/runnables_test.go | 3 ++ internal/framework/status/conditions_test.go | 3 ++ .../framework/status/status_suite_test.go | 1 + .../framework/status/updater_retry_test.go | 3 ++ .../provisioner/provisioner_suite_test.go | 1 + internal/mode/static/config_updater_test.go | 8 ++++ internal/mode/static/health_test.go | 1 + .../mode/static/log_level_setters_test.go | 3 ++ internal/mode/static/manager_test.go | 6 +++ .../nginx/config/base_http_config_test.go | 1 + .../mode/static/nginx/config/convert_test.go | 1 + .../static/nginx/config/generator_test.go | 1 + .../mode/static/nginx/config/maps_test.go | 2 + .../policies/clientsettings/generator_test.go | 6 ++- .../policies/clientsettings/validator_test.go | 8 ++++ .../policies/observability/generator_test.go | 3 ++ .../policies/observability/validator_test.go | 8 ++++ .../config/policies/policies_suite_test.go | 1 + .../mode/static/nginx/config/servers_test.go | 47 ++++++++++++++++++- .../static/nginx/config/split_clients_test.go | 21 +++++++++ .../static/nginx/config/telemetry_test.go | 2 + .../static/nginx/config/upstreams_test.go | 6 +++ .../nginx/config/validation/common_test.go | 3 ++ .../nginx/config/validation/framework_test.go | 3 ++ .../nginx/config/validation/generic_test.go | 5 ++ .../config/validation/http_filters_test.go | 7 +++ .../config/validation/http_njs_match_test.go | 7 +++ .../nginx/config/variable_names_test.go | 6 +++ .../mode/static/nginx/config/version_test.go | 1 + .../mode/static/nginx/file/file_suite_test.go | 1 + .../mode/static/nginx/file/folders_test.go | 4 ++ .../mode/static/nginx/runtime/manager_test.go | 3 ++ .../nginx/runtime/runtime_suite_test.go | 1 + .../mode/static/nginx/runtime/verify_test.go | 6 +++ internal/mode/static/sort/sort_test.go | 6 +++ .../static/state/changed_predicate_test.go | 6 +++ .../state/dataplane/configuration_test.go | 26 ++++++++++ .../static/state/dataplane/convert_test.go | 13 +++++ .../mode/static/state/dataplane/sort_test.go | 1 + .../static/state/graph/backend_refs_test.go | 23 +++++++++ .../state/graph/backend_tls_policy_test.go | 6 +++ .../static/state/graph/configmaps_test.go | 6 +++ .../state/graph/gateway_listener_test.go | 20 ++++++++ .../mode/static/state/graph/gateway_test.go | 9 ++++ .../static/state/graph/gatewayclass_test.go | 6 +++ .../mode/static/state/graph/graph_test.go | 10 ++++ .../mode/static/state/graph/grpcroute_test.go | 10 ++++ .../mode/static/state/graph/httproute_test.go | 18 +++++++ .../mode/static/state/graph/namespace_test.go | 6 +++ .../static/state/graph/nginxproxy_test.go | 12 +++++ .../mode/static/state/graph/policies_test.go | 18 +++++++ .../state/graph/policy_ancestor_test.go | 6 +++ .../state/graph/reference_grant_test.go | 7 +++ .../static/state/graph/route_common_test.go | 25 ++++++++++ .../mode/static/state/graph/secret_test.go | 1 + .../mode/static/state/graph/service_test.go | 3 ++ .../static/state/graph/validation_test.go | 3 ++ .../static/state/resolver/resolver_test.go | 6 +++ .../resolver/service_resolver_suite_test.go | 1 + .../mode/static/state/state_suite_test.go | 1 + internal/mode/static/state/store_test.go | 3 ++ internal/mode/static/static_suite_test.go | 1 + .../static/status/prepare_requests_test.go | 18 +++++++ .../mode/static/status/status_setters_test.go | 33 +++++++++++++ internal/mode/static/telemetry/data_test.go | 2 + .../mode/static/telemetry/exporter_test.go | 1 + .../mode/static/telemetry/job_worker_test.go | 2 + .../mode/static/telemetry/platform_test.go | 3 ++ .../static/telemetry/telemetry_suite_test.go | 1 + internal/mode/static/usage/job_worker_test.go | 5 ++ internal/mode/static/usage/reporter_test.go | 3 ++ internal/mode/static/usage/secret_test.go | 3 ++ tests/suite/system_suite_test.go | 1 + 89 files changed, 587 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 730b7f583d..b3d74eba96 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -79,6 +79,7 @@ linters: - nilerr - noctx - nolintlint + # - paralleltest - predeclared - promlinter - reassign @@ -88,6 +89,7 @@ linters: - stylecheck - tenv - thelper + - tparallel - typecheck - unconvert - unparam diff --git a/cmd/gateway/commands_test.go b/cmd/gateway/commands_test.go index 988cf2b98f..27c941fc0e 100644 --- a/cmd/gateway/commands_test.go +++ b/cmd/gateway/commands_test.go @@ -56,6 +56,7 @@ This test cannot be run with ginkgo. Ginkgo reports the following error: * See https://github.com/spf13/cobra/issues/2104. */ func TestRootCmd(t *testing.T) { + t.Parallel() testCase := flagTestCase{ name: "no flags", args: nil, @@ -66,6 +67,7 @@ func TestRootCmd(t *testing.T) { } func TestCommonFlagsValidation(t *testing.T) { + t.Parallel() tests := []flagTestCase{ { name: "valid flags", @@ -131,16 +133,20 @@ func TestCommonFlagsValidation(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name+"_static_mode", func(t *testing.T) { + t.Parallel() testFlag(t, createStaticModeCommand(), test) }) t.Run(test.name+"_provisioner_mode", func(t *testing.T) { + t.Parallel() testFlag(t, createProvisionerModeCommand(), test) }) } } func TestStaticModeCmdFlagValidation(t *testing.T) { + t.Parallel() tests := []flagTestCase{ { name: "valid flags", @@ -381,7 +387,9 @@ func TestStaticModeCmdFlagValidation(t *testing.T) { // common flags validation is tested separately for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() cmd := createStaticModeCommand() testFlag(t, cmd, test) }) @@ -389,6 +397,7 @@ func TestStaticModeCmdFlagValidation(t *testing.T) { } func TestProvisionerModeCmdFlagValidation(t *testing.T) { + t.Parallel() testCase := flagTestCase{ name: "valid flags", args: []string{ @@ -419,6 +428,7 @@ This test cannot be run with ginkgo. Ginkgo reports the following error for the * See https://github.com/spf13/cobra/issues/2104. */ func TestSleepCmdFlagValidation(t *testing.T) { + t.Parallel() tests := []flagTestCase{ { name: "valid flags", @@ -451,7 +461,9 @@ func TestSleepCmdFlagValidation(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() cmd := createSleepCommand() testFlag(t, cmd, test) }) @@ -459,6 +471,7 @@ func TestSleepCmdFlagValidation(t *testing.T) { } func TestParseFlags(t *testing.T) { + t.Parallel() g := NewWithT(t) flagSet := pflag.NewFlagSet("flagSet", 0) diff --git a/cmd/gateway/validation_test.go b/cmd/gateway/validation_test.go index f19e3ac84f..3b0e27369e 100644 --- a/cmd/gateway/validation_test.go +++ b/cmd/gateway/validation_test.go @@ -8,6 +8,7 @@ import ( ) func TestValidateGatewayControllerName(t *testing.T) { + t.Parallel() tests := []struct { name string value string @@ -51,7 +52,9 @@ func TestValidateGatewayControllerName(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := validateGatewayControllerName(test.value) @@ -66,6 +69,7 @@ func TestValidateGatewayControllerName(t *testing.T) { } func TestValidateResourceName(t *testing.T) { + t.Parallel() tests := []struct { name string value string @@ -114,7 +118,9 @@ func TestValidateResourceName(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := validateResourceName(test.value) @@ -129,6 +135,7 @@ func TestValidateResourceName(t *testing.T) { } func TestValidateNamespaceName(t *testing.T) { + t.Parallel() tests := []struct { name string value string @@ -177,7 +184,9 @@ func TestValidateNamespaceName(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := validateNamespaceName(test.value) @@ -192,6 +201,7 @@ func TestValidateNamespaceName(t *testing.T) { } func TestParseNamespacedResourceName(t *testing.T) { + t.Parallel() tests := []struct { name string value string @@ -239,7 +249,9 @@ func TestParseNamespacedResourceName(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) nsName, err := parseNamespacedResourceName(test.value) @@ -256,6 +268,7 @@ func TestParseNamespacedResourceName(t *testing.T) { } func TestValidateQualifiedName(t *testing.T) { + t.Parallel() tests := []struct { name string value string @@ -304,7 +317,9 @@ func TestValidateQualifiedName(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := validateQualifiedName(test.value) @@ -318,6 +333,7 @@ func TestValidateQualifiedName(t *testing.T) { } func TestValidateURL(t *testing.T) { + t.Parallel() tests := []struct { name string url string @@ -366,7 +382,9 @@ func TestValidateURL(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := validateURL(tc.url) @@ -380,6 +398,7 @@ func TestValidateURL(t *testing.T) { } func TestValidateIP(t *testing.T) { + t.Parallel() tests := []struct { name string expSubMsg string @@ -406,7 +425,9 @@ func TestValidateIP(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := validateIP(tc.ip) @@ -420,6 +441,7 @@ func TestValidateIP(t *testing.T) { } func TestValidateEndpoint(t *testing.T) { + t.Parallel() tests := []struct { name string endp string @@ -473,7 +495,9 @@ func TestValidateEndpoint(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := validateEndpoint(tc.endp) @@ -487,6 +511,7 @@ func TestValidateEndpoint(t *testing.T) { } func TestValidatePort(t *testing.T) { + t.Parallel() tests := []struct { name string port int @@ -510,7 +535,9 @@ func TestValidatePort(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := validatePort(tc.port) @@ -524,6 +551,7 @@ func TestValidatePort(t *testing.T) { } func TestEnsureNoPortCollisions(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(ensureNoPortCollisions(9113, 8081)).To(Succeed()) diff --git a/internal/framework/conditions/conditions_test.go b/internal/framework/conditions/conditions_test.go index 7bf69c271b..b446a6ecaf 100644 --- a/internal/framework/conditions/conditions_test.go +++ b/internal/framework/conditions/conditions_test.go @@ -8,6 +8,7 @@ import ( ) func TestDeduplicateConditions(t *testing.T) { + t.Parallel() conds := []Condition{ { Type: "Type1", @@ -61,6 +62,7 @@ func TestDeduplicateConditions(t *testing.T) { } func TestConvertConditions(t *testing.T) { + t.Parallel() conds := []Condition{ { Type: "Type1", diff --git a/internal/framework/controller/controller_suite_test.go b/internal/framework/controller/controller_suite_test.go index 2a0ef5ee0e..6e27263c66 100644 --- a/internal/framework/controller/controller_suite_test.go +++ b/internal/framework/controller/controller_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestControllers(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "Controller Suite") } diff --git a/internal/framework/controller/filter/filter_test.go b/internal/framework/controller/filter/filter_test.go index d9638aeb8d..d250dd312e 100644 --- a/internal/framework/controller/filter/filter_test.go +++ b/internal/framework/controller/filter/filter_test.go @@ -8,6 +8,7 @@ import ( ) func TestCreateSingleResourceFilter(t *testing.T) { + t.Parallel() targetNsName := types.NamespacedName{Namespace: "test", Name: "resource"} g := NewWithT(t) @@ -50,7 +51,9 @@ func TestCreateSingleResourceFilter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) shouldProcess, msg := filter(test.nsname) g.Expect(shouldProcess).To(Equal(test.expectedShouldProcess)) diff --git a/internal/framework/controller/index/endpointslice_test.go b/internal/framework/controller/index/endpointslice_test.go index 23e09dbf41..6fb55411be 100644 --- a/internal/framework/controller/index/endpointslice_test.go +++ b/internal/framework/controller/index/endpointslice_test.go @@ -11,6 +11,7 @@ import ( ) func TestServiceNameIndexFunc(t *testing.T) { + t.Parallel() testcases := []struct { msg string obj client.Object @@ -49,6 +50,7 @@ func TestServiceNameIndexFunc(t *testing.T) { } func TestServiceNameIndexFuncPanics(t *testing.T) { + t.Parallel() defer func() { g := NewWithT(t) g.Expect(recover()).ToNot(BeNil()) diff --git a/internal/framework/controller/predicate/annotation_test.go b/internal/framework/controller/predicate/annotation_test.go index 6fe18b3a28..619b6e68aa 100644 --- a/internal/framework/controller/predicate/annotation_test.go +++ b/internal/framework/controller/predicate/annotation_test.go @@ -10,6 +10,7 @@ import ( ) func TestAnnotationPredicate_Create(t *testing.T) { + t.Parallel() annotation := "test" tests := []struct { @@ -58,7 +59,9 @@ func TestAnnotationPredicate_Create(t *testing.T) { p := AnnotationPredicate{Annotation: annotation} for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) update := p.Create(test.event) g.Expect(update).To(Equal(test.expUpdate)) @@ -67,6 +70,7 @@ func TestAnnotationPredicate_Create(t *testing.T) { } func TestAnnotationPredicate_Update(t *testing.T) { + t.Parallel() annotation := "test" tests := []struct { @@ -211,7 +215,9 @@ func TestAnnotationPredicate_Update(t *testing.T) { p := AnnotationPredicate{Annotation: annotation} for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) update := p.Update(test.event) g.Expect(update).To(Equal(test.expUpdate)) diff --git a/internal/framework/controller/predicate/gatewayclass_test.go b/internal/framework/controller/predicate/gatewayclass_test.go index e89d974f00..91d2bad8bd 100644 --- a/internal/framework/controller/predicate/gatewayclass_test.go +++ b/internal/framework/controller/predicate/gatewayclass_test.go @@ -9,6 +9,7 @@ import ( ) func TestGatewayClassPredicate(t *testing.T) { + t.Parallel() g := NewWithT(t) p := GatewayClassPredicate{ControllerName: "nginx-ctlr"} diff --git a/internal/framework/controller/predicate/service_test.go b/internal/framework/controller/predicate/service_test.go index 90bda2fd2d..7933ac5c8b 100644 --- a/internal/framework/controller/predicate/service_test.go +++ b/internal/framework/controller/predicate/service_test.go @@ -13,6 +13,7 @@ import ( ) func TestServicePortsChangedPredicate_Update(t *testing.T) { + t.Parallel() testcases := []struct { objectOld client.Object objectNew client.Object @@ -227,7 +228,9 @@ func TestServicePortsChangedPredicate_Update(t *testing.T) { p := ServicePortsChangedPredicate{} for _, tc := range testcases { + tc := tc t.Run(tc.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) update := p.Update(event.UpdateEvent{ ObjectOld: tc.objectOld, @@ -240,6 +243,7 @@ func TestServicePortsChangedPredicate_Update(t *testing.T) { } func TestServicePortsChangedPredicate(t *testing.T) { + t.Parallel() g := NewWithT(t) p := GatewayServicePredicate{} @@ -250,6 +254,7 @@ func TestServicePortsChangedPredicate(t *testing.T) { } func TestGatewayServicePredicate_Update(t *testing.T) { + t.Parallel() testcases := []struct { objectOld client.Object objectNew client.Object @@ -440,7 +445,9 @@ func TestGatewayServicePredicate_Update(t *testing.T) { p := GatewayServicePredicate{NSName: types.NamespacedName{Namespace: "nginx-gateway", Name: "nginx"}} for _, tc := range testcases { + tc := tc t.Run(tc.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) update := p.Update(event.UpdateEvent{ ObjectOld: tc.objectOld, @@ -453,6 +460,7 @@ func TestGatewayServicePredicate_Update(t *testing.T) { } func TestGatewayServicePredicate(t *testing.T) { + t.Parallel() g := NewWithT(t) p := GatewayServicePredicate{} diff --git a/internal/framework/controller/register_test.go b/internal/framework/controller/register_test.go index f9cfc06cd6..049bc727b4 100644 --- a/internal/framework/controller/register_test.go +++ b/internal/framework/controller/register_test.go @@ -27,6 +27,7 @@ import ( ) func TestRegister(t *testing.T) { + t.Parallel() type fakes struct { mgr *controllerfakes.FakeManager indexer *controllerfakes.FakeFieldIndexer @@ -120,7 +121,9 @@ func TestRegister(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) newReconciler := func(c controller.ReconcilerConfig) *controller.Reconciler { diff --git a/internal/framework/events/events_suite_test.go b/internal/framework/events/events_suite_test.go index 1c318a89b4..d2b8ee906d 100644 --- a/internal/framework/events/events_suite_test.go +++ b/internal/framework/events/events_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestEvents(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "Events Suite") } diff --git a/internal/framework/events/events_test.go b/internal/framework/events/events_test.go index e36b539456..6ed5ce8b54 100644 --- a/internal/framework/events/events_test.go +++ b/internal/framework/events/events_test.go @@ -8,6 +8,7 @@ import ( ) func TestEventLoop_SwapBatches(t *testing.T) { + t.Parallel() g := NewWithT(t) eventLoop := NewEventLoop(nil, zap.New(), nil, nil) diff --git a/internal/framework/gatewayclass/validate_test.go b/internal/framework/gatewayclass/validate_test.go index 8359365477..d8def4964c 100644 --- a/internal/framework/gatewayclass/validate_test.go +++ b/internal/framework/gatewayclass/validate_test.go @@ -13,6 +13,7 @@ import ( ) func TestValidateCRDVersions(t *testing.T) { + t.Parallel() createCRDMetadata := func(version string) *metav1.PartialObjectMetadata { return &metav1.PartialObjectMetadata{ ObjectMeta: metav1.ObjectMeta{ @@ -113,7 +114,9 @@ func TestValidateCRDVersions(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) conds, valid := gatewayclass.ValidateCRDVersions(test.crds) diff --git a/internal/framework/helpers/helpers_test.go b/internal/framework/helpers/helpers_test.go index fbd1498b0b..0c4b598a8a 100644 --- a/internal/framework/helpers/helpers_test.go +++ b/internal/framework/helpers/helpers_test.go @@ -13,6 +13,7 @@ import ( ) func TestMustCastObject(t *testing.T) { + t.Parallel() g := NewWithT(t) var obj client.Object = &gatewayv1.Gateway{} @@ -27,6 +28,7 @@ func TestMustCastObject(t *testing.T) { } func TestEqualPointers(t *testing.T) { + t.Parallel() tests := []struct { p1 *string p2 *string @@ -78,7 +80,9 @@ func TestEqualPointers(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) val := helpers.EqualPointers(test.p1, test.p2) @@ -88,6 +92,7 @@ func TestEqualPointers(t *testing.T) { } func TestMustExecuteTemplate(t *testing.T) { + t.Parallel() g := NewWithT(t) tmpl := template.Must(template.New("test").Parse(`Hello {{.}}`)) @@ -96,6 +101,7 @@ func TestMustExecuteTemplate(t *testing.T) { } func TestMustExecuteTemplatePanics(t *testing.T) { + t.Parallel() g := NewWithT(t) execute := func() { diff --git a/internal/framework/runnables/cronjob_test.go b/internal/framework/runnables/cronjob_test.go index ca1154c30a..310ceef618 100644 --- a/internal/framework/runnables/cronjob_test.go +++ b/internal/framework/runnables/cronjob_test.go @@ -10,6 +10,7 @@ import ( ) func TestCronJob(t *testing.T) { + t.Parallel() g := NewWithT(t) readyChannel := make(chan struct{}) @@ -50,6 +51,7 @@ func TestCronJob(t *testing.T) { } func TestCronJob_ContextCanceled(t *testing.T) { + t.Parallel() g := NewWithT(t) readyChannel := make(chan struct{}) diff --git a/internal/framework/runnables/runnables_test.go b/internal/framework/runnables/runnables_test.go index 28af829306..9f34d9ccba 100644 --- a/internal/framework/runnables/runnables_test.go +++ b/internal/framework/runnables/runnables_test.go @@ -8,6 +8,7 @@ import ( ) func TestLeader(t *testing.T) { + t.Parallel() leader := &Leader{} g := NewWithT(t) @@ -15,6 +16,7 @@ func TestLeader(t *testing.T) { } func TestLeaderOrNonLeader(t *testing.T) { + t.Parallel() leaderOrNonLeader := &LeaderOrNonLeader{} g := NewWithT(t) @@ -22,6 +24,7 @@ func TestLeaderOrNonLeader(t *testing.T) { } func TestEnableAfterBecameLeader(t *testing.T) { + t.Parallel() enabled := false enableAfterBecameLeader := NewEnableAfterBecameLeader(func(_ context.Context) { enabled = true diff --git a/internal/framework/status/conditions_test.go b/internal/framework/status/conditions_test.go index c3d788e69d..838e068019 100644 --- a/internal/framework/status/conditions_test.go +++ b/internal/framework/status/conditions_test.go @@ -9,6 +9,7 @@ import ( ) func TestConditionsEqual(t *testing.T) { + t.Parallel() getDefaultConds := func() []v1.Condition { return []v1.Condition{ { @@ -110,7 +111,9 @@ func TestConditionsEqual(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) equal := ConditionsEqual(test.prevConds, test.curConds) g.Expect(equal).To(Equal(test.expEqual)) diff --git a/internal/framework/status/status_suite_test.go b/internal/framework/status/status_suite_test.go index b2dad44818..9dae71aec2 100644 --- a/internal/framework/status/status_suite_test.go +++ b/internal/framework/status/status_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestStatus(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "Status Suite") } diff --git a/internal/framework/status/updater_retry_test.go b/internal/framework/status/updater_retry_test.go index 69a8b5e388..5c6fa67b05 100644 --- a/internal/framework/status/updater_retry_test.go +++ b/internal/framework/status/updater_retry_test.go @@ -19,6 +19,7 @@ import ( ) func TestNewRetryUpdateFunc(t *testing.T) { + t.Parallel() tests := []struct { getReturns error updateReturns error @@ -70,7 +71,9 @@ func TestNewRetryUpdateFunc(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) fakeStatusUpdater := &statusfakes.FakeK8sUpdater{} diff --git a/internal/mode/provisioner/provisioner_suite_test.go b/internal/mode/provisioner/provisioner_suite_test.go index 6cfdb4144c..1435a2230e 100644 --- a/internal/mode/provisioner/provisioner_suite_test.go +++ b/internal/mode/provisioner/provisioner_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestProvisioner(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "Provisioner Suite") } diff --git a/internal/mode/static/config_updater_test.go b/internal/mode/static/config_updater_test.go index ee44971950..298c16a13b 100644 --- a/internal/mode/static/config_updater_test.go +++ b/internal/mode/static/config_updater_test.go @@ -16,6 +16,7 @@ import ( ) func TestUpdateControlPlane(t *testing.T) { + t.Parallel() debugLogCfg := &ngfAPI.NginxGateway{ Spec: ngfAPI.NginxGatewaySpec{ Logging: &ngfAPI.Logging{ @@ -71,7 +72,9 @@ func TestUpdateControlPlane(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) fakeLogSetter := &staticfakes.FakeLogLevelSetter{ @@ -103,6 +106,7 @@ func TestUpdateControlPlane(t *testing.T) { } func TestValidateLogLevel(t *testing.T) { + t.Parallel() validLevels := []ngfAPI.ControllerLogLevel{ ngfAPI.ControllerLogLevelError, ngfAPI.ControllerLogLevelInfo, @@ -116,7 +120,9 @@ func TestValidateLogLevel(t *testing.T) { } for _, level := range validLevels { + level := level t.Run(fmt.Sprintf("valid level %q", level), func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(validateLogLevel(level)).To(Succeed()) @@ -124,7 +130,9 @@ func TestValidateLogLevel(t *testing.T) { } for _, level := range invalidLevels { + level := level t.Run(fmt.Sprintf("invalid level %q", level), func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(validateLogLevel(level)).ToNot(Succeed()) diff --git a/internal/mode/static/health_test.go b/internal/mode/static/health_test.go index 352cc50b3c..5bfd7aab73 100644 --- a/internal/mode/static/health_test.go +++ b/internal/mode/static/health_test.go @@ -7,6 +7,7 @@ import ( ) func TestReadyCheck(t *testing.T) { + t.Parallel() g := NewWithT(t) nginxChecker := newNginxConfiguredOnStartChecker() g.Expect(nginxChecker.readyCheck(nil)).ToNot(Succeed()) diff --git a/internal/mode/static/log_level_setters_test.go b/internal/mode/static/log_level_setters_test.go index 214b9a15bc..df2d51f447 100644 --- a/internal/mode/static/log_level_setters_test.go +++ b/internal/mode/static/log_level_setters_test.go @@ -11,6 +11,7 @@ import ( ) func TestMultiLogLevelSetter_SetLevel(t *testing.T) { + t.Parallel() g := NewWithT(t) logr1 := &staticfakes.FakeLogLevelSetter{} @@ -41,6 +42,7 @@ func TestMultiLogLevelSetter_SetLevel(t *testing.T) { } func TestZapLogLevelSetter_SetLevel(t *testing.T) { + t.Parallel() g := NewWithT(t) zapSetter := newZapLogLevelSetter(zap.NewAtomicLevel()) @@ -58,6 +60,7 @@ func TestZapLogLevelSetter_SetLevel(t *testing.T) { } func TestPromLogLevelSetter_SetLevel(t *testing.T) { + t.Parallel() g := NewWithT(t) logger, err := newLeveledPrometheusLogger() diff --git a/internal/mode/static/manager_test.go b/internal/mode/static/manager_test.go index 041f5062b6..fe598dd28e 100644 --- a/internal/mode/static/manager_test.go +++ b/internal/mode/static/manager_test.go @@ -22,6 +22,7 @@ import ( ) func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) { + t.Parallel() const gcName = "nginx" partialObjectMetadataList := &metav1.PartialObjectMetadataList{} @@ -116,7 +117,9 @@ func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) objects, objectLists := prepareFirstEventBatchPreparerArgs(gcName, test.gwNsName, test.experimentalEnabled) @@ -128,6 +131,7 @@ func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) { } func TestGetMetricsOptions(t *testing.T) { + t.Parallel() tests := []struct { name string expectedOptions metricsserver.Options @@ -165,7 +169,9 @@ func TestGetMetricsOptions(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) metricsServerOptions := getMetricsOptions(test.metricsConfig) diff --git a/internal/mode/static/nginx/config/base_http_config_test.go b/internal/mode/static/nginx/config/base_http_config_test.go index 408118ecbc..8a54a575ab 100644 --- a/internal/mode/static/nginx/config/base_http_config_test.go +++ b/internal/mode/static/nginx/config/base_http_config_test.go @@ -10,6 +10,7 @@ import ( ) func TestExecuteBaseHttp(t *testing.T) { + t.Parallel() confOn := dataplane.Configuration{ BaseHTTPConfig: dataplane.BaseHTTPConfig{ HTTP2: true, diff --git a/internal/mode/static/nginx/config/convert_test.go b/internal/mode/static/nginx/config/convert_test.go index 0a3a059fac..6be41ccda6 100644 --- a/internal/mode/static/nginx/config/convert_test.go +++ b/internal/mode/static/nginx/config/convert_test.go @@ -10,6 +10,7 @@ import ( ) func TestConvertEndpoints(t *testing.T) { + t.Parallel() endpoints := []resolver.Endpoint{ { Address: "1.2.3.4", diff --git a/internal/mode/static/nginx/config/generator_test.go b/internal/mode/static/nginx/config/generator_test.go index f3eefa35f5..4940d72452 100644 --- a/internal/mode/static/nginx/config/generator_test.go +++ b/internal/mode/static/nginx/config/generator_test.go @@ -15,6 +15,7 @@ import ( ) func TestGenerate(t *testing.T) { + t.Parallel() bg := dataplane.BackendGroup{ Source: types.NamespacedName{Namespace: "test", Name: "hr"}, RuleIdx: 0, diff --git a/internal/mode/static/nginx/config/maps_test.go b/internal/mode/static/nginx/config/maps_test.go index a5227fb9b8..97eb6391ba 100644 --- a/internal/mode/static/nginx/config/maps_test.go +++ b/internal/mode/static/nginx/config/maps_test.go @@ -12,6 +12,7 @@ import ( ) func TestExecuteMaps(t *testing.T) { + t.Parallel() g := NewWithT(t) pathRules := []dataplane.PathRule{ { @@ -97,6 +98,7 @@ func TestExecuteMaps(t *testing.T) { } func TestBuildAddHeaderMaps(t *testing.T) { + t.Parallel() g := NewWithT(t) pathRules := []dataplane.PathRule{ { diff --git a/internal/mode/static/nginx/config/policies/clientsettings/generator_test.go b/internal/mode/static/nginx/config/policies/clientsettings/generator_test.go index 7d728fcfd2..bf41fcb866 100644 --- a/internal/mode/static/nginx/config/policies/clientsettings/generator_test.go +++ b/internal/mode/static/nginx/config/policies/clientsettings/generator_test.go @@ -13,6 +13,7 @@ import ( ) func TestGenerate(t *testing.T) { + t.Parallel() maxSize := helpers.GetPointer[ngfAPI.Size]("10m") bodyTimeout := helpers.GetPointer[ngfAPI.Duration]("600ms") keepaliveRequests := helpers.GetPointer[int32](900) @@ -160,7 +161,9 @@ func TestGenerate(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func(_ *testing.T) { + test := test + t.Run(test.name, func(t *testing.T) { + t.Parallel() generator := clientsettings.NewGenerator() resFiles := generator.GenerateForServer([]policies.Policy{test.policy}, http.Server{}) @@ -176,6 +179,7 @@ func TestGenerate(t *testing.T) { } func TestGenerateNoPolicies(t *testing.T) { + t.Parallel() g := NewWithT(t) generator := clientsettings.NewGenerator() diff --git a/internal/mode/static/nginx/config/policies/clientsettings/validator_test.go b/internal/mode/static/nginx/config/policies/clientsettings/validator_test.go index 9cb5884b6e..21f6cfcbc4 100644 --- a/internal/mode/static/nginx/config/policies/clientsettings/validator_test.go +++ b/internal/mode/static/nginx/config/policies/clientsettings/validator_test.go @@ -53,6 +53,7 @@ func createModifiedPolicy(mod policyModFunc) *ngfAPI.ClientSettingsPolicy { } func TestValidator_Validate(t *testing.T) { + t.Parallel() tests := []struct { name string policy *ngfAPI.ClientSettingsPolicy @@ -132,7 +133,9 @@ func TestValidator_Validate(t *testing.T) { v := clientsettings.NewValidator(validation.GenericValidator{}) for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) conds := v.Validate(test.policy, nil) @@ -142,6 +145,7 @@ func TestValidator_Validate(t *testing.T) { } func TestValidator_ValidatePanics(t *testing.T) { + t.Parallel() v := clientsettings.NewValidator(nil) validate := func() { @@ -154,6 +158,7 @@ func TestValidator_ValidatePanics(t *testing.T) { } func TestValidator_Conflicts(t *testing.T) { + t.Parallel() tests := []struct { polA *ngfAPI.ClientSettingsPolicy polB *ngfAPI.ClientSettingsPolicy @@ -255,7 +260,9 @@ func TestValidator_Conflicts(t *testing.T) { v := clientsettings.NewValidator(nil) for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(v.Conflicts(test.polA, test.polB)).To(Equal(test.conflicts)) @@ -264,6 +271,7 @@ func TestValidator_Conflicts(t *testing.T) { } func TestValidator_ConflictsPanics(t *testing.T) { + t.Parallel() v := clientsettings.NewValidator(nil) conflicts := func() { diff --git a/internal/mode/static/nginx/config/policies/observability/generator_test.go b/internal/mode/static/nginx/config/policies/observability/generator_test.go index 4faa880c0d..9ac4fa4600 100644 --- a/internal/mode/static/nginx/config/policies/observability/generator_test.go +++ b/internal/mode/static/nginx/config/policies/observability/generator_test.go @@ -15,6 +15,7 @@ import ( ) func TestGenerate(t *testing.T) { + t.Parallel() ratio := helpers.GetPointer[int32](25) zeroRatio := helpers.GetPointer[int32](0) context := helpers.GetPointer[ngfAPI.TraceContext](ngfAPI.TraceContextExtract) @@ -241,7 +242,9 @@ func TestGenerate(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) generator := observability.NewGenerator(test.telemetryConf) diff --git a/internal/mode/static/nginx/config/policies/observability/validator_test.go b/internal/mode/static/nginx/config/policies/observability/validator_test.go index 9f8976e4c2..15b320d71e 100644 --- a/internal/mode/static/nginx/config/policies/observability/validator_test.go +++ b/internal/mode/static/nginx/config/policies/observability/validator_test.go @@ -52,6 +52,7 @@ func createModifiedPolicy(mod policyModFunc) *ngfAPI.ObservabilityPolicy { } func TestValidator_Validate(t *testing.T) { + t.Parallel() globalSettings := &policies.GlobalSettings{ NginxProxyValid: true, TelemetryEnabled: true, @@ -184,7 +185,9 @@ func TestValidator_Validate(t *testing.T) { v := observability.NewValidator(validation.GenericValidator{}) for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) conds := v.Validate(test.policy, test.globalSettings) @@ -194,6 +197,7 @@ func TestValidator_Validate(t *testing.T) { } func TestValidator_ValidatePanics(t *testing.T) { + t.Parallel() v := observability.NewValidator(nil) validate := func() { @@ -206,6 +210,7 @@ func TestValidator_ValidatePanics(t *testing.T) { } func TestValidator_Conflicts(t *testing.T) { + t.Parallel() tests := []struct { polA *ngfAPI.ObservabilityPolicy polB *ngfAPI.ObservabilityPolicy @@ -243,7 +248,9 @@ func TestValidator_Conflicts(t *testing.T) { v := observability.NewValidator(nil) for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(v.Conflicts(test.polA, test.polB)).To(Equal(test.conflicts)) @@ -252,6 +259,7 @@ func TestValidator_Conflicts(t *testing.T) { } func TestValidator_ConflictsPanics(t *testing.T) { + t.Parallel() v := observability.NewValidator(nil) conflicts := func() { diff --git a/internal/mode/static/nginx/config/policies/policies_suite_test.go b/internal/mode/static/nginx/config/policies/policies_suite_test.go index 6703df23f1..a22933037a 100644 --- a/internal/mode/static/nginx/config/policies/policies_suite_test.go +++ b/internal/mode/static/nginx/config/policies/policies_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestPolicies(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "Policies Suite") } diff --git a/internal/mode/static/nginx/config/servers_test.go b/internal/mode/static/nginx/config/servers_test.go index 2ef832ea09..35be30f6dd 100644 --- a/internal/mode/static/nginx/config/servers_test.go +++ b/internal/mode/static/nginx/config/servers_test.go @@ -18,6 +18,7 @@ import ( ) func TestExecuteServers(t *testing.T) { + t.Parallel() conf := dataplane.Configuration{ HTTPServers: []dataplane.VirtualServer{ { @@ -277,6 +278,7 @@ func TestExecuteServersForIPFamily(t *testing.T) { } func TestExecuteForDefaultServers(t *testing.T) { + t.Parallel() testcases := []struct { msg string httpPorts []int @@ -344,7 +346,9 @@ func TestExecuteForDefaultServers(t *testing.T) { httpDefaultFmt := "listen %d default_server" for _, tc := range testcases { + tc := tc t.Run(tc.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) serverResults := executeServers(tc.conf, &policiesfakes.FakeGenerator{}) @@ -365,6 +369,7 @@ func TestExecuteForDefaultServers(t *testing.T) { } func TestCreateServers(t *testing.T) { + t.Parallel() const ( sslKeyPairID = "test-keypair" ) @@ -1288,6 +1293,7 @@ func modifyMatchPairs(matchPairs httpMatchPairs) httpMatchPairs { } func TestCreateServersConflicts(t *testing.T) { + t.Parallel() fooGroup := dataplane.BackendGroup{ Source: types.NamespacedName{Namespace: "test", Name: "route"}, RuleIdx: 0, @@ -1460,7 +1466,9 @@ func TestCreateServersConflicts(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() httpServers := []dataplane.VirtualServer{ { IsDefault: true, @@ -1498,6 +1506,7 @@ func TestCreateServersConflicts(t *testing.T) { } func TestCreateLocationsRootPath(t *testing.T) { + t.Parallel() hrNsName := types.NamespacedName{Namespace: "test", Name: "route1"} fooGroup := dataplane.BackendGroup{ @@ -1663,7 +1672,9 @@ func TestCreateLocationsRootPath(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) locs, httpMatchPair, grpc := createLocations(&dataplane.VirtualServer{ @@ -1678,6 +1689,7 @@ func TestCreateLocationsRootPath(t *testing.T) { } func TestCreateReturnValForRedirectFilter(t *testing.T) { + t.Parallel() const listenerPortCustom = 123 const listenerPortHTTP = 80 const listenerPortHTTPS = 443 @@ -1799,7 +1811,9 @@ func TestCreateReturnValForRedirectFilter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := createReturnValForRedirectFilter(test.filter, test.listenerPort) @@ -1809,6 +1823,7 @@ func TestCreateReturnValForRedirectFilter(t *testing.T) { } func TestCreateRewritesValForRewriteFilter(t *testing.T) { + t.Parallel() tests := []struct { filter *dataplane.HTTPURLRewriteFilter expected *rewriteConfig @@ -1925,7 +1940,9 @@ func TestCreateRewritesValForRewriteFilter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := createRewritesValForRewriteFilter(test.filter, test.path) @@ -1935,6 +1952,7 @@ func TestCreateRewritesValForRewriteFilter(t *testing.T) { } func TestCreateRouteMatch(t *testing.T) { + t.Parallel() testPath := "/internal_loc" testMethodMatch := helpers.GetPointer("PUT") @@ -2084,7 +2102,9 @@ func TestCreateRouteMatch(t *testing.T) { }, } for _, tc := range tests { + tc := tc t.Run(tc.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := createRouteMatch(tc.match, testPath) @@ -2094,6 +2114,7 @@ func TestCreateRouteMatch(t *testing.T) { } func TestCreateQueryParamKeyValString(t *testing.T) { + t.Parallel() g := NewWithT(t) expected := "key=value" @@ -2120,6 +2141,7 @@ func TestCreateQueryParamKeyValString(t *testing.T) { } func TestCreateHeaderKeyValString(t *testing.T) { + t.Parallel() g := NewWithT(t) expected := "kEy:vALUe" @@ -2135,6 +2157,7 @@ func TestCreateHeaderKeyValString(t *testing.T) { } func TestIsPathOnlyMatch(t *testing.T) { + t.Parallel() tests := []struct { msg string match dataplane.Match @@ -2179,7 +2202,9 @@ func TestIsPathOnlyMatch(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := isPathOnlyMatch(tc.match) @@ -2189,6 +2214,7 @@ func TestIsPathOnlyMatch(t *testing.T) { } func TestCreateProxyPass(t *testing.T) { + t.Parallel() g := NewWithT(t) tests := []struct { @@ -2264,6 +2290,7 @@ func TestCreateProxyPass(t *testing.T) { } func TestCreateMatchLocation(t *testing.T) { + t.Parallel() g := NewWithT(t) expectedNoGRPC := http.Location{ @@ -2287,6 +2314,7 @@ func TestCreateMatchLocation(t *testing.T) { } func TestGenerateProxySetHeaders(t *testing.T) { + t.Parallel() tests := []struct { filters *dataplane.HTTPFilters msg string @@ -2431,7 +2459,9 @@ func TestGenerateProxySetHeaders(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) headers := generateProxySetHeaders(tc.filters, tc.GRPC) @@ -2441,7 +2471,7 @@ func TestGenerateProxySetHeaders(t *testing.T) { } func TestConvertBackendTLSFromGroup(t *testing.T) { - g := NewWithT(t) + t.Parallel() tests := []struct { expected *http.ProxySSLVerify @@ -2522,7 +2552,10 @@ func TestConvertBackendTLSFromGroup(t *testing.T) { } for _, tc := range tests { - t.Run(tc.msg, func(_ *testing.T) { + tc := tc + t.Run(tc.msg, func(t *testing.T) { + t.Parallel() + g := NewWithT(t) result := createProxyTLSFromBackends(tc.grp) g.Expect(result).To(Equal(tc.expected)) }) @@ -2530,6 +2563,7 @@ func TestConvertBackendTLSFromGroup(t *testing.T) { } func TestGenerateResponseHeaders(t *testing.T) { + t.Parallel() tests := []struct { filters *dataplane.HTTPFilters msg string @@ -2588,7 +2622,9 @@ func TestGenerateResponseHeaders(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) headers := generateResponseHeaders(tc.filters) @@ -2598,6 +2634,7 @@ func TestGenerateResponseHeaders(t *testing.T) { } func TestCreateIncludesFromPolicyGenerateResult(t *testing.T) { + t.Parallel() tests := []struct { name string files []policies.File @@ -2642,7 +2679,9 @@ func TestCreateIncludesFromPolicyGenerateResult(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) includes := createIncludesFromPolicyGenerateResult(test.files) @@ -2652,6 +2691,7 @@ func TestCreateIncludesFromPolicyGenerateResult(t *testing.T) { } func TestCreateIncludeFileResults(t *testing.T) { + t.Parallel() servers := []http.Server{ { Includes: []http.Include{ @@ -2742,6 +2782,7 @@ func TestCreateIncludeFileResults(t *testing.T) { } func TestGetIPFamily(t *testing.T) { + t.Parallel() test := []struct { msg string baseHTTPConfig dataplane.BaseHTTPConfig @@ -2765,7 +2806,9 @@ func TestGetIPFamily(t *testing.T) { } for _, tc := range test { + tc := tc t.Run(tc.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := getIPFamily(tc.baseHTTPConfig) g.Expect(result).To(Equal(tc.expected)) diff --git a/internal/mode/static/nginx/config/split_clients_test.go b/internal/mode/static/nginx/config/split_clients_test.go index 9ee6785ca9..95d8423493 100644 --- a/internal/mode/static/nginx/config/split_clients_test.go +++ b/internal/mode/static/nginx/config/split_clients_test.go @@ -11,6 +11,7 @@ import ( ) func TestExecuteSplitClients(t *testing.T) { + t.Parallel() bg1 := dataplane.BackendGroup{ Source: types.NamespacedName{Namespace: "test", Name: "hr"}, RuleIdx: 0, @@ -96,7 +97,9 @@ func TestExecuteSplitClients(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) splitResults := executeSplitClients(dataplane.Configuration{BackendGroups: test.backendGroups}) g.Expect(splitResults).To(HaveLen(1)) @@ -115,6 +118,7 @@ func TestExecuteSplitClients(t *testing.T) { } func TestCreateSplitClients(t *testing.T) { + t.Parallel() hrNoSplit := types.NamespacedName{Namespace: "test", Name: "hr-no-split"} hrOneSplit := types.NamespacedName{Namespace: "test", Name: "hr-one-split"} hrTwoSplits := types.NamespacedName{Namespace: "test", Name: "hr-two-splits"} @@ -240,7 +244,9 @@ func TestCreateSplitClients(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := createSplitClients(test.backendGroups) g.Expect(result).To(Equal(test.expSplitClients)) @@ -249,6 +255,7 @@ func TestCreateSplitClients(t *testing.T) { } func TestCreateSplitClientDistributions(t *testing.T) { + t.Parallel() tests := []struct { msg string backends []dataplane.Backend @@ -387,7 +394,9 @@ func TestCreateSplitClientDistributions(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := createSplitClientDistributions(dataplane.BackendGroup{Backends: test.backends}) g.Expect(result).To(Equal(test.expDistributions)) @@ -396,6 +405,7 @@ func TestCreateSplitClientDistributions(t *testing.T) { } func TestGetSplitClientValue(t *testing.T) { + t.Parallel() tests := []struct { msg string expValue string @@ -420,7 +430,9 @@ func TestGetSplitClientValue(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := getSplitClientValue(test.backend) g.Expect(result).To(Equal(test.expValue)) @@ -429,6 +441,7 @@ func TestGetSplitClientValue(t *testing.T) { } func TestPercentOf(t *testing.T) { + t.Parallel() tests := []struct { msg string weight int32 @@ -492,7 +505,9 @@ func TestPercentOf(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) percent := percentOf(test.weight, test.totalWeight) g.Expect(percent).To(Equal(test.expPercent)) @@ -501,6 +516,7 @@ func TestPercentOf(t *testing.T) { } func TestBackendGroupNeedsSplit(t *testing.T) { + t.Parallel() tests := []struct { msg string backends []dataplane.Backend @@ -573,7 +589,9 @@ func TestBackendGroupNeedsSplit(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) bg := dataplane.BackendGroup{ Source: types.NamespacedName{Namespace: "test", Name: "hr"}, @@ -586,6 +604,7 @@ func TestBackendGroupNeedsSplit(t *testing.T) { } func TestBackendGroupName(t *testing.T) { + t.Parallel() tests := []struct { msg string expName string @@ -669,7 +688,9 @@ func TestBackendGroupName(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) bg := dataplane.BackendGroup{ Source: types.NamespacedName{Namespace: "test", Name: "hr"}, diff --git a/internal/mode/static/nginx/config/telemetry_test.go b/internal/mode/static/nginx/config/telemetry_test.go index 6d59c1abac..5838152985 100644 --- a/internal/mode/static/nginx/config/telemetry_test.go +++ b/internal/mode/static/nginx/config/telemetry_test.go @@ -10,6 +10,7 @@ import ( ) func TestExecuteTelemetry(t *testing.T) { + t.Parallel() conf := dataplane.Configuration{ Telemetry: dataplane.Telemetry{ Endpoint: "1.2.3.4:123", @@ -50,6 +51,7 @@ func TestExecuteTelemetry(t *testing.T) { } func TestExecuteTelemetryNil(t *testing.T) { + t.Parallel() conf := dataplane.Configuration{ Telemetry: dataplane.Telemetry{}, } diff --git a/internal/mode/static/nginx/config/upstreams_test.go b/internal/mode/static/nginx/config/upstreams_test.go index 8ec1c33386..ad7b59deb7 100644 --- a/internal/mode/static/nginx/config/upstreams_test.go +++ b/internal/mode/static/nginx/config/upstreams_test.go @@ -12,6 +12,7 @@ import ( ) func TestExecuteUpstreams(t *testing.T) { + t.Parallel() gen := GeneratorImpl{} stateUpstreams := []dataplane.Upstream{ { @@ -72,6 +73,7 @@ func TestExecuteUpstreams(t *testing.T) { } func TestCreateUpstreams(t *testing.T) { + t.Parallel() gen := GeneratorImpl{} stateUpstreams := []dataplane.Upstream{ { @@ -175,6 +177,7 @@ func TestCreateUpstreams(t *testing.T) { } func TestCreateUpstream(t *testing.T) { + t.Parallel() gen := GeneratorImpl{} tests := []struct { msg string @@ -273,7 +276,9 @@ func TestCreateUpstream(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := gen.createUpstream(test.stateUpstream) g.Expect(result).To(Equal(test.expectedUpstream)) @@ -282,6 +287,7 @@ func TestCreateUpstream(t *testing.T) { } func TestCreateUpstreamPlus(t *testing.T) { + t.Parallel() gen := GeneratorImpl{plus: true} stateUpstream := dataplane.Upstream{ diff --git a/internal/mode/static/nginx/config/validation/common_test.go b/internal/mode/static/nginx/config/validation/common_test.go index f7c2f3be74..da3059e4c4 100644 --- a/internal/mode/static/nginx/config/validation/common_test.go +++ b/internal/mode/static/nginx/config/validation/common_test.go @@ -6,6 +6,7 @@ import ( ) func TestValidateEscapedString(t *testing.T) { + t.Parallel() validator := func(value string) error { return validateEscapedString(value, []string{"example"}) } testValidValuesForSimpleValidator( @@ -25,6 +26,7 @@ func TestValidateEscapedString(t *testing.T) { } func TestValidateEscapedStringNoVarExpansion(t *testing.T) { + t.Parallel() validator := func(value string) error { return validateEscapedStringNoVarExpansion(value, []string{"example"}) } testValidValuesForSimpleValidator( @@ -45,6 +47,7 @@ func TestValidateEscapedStringNoVarExpansion(t *testing.T) { } func TestValidateValidHeaderName(t *testing.T) { + t.Parallel() validator := func(value string) error { return validateHeaderName(value) } testValidValuesForSimpleValidator( diff --git a/internal/mode/static/nginx/config/validation/framework_test.go b/internal/mode/static/nginx/config/validation/framework_test.go index 58e727fbc7..7e0ff5d0ce 100644 --- a/internal/mode/static/nginx/config/validation/framework_test.go +++ b/internal/mode/static/nginx/config/validation/framework_test.go @@ -79,6 +79,7 @@ func testInvalidValuesForSupportedValuesValidator[T configValue]( } func TestValidateInSupportedValues(t *testing.T) { + t.Parallel() supportedValues := map[string]struct{}{ "value1": {}, "value2": {}, @@ -105,6 +106,7 @@ func TestValidateInSupportedValues(t *testing.T) { } func TestValidateNoUnsupportedValues(t *testing.T) { + t.Parallel() unsupportedValues := map[string]struct{}{ "badvalue1": {}, "badvalue2": {}, @@ -133,6 +135,7 @@ func TestValidateNoUnsupportedValues(t *testing.T) { } func TestGetSortedKeysAsString(t *testing.T) { + t.Parallel() values := map[string]struct{}{ "value3": {}, "value1": {}, diff --git a/internal/mode/static/nginx/config/validation/generic_test.go b/internal/mode/static/nginx/config/validation/generic_test.go index 86903bfa38..6934372c0f 100644 --- a/internal/mode/static/nginx/config/validation/generic_test.go +++ b/internal/mode/static/nginx/config/validation/generic_test.go @@ -3,6 +3,7 @@ package validation import "testing" func TestGenericValidator_ValidateEscapedStringNoVarExpansion(t *testing.T) { + t.Parallel() validator := GenericValidator{} testValidValuesForSimpleValidator( @@ -24,6 +25,7 @@ func TestGenericValidator_ValidateEscapedStringNoVarExpansion(t *testing.T) { } func TestValidateServiceName(t *testing.T) { + t.Parallel() validator := GenericValidator{} testValidValuesForSimpleValidator( @@ -45,6 +47,7 @@ func TestValidateServiceName(t *testing.T) { } func TestValidateNginxDuration(t *testing.T) { + t.Parallel() validator := GenericValidator{} testValidValuesForSimpleValidator( @@ -65,6 +68,7 @@ func TestValidateNginxDuration(t *testing.T) { } func TestValidateNginxSize(t *testing.T) { + t.Parallel() validator := GenericValidator{} testValidValuesForSimpleValidator( @@ -86,6 +90,7 @@ func TestValidateNginxSize(t *testing.T) { } func TestValidateEndpoint(t *testing.T) { + t.Parallel() validator := GenericValidator{} testValidValuesForSimpleValidator( diff --git a/internal/mode/static/nginx/config/validation/http_filters_test.go b/internal/mode/static/nginx/config/validation/http_filters_test.go index d58716599c..bd06ed2b41 100644 --- a/internal/mode/static/nginx/config/validation/http_filters_test.go +++ b/internal/mode/static/nginx/config/validation/http_filters_test.go @@ -6,6 +6,7 @@ import ( ) func TestValidateRedirectScheme(t *testing.T) { + t.Parallel() validator := HTTPRedirectValidator{} testValidValuesForSupportedValuesValidator( @@ -24,6 +25,7 @@ func TestValidateRedirectScheme(t *testing.T) { } func TestValidateRedirectPort(t *testing.T) { + t.Parallel() validator := HTTPRedirectValidator{} testValidValuesForSimpleValidator( @@ -35,6 +37,7 @@ func TestValidateRedirectPort(t *testing.T) { } func TestValidateRedirectStatusCode(t *testing.T) { + t.Parallel() validator := HTTPRedirectValidator{} testValidValuesForSupportedValuesValidator( @@ -52,6 +55,7 @@ func TestValidateRedirectStatusCode(t *testing.T) { } func TestValidateHostname(t *testing.T) { + t.Parallel() validator := HTTPRedirectValidator{} testValidValuesForSimpleValidator( @@ -68,6 +72,7 @@ func TestValidateHostname(t *testing.T) { } func TestValidateRewritePath(t *testing.T) { + t.Parallel() validator := HTTPURLRewriteValidator{} testValidValuesForSimpleValidator( @@ -89,6 +94,7 @@ func TestValidateRewritePath(t *testing.T) { } func TestValidateFilterHeaderName(t *testing.T) { + t.Parallel() validator := HTTPHeaderValidator{} testValidValuesForSimpleValidator( @@ -102,6 +108,7 @@ func TestValidateFilterHeaderName(t *testing.T) { } func TestValidateFilterHeaderValue(t *testing.T) { + t.Parallel() validator := HTTPHeaderValidator{} testValidValuesForSimpleValidator( diff --git a/internal/mode/static/nginx/config/validation/http_njs_match_test.go b/internal/mode/static/nginx/config/validation/http_njs_match_test.go index 6856dea988..70293060f8 100644 --- a/internal/mode/static/nginx/config/validation/http_njs_match_test.go +++ b/internal/mode/static/nginx/config/validation/http_njs_match_test.go @@ -5,6 +5,7 @@ import ( ) func TestValidatePathInMatch(t *testing.T) { + t.Parallel() validator := HTTPNJSMatchValidator{} testValidValuesForSimpleValidator( @@ -28,6 +29,7 @@ func TestValidatePathInMatch(t *testing.T) { } func TestValidateHeaderNameInMatch(t *testing.T) { + t.Parallel() validator := HTTPNJSMatchValidator{} testValidValuesForSimpleValidator( @@ -50,6 +52,7 @@ func TestValidateHeaderNameInMatch(t *testing.T) { } func TestValidateHeaderValueInMatch(t *testing.T) { + t.Parallel() validator := HTTPNJSMatchValidator{} testValidValuesForSimpleValidator( @@ -70,6 +73,7 @@ func TestValidateHeaderValueInMatch(t *testing.T) { } func TestValidateQueryParamNameInMatch(t *testing.T) { + t.Parallel() validator := HTTPNJSMatchValidator{} testValidValuesForSimpleValidator( @@ -85,6 +89,7 @@ func TestValidateQueryParamNameInMatch(t *testing.T) { } func TestValidateQueryParamValueInMatch(t *testing.T) { + t.Parallel() validator := HTTPNJSMatchValidator{} testValidValuesForSimpleValidator( @@ -100,6 +105,7 @@ func TestValidateQueryParamValueInMatch(t *testing.T) { } func TestValidateMethodInMatch(t *testing.T) { + t.Parallel() validator := HTTPNJSMatchValidator{} testValidValuesForSupportedValuesValidator( @@ -123,6 +129,7 @@ func TestValidateMethodInMatch(t *testing.T) { } func TestValidateCommonMatchPart(t *testing.T) { + t.Parallel() testValidValuesForSimpleValidator( t, validateCommonNJSMatchPart, diff --git a/internal/mode/static/nginx/config/variable_names_test.go b/internal/mode/static/nginx/config/variable_names_test.go index acaebe9aa2..6a7b6fe6d2 100644 --- a/internal/mode/static/nginx/config/variable_names_test.go +++ b/internal/mode/static/nginx/config/variable_names_test.go @@ -7,6 +7,7 @@ import ( ) func TestConvertStringToSafeVariableName(t *testing.T) { + t.Parallel() tests := []struct { msg string s string @@ -24,7 +25,9 @@ func TestConvertStringToSafeVariableName(t *testing.T) { }, } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(convertStringToSafeVariableName(test.s)).To(Equal(test.expected)) }) @@ -32,6 +35,7 @@ func TestConvertStringToSafeVariableName(t *testing.T) { } func TestGenerateAddHeaderMapVariableName(t *testing.T) { + t.Parallel() tests := []struct { msg string headerName string @@ -49,7 +53,9 @@ func TestGenerateAddHeaderMapVariableName(t *testing.T) { }, } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) actual := generateAddHeaderMapVariableName(test.headerName) g.Expect(actual).To(Equal(test.expected)) diff --git a/internal/mode/static/nginx/config/version_test.go b/internal/mode/static/nginx/config/version_test.go index 4219844c39..176db3dfec 100644 --- a/internal/mode/static/nginx/config/version_test.go +++ b/internal/mode/static/nginx/config/version_test.go @@ -8,6 +8,7 @@ import ( ) func TestExecuteVersion(t *testing.T) { + t.Parallel() g := NewWithT(t) expSubStrings := map[string]int{ "return 200 42;": 1, diff --git a/internal/mode/static/nginx/file/file_suite_test.go b/internal/mode/static/nginx/file/file_suite_test.go index 46afb4ea54..9017ae221f 100644 --- a/internal/mode/static/nginx/file/file_suite_test.go +++ b/internal/mode/static/nginx/file/file_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestFile(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "File Suite") } diff --git a/internal/mode/static/nginx/file/folders_test.go b/internal/mode/static/nginx/file/folders_test.go index 9e1e8f518b..8a4caf5285 100644 --- a/internal/mode/static/nginx/file/folders_test.go +++ b/internal/mode/static/nginx/file/folders_test.go @@ -21,6 +21,7 @@ func writeFile(t *testing.T, name string, data []byte) { } func TestClearFoldersRemoves(t *testing.T) { + t.Parallel() g := NewWithT(t) tempDir := t.TempDir() @@ -41,6 +42,7 @@ func TestClearFoldersRemoves(t *testing.T) { } func TestClearFoldersFails(t *testing.T) { + t.Parallel() files := []string{"file"} testErr := errors.New("test error") @@ -77,7 +79,9 @@ func TestClearFoldersFails(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) removedFiles, err := file.ClearFolders(test.fileMgr, files) diff --git a/internal/mode/static/nginx/runtime/manager_test.go b/internal/mode/static/nginx/runtime/manager_test.go index 323bb514a5..1b3be5b446 100644 --- a/internal/mode/static/nginx/runtime/manager_test.go +++ b/internal/mode/static/nginx/runtime/manager_test.go @@ -24,6 +24,7 @@ var _ = Describe("NGINX Runtime Manager", func() { }) func TestFindMainProcess(t *testing.T) { + t.Parallel() readFileFuncGen := func(content []byte) readFileFunc { return func(name string) ([]byte, error) { if name != pidFile { @@ -111,7 +112,9 @@ func TestFindMainProcess(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result, err := findMainProcess(test.ctx, test.checkFile, test.readFile, 2*time.Millisecond) diff --git a/internal/mode/static/nginx/runtime/runtime_suite_test.go b/internal/mode/static/nginx/runtime/runtime_suite_test.go index 7a31e6ebf4..8916c4bf14 100644 --- a/internal/mode/static/nginx/runtime/runtime_suite_test.go +++ b/internal/mode/static/nginx/runtime/runtime_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestRuntime(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "Runtime Suite") } diff --git a/internal/mode/static/nginx/runtime/verify_test.go b/internal/mode/static/nginx/runtime/verify_test.go index fda58b56f3..921f6090fd 100644 --- a/internal/mode/static/nginx/runtime/verify_test.go +++ b/internal/mode/static/nginx/runtime/verify_test.go @@ -30,6 +30,7 @@ func getTestHTTPClient() *http.Client { } func TestVerifyClient(t *testing.T) { + t.Parallel() c := verifyClient{ client: getTestHTTPClient(), timeout: 25 * time.Millisecond, @@ -86,7 +87,9 @@ func TestVerifyClient(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := c.waitForCorrectVersion(test.ctx, test.expectedVersion, "/childfile", []byte("1 2 3"), test.readFile) @@ -101,6 +104,7 @@ func TestVerifyClient(t *testing.T) { } func TestEnsureNewNginxWorkers(t *testing.T) { + t.Parallel() previousContents := []byte("1 2 3") newContents := []byte("4 5 6") @@ -162,7 +166,9 @@ func TestEnsureNewNginxWorkers(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := ensureNewNginxWorkers( diff --git a/internal/mode/static/sort/sort_test.go b/internal/mode/static/sort/sort_test.go index d1b63e830d..402c8ad6ab 100644 --- a/internal/mode/static/sort/sort_test.go +++ b/internal/mode/static/sort/sort_test.go @@ -11,6 +11,7 @@ import ( ) func TestLessObjectMeta(t *testing.T) { + t.Parallel() before := metav1.Now() later := metav1.NewTime(before.Add(1 * time.Second)) @@ -79,7 +80,9 @@ func TestLessObjectMeta(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := LessObjectMeta(test.meta1, test.meta2) @@ -92,6 +95,7 @@ func TestLessObjectMeta(t *testing.T) { } func TestLessClientObject(t *testing.T) { + t.Parallel() before := metav1.Now() later := metav1.NewTime(before.Add(1 * time.Second)) @@ -176,7 +180,9 @@ func TestLessClientObject(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := LessClientObject(test.obj1, test.obj2) diff --git a/internal/mode/static/state/changed_predicate_test.go b/internal/mode/static/state/changed_predicate_test.go index 7e7bf7304d..0735c3461b 100644 --- a/internal/mode/static/state/changed_predicate_test.go +++ b/internal/mode/static/state/changed_predicate_test.go @@ -13,6 +13,7 @@ import ( ) func TestFuncPredicate(t *testing.T) { + t.Parallel() alwaysTrueFunc := func(_ ngftypes.ObjectType, _ types.NamespacedName) bool { return true } emptyObject := &v1.Pod{} @@ -25,6 +26,7 @@ func TestFuncPredicate(t *testing.T) { } func TestFuncPredicate_Panic(t *testing.T) { + t.Parallel() alwaysTrueFunc := func(_ ngftypes.ObjectType, _ types.NamespacedName) bool { return true } p := funcPredicate{stateChanged: alwaysTrueFunc} @@ -38,6 +40,7 @@ func TestFuncPredicate_Panic(t *testing.T) { } func TestAnnotationChangedPredicate_Delete(t *testing.T) { + t.Parallel() p := annotationChangedPredicate{} g := NewWithT(t) @@ -45,6 +48,7 @@ func TestAnnotationChangedPredicate_Delete(t *testing.T) { } func TestAnnotationChangedPredicate_Update(t *testing.T) { + t.Parallel() annotation := "test" tests := []struct { @@ -139,7 +143,9 @@ func TestAnnotationChangedPredicate_Update(t *testing.T) { p := annotationChangedPredicate{annotation: annotation} for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) if test.expPanic { upsert := func() { diff --git a/internal/mode/static/state/dataplane/configuration_test.go b/internal/mode/static/state/dataplane/configuration_test.go index edc9ae602e..5eb4e666b2 100644 --- a/internal/mode/static/state/dataplane/configuration_test.go +++ b/internal/mode/static/state/dataplane/configuration_test.go @@ -109,6 +109,7 @@ func createFakePolicy(name string, kind string) policies.Policy { } func TestBuildConfiguration(t *testing.T) { + t.Parallel() const ( invalidMatchesPath = "/not-valid-matches" invalidFiltersPath = "/not-valid-filters" @@ -2183,7 +2184,9 @@ func TestBuildConfiguration(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := BuildConfiguration( @@ -2208,6 +2211,7 @@ func TestBuildConfiguration(t *testing.T) { } func TestGetPath(t *testing.T) { + t.Parallel() tests := []struct { path *v1.HTTPPathMatch expected string @@ -2236,7 +2240,9 @@ func TestGetPath(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := getPath(test.path) g.Expect(result).To(Equal(test.expected)) @@ -2245,6 +2251,7 @@ func TestGetPath(t *testing.T) { } func TestCreateFilters(t *testing.T) { + t.Parallel() redirect1 := v1.HTTPRouteFilter{ Type: v1.HTTPRouteFilterRequestRedirect, RequestRedirect: &v1.HTTPRequestRedirectFilter{ @@ -2403,7 +2410,9 @@ func TestCreateFilters(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := createHTTPFilters(test.filters) @@ -2413,6 +2422,7 @@ func TestCreateFilters(t *testing.T) { } func TestGetListenerHostname(t *testing.T) { + t.Parallel() var emptyHostname v1.Hostname var hostname v1.Hostname = "example.com" @@ -2439,7 +2449,9 @@ func TestGetListenerHostname(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := getListenerHostname(test.hostname) g.Expect(result).To(Equal(test.expected)) @@ -2462,6 +2474,7 @@ func refsToValidRules(refs ...[]graph.BackendRef) []graph.RouteRule { } func TestBuildUpstreams(t *testing.T) { + t.Parallel() fooEndpoints := []resolver.Endpoint{ { Address: "10.0.0.0", @@ -2729,6 +2742,7 @@ func TestBuildUpstreams(t *testing.T) { } func TestBuildBackendGroups(t *testing.T) { + t.Parallel() createBackendGroup := func(name string, ruleIdx int, backendNames ...string) BackendGroup { backends := make([]Backend, len(backendNames)) for i, name := range backendNames { @@ -2801,6 +2815,7 @@ func TestBuildBackendGroups(t *testing.T) { } func TestHostnameMoreSpecific(t *testing.T) { + t.Parallel() tests := []struct { host1 *v1.Hostname host2 *v1.Hostname @@ -2852,7 +2867,9 @@ func TestHostnameMoreSpecific(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(listenerHostnameMoreSpecific(tc.host1, tc.host2)).To(Equal(tc.host1Wins)) @@ -2861,6 +2878,7 @@ func TestHostnameMoreSpecific(t *testing.T) { } func TestConvertBackendTLS(t *testing.T) { + t.Parallel() btpCaCertRefs := &graph.BackendTLSPolicy{ Source: &v1alpha3.BackendTLSPolicy{ ObjectMeta: metav1.ObjectMeta{ @@ -2928,7 +2946,9 @@ func TestConvertBackendTLS(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(convertBackendTLS(tc.btp)).To(Equal(tc.expected)) @@ -2937,6 +2957,7 @@ func TestConvertBackendTLS(t *testing.T) { } func TestBuildTelemetry(t *testing.T) { + t.Parallel() telemetryConfigured := &graph.NginxProxy{ Source: &ngfAPI.NginxProxy{ Spec: ngfAPI.NginxProxySpec{ @@ -3158,7 +3179,9 @@ func TestBuildTelemetry(t *testing.T) { } for _, tc := range tests { + tc := tc t.Run(tc.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) tel := buildTelemetry(tc.g) sort.Slice(tel.Ratios, func(i, j int) bool { @@ -3170,6 +3193,7 @@ func TestBuildTelemetry(t *testing.T) { } func TestBuildPolicies(t *testing.T) { + t.Parallel() getPolicy := func(kind, name string) policies.Policy { return &policiesfakes.FakePolicy{ GetNameStub: func() string { @@ -3233,7 +3257,9 @@ func TestBuildPolicies(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) pols := buildPolicies(test.policies) diff --git a/internal/mode/static/state/dataplane/convert_test.go b/internal/mode/static/state/dataplane/convert_test.go index 1688c1591f..18c978efdb 100644 --- a/internal/mode/static/state/dataplane/convert_test.go +++ b/internal/mode/static/state/dataplane/convert_test.go @@ -10,6 +10,7 @@ import ( ) func TestConvertMatch(t *testing.T) { + t.Parallel() path := v1.HTTPPathMatch{ Type: helpers.GetPointer(v1.PathMatchPathPrefix), Value: helpers.GetPointer("/"), @@ -114,7 +115,9 @@ func TestConvertMatch(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := convertMatch(test.match) @@ -124,6 +127,7 @@ func TestConvertMatch(t *testing.T) { } func TestConvertHTTPRequestRedirectFilter(t *testing.T) { + t.Parallel() tests := []struct { filter *v1.HTTPRequestRedirectFilter expected *HTTPRequestRedirectFilter @@ -152,7 +156,9 @@ func TestConvertHTTPRequestRedirectFilter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := convertHTTPRequestRedirectFilter(test.filter) @@ -162,6 +168,7 @@ func TestConvertHTTPRequestRedirectFilter(t *testing.T) { } func TestConvertHTTPURLRewriteFilter(t *testing.T) { + t.Parallel() tests := []struct { filter *v1.HTTPURLRewriteFilter expected *HTTPURLRewriteFilter @@ -209,7 +216,9 @@ func TestConvertHTTPURLRewriteFilter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := convertHTTPURLRewriteFilter(test.filter) @@ -219,6 +228,7 @@ func TestConvertHTTPURLRewriteFilter(t *testing.T) { } func TestConvertHTTPHeaderFilter(t *testing.T) { + t.Parallel() tests := []struct { filter *v1.HTTPHeaderFilter expected *HTTPHeaderFilter @@ -257,7 +267,9 @@ func TestConvertHTTPHeaderFilter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := convertHTTPHeaderFilter(test.filter) @@ -267,6 +279,7 @@ func TestConvertHTTPHeaderFilter(t *testing.T) { } func TestConvertPathType(t *testing.T) { + t.Parallel() g := NewWithT(t) tests := []struct { diff --git a/internal/mode/static/state/dataplane/sort_test.go b/internal/mode/static/state/dataplane/sort_test.go index 9ab1ca5b4b..e500d05afe 100644 --- a/internal/mode/static/state/dataplane/sort_test.go +++ b/internal/mode/static/state/dataplane/sort_test.go @@ -12,6 +12,7 @@ import ( ) func TestSort(t *testing.T) { + t.Parallel() // timestamps earlier := metav1.Now() later := metav1.NewTime(earlier.Add(1 * time.Second)) diff --git a/internal/mode/static/state/graph/backend_refs_test.go b/internal/mode/static/state/graph/backend_refs_test.go index 9f32b552e6..4a2b057acc 100644 --- a/internal/mode/static/state/graph/backend_refs_test.go +++ b/internal/mode/static/state/graph/backend_refs_test.go @@ -37,6 +37,7 @@ func getModifiedRef(mod func(ref gatewayv1.BackendRef) gatewayv1.BackendRef) gat } func TestValidateRouteBackendRef(t *testing.T) { + t.Parallel() tests := []struct { expectedCondition conditions.Condition name string @@ -84,7 +85,9 @@ func TestValidateRouteBackendRef(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) alwaysTrueRefGrantResolver := func(_ toResource) bool { return true } @@ -97,6 +100,7 @@ func TestValidateRouteBackendRef(t *testing.T) { } func TestValidateBackendRef(t *testing.T) { + t.Parallel() alwaysFalseRefGrantResolver := func(_ toResource) bool { return false } alwaysTrueRefGrantResolver := func(_ toResource) bool { return true } @@ -203,7 +207,9 @@ func TestValidateBackendRef(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) valid, cond := validateBackendRef(test.ref, "test", test.refGrantResolver, field.NewPath("test")) @@ -215,6 +221,7 @@ func TestValidateBackendRef(t *testing.T) { } func TestValidateWeight(t *testing.T) { + t.Parallel() validWeights := []int32{0, 1, 1000000} invalidWeights := []int32{-1, 1000001} @@ -231,6 +238,7 @@ func TestValidateWeight(t *testing.T) { } func TestGetIPFamilyAndPortFromRef(t *testing.T) { + t.Parallel() svc1 := &v1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: "service1", @@ -300,7 +308,9 @@ func TestGetIPFamilyAndPortFromRef(t *testing.T) { refPath := field.NewPath("test") for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) svcIPFamily, servicePort, err := getIPFamilyAndPortFromRef(test.ref, test.svcNsName, services, refPath) @@ -389,6 +399,7 @@ func TestVerifyIPFamily(t *testing.T) { } func TestAddBackendRefsToRulesTest(t *testing.T) { + // t.Parallel() sectionNameRefs := []ParentRef{ { Idx: 0, @@ -731,7 +742,9 @@ func TestAddBackendRefsToRulesTest(t *testing.T) { } for _, test := range tests { + // test := test t.Run(test.name, func(t *testing.T) { + // t.Parallel() g := NewWithT(t) resolver := newReferenceGrantResolver(nil) addBackendRefsToRules(test.route, resolver, services, test.policies, nil) @@ -748,6 +761,7 @@ func TestAddBackendRefsToRulesTest(t *testing.T) { } func TestCreateBackend(t *testing.T) { + t.Parallel() createService := func(name string) *v1.Service { return &v1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -1006,7 +1020,9 @@ func TestCreateBackend(t *testing.T) { refPath := field.NewPath("test") for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) alwaysTrueRefGrantResolver := func(_ toResource) bool { return true } @@ -1035,6 +1051,7 @@ func TestCreateBackend(t *testing.T) { } func TestGetServicePort(t *testing.T) { + t.Parallel() svc := &v1.Service{ Spec: v1.ServiceSpec{ Ports: []v1.ServicePort{ @@ -1065,6 +1082,7 @@ func TestGetServicePort(t *testing.T) { } func TestValidateBackendTLSPolicyMatchingAllBackends(t *testing.T) { + t.Parallel() getBtp := func(name, caCertName string) *BackendTLSPolicy { return &BackendTLSPolicy{ Source: &v1alpha3.BackendTLSPolicy{ @@ -1155,7 +1173,9 @@ func TestValidateBackendTLSPolicyMatchingAllBackends(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) cond := validateBackendTLSPolicyMatchingAllBackends(test.backendRefs) @@ -1166,6 +1186,7 @@ func TestValidateBackendTLSPolicyMatchingAllBackends(t *testing.T) { } func TestFindBackendTLSPolicyForService(t *testing.T) { + t.Parallel() oldCreationTimestamp := metav1.Now() newCreationTimestamp := metav1.Now() getBtp := func(name string, timestamp metav1.Time) *BackendTLSPolicy { @@ -1230,7 +1251,9 @@ func TestFindBackendTLSPolicyForService(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) btp, err := findBackendTLSPolicyForService(test.backendTLSPolicies, ref.Namespace, string(ref.Name), "test") diff --git a/internal/mode/static/state/graph/backend_tls_policy_test.go b/internal/mode/static/state/graph/backend_tls_policy_test.go index b4ded8f21d..63749271b8 100644 --- a/internal/mode/static/state/graph/backend_tls_policy_test.go +++ b/internal/mode/static/state/graph/backend_tls_policy_test.go @@ -16,6 +16,7 @@ import ( ) func TestProcessBackendTLSPoliciesEmpty(t *testing.T) { + t.Parallel() backendTLSPolicies := map[types.NamespacedName]*v1alpha3.BackendTLSPolicy{ {Namespace: "test", Name: "tls-policy"}: { ObjectMeta: metav1.ObjectMeta{ @@ -70,7 +71,9 @@ func TestProcessBackendTLSPoliciesEmpty(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) processed := processBackendTLSPolicies(test.backendTLSPolicies, nil, "test", test.gateway) @@ -81,6 +84,7 @@ func TestProcessBackendTLSPoliciesEmpty(t *testing.T) { } func TestValidateBackendTLSPolicy(t *testing.T) { + // t.Parallel() targetRefNormalCase := []v1alpha2.LocalPolicyTargetReferenceWithSectionName{ { LocalPolicyTargetReference: v1alpha2.LocalPolicyTargetReference{ @@ -394,7 +398,9 @@ func TestValidateBackendTLSPolicy(t *testing.T) { configMapResolver := newConfigMapResolver(configMaps) for _, test := range tests { + // test := test t.Run(test.name, func(t *testing.T) { + // t.Parallel() g := NewWithT(t) valid, ignored, conds := validateBackendTLSPolicy(test.tlsPolicy, configMapResolver, "test") diff --git a/internal/mode/static/state/graph/configmaps_test.go b/internal/mode/static/state/graph/configmaps_test.go index 4e9430c510..8130bafdc5 100644 --- a/internal/mode/static/state/graph/configmaps_test.go +++ b/internal/mode/static/state/graph/configmaps_test.go @@ -88,6 +88,7 @@ UdxohGqleWFMQ3UNLOvc9Fk+q72ryg== ) func TestValidateCA(t *testing.T) { + t.Parallel() base64Data := make([]byte, base64.StdEncoding.EncodedLen(len(caBlock))) base64.StdEncoding.Encode(base64Data, []byte(caBlock)) @@ -119,7 +120,9 @@ func TestValidateCA(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := validateCA(test.data) @@ -133,6 +136,7 @@ func TestValidateCA(t *testing.T) { } func TestResolve(t *testing.T) { + // t.Parallel() configMaps := map[types.NamespacedName]*v1.ConfigMap{ {Namespace: "test", Name: "configmap1"}: { ObjectMeta: metav1.ObjectMeta{ @@ -207,7 +211,9 @@ func TestResolve(t *testing.T) { } for _, test := range tests { + // test := test t.Run(test.name, func(t *testing.T) { + // t.Parallel() g := NewWithT(t) err := configMapResolver.resolve(test.nsname) diff --git a/internal/mode/static/state/graph/gateway_listener_test.go b/internal/mode/static/state/graph/gateway_listener_test.go index 712ab867d4..8a5832ab5d 100644 --- a/internal/mode/static/state/graph/gateway_listener_test.go +++ b/internal/mode/static/state/graph/gateway_listener_test.go @@ -15,6 +15,7 @@ import ( ) func TestValidateHTTPListener(t *testing.T) { + t.Parallel() protectedPorts := ProtectedPorts{9113: "MetricsPort"} tests := []struct { @@ -59,7 +60,9 @@ func TestValidateHTTPListener(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) v := createHTTPListenerValidator(protectedPorts) @@ -73,6 +76,7 @@ func TestValidateHTTPListener(t *testing.T) { } func TestValidateHTTPSListener(t *testing.T) { + t.Parallel() secretNs := "secret-ns" validSecretRef := v1.SecretObjectReference{ @@ -226,7 +230,9 @@ func TestValidateHTTPSListener(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) v := createHTTPSListenerValidator(protectedPorts) @@ -239,6 +245,7 @@ func TestValidateHTTPSListener(t *testing.T) { } func TestValidateListenerHostname(t *testing.T) { + t.Parallel() tests := []struct { hostname *v1.Hostname name string @@ -272,7 +279,9 @@ func TestValidateListenerHostname(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) conds, attachable := validateListenerHostname(v1.Listener{Hostname: test.hostname}) @@ -289,6 +298,7 @@ func TestValidateListenerHostname(t *testing.T) { } func TestGetAndValidateListenerSupportedKinds(t *testing.T) { + t.Parallel() HTTPRouteGroupKind := v1.RouteGroupKind{ Kind: kinds.HTTPRoute, Group: helpers.GetPointer[v1.Group](v1.GroupName), @@ -416,7 +426,9 @@ func TestGetAndValidateListenerSupportedKinds(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) listener := v1.Listener{ @@ -441,6 +453,7 @@ func TestGetAndValidateListenerSupportedKinds(t *testing.T) { } func TestValidateListenerLabelSelector(t *testing.T) { + t.Parallel() tests := []struct { selector *metav1.LabelSelector from v1.FromNamespaces @@ -468,7 +481,9 @@ func TestValidateListenerLabelSelector(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) // create iteration variable inside the loop to fix implicit memory aliasing @@ -496,19 +511,24 @@ func TestValidateListenerLabelSelector(t *testing.T) { } func TestValidateListenerPort(t *testing.T) { + t.Parallel() validPorts := []v1.PortNumber{1, 80, 443, 1000, 50000, 65535} invalidPorts := []v1.PortNumber{-1, 0, 65536, 80000, 9113} protectedPorts := ProtectedPorts{9113: "MetricsPort"} for _, p := range validPorts { + p := p t.Run(fmt.Sprintf("valid port %d", p), func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(validateListenerPort(p, protectedPorts)).To(Succeed()) }) } for _, p := range invalidPorts { + p := p t.Run(fmt.Sprintf("invalid port %d", p), func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(validateListenerPort(p, protectedPorts)).ToNot(Succeed()) }) diff --git a/internal/mode/static/state/graph/gateway_test.go b/internal/mode/static/state/graph/gateway_test.go index 990568b0a1..5c2f09eddd 100644 --- a/internal/mode/static/state/graph/gateway_test.go +++ b/internal/mode/static/state/graph/gateway_test.go @@ -18,6 +18,7 @@ import ( ) func TestProcessedGatewaysGetAllNsNames(t *testing.T) { + t.Parallel() winner := &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", @@ -57,7 +58,9 @@ func TestProcessedGatewaysGetAllNsNames(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := test.gws.GetAllNsNames() g.Expect(result).To(Equal(test.expected)) @@ -66,6 +69,7 @@ func TestProcessedGatewaysGetAllNsNames(t *testing.T) { } func TestProcessGateways(t *testing.T) { + t.Parallel() const gcName = "test-gc" winner := &v1.Gateway{ @@ -132,7 +136,9 @@ func TestProcessGateways(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := processGateways(test.gws, gcName) g.Expect(helpers.Diff(test.expected, result)).To(BeEmpty()) @@ -141,6 +147,7 @@ func TestProcessGateways(t *testing.T) { } func TestBuildGateway(t *testing.T) { + // t.Parallel() const gcName = "my-gateway-class" labelSet := map[string]string{ @@ -1029,7 +1036,9 @@ func TestBuildGateway(t *testing.T) { }) for _, test := range tests { + // test := test t.Run(test.name, func(t *testing.T) { + // t.Parallel() g := NewWithT(t) resolver := newReferenceGrantResolver(test.refGrants) result := buildGateway(test.gateway, secretResolver, test.gatewayClass, resolver, protectedPorts) diff --git a/internal/mode/static/state/graph/gatewayclass_test.go b/internal/mode/static/state/graph/gatewayclass_test.go index 1b10997e4d..243f74de30 100644 --- a/internal/mode/static/state/graph/gatewayclass_test.go +++ b/internal/mode/static/state/graph/gatewayclass_test.go @@ -19,6 +19,7 @@ import ( ) func TestProcessGatewayClasses(t *testing.T) { + t.Parallel() gcName := "test-gc" ctlrName := "test-ctlr" winner := &v1.GatewayClass{ @@ -113,7 +114,9 @@ func TestProcessGatewayClasses(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result, exists := processGatewayClasses(test.gcs, gcName, ctlrName) g.Expect(helpers.Diff(test.expected, result)).To(BeEmpty()) @@ -123,6 +126,7 @@ func TestProcessGatewayClasses(t *testing.T) { } func TestBuildGatewayClass(t *testing.T) { + t.Parallel() validGC := &v1.GatewayClass{} gcWithParams := &v1.GatewayClass{ @@ -287,7 +291,9 @@ func TestBuildGatewayClass(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := buildGatewayClass(test.gc, test.np, test.crdMetadata) diff --git a/internal/mode/static/state/graph/graph_test.go b/internal/mode/static/state/graph/graph_test.go index 3312aea694..8eeed80c68 100644 --- a/internal/mode/static/state/graph/graph_test.go +++ b/internal/mode/static/state/graph/graph_test.go @@ -30,6 +30,7 @@ import ( ) func TestBuildGraph(t *testing.T) { + t.Parallel() const ( gcName = "my-class" controllerName = "my.controller" @@ -853,7 +854,9 @@ func TestBuildGraph(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) // The diffs get very large so the format max length will make sure the output doesn't get truncated. @@ -879,6 +882,7 @@ func TestBuildGraph(t *testing.T) { } func TestIsReferenced(t *testing.T) { + // t.Parallel() baseSecret := &v1.Secret{ ObjectMeta: metav1.ObjectMeta{ Namespace: testNs, @@ -1171,7 +1175,9 @@ func TestIsReferenced(t *testing.T) { }, } for _, test := range tests { + // test := test t.Run(test.name, func(t *testing.T) { + // t.Parallel() g := NewWithT(t) test.graph.GatewayClass = test.gc @@ -1182,6 +1188,7 @@ func TestIsReferenced(t *testing.T) { } func TestIsNGFPolicyRelevant(t *testing.T) { + t.Parallel() policyGVK := schema.GroupVersionKind{Kind: "MyKind"} existingPolicyNsName := types.NamespacedName{Namespace: "test", Name: "pol"} @@ -1323,7 +1330,9 @@ func TestIsNGFPolicyRelevant(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) relevant := test.graph.IsNGFPolicyRelevant(test.policy, policyGVK, test.nsname) @@ -1333,6 +1342,7 @@ func TestIsNGFPolicyRelevant(t *testing.T) { } func TestIsNGFPolicyRelevantPanics(t *testing.T) { + t.Parallel() g := NewWithT(t) graph := &Graph{} nsname := types.NamespacedName{Namespace: "test", Name: "pol"} diff --git a/internal/mode/static/state/graph/grpcroute_test.go b/internal/mode/static/state/graph/grpcroute_test.go index ed8e455853..09d7d79638 100644 --- a/internal/mode/static/state/graph/grpcroute_test.go +++ b/internal/mode/static/state/graph/grpcroute_test.go @@ -79,6 +79,7 @@ func createGRPCRoute( } func TestBuildGRPCRoutes(t *testing.T) { + t.Parallel() gwNsName := types.NamespacedName{Namespace: "test", Name: "gateway"} gr := createGRPCRoute("gr-1", gwNsName.Name, "example.com", []v1.GRPCRouteRule{}) @@ -136,7 +137,9 @@ func TestBuildGRPCRoutes(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) routes := buildRoutesForGateways( validator, @@ -151,6 +154,7 @@ func TestBuildGRPCRoutes(t *testing.T) { } func TestBuildGRPCRoute(t *testing.T) { + t.Parallel() gatewayNsName := types.NamespacedName{Namespace: "test", Name: "gateway"} methodMatchRule := createGRPCMethodMatch("myService", "myMethod", "Exact") @@ -684,7 +688,9 @@ func TestBuildGRPCRoute(t *testing.T) { gatewayNsNames := []types.NamespacedName{gatewayNsName} for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) route := buildGRPCRoute(test.validator, test.gr, gatewayNsNames, test.http2disabled) @@ -694,6 +700,7 @@ func TestBuildGRPCRoute(t *testing.T) { } func TestConvertGRPCMatches(t *testing.T) { + t.Parallel() methodMatch := createGRPCMethodMatch("myService", "myMethod", "Exact").Matches headersMatch := createGRPCHeadersMatch("Exact", "MyHeader", "SomeValue").Matches @@ -755,7 +762,9 @@ func TestConvertGRPCMatches(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) httpMatches := convertGRPCMatches(test.methodMatches) @@ -765,6 +774,7 @@ func TestConvertGRPCMatches(t *testing.T) { } func TestConvertGRPCFilters(t *testing.T) { + t.Parallel() grFilters := []v1.GRPCRouteFilter{ { Type: "RequestHeaderModifier", diff --git a/internal/mode/static/state/graph/httproute_test.go b/internal/mode/static/state/graph/httproute_test.go index 68d58a40d7..07eb7c484d 100644 --- a/internal/mode/static/state/graph/httproute_test.go +++ b/internal/mode/static/state/graph/httproute_test.go @@ -87,6 +87,7 @@ func addFilterToPath(hr *gatewayv1.HTTPRoute, path string, filter gatewayv1.HTTP } func TestBuildHTTPRoutes(t *testing.T) { + t.Parallel() gwNsName := types.NamespacedName{Namespace: "test", Name: "gateway"} hr := createHTTPRoute("hr-1", gwNsName.Name, "example.com", "/") @@ -143,7 +144,9 @@ func TestBuildHTTPRoutes(t *testing.T) { validator := &validationfakes.FakeHTTPFieldsValidator{} for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) routes := buildRoutesForGateways( validator, @@ -158,6 +161,7 @@ func TestBuildHTTPRoutes(t *testing.T) { } func TestBuildHTTPRoute(t *testing.T) { + t.Parallel() const ( invalidPath = "/invalid" invalidRedirectHostname = "invalid.example.com" @@ -579,7 +583,9 @@ func TestBuildHTTPRoute(t *testing.T) { gatewayNsNames := []types.NamespacedName{gatewayNsName} for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) route := buildHTTPRoute(test.validator, test.hr, gatewayNsNames) @@ -589,6 +595,7 @@ func TestBuildHTTPRoute(t *testing.T) { } func TestValidateMatch(t *testing.T) { + t.Parallel() createAllValidValidator := func() *validationfakes.FakeHTTPFieldsValidator { v := &validationfakes.FakeHTTPFieldsValidator{} v.ValidateMethodInMatchReturns(true, nil) @@ -843,7 +850,9 @@ func TestValidateMatch(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) allErrs := validateMatch(test.validator, test.match, field.NewPath("test")) g.Expect(allErrs).To(HaveLen(test.expectErrCount)) @@ -852,6 +861,7 @@ func TestValidateMatch(t *testing.T) { } func TestValidateFilter(t *testing.T) { + t.Parallel() tests := []struct { filter gatewayv1.HTTPRouteFilter name string @@ -901,7 +911,9 @@ func TestValidateFilter(t *testing.T) { filterPath := field.NewPath("test") for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) allErrs := validateFilter(&validationfakes.FakeHTTPFieldsValidator{}, test.filter, filterPath) g.Expect(allErrs).To(HaveLen(test.expectErrCount)) @@ -910,6 +922,7 @@ func TestValidateFilter(t *testing.T) { } func TestValidateFilterRedirect(t *testing.T) { + t.Parallel() createAllValidValidator := func() *validationfakes.FakeHTTPFieldsValidator { v := &validationfakes.FakeHTTPFieldsValidator{} @@ -1029,7 +1042,9 @@ func TestValidateFilterRedirect(t *testing.T) { filterPath := field.NewPath("test") for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) allErrs := validateFilterRedirect(test.validator, test.requestRedirect, filterPath) @@ -1039,6 +1054,7 @@ func TestValidateFilterRedirect(t *testing.T) { } func TestValidateFilterRewrite(t *testing.T) { + t.Parallel() tests := []struct { urlRewrite *gatewayv1.HTTPURLRewriteFilter validator *validationfakes.FakeHTTPFieldsValidator @@ -1147,7 +1163,9 @@ func TestValidateFilterRewrite(t *testing.T) { filterPath := field.NewPath("test") for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) allErrs := validateFilterRewrite(test.validator, test.urlRewrite, filterPath) g.Expect(allErrs).To(HaveLen(test.expectErrCount)) diff --git a/internal/mode/static/state/graph/namespace_test.go b/internal/mode/static/state/graph/namespace_test.go index 8781fc6f8c..1e97f62b7a 100644 --- a/internal/mode/static/state/graph/namespace_test.go +++ b/internal/mode/static/state/graph/namespace_test.go @@ -12,6 +12,7 @@ import ( ) func TestBuildReferencedNamespaces(t *testing.T) { + t.Parallel() ns1 := &v1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: "ns1", @@ -169,7 +170,9 @@ func TestBuildReferencedNamespaces(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(buildReferencedNamespaces(clusterNamespaces, test.gw)).To(Equal(test.expectedRefNS)) }) @@ -177,6 +180,7 @@ func TestBuildReferencedNamespaces(t *testing.T) { } func TestIsNamespaceReferenced(t *testing.T) { + t.Parallel() tests := []struct { ns *v1.Namespace gw *Gateway @@ -212,7 +216,9 @@ func TestIsNamespaceReferenced(t *testing.T) { // Other test cases should be covered by testing of BuildReferencedNamespaces for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(isNamespaceReferenced(test.ns, test.gw)).To(Equal(test.exp)) }) diff --git a/internal/mode/static/state/graph/nginxproxy_test.go b/internal/mode/static/state/graph/nginxproxy_test.go index efec06e865..68bac73b1f 100644 --- a/internal/mode/static/state/graph/nginxproxy_test.go +++ b/internal/mode/static/state/graph/nginxproxy_test.go @@ -16,6 +16,7 @@ import ( ) func TestGetNginxProxy(t *testing.T) { + t.Parallel() tests := []struct { nps map[types.NamespacedName]*ngfAPI.NginxProxy gc *v1.GatewayClass @@ -82,7 +83,9 @@ func TestGetNginxProxy(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(buildNginxProxy(test.nps, test.gc, &validationfakes.FakeGenericValidator{})).To(Equal(test.expNP)) @@ -91,6 +94,7 @@ func TestGetNginxProxy(t *testing.T) { } func TestIsNginxProxyReferenced(t *testing.T) { + t.Parallel() tests := []struct { gc *GatewayClass npName types.NamespacedName @@ -146,7 +150,9 @@ func TestIsNginxProxyReferenced(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(isNginxProxyReferenced(test.npName, test.gc)).To(Equal(test.expRes)) @@ -155,6 +161,7 @@ func TestIsNginxProxyReferenced(t *testing.T) { } func TestGCReferencesAnyNginxProxy(t *testing.T) { + t.Parallel() tests := []struct { gc *v1.GatewayClass name string @@ -214,7 +221,9 @@ func TestGCReferencesAnyNginxProxy(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(gcReferencesAnyNginxProxy(test.gc)).To(Equal(test.expRes)) @@ -223,6 +232,7 @@ func TestGCReferencesAnyNginxProxy(t *testing.T) { } func TestValidateNginxProxy(t *testing.T) { + t.Parallel() createValidValidator := func() *validationfakes.FakeGenericValidator { v := &validationfakes.FakeGenericValidator{} v.ValidateEscapedStringNoVarExpansionReturns(nil) @@ -345,7 +355,9 @@ func TestValidateNginxProxy(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) allErrs := validateNginxProxy(test.validator, test.np) diff --git a/internal/mode/static/state/graph/policies_test.go b/internal/mode/static/state/graph/policies_test.go index 59ea1dad8b..782f73efd7 100644 --- a/internal/mode/static/state/graph/policies_test.go +++ b/internal/mode/static/state/graph/policies_test.go @@ -23,6 +23,7 @@ import ( var testNs = "test" func TestAttachPolicies(t *testing.T) { + t.Parallel() policyGVK := schema.GroupVersionKind{Group: "Group", Version: "Version", Kind: "Policy"} gwPolicyKey := createTestPolicyKey(policyGVK, "gw-policy") @@ -219,7 +220,9 @@ func TestAttachPolicies(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) test.graph.attachPolicies("nginx-gateway") @@ -229,6 +232,7 @@ func TestAttachPolicies(t *testing.T) { } func TestAttachPolicyToRoute(t *testing.T) { + t.Parallel() routeNsName := types.NamespacedName{Namespace: testNs, Name: "hr-route"} createRoute := func(routeType RouteType, valid, attachable, parentRefs bool) *L7Route { @@ -360,7 +364,9 @@ func TestAttachPolicyToRoute(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) attachPolicyToRoute(test.policy, test.route, "nginx-gateway") @@ -377,6 +383,7 @@ func TestAttachPolicyToRoute(t *testing.T) { } func TestAttachPolicyToGateway(t *testing.T) { + t.Parallel() gatewayNsName := types.NamespacedName{Namespace: testNs, Name: "gateway"} gateway2NsName := types.NamespacedName{Namespace: testNs, Name: "gateway2"} ignoredGatewayNsName := types.NamespacedName{Namespace: testNs, Name: "ignored"} @@ -524,7 +531,9 @@ func TestAttachPolicyToGateway(t *testing.T) { ignoredGatewayNsName: nil, } + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) attachPolicyToGateway(test.policy, test.policy.TargetRefs[0], test.gw, ignoredGateways, "nginx-gateway") @@ -541,6 +550,7 @@ func TestAttachPolicyToGateway(t *testing.T) { } func TestProcessPolicies(t *testing.T) { + t.Parallel() policyGVK := schema.GroupVersionKind{Group: "Group", Version: "Version", Kind: "MyPolicy"} // These refs reference objects that belong to NGF. @@ -772,7 +782,9 @@ func TestProcessPolicies(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) processed := processPolicies(test.policies, test.validator, gateways, routes, nil) @@ -782,6 +794,7 @@ func TestProcessPolicies(t *testing.T) { } func TestProcessPolicies_RouteOverlap(t *testing.T) { + t.Parallel() hrRefCoffee := createTestRef(kinds.HTTPRoute, v1.GroupName, "hr-coffee") hrRefCoffeeTea := createTestRef(kinds.HTTPRoute, v1.GroupName, "hr-coffee-tea") @@ -910,7 +923,9 @@ func TestProcessPolicies_RouteOverlap(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) processed := processPolicies(test.policies, test.validator, gateways, test.routes, nil) @@ -925,6 +940,7 @@ func TestProcessPolicies_RouteOverlap(t *testing.T) { } func TestMarkConflictedPolicies(t *testing.T) { + t.Parallel() hrRef := createTestRef(kinds.HTTPRoute, v1.GroupName, "hr") hrTargetRef := PolicyTargetRef{ Kind: hrRef.Kind, @@ -1052,7 +1068,9 @@ func TestMarkConflictedPolicies(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) markConflictedPolicies(test.policies, test.fakeValidator) diff --git a/internal/mode/static/state/graph/policy_ancestor_test.go b/internal/mode/static/state/graph/policy_ancestor_test.go index 7b90a3b3a6..19b3904bb0 100644 --- a/internal/mode/static/state/graph/policy_ancestor_test.go +++ b/internal/mode/static/state/graph/policy_ancestor_test.go @@ -11,6 +11,7 @@ import ( ) func TestBackendTLSPolicyAncestorsFull(t *testing.T) { + t.Parallel() createCurStatus := func(numAncestors int, ctlrName string) []v1alpha2.PolicyAncestorStatus { statuses := make([]v1alpha2.PolicyAncestorStatus, 0, numAncestors) @@ -46,7 +47,9 @@ func TestBackendTLSPolicyAncestorsFull(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) full := backendTLSPolicyAncestorsFull(test.curStatus, "nginx-gateway") @@ -56,6 +59,7 @@ func TestBackendTLSPolicyAncestorsFull(t *testing.T) { } func TestNGFPolicyAncestorsFull(t *testing.T) { + t.Parallel() type ancestorConfig struct { numCurrNGFAncestors int numCurrNonNGFAncestors int @@ -156,7 +160,9 @@ func TestNGFPolicyAncestorsFull(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) policy := createPolicy(test.cfg) diff --git a/internal/mode/static/state/graph/reference_grant_test.go b/internal/mode/static/state/graph/reference_grant_test.go index 4551499891..339cf1e4ed 100644 --- a/internal/mode/static/state/graph/reference_grant_test.go +++ b/internal/mode/static/state/graph/reference_grant_test.go @@ -12,6 +12,7 @@ import ( ) func TestReferenceGrantResolver(t *testing.T) { + t.Parallel() gwNs := "gw-ns" secretNsName := types.NamespacedName{Namespace: "test", Name: "certificate"} @@ -160,7 +161,9 @@ func TestReferenceGrantResolver(t *testing.T) { resolver := newReferenceGrantResolver(refGrants) for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(resolver.refAllowed(test.to, test.from)).To(Equal(test.allowed)) @@ -169,6 +172,7 @@ func TestReferenceGrantResolver(t *testing.T) { } func TestToSecret(t *testing.T) { + t.Parallel() ref := toSecret(types.NamespacedName{Namespace: "ns", Name: "secret"}) exp := toResource{ @@ -182,6 +186,7 @@ func TestToSecret(t *testing.T) { } func TestToService(t *testing.T) { + t.Parallel() ref := toService(types.NamespacedName{Namespace: "ns", Name: "service"}) exp := toResource{ @@ -195,6 +200,7 @@ func TestToService(t *testing.T) { } func TestFromGateway(t *testing.T) { + t.Parallel() ref := fromGateway("ns") exp := fromResource{ @@ -208,6 +214,7 @@ func TestFromGateway(t *testing.T) { } func TestFromHTTPRoute(t *testing.T) { + t.Parallel() ref := fromHTTPRoute("ns") exp := fromResource{ diff --git a/internal/mode/static/state/graph/route_common_test.go b/internal/mode/static/state/graph/route_common_test.go index 4d4dee7dc0..26063836dc 100644 --- a/internal/mode/static/state/graph/route_common_test.go +++ b/internal/mode/static/state/graph/route_common_test.go @@ -22,6 +22,7 @@ import ( ) func TestBuildSectionNameRefs(t *testing.T) { + t.Parallel() const routeNamespace = "test" gwNsName1 := types.NamespacedName{Namespace: routeNamespace, Name: "gateway-1"} @@ -122,7 +123,9 @@ func TestBuildSectionNameRefs(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result, err := buildSectionNameRefs(test.parentRefs, routeNamespace, gwNsNames) @@ -137,6 +140,7 @@ func TestBuildSectionNameRefs(t *testing.T) { } func TestFindGatewayForParentRef(t *testing.T) { + t.Parallel() gwNsName1 := types.NamespacedName{Namespace: "test-1", Name: "gateway-1"} gwNsName2 := types.NamespacedName{Namespace: "test-2", Name: "gateway-2"} @@ -211,7 +215,9 @@ func TestFindGatewayForParentRef(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) gw, found := findGatewayForParentRef(test.ref, routeNamespace, gwNsNames) @@ -222,6 +228,7 @@ func TestFindGatewayForParentRef(t *testing.T) { } func TestBindRouteToListeners(t *testing.T) { + // t.Parallel() // we create a new listener each time because the function under test can modify it createListener := func(name string) *Listener { return &Listener{ @@ -1218,7 +1225,9 @@ func TestBindRouteToListeners(t *testing.T) { }, } for _, test := range tests { + // test := test t.Run(test.name, func(t *testing.T) { + // t.Parallel() g := NewWithT(t) bindL7RouteToListeners( @@ -1235,6 +1244,7 @@ func TestBindRouteToListeners(t *testing.T) { } func TestFindAcceptedHostnames(t *testing.T) { + t.Parallel() var listenerHostnameFoo gatewayv1.Hostname = "foo.example.com" var listenerHostnameCafe gatewayv1.Hostname = "cafe.example.com" var listenerHostnameWildcard gatewayv1.Hostname = "*.example.com" @@ -1309,7 +1319,9 @@ func TestFindAcceptedHostnames(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := findAcceptedHostnames(test.listenerHostname, test.routeHostnames) g.Expect(result).To(Equal(test.expected)) @@ -1318,6 +1330,7 @@ func TestFindAcceptedHostnames(t *testing.T) { } func TestGetHostname(t *testing.T) { + t.Parallel() var emptyHostname gatewayv1.Hostname var hostname gatewayv1.Hostname = "example.com" @@ -1344,7 +1357,9 @@ func TestGetHostname(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.msg, func(t *testing.T) { + t.Parallel() g := NewWithT(t) result := getHostname(test.h) g.Expect(result).To(Equal(test.expected)) @@ -1353,6 +1368,7 @@ func TestGetHostname(t *testing.T) { } func TestValidateHostnames(t *testing.T) { + t.Parallel() const validHostname = "example.com" tests := []struct { @@ -1382,7 +1398,9 @@ func TestValidateHostnames(t *testing.T) { path := field.NewPath("test") for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := validateHostnames(test.hostnames, path) @@ -1397,6 +1415,7 @@ func TestValidateHostnames(t *testing.T) { } func TestValidateFilterRequestHeaderModifier(t *testing.T) { + t.Parallel() createAllValidValidator := func() *validationfakes.FakeHTTPFieldsValidator { v := &validationfakes.FakeHTTPFieldsValidator{} return v @@ -1530,7 +1549,9 @@ func TestValidateFilterRequestHeaderModifier(t *testing.T) { filterPath := field.NewPath("test") for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) allErrs := validateFilterHeaderModifier( test.validator, test.filter.RequestHeaderModifier, filterPath, @@ -1541,6 +1562,7 @@ func TestValidateFilterRequestHeaderModifier(t *testing.T) { } func TestValidateFilterResponseHeaderModifier(t *testing.T) { + t.Parallel() createAllValidValidator := func() *validationfakes.FakeHTTPFieldsValidator { v := &validationfakes.FakeHTTPFieldsValidator{} return v @@ -1708,7 +1730,9 @@ func TestValidateFilterResponseHeaderModifier(t *testing.T) { filterPath := field.NewPath("test") for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) allErrs := validateFilterResponseHeaderModifier( test.validator, test.filter.ResponseHeaderModifier, filterPath, @@ -1719,6 +1743,7 @@ func TestValidateFilterResponseHeaderModifier(t *testing.T) { } func TestRouteKeyForKind(t *testing.T) { + t.Parallel() nsname := types.NamespacedName{Namespace: testNs, Name: "route"} g := NewWithT(t) diff --git a/internal/mode/static/state/graph/secret_test.go b/internal/mode/static/state/graph/secret_test.go index 54ebc3ca8a..79e9cf2578 100644 --- a/internal/mode/static/state/graph/secret_test.go +++ b/internal/mode/static/state/graph/secret_test.go @@ -67,6 +67,7 @@ cpLlHMAqbLJ8WYGJCkhiWxyal6hYTyWY4cVkC0xtTl/hUE9IeNKo ) func TestSecretResolver(t *testing.T) { + // t.Parallel() var ( validSecret1 = &apiv1.Secret{ ObjectMeta: metav1.ObjectMeta{ diff --git a/internal/mode/static/state/graph/service_test.go b/internal/mode/static/state/graph/service_test.go index 3f233c84fd..ba1490f820 100644 --- a/internal/mode/static/state/graph/service_test.go +++ b/internal/mode/static/state/graph/service_test.go @@ -8,6 +8,7 @@ import ( ) func TestBuildReferencedServices(t *testing.T) { + t.Parallel() getNormalL7Route := func() *L7Route { return &L7Route{ ParentRefs: []ParentRef{ @@ -314,7 +315,9 @@ func TestBuildReferencedServices(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) g.Expect(buildReferencedServices(test.l7Routes, test.l4Routes)).To(Equal(test.exp)) }) diff --git a/internal/mode/static/state/graph/validation_test.go b/internal/mode/static/state/graph/validation_test.go index d364adcf8f..5df1ad1cea 100644 --- a/internal/mode/static/state/graph/validation_test.go +++ b/internal/mode/static/state/graph/validation_test.go @@ -7,6 +7,7 @@ import ( ) func TestValidateHostname(t *testing.T) { + t.Parallel() tests := []struct { name string hostname string @@ -40,7 +41,9 @@ func TestValidateHostname(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) err := validateHostname(test.hostname) diff --git a/internal/mode/static/state/resolver/resolver_test.go b/internal/mode/static/state/resolver/resolver_test.go index adb87bb1ac..4aa015b378 100644 --- a/internal/mode/static/state/resolver/resolver_test.go +++ b/internal/mode/static/state/resolver/resolver_test.go @@ -104,6 +104,7 @@ var ( ) func TestFilterEndpointSliceList(t *testing.T) { + t.Parallel() test := []struct { msg string sliceList discoveryV1.EndpointSliceList @@ -169,6 +170,7 @@ func TestFilterEndpointSliceList(t *testing.T) { } func TestGetDefaultPort(t *testing.T) { + t.Parallel() testcases := []struct { msg string svcPort v1.ServicePort @@ -206,6 +208,7 @@ func TestGetDefaultPort(t *testing.T) { } func TestIgnoreEndpointSlice(t *testing.T) { + t.Parallel() var ( port4000 int32 = 4000 port8080 int32 = 8080 @@ -314,6 +317,7 @@ func TestIgnoreEndpointSlice(t *testing.T) { } func TestEndpointReady(t *testing.T) { + t.Parallel() testcases := []struct { endpoint discoveryV1.Endpoint msg string @@ -354,6 +358,7 @@ func TestEndpointReady(t *testing.T) { } func TestFindPort(t *testing.T) { + t.Parallel() testcases := []struct { msg string ports []discoveryV1.EndpointPort @@ -486,6 +491,7 @@ func TestFindPort(t *testing.T) { } func TestCalculateReadyEndpoints(t *testing.T) { + t.Parallel() g := NewWithT(t) slices := []discoveryV1.EndpointSlice{ diff --git a/internal/mode/static/state/resolver/service_resolver_suite_test.go b/internal/mode/static/state/resolver/service_resolver_suite_test.go index ba1f845a4b..618aef434e 100644 --- a/internal/mode/static/state/resolver/service_resolver_suite_test.go +++ b/internal/mode/static/state/resolver/service_resolver_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestServiceResolver(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "ServiceResolver Suite") } diff --git a/internal/mode/static/state/state_suite_test.go b/internal/mode/static/state/state_suite_test.go index 4431b60a8e..058b439dae 100644 --- a/internal/mode/static/state/state_suite_test.go +++ b/internal/mode/static/state/state_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestState(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "State Suite") } diff --git a/internal/mode/static/state/store_test.go b/internal/mode/static/state/store_test.go index b4184d3154..13113e97aa 100644 --- a/internal/mode/static/state/store_test.go +++ b/internal/mode/static/state/store_test.go @@ -10,6 +10,7 @@ import ( ) func TestSetChangeType(t *testing.T) { + // t.Parallel() ctu := newChangeTrackingUpdater(nil, nil) // Order matters for these cases. @@ -44,7 +45,9 @@ func TestSetChangeType(t *testing.T) { } for _, test := range tests { + // test := test t.Run(test.name, func(t *testing.T) { + // t.Parallel() g := NewWithT(t) ctu.setChangeType(test.obj, test.changed) g.Expect(ctu.changeType).To(Equal(test.exp)) diff --git a/internal/mode/static/static_suite_test.go b/internal/mode/static/static_suite_test.go index 95fafaeec7..0d47b11d5b 100644 --- a/internal/mode/static/static_suite_test.go +++ b/internal/mode/static/static_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestStatic(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "Static Suite") } diff --git a/internal/mode/static/status/prepare_requests_test.go b/internal/mode/static/status/prepare_requests_test.go index 3e98e777c1..aa6b6f3eca 100644 --- a/internal/mode/static/status/prepare_requests_test.go +++ b/internal/mode/static/status/prepare_requests_test.go @@ -212,6 +212,7 @@ var ( ) func TestBuildHTTPRouteStatuses(t *testing.T) { + t.Parallel() hrValid := &v1.HTTPRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", @@ -291,6 +292,7 @@ func TestBuildHTTPRouteStatuses(t *testing.T) { } func TestBuildGRPCRouteStatuses(t *testing.T) { + t.Parallel() grValid := &v1.GRPCRoute{ ObjectMeta: metav1.ObjectMeta{ Namespace: "test", @@ -445,6 +447,7 @@ func TestBuildTLSRouteStatuses(t *testing.T) { } func TestBuildRouteStatusesNginxErr(t *testing.T) { + t.Parallel() const gatewayCtlrName = "controller" hr1 := &v1.HTTPRoute{ @@ -546,6 +549,7 @@ func TestBuildRouteStatusesNginxErr(t *testing.T) { } func TestBuildGatewayClassStatuses(t *testing.T) { + t.Parallel() transitionTime := helpers.PrepareTimeForFakeClient(metav1.Now()) tests := []struct { @@ -637,7 +641,9 @@ func TestBuildGatewayClassStatuses(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) k8sClient := createK8sClientFor(&v1.GatewayClass{}) @@ -676,6 +682,7 @@ func TestBuildGatewayClassStatuses(t *testing.T) { } func TestBuildGatewayStatuses(t *testing.T) { + t.Parallel() createGateway := func() *v1.Gateway { return &v1.Gateway{ ObjectMeta: metav1.ObjectMeta{ @@ -1130,7 +1137,9 @@ func TestBuildGatewayStatuses(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) k8sClient := createK8sClientFor(&v1.Gateway{}) @@ -1176,6 +1185,7 @@ func TestBuildGatewayStatuses(t *testing.T) { } func TestBuildBackendTLSPolicyStatuses(t *testing.T) { + t.Parallel() const gatewayCtlrName = "controller" transitionTime := helpers.PrepareTimeForFakeClient(metav1.Now()) @@ -1356,7 +1366,9 @@ func TestBuildBackendTLSPolicyStatuses(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) k8sClient := createK8sClientFor(&v1alpha3.BackendTLSPolicy{}) @@ -1386,6 +1398,7 @@ func TestBuildBackendTLSPolicyStatuses(t *testing.T) { } func TestBuildNginxGatewayStatus(t *testing.T) { + t.Parallel() transitionTime := helpers.PrepareTimeForFakeClient(metav1.Now()) tests := []struct { @@ -1448,7 +1461,9 @@ func TestBuildNginxGatewayStatus(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) k8sClient := createK8sClientFor(&ngfAPI.NginxGateway{}) @@ -1479,6 +1494,7 @@ func TestBuildNginxGatewayStatus(t *testing.T) { } func TestBuildNGFPolicyStatuses(t *testing.T) { + t.Parallel() const gatewayCtlrName = "controller" transitionTime := helpers.PrepareTimeForFakeClient(metav1.Now()) @@ -1740,7 +1756,9 @@ func TestBuildNGFPolicyStatuses(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) k8sClient := createK8sClientFor(&ngfAPI.ClientSettingsPolicy{}) diff --git a/internal/mode/static/status/status_setters_test.go b/internal/mode/static/status/status_setters_test.go index d91c610ff7..55ece8870b 100644 --- a/internal/mode/static/status/status_setters_test.go +++ b/internal/mode/static/status/status_setters_test.go @@ -16,6 +16,7 @@ import ( ) func TestNewNginxGatewayStatusSetter(t *testing.T) { + t.Parallel() tests := []struct { name string status, newStatus ngfAPI.NginxGatewayStatus @@ -52,7 +53,9 @@ func TestNewNginxGatewayStatusSetter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) setter := newNginxGatewayStatusSetter(test.newStatus) @@ -67,6 +70,7 @@ func TestNewNginxGatewayStatusSetter(t *testing.T) { } func TestNewGatewayStatusSetter(t *testing.T) { + t.Parallel() expAddress := gatewayv1.GatewayStatusAddress{ Type: helpers.GetPointer(gatewayv1.IPAddressType), Value: "10.0.0.0", @@ -113,7 +117,9 @@ func TestNewGatewayStatusSetter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) setter := newGatewayStatusSetter(test.newStatus) @@ -128,6 +134,7 @@ func TestNewGatewayStatusSetter(t *testing.T) { } func TestNewHTTPRouteStatusSetter(t *testing.T) { + t.Parallel() const ( controllerName = "controller" otherControllerName = "different" @@ -288,7 +295,9 @@ func TestNewHTTPRouteStatusSetter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) setter := newHTTPRouteStatusSetter(test.newStatus, controllerName) @@ -303,6 +312,7 @@ func TestNewHTTPRouteStatusSetter(t *testing.T) { } func TestNewGRPCRouteStatusSetter(t *testing.T) { + t.Parallel() const ( controllerName = "controller" otherControllerName = "different" @@ -463,7 +473,9 @@ func TestNewGRPCRouteStatusSetter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) setter := newGRPCRouteStatusSetter(test.newStatus, controllerName) @@ -653,6 +665,7 @@ func TestNewTLSRouteStatusSetter(t *testing.T) { } func TestNewGatewayClassStatusSetter(t *testing.T) { + t.Parallel() tests := []struct { name string status, newStatus gatewayv1.GatewayClassStatus @@ -688,7 +701,9 @@ func TestNewGatewayClassStatusSetter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) setter := newGatewayClassStatusSetter(test.newStatus) @@ -703,6 +718,7 @@ func TestNewGatewayClassStatusSetter(t *testing.T) { } func TestNewBackendTLSPolicyStatusSetter(t *testing.T) { + t.Parallel() const ( controllerName = "controller" otherControllerName = "other-controller" @@ -828,7 +844,9 @@ func TestNewBackendTLSPolicyStatusSetter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) setter := newBackendTLSPolicyStatusSetter(test.newStatus, controllerName) @@ -843,6 +861,7 @@ func TestNewBackendTLSPolicyStatusSetter(t *testing.T) { } func TestNewNGFPolicyStatusSetter(t *testing.T) { + t.Parallel() const ( controllerName = "controller" otherControllerName = "other-controller" @@ -968,7 +987,9 @@ func TestNewNGFPolicyStatusSetter(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) setter := newNGFPolicyStatusSetter(test.newStatus, controllerName) @@ -990,6 +1011,7 @@ func TestNewNGFPolicyStatusSetter(t *testing.T) { } func TestGWStatusEqual(t *testing.T) { + t.Parallel() getDefaultStatus := func() gatewayv1.GatewayStatus { return gatewayv1.GatewayStatus{ Addresses: []gatewayv1.GatewayStatusAddress{ @@ -1179,7 +1201,9 @@ func TestGWStatusEqual(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) equal := gwStatusEqual(test.prevStatus, test.curStatus) @@ -1189,6 +1213,7 @@ func TestGWStatusEqual(t *testing.T) { } func TestHRStatusEqual(t *testing.T) { + t.Parallel() testConds := []metav1.Condition{ { Type: "type", /* conditions are covered by another test*/ @@ -1316,7 +1341,9 @@ func TestHRStatusEqual(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) equal := routeStatusEqual("ours", test.prevStatus.Parents, test.curStatus.Parents) g.Expect(equal).To(Equal(test.expEqual)) @@ -1325,6 +1352,7 @@ func TestHRStatusEqual(t *testing.T) { } func TestRouteParentStatusEqual(t *testing.T) { + t.Parallel() getDefaultStatus := func() gatewayv1.RouteParentStatus { return gatewayv1.RouteParentStatus{ ParentRef: gatewayv1.ParentReference{ @@ -1407,7 +1435,9 @@ func TestRouteParentStatusEqual(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) equal := routeParentStatusEqual(test.p1, test.p2) g.Expect(equal).To(Equal(test.expEqual)) @@ -1416,6 +1446,7 @@ func TestRouteParentStatusEqual(t *testing.T) { } func TestPolicyStatusEqual(t *testing.T) { + t.Parallel() getPolicyStatus := func() v1alpha2.PolicyStatus { return v1alpha2.PolicyStatus{ Ancestors: []v1alpha2.PolicyAncestorStatus{ @@ -1556,7 +1587,9 @@ func TestPolicyStatusEqual(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) equal := policyStatusEqual(test.controllerName, test.previous, test.current) g.Expect(equal).To(Equal(test.expEqual)) diff --git a/internal/mode/static/telemetry/data_test.go b/internal/mode/static/telemetry/data_test.go index cb4b09df86..a476f132f8 100644 --- a/internal/mode/static/telemetry/data_test.go +++ b/internal/mode/static/telemetry/data_test.go @@ -9,6 +9,7 @@ import ( ) func TestDataAttributes(t *testing.T) { + t.Parallel() data := Data{ ImageSource: "local", Data: tel.Data{ @@ -75,6 +76,7 @@ func TestDataAttributes(t *testing.T) { } func TestDataAttributesWithEmptyData(t *testing.T) { + t.Parallel() data := Data{} expected := []attribute.KeyValue{ diff --git a/internal/mode/static/telemetry/exporter_test.go b/internal/mode/static/telemetry/exporter_test.go index 6a86a01685..d44a7d2e24 100644 --- a/internal/mode/static/telemetry/exporter_test.go +++ b/internal/mode/static/telemetry/exporter_test.go @@ -10,6 +10,7 @@ import ( ) func TestLoggingExporter(t *testing.T) { + t.Parallel() g := NewWithT(t) var buffer bytes.Buffer diff --git a/internal/mode/static/telemetry/job_worker_test.go b/internal/mode/static/telemetry/job_worker_test.go index 88cc7fbc4c..1425fc3970 100644 --- a/internal/mode/static/telemetry/job_worker_test.go +++ b/internal/mode/static/telemetry/job_worker_test.go @@ -15,6 +15,7 @@ import ( ) func TestCreateTelemetryJobWorker_Succeeds(t *testing.T) { + t.Parallel() g := NewWithT(t) exporter := &telemetryfakes.FakeExporter{} @@ -39,6 +40,7 @@ func TestCreateTelemetryJobWorker_Succeeds(t *testing.T) { } func TestCreateTelemetryJobWorker_CollectFails(t *testing.T) { + t.Parallel() g := NewWithT(t) exporter := &telemetryfakes.FakeExporter{} diff --git a/internal/mode/static/telemetry/platform_test.go b/internal/mode/static/telemetry/platform_test.go index 0c2939d820..0f345f9f70 100644 --- a/internal/mode/static/telemetry/platform_test.go +++ b/internal/mode/static/telemetry/platform_test.go @@ -9,6 +9,7 @@ import ( ) func TestGetPlatform(t *testing.T) { + t.Parallel() tests := []struct { node *v1.Node namespaces *v1.NamespaceList @@ -127,7 +128,9 @@ func TestGetPlatform(t *testing.T) { }, } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) platform := getPlatform(*test.node, *test.namespaces) diff --git a/internal/mode/static/telemetry/telemetry_suite_test.go b/internal/mode/static/telemetry/telemetry_suite_test.go index 2eae64e153..2f5a50adb4 100644 --- a/internal/mode/static/telemetry/telemetry_suite_test.go +++ b/internal/mode/static/telemetry/telemetry_suite_test.go @@ -8,6 +8,7 @@ import ( ) func TestTelemetry(t *testing.T) { + t.Parallel() RegisterFailHandler(Fail) RunSpecs(t, "Telemetry Suite") } diff --git a/internal/mode/static/usage/job_worker_test.go b/internal/mode/static/usage/job_worker_test.go index c94bf15698..4aa7591f4a 100644 --- a/internal/mode/static/usage/job_worker_test.go +++ b/internal/mode/static/usage/job_worker_test.go @@ -22,6 +22,7 @@ import ( ) func TestCreateUsageJobWorker(t *testing.T) { + t.Parallel() replicas := int32(1) ngfReplicaSet := &appsv1.ReplicaSet{ ObjectMeta: metav1.ObjectMeta{ @@ -138,7 +139,9 @@ func TestCreateUsageJobWorker(t *testing.T) { } for _, test := range tests { + test := test t.Run(test.name, func(t *testing.T) { + t.Parallel() g := NewWithT(t) k8sClientReader := &eventsfakes.FakeReader{} @@ -178,6 +181,7 @@ func TestCreateUsageJobWorker(t *testing.T) { } func TestGetTotalNGFPodCount(t *testing.T) { + t.Parallel() g := NewWithT(t) rs1Replicas := int32(1) @@ -241,6 +245,7 @@ func TestGetTotalNGFPodCount(t *testing.T) { } func TestCollectNodeCount(t *testing.T) { + t.Parallel() g := NewWithT(t) node1 := &v1.Node{ diff --git a/internal/mode/static/usage/reporter_test.go b/internal/mode/static/usage/reporter_test.go index b57a5b3613..60db79f313 100644 --- a/internal/mode/static/usage/reporter_test.go +++ b/internal/mode/static/usage/reporter_test.go @@ -13,6 +13,7 @@ import ( ) func TestReport(t *testing.T) { + t.Parallel() g := NewWithT(t) data := ClusterDetails{ @@ -68,6 +69,7 @@ func TestReport(t *testing.T) { } func TestReport_NoCredentials(t *testing.T) { + t.Parallel() g := NewWithT(t) insecureSkipVerify := false reporter, err := NewNIMReporter(NewUsageSecret(), "", insecureSkipVerify) @@ -79,6 +81,7 @@ func TestReport_NoCredentials(t *testing.T) { } func TestReport_ServerError(t *testing.T) { + t.Parallel() g := NewWithT(t) server := httptest.NewServer( diff --git a/internal/mode/static/usage/secret_test.go b/internal/mode/static/usage/secret_test.go index 0320c72c16..82a5abd886 100644 --- a/internal/mode/static/usage/secret_test.go +++ b/internal/mode/static/usage/secret_test.go @@ -9,6 +9,7 @@ import ( ) func TestSet(t *testing.T) { + t.Parallel() store := NewUsageSecret() secret := &v1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -25,6 +26,7 @@ func TestSet(t *testing.T) { } func TestDelete(t *testing.T) { + t.Parallel() store := NewUsageSecret() secret := &v1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -42,6 +44,7 @@ func TestDelete(t *testing.T) { } func TestGetCredentials(t *testing.T) { + t.Parallel() store := NewUsageSecret() secret := &v1.Secret{ ObjectMeta: metav1.ObjectMeta{ diff --git a/tests/suite/system_suite_test.go b/tests/suite/system_suite_test.go index f0f3aa6993..8aac4dda1a 100644 --- a/tests/suite/system_suite_test.go +++ b/tests/suite/system_suite_test.go @@ -36,6 +36,7 @@ import ( ) func TestNGF(t *testing.T) { + t.Parallel() flag.Parse() if *gatewayAPIVersion == "" { panic("Gateway API version must be set")