Skip to content

Commit 24b9748

Browse files
author
VikramBedi
committed
use diff namespace for label selector test
1 parent bd7b2c1 commit 24b9748

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

test/suites/integration/allowed_routes_test.go

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ import (
1818

1919
var _ = Describe("AllowedRoutes Test", Ordered, func() {
2020
var (
21-
diffNS = "diff-namespace"
22-
23-
deployment *appsv1.Deployment
24-
service *corev1.Service
25-
diffNamespace *corev1.Namespace
26-
httpRoute *gwv1.HTTPRoute
27-
tlsRoute *gwv1alpha2.TLSRoute
21+
diffNS = "diff-namespace"
22+
labeledNS = "labeled-namespace"
23+
24+
deployment *appsv1.Deployment
25+
service *corev1.Service
26+
diffNamespace *corev1.Namespace
27+
labeledNamespace *corev1.Namespace
28+
labeledDeployment *appsv1.Deployment
29+
labeledService *corev1.Service
30+
httpRoute *gwv1.HTTPRoute
31+
tlsRoute *gwv1alpha2.TLSRoute
2832

2933
originalGatewaySpec gwv1.GatewaySpec
3034
)
@@ -88,6 +92,22 @@ var _ = Describe("AllowedRoutes Test", Ordered, func() {
8892
Namespace: diffNS,
8993
})
9094
testFramework.ExpectCreated(ctx, deployment, service)
95+
96+
labeledNamespace = &corev1.Namespace{
97+
ObjectMeta: metav1.ObjectMeta{
98+
Name: labeledNS,
99+
Labels: map[string]string{
100+
"env": "prod",
101+
},
102+
},
103+
}
104+
testFramework.ExpectCreated(ctx, labeledNamespace)
105+
106+
labeledDeployment, labeledService = testFramework.NewNginxApp(test.ElasticSearchOptions{
107+
Name: "inventory-ver2",
108+
Namespace: labeledNS,
109+
})
110+
testFramework.ExpectCreated(ctx, labeledDeployment, labeledService)
91111
})
92112

93113
Context("Listeners with default policy to allow routes from same namespace", func() {
@@ -187,16 +207,6 @@ var _ = Describe("AllowedRoutes Test", Ordered, func() {
187207

188208
Context("Listeners with namespace selector allowing routes from specific labeled namespaces", func() {
189209
BeforeEach(func() {
190-
Eventually(func(g Gomega) {
191-
ns := &corev1.Namespace{}
192-
g.Expect(testFramework.Get(ctx, client.ObjectKey{Name: diffNS}, ns)).To(Succeed())
193-
if ns.Labels == nil {
194-
ns.Labels = make(map[string]string)
195-
}
196-
ns.Labels["env"] = "prod"
197-
g.Expect(testFramework.Update(ctx, ns)).To(Succeed())
198-
}).Should(Succeed())
199-
200210
updateGatewayAndWait([]gwv1.Listener{
201211
{
202212
Name: "http",
@@ -228,7 +238,7 @@ var _ = Describe("AllowedRoutes Test", Ordered, func() {
228238
})
229239

230240
It("HTTPRoute from prod labeled namespace should be accepted by HTTP listener with matching selector", func() {
231-
httpRoute = testFramework.NewHttpRoute(testGateway, service, "Service")
241+
httpRoute = testFramework.NewHttpRoute(testGateway, labeledService, "Service")
232242
testFramework.ExpectCreated(ctx, httpRoute)
233243

234244
Eventually(func(g Gomega) {
@@ -716,7 +726,7 @@ var _ = Describe("AllowedRoutes Test", Ordered, func() {
716726
})
717727

718728
AfterAll(func() {
719-
testFramework.ExpectDeletedThenNotFound(ctx, deployment, service, diffNamespace)
729+
testFramework.ExpectDeletedThenNotFound(ctx, deployment, service, diffNamespace, labeledDeployment, labeledService, labeledNamespace)
720730
})
721731
})
722732

0 commit comments

Comments
 (0)