Skip to content

Commit d6a539a

Browse files
committed
address lint issues·
Signed-off-by: Eguzki Astiz Lezaun <eastizle@redhat.com>
1 parent e86d520 commit d6a539a

4 files changed

Lines changed: 69 additions & 65 deletions

File tree

test/e2e/apikey_approval_gc_test.go

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -89,35 +89,11 @@ var _ = Describe("APIKeyApproval Garbage Collection", Ordered, func() {
8989
})
9090

9191
BeforeAll(func() {
92-
By("creating the owner namespace")
93-
cmd := exec.Command("kubectl", "create", "ns", ownerNamespace)
94-
_, err := utils.Run(cmd)
95-
Expect(err).NotTo(HaveOccurred(), "Failed to create owner namespace")
96-
97-
By("creating the consumer namespace")
98-
cmd = exec.Command("kubectl", "create", "ns", consumerNamespace)
99-
_, err = utils.Run(cmd)
100-
Expect(err).NotTo(HaveOccurred(), "Failed to create consumer namespace")
101-
102-
By("creating the kuadrant namespace")
103-
cmd = exec.Command("kubectl", "create", "ns", kuadrantNamespace)
104-
_, err = utils.Run(cmd)
105-
Expect(err).NotTo(HaveOccurred(), "Failed to create kuadrant namespace")
106-
107-
By("creating the kuadrant instance")
108-
kuadrantYAML := fmt.Sprintf(`
109-
apiVersion: kuadrant.io/v1beta1
110-
kind: Kuadrant
111-
metadata:
112-
name: kuadrant
113-
namespace: %s
114-
spec: {}
115-
`, kuadrantNamespace)
92+
SetDefaultEventuallyTimeout(2 * time.Minute)
93+
SetDefaultEventuallyPollingInterval(2 * time.Second)
11694

117-
cmd = exec.Command("kubectl", "apply", "-f", "-")
118-
cmd.Stdin = utils.StringReader(kuadrantYAML)
119-
_, err = utils.Run(cmd)
120-
Expect(err).NotTo(HaveOccurred(), "Failed to create Kuadrant")
95+
By("setting up namespaces and Kuadrant instance")
96+
SetupNamespacesAndKuadrant(ownerNamespace, consumerNamespace, kuadrantNamespace)
12197
})
12298

12399
AfterAll(func() {
@@ -134,9 +110,6 @@ spec: {}
134110
_, _ = utils.Run(cmd)
135111
})
136112

