tao12345666333 commented on code in PR #1103:
URL:
https://github.com/apache/apisix-ingress-controller/pull/1103#discussion_r911665457
##########
test/e2e/suite-endpoints/endpoints.go:
##########
@@ -119,27 +110,48 @@ spec:
- serviceName: %s
servicePort: %d
`, backendSvc, backendSvcPort[0])
- assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromString(apisixRoute))
- time.Sleep(12 * time.Second)
- ups, err := s.ListApisixUpstreams()
- assert.Nil(ginkgo.GinkgoT(), err, "listing APISIX upstreams")
- assert.Len(ginkgo.GinkgoT(), ups, 1)
- assert.Len(ginkgo.GinkgoT(), ups[0].Nodes, 1)
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromString(apisixRoute))
+ time.Sleep(12 * time.Second)
+ ups, err := s.ListApisixUpstreams()
+ assert.Nil(ginkgo.GinkgoT(), err, "listing APISIX
upstreams")
+ assert.Len(ginkgo.GinkgoT(), ups, 1)
+ assert.Len(ginkgo.GinkgoT(), ups[0].Nodes, 1)
- // port in nodes is still the targetPort, not the service port
- assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[0].Port, 80)
+ // port in nodes is still the targetPort, not the
service port
+ assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[0].Port, 80)
- // scale HTTPBIN, so the endpoints controller has the
opportunity to update upstream.
- assert.Nil(ginkgo.GinkgoT(), s.ScaleHTTPBIN(3))
- time.Sleep(30 * time.Second)
- ups, err = s.ListApisixUpstreams()
- assert.Nil(ginkgo.GinkgoT(), err, "listing APISIX upstreams")
- assert.Len(ginkgo.GinkgoT(), ups, 1)
- assert.Len(ginkgo.GinkgoT(), ups[0].Nodes, 3)
+ // scale HTTPBIN, so the endpoints controller has the
opportunity to update upstream.
+ assert.Nil(ginkgo.GinkgoT(), s.ScaleHTTPBIN(3))
+ time.Sleep(30 * time.Second)
+ ups, err = s.ListApisixUpstreams()
+ assert.Nil(ginkgo.GinkgoT(), err, "listing APISIX
upstreams")
+ assert.Len(ginkgo.GinkgoT(), ups, 1)
+ assert.Len(ginkgo.GinkgoT(), ups[0].Nodes, 3)
- // port in nodes is still the targetPort, not the service port
- assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[0].Port, 80)
- assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[1].Port, 80)
- assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[2].Port, 80)
+ // port in nodes is still the targetPort, not the
service port
+ assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[0].Port, 80)
+ assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[1].Port, 80)
+ assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[2].Port, 80)
+ })
+ }
+ ginkgo.Describe("suite-endpoints: scaffold v2beta3", func() {
+ suites(scaffold.NewScaffold(&scaffold.Options{
+ Name: "endpoints-port",
+ Kubeconfig: scaffold.GetKubeconfig(),
+ APISIXConfigPath: "testdata/apisix-gw-config.yaml",
+ IngressAPISIXReplicas: 1,
+ HTTPBinServicePort: 8080,
+ ApisixResourceVersion:
scaffold.ApisixResourceVersion().V2beta3,
+ }))
+ })
+ ginkgo.Describe("suite-endpoints: scaffold v2", func() {
+ suites(scaffold.NewScaffold(&scaffold.Options{
+ Name: "endpoints-port",
+ Kubeconfig: scaffold.GetKubeconfig(),
+ APISIXConfigPath: "testdata/apisix-gw-config.yaml",
+ IngressAPISIXReplicas: 1,
+ HTTPBinServicePort: 8080,
+ ApisixResourceVersion:
scaffold.ApisixResourceVersion().V2,
+ }))
Review Comment:
ditto
##########
test/e2e/suite-ingress/resourcesync.go:
##########
@@ -132,96 +123,120 @@ spec:
}
}
}`, consumer.Username)))
- }
+ }
+
+ _ = s.NewAPISIXClient().
+ GET("/ip").
+ WithHeader("Host", "httpbin.org").
+ Expect().
+ Status(http.StatusNotFound)
+
+ _ = s.NewAPISIXClient().
+ GET("/headers").
+ WithHeader("Host", "local.httpbin.org").
+ Expect().
+ Status(http.StatusNotFound)
+
+ waitTime := time.Until(readyTime).Seconds()
+ time.Sleep(time.Duration(waitTime) * time.Second)
+
+ _ = s.NewAPISIXClient().
+ GET("/ip").
+ WithHeader("Host", "httpbin.org").
+ WithHeader("apikey", "foo-key").
+ Expect().
+ Status(http.StatusOK)
+
+ _ = s.NewAPISIXClient().
+ GET("/headers").
+ WithHeader("Host", "local.httpbin.org").
+ Expect().
+ Status(http.StatusOK)
+
+ consumers, _ = s.ListApisixConsumers()
+ assert.Len(ginkgo.GinkgoT(), consumers, 1)
+ data, _ := json.Marshal(consumers[0])
+ assert.Contains(ginkgo.GinkgoT(), string(data),
"foo-key")
+ })
+
+ ginkgo.It("for deleted resource sync consistency", func() {
+ // crd resource sync interval
+ readyTime := time.Now().Add(60 * time.Second)
+
+ routes, _ := s.ListApisixRoutes()
+ assert.Len(ginkgo.GinkgoT(), routes, 2)
+
+ consumers, _ := s.ListApisixConsumers()
+ assert.Len(ginkgo.GinkgoT(), consumers, 1)
+
+ for _, route := range routes {
+ _ =
s.DeleteApisixRouteByApisixAdmin(id.GenID(route.Name))
+ }
+
+ for _, consumer := range consumers {
+
s.DeleteApisixConsumerByApisixAdmin(consumer.Username)
+ }
+
+ _ = s.NewAPISIXClient().
+ GET("/ip").
+ WithHeader("Host", "httpbin.org").
+ Expect().
+ Status(http.StatusNotFound)
+
+ _ = s.NewAPISIXClient().
+ GET("/headers").
+ WithHeader("Host", "local.httpbin.org").
+ Expect().
+ Status(http.StatusNotFound)
+
+ routes, _ = s.ListApisixRoutes()
+ assert.Len(ginkgo.GinkgoT(), routes, 0)
+ consumers, _ = s.ListApisixConsumers()
+ assert.Len(ginkgo.GinkgoT(), consumers, 0)
+
+ waitTime := time.Until(readyTime).Seconds()
+ time.Sleep(time.Duration(waitTime) * time.Second)
+
+ _ = s.NewAPISIXClient().
+ GET("/ip").
+ WithHeader("Host", "httpbin.org").
+ WithHeader("apikey", "foo-key").
+ Expect().
+ Status(http.StatusOK)
+
+ _ = s.NewAPISIXClient().
+ GET("/headers").
+ WithHeader("Host", "local.httpbin.org").
+ Expect().
+ Status(http.StatusOK)
+
+ consumers, _ = s.ListApisixConsumers()
+ assert.Len(ginkgo.GinkgoT(), consumers, 1)
+ data, _ := json.Marshal(consumers[0])
+ assert.Contains(ginkgo.GinkgoT(), string(data),
"foo-key")
+ })
+ }
- _ = s.NewAPISIXClient().
- GET("/ip").
- WithHeader("Host", "httpbin.org").
- Expect().
- Status(http.StatusNotFound)
-
- _ = s.NewAPISIXClient().
- GET("/headers").
- WithHeader("Host", "local.httpbin.org").
- Expect().
- Status(http.StatusNotFound)
-
- waitTime := time.Until(readyTime).Seconds()
- time.Sleep(time.Duration(waitTime) * time.Second)
-
- _ = s.NewAPISIXClient().
- GET("/ip").
- WithHeader("Host", "httpbin.org").
- WithHeader("apikey", "foo-key").
- Expect().
- Status(http.StatusOK)
-
- _ = s.NewAPISIXClient().
- GET("/headers").
- WithHeader("Host", "local.httpbin.org").
- Expect().
- Status(http.StatusOK)
-
- consumers, _ = s.ListApisixConsumers()
- assert.Len(ginkgo.GinkgoT(), consumers, 1)
- data, _ := json.Marshal(consumers[0])
- assert.Contains(ginkgo.GinkgoT(), string(data), "foo-key")
+ ginkgo.Describe("suite-ingress: scaffold v2beta3", func() {
+ suites(scaffold.NewScaffold(&scaffold.Options{
+ Name: "sync",
+ Kubeconfig: scaffold.GetKubeconfig(),
+ APISIXConfigPath:
"testdata/apisix-gw-config.yaml",
+ IngressAPISIXReplicas: 1,
+ HTTPBinServicePort: 80,
+ ApisixResourceVersion:
scaffold.ApisixResourceVersion().V2beta3,
+ ApisixResourceSyncInterval: "60s",
+ }))
})
-
- ginkgo.It("for deleted resource sync consistency", func() {
- // crd resource sync interval
- readyTime := time.Now().Add(60 * time.Second)
-
- routes, _ := s.ListApisixRoutes()
- assert.Len(ginkgo.GinkgoT(), routes, 2)
-
- consumers, _ := s.ListApisixConsumers()
- assert.Len(ginkgo.GinkgoT(), consumers, 1)
-
- for _, route := range routes {
- _ =
s.DeleteApisixRouteByApisixAdmin(id.GenID(route.Name))
- }
-
- for _, consumer := range consumers {
- s.DeleteApisixConsumerByApisixAdmin(consumer.Username)
- }
-
- _ = s.NewAPISIXClient().
- GET("/ip").
- WithHeader("Host", "httpbin.org").
- Expect().
- Status(http.StatusNotFound)
-
- _ = s.NewAPISIXClient().
- GET("/headers").
- WithHeader("Host", "local.httpbin.org").
- Expect().
- Status(http.StatusNotFound)
-
- routes, _ = s.ListApisixRoutes()
- assert.Len(ginkgo.GinkgoT(), routes, 0)
- consumers, _ = s.ListApisixConsumers()
- assert.Len(ginkgo.GinkgoT(), consumers, 0)
-
- waitTime := time.Until(readyTime).Seconds()
- time.Sleep(time.Duration(waitTime) * time.Second)
-
- _ = s.NewAPISIXClient().
- GET("/ip").
- WithHeader("Host", "httpbin.org").
- WithHeader("apikey", "foo-key").
- Expect().
- Status(http.StatusOK)
-
- _ = s.NewAPISIXClient().
- GET("/headers").
- WithHeader("Host", "local.httpbin.org").
- Expect().
- Status(http.StatusOK)
-
- consumers, _ = s.ListApisixConsumers()
- assert.Len(ginkgo.GinkgoT(), consumers, 1)
- data, _ := json.Marshal(consumers[0])
- assert.Contains(ginkgo.GinkgoT(), string(data), "foo-key")
+ ginkgo.Describe("suite-ingress: scaffold v2", func() {
+ suites(scaffold.NewScaffold(&scaffold.Options{
+ Name: "sync",
+ Kubeconfig: scaffold.GetKubeconfig(),
+ APISIXConfigPath:
"testdata/apisix-gw-config.yaml",
+ IngressAPISIXReplicas: 1,
+ HTTPBinServicePort: 80,
+ ApisixResourceVersion:
scaffold.ApisixResourceVersion().V2,
+ ApisixResourceSyncInterval: "60s",
+ }))
Review Comment:
ditto
##########
test/e2e/suite-ingress/webhook.go:
##########
@@ -64,11 +54,35 @@ spec:
break_response_code: 100 # should in [200, 599]
`, backendSvc, backendPorts[0])
- err := s.CreateResourceFromString(ar)
- assert.Error(ginkgo.GinkgoT(), err, "Failed to create
ApisixRoute")
- assert.Contains(ginkgo.GinkgoT(), err.Error(), "admission
webhook")
- assert.Contains(ginkgo.GinkgoT(), err.Error(), "denied the
request")
- assert.Contains(ginkgo.GinkgoT(), err.Error(), "api-breaker
plugin's config is invalid")
- assert.Contains(ginkgo.GinkgoT(), err.Error(), "Must be greater
than or equal to 200")
+ err := s.CreateResourceFromString(ar)
+ assert.Error(ginkgo.GinkgoT(), err, "Failed to create
ApisixRoute")
+ assert.Contains(ginkgo.GinkgoT(), err.Error(),
"admission webhook")
+ assert.Contains(ginkgo.GinkgoT(), err.Error(), "denied
the request")
+ assert.Contains(ginkgo.GinkgoT(), err.Error(),
"api-breaker plugin's config is invalid")
+ assert.Contains(ginkgo.GinkgoT(), err.Error(), "Must be
greater than or equal to 200")
+ })
+ }
+
+ ginkgo.Describe("suite-ingress: scaffold v2beta3", func() {
+ suites(scaffold.NewScaffold(&scaffold.Options{
+ Name: "webhook",
+ Kubeconfig: scaffold.GetKubeconfig(),
+ APISIXConfigPath: "testdata/apisix-gw-config.yaml",
+ IngressAPISIXReplicas: 1,
+ HTTPBinServicePort: 80,
+ ApisixResourceVersion:
scaffold.ApisixResourceVersion().V2beta3,
+ EnableWebhooks: false,
+ }))
+ })
+ ginkgo.Describe("suite-ingress: scaffold v2", func() {
+ suites(scaffold.NewScaffold(&scaffold.Options{
+ Name: "webhook",
+ Kubeconfig: scaffold.GetKubeconfig(),
+ APISIXConfigPath: "testdata/apisix-gw-config.yaml",
+ IngressAPISIXReplicas: 1,
+ HTTPBinServicePort: 80,
+ ApisixResourceVersion:
scaffold.ApisixResourceVersion().V2,
+ EnableWebhooks: false,
+ }))
Review Comment:
ditto
##########
test/e2e/suite-endpoints/endpoints.go:
##########
@@ -119,27 +110,48 @@ spec:
- serviceName: %s
servicePort: %d
`, backendSvc, backendSvcPort[0])
- assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromString(apisixRoute))
- time.Sleep(12 * time.Second)
- ups, err := s.ListApisixUpstreams()
- assert.Nil(ginkgo.GinkgoT(), err, "listing APISIX upstreams")
- assert.Len(ginkgo.GinkgoT(), ups, 1)
- assert.Len(ginkgo.GinkgoT(), ups[0].Nodes, 1)
+ assert.Nil(ginkgo.GinkgoT(),
s.CreateResourceFromString(apisixRoute))
+ time.Sleep(12 * time.Second)
+ ups, err := s.ListApisixUpstreams()
+ assert.Nil(ginkgo.GinkgoT(), err, "listing APISIX
upstreams")
+ assert.Len(ginkgo.GinkgoT(), ups, 1)
+ assert.Len(ginkgo.GinkgoT(), ups[0].Nodes, 1)
- // port in nodes is still the targetPort, not the service port
- assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[0].Port, 80)
+ // port in nodes is still the targetPort, not the
service port
+ assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[0].Port, 80)
- // scale HTTPBIN, so the endpoints controller has the
opportunity to update upstream.
- assert.Nil(ginkgo.GinkgoT(), s.ScaleHTTPBIN(3))
- time.Sleep(30 * time.Second)
- ups, err = s.ListApisixUpstreams()
- assert.Nil(ginkgo.GinkgoT(), err, "listing APISIX upstreams")
- assert.Len(ginkgo.GinkgoT(), ups, 1)
- assert.Len(ginkgo.GinkgoT(), ups[0].Nodes, 3)
+ // scale HTTPBIN, so the endpoints controller has the
opportunity to update upstream.
+ assert.Nil(ginkgo.GinkgoT(), s.ScaleHTTPBIN(3))
+ time.Sleep(30 * time.Second)
+ ups, err = s.ListApisixUpstreams()
+ assert.Nil(ginkgo.GinkgoT(), err, "listing APISIX
upstreams")
+ assert.Len(ginkgo.GinkgoT(), ups, 1)
+ assert.Len(ginkgo.GinkgoT(), ups[0].Nodes, 3)
- // port in nodes is still the targetPort, not the service port
- assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[0].Port, 80)
- assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[1].Port, 80)
- assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[2].Port, 80)
+ // port in nodes is still the targetPort, not the
service port
+ assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[0].Port, 80)
+ assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[1].Port, 80)
+ assert.Equal(ginkgo.GinkgoT(), ups[0].Nodes[2].Port, 80)
+ })
+ }
+ ginkgo.Describe("suite-endpoints: scaffold v2beta3", func() {
+ suites(scaffold.NewScaffold(&scaffold.Options{
+ Name: "endpoints-port",
+ Kubeconfig: scaffold.GetKubeconfig(),
+ APISIXConfigPath: "testdata/apisix-gw-config.yaml",
+ IngressAPISIXReplicas: 1,
+ HTTPBinServicePort: 8080,
+ ApisixResourceVersion:
scaffold.ApisixResourceVersion().V2beta3,
+ }))
+ })
Review Comment:
how ablout using `suites(scaffold.NewDefaultScaffold())` ?
##########
test/e2e/suite-ingress/resourcesync.go:
##########
@@ -132,96 +123,120 @@ spec:
}
}
}`, consumer.Username)))
- }
+ }
+
+ _ = s.NewAPISIXClient().
+ GET("/ip").
+ WithHeader("Host", "httpbin.org").
+ Expect().
+ Status(http.StatusNotFound)
+
+ _ = s.NewAPISIXClient().
+ GET("/headers").
+ WithHeader("Host", "local.httpbin.org").
+ Expect().
+ Status(http.StatusNotFound)
+
+ waitTime := time.Until(readyTime).Seconds()
+ time.Sleep(time.Duration(waitTime) * time.Second)
+
+ _ = s.NewAPISIXClient().
+ GET("/ip").
+ WithHeader("Host", "httpbin.org").
+ WithHeader("apikey", "foo-key").
+ Expect().
+ Status(http.StatusOK)
+
+ _ = s.NewAPISIXClient().
+ GET("/headers").
+ WithHeader("Host", "local.httpbin.org").
+ Expect().
+ Status(http.StatusOK)
+
+ consumers, _ = s.ListApisixConsumers()
+ assert.Len(ginkgo.GinkgoT(), consumers, 1)
+ data, _ := json.Marshal(consumers[0])
+ assert.Contains(ginkgo.GinkgoT(), string(data),
"foo-key")
+ })
+
+ ginkgo.It("for deleted resource sync consistency", func() {
+ // crd resource sync interval
+ readyTime := time.Now().Add(60 * time.Second)
+
+ routes, _ := s.ListApisixRoutes()
+ assert.Len(ginkgo.GinkgoT(), routes, 2)
+
+ consumers, _ := s.ListApisixConsumers()
+ assert.Len(ginkgo.GinkgoT(), consumers, 1)
+
+ for _, route := range routes {
+ _ =
s.DeleteApisixRouteByApisixAdmin(id.GenID(route.Name))
+ }
+
+ for _, consumer := range consumers {
+
s.DeleteApisixConsumerByApisixAdmin(consumer.Username)
+ }
+
+ _ = s.NewAPISIXClient().
+ GET("/ip").
+ WithHeader("Host", "httpbin.org").
+ Expect().
+ Status(http.StatusNotFound)
+
+ _ = s.NewAPISIXClient().
+ GET("/headers").
+ WithHeader("Host", "local.httpbin.org").
+ Expect().
+ Status(http.StatusNotFound)
+
+ routes, _ = s.ListApisixRoutes()
+ assert.Len(ginkgo.GinkgoT(), routes, 0)
+ consumers, _ = s.ListApisixConsumers()
+ assert.Len(ginkgo.GinkgoT(), consumers, 0)
+
+ waitTime := time.Until(readyTime).Seconds()
+ time.Sleep(time.Duration(waitTime) * time.Second)
+
+ _ = s.NewAPISIXClient().
+ GET("/ip").
+ WithHeader("Host", "httpbin.org").
+ WithHeader("apikey", "foo-key").
+ Expect().
+ Status(http.StatusOK)
+
+ _ = s.NewAPISIXClient().
+ GET("/headers").
+ WithHeader("Host", "local.httpbin.org").
+ Expect().
+ Status(http.StatusOK)
+
+ consumers, _ = s.ListApisixConsumers()
+ assert.Len(ginkgo.GinkgoT(), consumers, 1)
+ data, _ := json.Marshal(consumers[0])
+ assert.Contains(ginkgo.GinkgoT(), string(data),
"foo-key")
+ })
+ }
- _ = s.NewAPISIXClient().
- GET("/ip").
- WithHeader("Host", "httpbin.org").
- Expect().
- Status(http.StatusNotFound)
-
- _ = s.NewAPISIXClient().
- GET("/headers").
- WithHeader("Host", "local.httpbin.org").
- Expect().
- Status(http.StatusNotFound)
-
- waitTime := time.Until(readyTime).Seconds()
- time.Sleep(time.Duration(waitTime) * time.Second)
-
- _ = s.NewAPISIXClient().
- GET("/ip").
- WithHeader("Host", "httpbin.org").
- WithHeader("apikey", "foo-key").
- Expect().
- Status(http.StatusOK)
-
- _ = s.NewAPISIXClient().
- GET("/headers").
- WithHeader("Host", "local.httpbin.org").
- Expect().
- Status(http.StatusOK)
-
- consumers, _ = s.ListApisixConsumers()
- assert.Len(ginkgo.GinkgoT(), consumers, 1)
- data, _ := json.Marshal(consumers[0])
- assert.Contains(ginkgo.GinkgoT(), string(data), "foo-key")
+ ginkgo.Describe("suite-ingress: scaffold v2beta3", func() {
+ suites(scaffold.NewScaffold(&scaffold.Options{
+ Name: "sync",
+ Kubeconfig: scaffold.GetKubeconfig(),
+ APISIXConfigPath:
"testdata/apisix-gw-config.yaml",
+ IngressAPISIXReplicas: 1,
+ HTTPBinServicePort: 80,
+ ApisixResourceVersion:
scaffold.ApisixResourceVersion().V2beta3,
+ ApisixResourceSyncInterval: "60s",
+ }))
Review Comment:
ditto
--
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]