Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests in internal/framework in parallel (2) #2367

Merged
merged 6 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/framework/controller/controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestControllers(t *testing.T) {
t.Parallel()
RegisterFailHandler(Fail)
RunSpecs(t, "Controller Suite")
}
3 changes: 3 additions & 0 deletions internal/framework/controller/filter/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestCreateSingleResourceFilter(t *testing.T) {
t.Parallel()
targetNsName := types.NamespacedName{Namespace: "test", Name: "resource"}

g := NewWithT(t)
Expand Down Expand Up @@ -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))
Expand Down
13 changes: 10 additions & 3 deletions internal/framework/controller/index/endpointslice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

func TestServiceNameIndexFunc(t *testing.T) {
t.Parallel()
testcases := []struct {
lucacome marked this conversation as resolved.
Show resolved Hide resolved
msg string
obj client.Object
Expand Down Expand Up @@ -42,13 +43,19 @@ func TestServiceNameIndexFunc(t *testing.T) {
}

for _, tc := range testcases {
g := NewWithT(t)
output := ServiceNameIndexFunc(tc.obj)
g.Expect(output).To(Equal(tc.expOutput))
tc := tc
t.Run(tc.msg, func(t *testing.T) {
t.Parallel()
g := NewWithT(t)

output := ServiceNameIndexFunc(tc.obj)
g.Expect(output).To(Equal(tc.expOutput))
})
}
}

func TestServiceNameIndexFuncPanics(t *testing.T) {
t.Parallel()
defer func() {
g := NewWithT(t)
g.Expect(recover()).ToNot(BeNil())
Expand Down
6 changes: 6 additions & 0 deletions internal/framework/controller/predicate/annotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

func TestAnnotationPredicate_Create(t *testing.T) {
t.Parallel()
annotation := "test"

tests := []struct {
Expand Down Expand Up @@ -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))
Expand All @@ -67,6 +70,7 @@ func TestAnnotationPredicate_Create(t *testing.T) {
}

func TestAnnotationPredicate_Update(t *testing.T) {
t.Parallel()
annotation := "test"

tests := []struct {
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

func TestGatewayClassPredicate(t *testing.T) {
t.Parallel()
g := NewWithT(t)

p := GatewayClassPredicate{ControllerName: "nginx-ctlr"}
Expand Down
8 changes: 8 additions & 0 deletions internal/framework/controller/predicate/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
)

func TestServicePortsChangedPredicate_Update(t *testing.T) {
t.Parallel()
testcases := []struct {
objectOld client.Object
objectNew client.Object
Expand Down Expand Up @@ -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,
Expand All @@ -240,6 +243,7 @@ func TestServicePortsChangedPredicate_Update(t *testing.T) {
}

func TestServicePortsChangedPredicate(t *testing.T) {
t.Parallel()
g := NewWithT(t)

p := GatewayServicePredicate{}
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -453,6 +460,7 @@ func TestGatewayServicePredicate_Update(t *testing.T) {
}

func TestGatewayServicePredicate(t *testing.T) {
t.Parallel()
g := NewWithT(t)

p := GatewayServicePredicate{}
Expand Down
3 changes: 3 additions & 0 deletions internal/framework/controller/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
)

func TestRegister(t *testing.T) {
t.Parallel()
type fakes struct {
mgr *controllerfakes.FakeManager
indexer *controllerfakes.FakeFieldIndexer
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions internal/framework/status/conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

func TestConditionsEqual(t *testing.T) {
t.Parallel()
getDefaultConds := func() []v1.Condition {
return []v1.Condition{
{
Expand Down Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions internal/framework/status/status_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestStatus(t *testing.T) {
t.Parallel()
RegisterFailHandler(Fail)
RunSpecs(t, "Status Suite")
}
3 changes: 3 additions & 0 deletions internal/framework/status/updater_retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
)

func TestNewRetryUpdateFunc(t *testing.T) {
t.Parallel()
tests := []struct {
getReturns error
updateReturns error
Expand Down Expand Up @@ -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{}
Expand Down
Loading