137-
SetDefaultEventuallyTimeout(2 * time.Minute)
138-
SetDefaultEventuallyPollingInterval(2 * time.Second)
139-
140113
Context("APIKeyApproval owner reference and garbage collection", func() {
141114
It("should garbage collect APIKeyApproval when APIKey is deleted", func() {
142115
By("creating an HTTPRoute as a reference target")

test/e2e/automatic_approval_test.go

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -100,35 +100,11 @@ var _ = Describe("Automatic Approval", Ordered, func() {
100100
})
101101

102102
BeforeAll(func() {
103-
By("creating the owner namespace")
104-
cmd := exec.Command("kubectl", "create", "ns", ownerNamespace)
105-
_, err := utils.Run(cmd)
106-
Expect(err).NotTo(HaveOccurred(), "Failed to create owner namespace")
107-
108-
By("creating the consumer namespace")
109-
cmd = exec.Command("kubectl", "create", "ns", consumerNamespace)
110-
_, err = utils.Run(cmd)
111-
Expect(err).NotTo(HaveOccurred(), "Failed to create consumer namespace")
112-
113-
By("creating the kuadrant namespace")
114-
cmd = exec.Command("kubectl", "create", "ns", kuadrantNamespace)
115-
_, err = utils.Run(cmd)
116-
Expect(err).NotTo(HaveOccurred(), "Failed to create kuadrant namespace")
117-
118-
By("creating the kuadrant instance")
119-
kuadrantYAML := fmt.Sprintf(`
120-
apiVersion: kuadrant.io/v1beta1
121-
kind: Kuadrant
122-
metadata:
123-
name: kuadrant
124-
namespace: %s
125-
spec: {}
126-
`, kuadrantNamespace)
103+
SetDefaultEventuallyTimeout(2 * time.Minute)
104+
SetDefaultEventuallyPollingInterval(2 * time.Second)
127105

128-
cmd = exec.Command("kubectl", "apply", "-f", "-")
129-
cmd.Stdin = utils.StringReader(kuadrantYAML)
130-
_, err = utils.Run(cmd)
131-
Expect(err).NotTo(HaveOccurred(), "Failed to create Kuadrant")
106+
By("setting up namespaces and Kuadrant instance")
107+
SetupNamespacesAndKuadrant(ownerNamespace, consumerNamespace, kuadrantNamespace)
132108
})
133109

134110
AfterAll(func() {
@@ -145,9 +121,6 @@ spec: {}
145121
_, _ = utils.Run(cmd)
146122
})
147123

148-
SetDefaultEventuallyTimeout(2 * time.Minute)
149-
SetDefaultEventuallyPollingInterval(2 * time.Second)
150-
151124
Context("APIKey with automatic approval mode", func() {
152125
It("should create APIKeyRequest, automatic approval, and approve the APIKey", func() {
153126
By("creating an HTTPRoute as a reference target")

test/e2e/e2e_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ const metricsRoleBindingName = "developer-portal-controller-metrics-binding"
4545
var _ = Describe("Manager", Ordered, func() {
4646
var controllerPodName string
4747

48+
BeforeAll(func() {
49+
SetDefaultEventuallyTimeout(2 * time.Minute)
50+
SetDefaultEventuallyPollingInterval(time.Second)
51+
})
52+
4853
AfterAll(func() {
4954
By("cleaning up the curl pod for metrics")
5055
cmd := exec.Command("kubectl", "delete", "pod", "curl-metrics", "-n", namespace)
@@ -98,9 +103,6 @@ var _ = Describe("Manager", Ordered, func() {
98103
}
99104
})
100105

101-
SetDefaultEventuallyTimeout(2 * time.Minute)
102-
SetDefaultEventuallyPollingInterval(time.Second)
103-
104106
Context("Manager", func() {
105107
It("should run successfully", func() {
106108
By("validating that the controller-manager pod is running as expected")

test/e2e/test_helpers.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Copyright 2026.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package e2e
18+
19+
import (
20+
"fmt"
21+
"os/exec"
22+
23+
"github.com/onsi/gomega"
24+
25+
"github.com/kuadrant/developer-portal-controller/test/utils"
26+
)
27+
28+
// SetupNamespacesAndKuadrant creates the owner, consumer, and kuadrant namespaces,
29+
// and creates a Kuadrant instance. This is a common setup step for e2e tests.
30+
func SetupNamespacesAndKuadrant(ownerNamespace, consumerNamespace, kuadrantNamespace string) {
31+
cmd := exec.Command("kubectl", "create", "ns", ownerNamespace)
32+
_, err := utils.Run(cmd)
33+
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to create owner namespace")
34+
35+
cmd = exec.Command("kubectl", "create", "ns", consumerNamespace)
36+
_, err = utils.Run(cmd)
37+
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to create consumer namespace")
38+
39+
cmd = exec.Command("kubectl", "create", "ns", kuadrantNamespace)
40+
_, err = utils.Run(cmd)
41+
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to create kuadrant namespace")
42+
43+
kuadrantYAML := fmt.Sprintf(`
44+
apiVersion: kuadrant.io/v1beta1
45+
kind: Kuadrant
46+
metadata:
47+
name: kuadrant
48+
namespace: %s
49+
spec: {}
50+
`, kuadrantNamespace)
51+
52+
cmd = exec.Command("kubectl", "apply", "-f", "-")
53+
cmd.Stdin = utils.StringReader(kuadrantYAML)
54+
_, err = utils.Run(cmd)
55+
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "Failed to create Kuadrant")
56+
}

0 commit comments

Comments
 (0)