tao12345666333 commented on code in PR #1238:
URL:
https://github.com/apache/apisix-ingress-controller/pull/1238#discussion_r956965068
##########
test/e2e/suite-ingress/suite-ingress-features/namespace.go:
##########
@@ -90,18 +143,48 @@ spec:
port:
number: %d
`, backendSvc, backendSvcPort[0])
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromString(route3), "creating ingress")
+ time.Sleep(6 * time.Second)
+ routes, err = s.ListApisixRoutes()
+ assert.Nil(ginkgo.GinkgoT(), err)
+ assert.Len(ginkgo.GinkgoT(), routes, 1)
+ _ =
s.NewAPISIXClient().GET("/headers").WithHeader("Host",
"local.httpbin.org").Expect().Status(http.StatusNotFound)
+
+ // remove route1
+ assert.Nil(ginkgo.GinkgoT(),
s.DeleteResourceFromStringWithNamespace(route1, namespace1), "delte ingress")
Review Comment:
```suggestion
assert.Nil(ginkgo.GinkgoT(),
s.DeleteResourceFromStringWithNamespace(route1, namespace1), "delete ingress")
```
##########
test/e2e/suite-ingress/suite-ingress-features/namespace.go:
##########
@@ -90,18 +143,48 @@ spec:
port:
number: %d
`, backendSvc, backendSvcPort[0])
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromString(route3), "creating ingress")
+ time.Sleep(6 * time.Second)
+ routes, err = s.ListApisixRoutes()
+ assert.Nil(ginkgo.GinkgoT(), err)
+ assert.Len(ginkgo.GinkgoT(), routes, 1)
+ _ =
s.NewAPISIXClient().GET("/headers").WithHeader("Host",
"local.httpbin.org").Expect().Status(http.StatusNotFound)
+
+ // remove route1
+ assert.Nil(ginkgo.GinkgoT(),
s.DeleteResourceFromStringWithNamespace(route1, namespace1), "delte ingress")
+ time.Sleep(6 * time.Second)
+
+ deleteNamespace(namespace1)
+ time.Sleep(6 * time.Second)
+ routes, err = s.ListApisixRoutes()
+ assert.Nil(ginkgo.GinkgoT(), err)
+ assert.Len(ginkgo.GinkgoT(), routes, 0)
+
+ // restart ingress-controller
+ s.RestartIngressControllerDeploy()
+ time.Sleep(6 * time.Second)
+ assert.Nil(ginkgo.GinkgoT(), err)
+ assert.Len(ginkgo.GinkgoT(), routes, 0)
- assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromStringWithNamespace(route, "default"), "creating ingress")
- _ =
s.NewAPISIXClient().GET("/headers").WithHeader("Host",
"httpbin.com").Expect().Status(http.StatusNotFound)
+ createNamespaceLabel(namespace2)
+ defer deleteNamespace(namespace2)
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromStringWithNamespace(route1, namespace2), "creating ingress")
+ assert.Nil(ginkgo.GinkgoT(),
s.EnsureNumApisixRoutesCreated(1))
+ _ = s.NewAPISIXClient().GET("/ip").WithHeader("Host",
"httpbin.com").Expect().Status(http.StatusOK)
+ _ =
s.NewAPISIXClient().GET("/headers").WithHeader("Host",
"httpbin.org").Expect().Status(http.StatusNotFound)
+ _ =
s.NewAPISIXClient().GET("/headers").WithHeader("Host",
"local.httpbin.org").Expect().Status(http.StatusNotFound)
})
})
})
-var _ = ginkgo.Describe("suite-ingress-features: namespacing filtering
disable", func() {
- s := scaffold.NewDefaultScaffold()
+var _ = ginkgo.Describe("suite-ingress-features: namespacing fltering
disable", func() {
Review Comment:
```suggestion
var _ = ginkgo.Describe("suite-ingress-features: namespacing filtering
disable", func() {
```
##########
test/e2e/suite-ingress/suite-ingress-features/namespace.go:
##########
@@ -189,3 +271,134 @@ spec:
})
})
})
+
+var _ = ginkgo.Describe("suite-ingress-features: namespacing un-label", func()
{
+ labelName, labelValue := fmt.Sprintf("namespace-selector-%d",
time.Now().Nanosecond()), "watch"
+ s := scaffold.NewScaffold(&scaffold.Options{
+ Name: "un-label",
+ IngressAPISIXReplicas: 1,
+ ApisixResourceVersion: scaffold.ApisixResourceVersion().Default,
+ NamespaceSelectorLabel: map[string]string{
+ labelName: labelValue,
+ },
+ DisableNamespaceLabel: true,
+ })
+ namespace1 := fmt.Sprintf("un-label-%d", time.Now().Nanosecond())
+
+ ginkgo.It("un-label", func() {
+ client := s.GetKubernetesClient()
+
+ ns := fmt.Sprintf(`
+apiVersion: v1
+kind: Namespace
+metadata:
+ name: %s
+ labels:
+ %s: %s
+`, namespace1, labelName, labelValue)
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromStringWithNamespace(ns, namespace1), "creating namespace")
+ //defer s.DeleteResourceFromStringWithNamespace(ns, namespace1)
+ _, err := s.NewHTTPBINWithNamespace(namespace1)
+ assert.Nil(ginkgo.GinkgoT(), err, "create httpbin service in",
namespace1)
+
+ backendSvc, backendSvcPort := s.DefaultHTTPBackend()
+ route1 := fmt.Sprintf(`
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+ name: httpbin-route
+spec:
+ ingressClassName: apisix
+ rules:
+ - host: httpbin.com
+ http:
+ paths:
+ - path: /ip
+ pathType: Exact
+ backend:
+ service:
+ name: %s
+ port:
+ number: %d
+`, backendSvc, backendSvcPort[0])
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromStringWithNamespace(route1, namespace1), "creating ingress")
+ assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(1))
+ time.Sleep(time.Second * 6)
+ _ = s.NewAPISIXClient().GET("/ip").WithHeader("Host",
"httpbin.com").Expect().Status(http.StatusOK).Body().Raw()
+
+ assert.Nil(ginkgo.GinkgoT(),
s.DeleteResourceFromStringWithNamespace(route1, namespace1), "deleting ingress")
+ // un-label
+ _, err = client.CoreV1().Namespaces().Update(
+ context.Background(),
+ &v1.Namespace{ObjectMeta: metav1.ObjectMeta{
+ Name: namespace1,
+ Labels: map[string]string{},
+ }},
+ metav1.UpdateOptions{},
+ )
+ assert.Nil(ginkgo.GinkgoT(), err, "creating namespace")
Review Comment:
```suggestion
assert.Nil(ginkgo.GinkgoT(), err, "unlabel the namespace")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]