Skip to content

Commit

Permalink
Run tests in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome committed Sep 26, 2024
1 parent 365bd3f commit e9bbbc8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ linters:
- nilnil
- noctx
- nolintlint
- paralleltest
- predeclared
- promlinter
- reassign
Expand Down
2 changes: 2 additions & 0 deletions internal/mode/static/state/graph/backend_refs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ func TestVerifyIPFamily(t *testing.T) {
}

func TestAddBackendRefsToRulesTest(t *testing.T) {
t.Parallel()
sectionNameRefs := []ParentRef{
{
Idx: 0,
Expand Down Expand Up @@ -741,6 +742,7 @@ func TestAddBackendRefsToRulesTest(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
g := NewWithT(t)
resolver := newReferenceGrantResolver(nil)
addBackendRefsToRules(test.route, resolver, services, test.policies, nil)
Expand Down
2 changes: 2 additions & 0 deletions internal/mode/static/state/graph/backend_tls_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func TestProcessBackendTLSPoliciesEmpty(t *testing.T) {
}

func TestValidateBackendTLSPolicy(t *testing.T) {
t.Parallel()
targetRefNormalCase := []v1alpha2.LocalPolicyTargetReferenceWithSectionName{
{
LocalPolicyTargetReference: v1alpha2.LocalPolicyTargetReference{
Expand Down Expand Up @@ -408,6 +409,7 @@ func TestValidateBackendTLSPolicy(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
g := NewWithT(t)

valid, ignored, conds := validateBackendTLSPolicy(test.tlsPolicy, configMapResolver, "test")
Expand Down
2 changes: 2 additions & 0 deletions internal/mode/static/state/graph/configmaps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,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{
Expand Down Expand Up @@ -210,6 +211,7 @@ func TestResolve(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
g := NewWithT(t)

err := configMapResolver.resolve(test.nsname)
Expand Down
2 changes: 2 additions & 0 deletions internal/mode/static/state/graph/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func TestProcessGateways(t *testing.T) {
}

func TestBuildGateway(t *testing.T) {
t.Parallel()
const gcName = "my-gateway-class"

labelSet := map[string]string{
Expand Down Expand Up @@ -1034,6 +1035,7 @@ func TestBuildGateway(t *testing.T) {

for _, test := range tests {
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)
Expand Down
4 changes: 4 additions & 0 deletions internal/mode/static/state/graph/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
)

func TestBuildGraph(t *testing.T) {
t.Parallel()
const (
gcName = "my-class"
controllerName = "my.controller"
Expand Down Expand Up @@ -854,6 +855,7 @@ func TestBuildGraph(t *testing.T) {

for _, test := range tests {
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.
Expand All @@ -879,6 +881,7 @@ func TestBuildGraph(t *testing.T) {
}

func TestIsReferenced(t *testing.T) {
t.Parallel()
baseSecret := &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Namespace: testNs,
Expand Down Expand Up @@ -1172,6 +1175,7 @@ func TestIsReferenced(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
g := NewWithT(t)

test.graph.GatewayClass = test.gc
Expand Down
2 changes: 2 additions & 0 deletions internal/mode/static/state/graph/route_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,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{
Expand Down Expand Up @@ -1223,6 +1224,7 @@ func TestBindRouteToListeners(t *testing.T) {
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
g := NewWithT(t)

bindL7RouteToListeners(
Expand Down

0 comments on commit e9bbbc8

Please sign in to comment.