You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/08/29 03:29:32 UTC

[GitHub] [apisix-ingress-controller] AlinsRan commented on a diff in pull request #1238: fix: namespace_selector invalid when restarting

AlinsRan commented on code in PR #1238:
URL: https://github.com/apache/apisix-ingress-controller/pull/1238#discussion_r956867378


##########
test/e2e/suite-ingress/suite-ingress-features/namespace.go:
##########
@@ -189,3 +269,130 @@ spec:
 		})
 	})
 })
+
+var _ = ginkgo.Describe("suite-ingress-features: namespacing ub-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() {
+		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")
+		ns = fmt.Sprintf(`
+apiVersion: v1
+kind: Namespace
+metadata:
+  name: %s
+`, namespace1)
+		assert.Nil(ginkgo.GinkgoT(), s.CreateResourceFromString(ns), "creating namespace")
+		assert.Nil(ginkgo.GinkgoT(), err, "create httpbin service in", namespace1)
+		time.Sleep(6 * time.Second)
+		routes, err := s.ListApisixRoutes()
+		assert.Nil(ginkgo.GinkgoT(), err)
+		assert.Len(ginkgo.GinkgoT(), routes, 0)

Review Comment:
   There is no such interface. This can be done, but it is not convenient.



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org