tao12345666333 commented on a change in pull request #919:
URL:
https://github.com/apache/apisix-ingress-controller/pull/919#discussion_r828840444
##########
File path: test/e2e/ingress/namespace.go
##########
@@ -86,7 +88,94 @@ spec:
servicePort: %d
`, backendSvc, backendSvcPort[0])
- assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromStringWithNamespace(route, "default"), "creating
ApisixRoute")
- _ = s.NewAPISIXClient().GET("/headers").WithHeader("Host",
"httpbin.com").Expect().Status(http.StatusNotFound)
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromStringWithNamespace(route, "default"), "creating
ApisixRoute")
+ _ =
s.NewAPISIXClient().GET("/headers").WithHeader("Host",
"httpbin.com").Expect().Status(http.StatusNotFound)
+ })
+ })
+
+ ginkgo.Context("without namespace_selector", func() {
+ // make namespace_selector empty
+ s.DisableNamespaceSelector()
+ namespace := "second-httpbin-service-namespace"
+
+ // create another http-bin service in a new namespace.
+ ginkgo.BeforeEach(func() {
+ k8s.CreateNamespace(ginkgo.GinkgoT(),
&k8s.KubectlOptions{
+ ConfigPath: scaffold.GetKubeconfig(),
+ }, namespace)
+ _, err := s.NewHTTPBINWithNamespace(namespace)
+ assert.Nil(ginkgo.GinkgoT(), err, "create second
httpbin service")
+ })
+
+ // clean this tmp namespace when test case is done.
+ ginkgo.AfterEach(func() {
+ err := k8s.DeleteNamespaceE(ginkgo.GinkgoT(),
&k8s.KubectlOptions{
+ ConfigPath: scaffold.GetKubeconfig()},
namespace)
+ assert.Nilf(ginkgo.GinkgoT(), err, "deleting namespace
%s", namespace)
+ })
+
+ ginkgo.It("all resources will be watched", func() {
+ backendSvc, backendSvcPort := s.DefaultHTTPBackend()
+ route := fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2beta3
+kind: ApisixRoute
+metadata:
+ name: httpbin-route
+spec:
+ http:
+ - name: rule1
+ match:
+ hosts:
+ - httpbin.com
+ paths:
+ - /ip
+ backends:
+ - serviceName: %s
+ servicePort: %d
+`, backendSvc, backendSvcPort[0])
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromString(route), "creating first ApisixRoute")
+ time.Sleep(3 * time.Second)
+
+ // Now create another ApisixRoute in another namespace.
+ backendSvc, backendSvcPort = s.DefaultHTTPBackend()
+ route = fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2beta3
+kind: ApisixRoute
+metadata:
+ name: httpbin-route
+spec:
+ http:
+ - name: rule1
+ match:
+ hosts:
+ - httpbin.com
+ paths:
+ - /headers
+ backends:
+ - serviceName: %s
+ servicePort: %d
+`, backendSvc, backendSvcPort[0])
+
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromStringWithNamespace(route, namespace), "creating second
ApisixRoute")
+
+ // restart ingress-controller
+ pods, err := s.GetIngressPodDetails()
+ assert.Nil(ginkgo.GinkgoT(), err)
+ assert.Len(ginkgo.GinkgoT(), pods, 1)
+ ginkgo.GinkgoT().Logf("restart
apisix-ingress-controller pod %s", pods[0].Name)
+ assert.Nil(ginkgo.GinkgoT(), s.KillPod(pods[0].Name))
+ time.Sleep(6 * time.Second)
+ // Two ApisixRoutes have been created at this time.
+ assert.Nil(ginkgo.GinkgoT(),
s.EnsureNumApisixRoutesCreated(2), "checking number of routes")
+ assert.Nil(ginkgo.GinkgoT(),
s.EnsureNumApisixUpstreamsCreated(2), "checking number of upstreams")
+
+ body :=
s.NewAPISIXClient().GET("/ip").WithHeader("Host",
"httpbin.com").Expect().Status(http.StatusOK).Body().Raw()
+ var placeholder ip
+ err = json.Unmarshal([]byte(body), &placeholder)
+ assert.Nil(ginkgo.GinkgoT(), err, "unmarshalling IP")
+ body =
s.NewAPISIXClient().GET("/headers").WithHeader("Host",
"httpbin.com").Expect().Status(http.StatusOK).Body().Raw()
+ err = json.Unmarshal([]byte(body), &placeholder)
+ assert.Nil(ginkgo.GinkgoT(), err, "unmarshalling IP")
Review comment:
please see
https://github.com/apache/apisix-ingress-controller/pull/919#discussion_r828601911
##########
File path: test/e2e/ingress/namespace.go
##########
@@ -86,7 +88,94 @@ spec:
servicePort: %d
`, backendSvc, backendSvcPort[0])
- assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromStringWithNamespace(route, "default"), "creating
ApisixRoute")
- _ = s.NewAPISIXClient().GET("/headers").WithHeader("Host",
"httpbin.com").Expect().Status(http.StatusNotFound)
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromStringWithNamespace(route, "default"), "creating
ApisixRoute")
+ _ =
s.NewAPISIXClient().GET("/headers").WithHeader("Host",
"httpbin.com").Expect().Status(http.StatusNotFound)
+ })
+ })
+
+ ginkgo.Context("without namespace_selector", func() {
+ // make namespace_selector empty
+ s.DisableNamespaceSelector()
+ namespace := "second-httpbin-service-namespace"
+
+ // create another http-bin service in a new namespace.
+ ginkgo.BeforeEach(func() {
+ k8s.CreateNamespace(ginkgo.GinkgoT(),
&k8s.KubectlOptions{
+ ConfigPath: scaffold.GetKubeconfig(),
+ }, namespace)
+ _, err := s.NewHTTPBINWithNamespace(namespace)
+ assert.Nil(ginkgo.GinkgoT(), err, "create second
httpbin service")
+ })
+
+ // clean this tmp namespace when test case is done.
+ ginkgo.AfterEach(func() {
+ err := k8s.DeleteNamespaceE(ginkgo.GinkgoT(),
&k8s.KubectlOptions{
+ ConfigPath: scaffold.GetKubeconfig()},
namespace)
+ assert.Nilf(ginkgo.GinkgoT(), err, "deleting namespace
%s", namespace)
+ })
+
+ ginkgo.It("all resources will be watched", func() {
+ backendSvc, backendSvcPort := s.DefaultHTTPBackend()
+ route := fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2beta3
+kind: ApisixRoute
+metadata:
+ name: httpbin-route
+spec:
+ http:
+ - name: rule1
+ match:
+ hosts:
+ - httpbin.com
+ paths:
+ - /ip
+ backends:
+ - serviceName: %s
+ servicePort: %d
+`, backendSvc, backendSvcPort[0])
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromString(route), "creating first ApisixRoute")
+ time.Sleep(3 * time.Second)
+
+ // Now create another ApisixRoute in another namespace.
+ backendSvc, backendSvcPort = s.DefaultHTTPBackend()
+ route = fmt.Sprintf(`
+apiVersion: apisix.apache.org/v2beta3
+kind: ApisixRoute
+metadata:
+ name: httpbin-route
+spec:
+ http:
+ - name: rule1
+ match:
+ hosts:
+ - httpbin.com
+ paths:
+ - /headers
+ backends:
+ - serviceName: %s
+ servicePort: %d
+`, backendSvc, backendSvcPort[0])
+
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromStringWithNamespace(route, namespace), "creating second
ApisixRoute")
+
+ // restart ingress-controller
+ pods, err := s.GetIngressPodDetails()
+ assert.Nil(ginkgo.GinkgoT(), err)
+ assert.Len(ginkgo.GinkgoT(), pods, 1)
+ ginkgo.GinkgoT().Logf("restart
apisix-ingress-controller pod %s", pods[0].Name)
+ assert.Nil(ginkgo.GinkgoT(), s.KillPod(pods[0].Name))
+ time.Sleep(6 * time.Second)
+ // Two ApisixRoutes have been created at this time.
+ assert.Nil(ginkgo.GinkgoT(),
s.EnsureNumApisixRoutesCreated(2), "checking number of routes")
+ assert.Nil(ginkgo.GinkgoT(),
s.EnsureNumApisixUpstreamsCreated(2), "checking number of upstreams")
+
+ body :=
s.NewAPISIXClient().GET("/ip").WithHeader("Host",
"httpbin.com").Expect().Status(http.StatusOK).Body().Raw()
+ var placeholder ip
+ err = json.Unmarshal([]byte(body), &placeholder)
+ assert.Nil(ginkgo.GinkgoT(), err, "unmarshalling IP")
+ body =
s.NewAPISIXClient().GET("/headers").WithHeader("Host",
"httpbin.com").Expect().Status(http.StatusOK).Body().Raw()
+ err = json.Unmarshal([]byte(body), &placeholder)
+ assert.Nil(ginkgo.GinkgoT(), err, "unmarshalling IP")
Review comment:
we will squash commits when merging. So there is no need to force push,
which will cause the previous review records to be lost
--
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]