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 2021/04/12 02:47:45 UTC
[GitHub] [apisix-dashboard] Jaycean opened a new pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Jaycean opened a new pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754
Please answer these questions before submitting a pull request, **or your PR will get closed**.
**Why submit this pull request?**
- [ ] Bugfix
- [x] New feature provided
- [ ] Improve performance
- [ ] Backport patches
**What changes will this PR take into?**
feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
**Related issues**
#1500
**Checklist:**
- [x] Did you explain what problem does this PR solve? Or what new features have been added?
- [ ] Have you added corresponding test cases?
- [ ] Have you modified the corresponding document?
- [x] Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] Jaycean commented on pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
Jaycean commented on pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#issuecomment-818354012
cc @juzhiyuan @liuxiran FE CI Failed. PTAL
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] juzhiyuan merged pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
juzhiyuan merged pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] Jaycean commented on a change in pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
Jaycean commented on a change in pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#discussion_r612057247
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
Review comment:
done.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
Review comment:
done.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
Review comment:
done.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
Review comment:
done.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
Review comment:
done.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create service", func() {
+ table.DescribeTable("test route create service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ]
+ }
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "service_id": "200"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ Sleep: base.SleepTime,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(18)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(6))
+ })
+ table.DescribeTable("delete route and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/services/200",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
Review comment:
done.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create service", func() {
+ table.DescribeTable("test route create service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ]
+ }
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "service_id": "200"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ Sleep: base.SleepTime,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(18)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(6))
+ })
+ table.DescribeTable("delete route and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/services/200",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create upstream", func() {
+ table.DescribeTable("test route create upstream",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("create upstream", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes":[
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
Review comment:
done.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create service", func() {
+ table.DescribeTable("test route create service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ]
+ }
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "service_id": "200"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ Sleep: base.SleepTime,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(18)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(6))
+ })
+ table.DescribeTable("delete route and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/services/200",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create upstream", func() {
+ table.DescribeTable("test route create upstream",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("create upstream", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes":[
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(12)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(4))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(4))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(4))
+ })
+ table.DescribeTable("delete route and upstream",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove upstream", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/upstreams/1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
Review comment:
done.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ )
Review comment:
done.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create service", func() {
+ table.DescribeTable("test route create service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ]
+ }
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "service_id": "200"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ Sleep: base.SleepTime,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(18)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(6))
+ })
+ table.DescribeTable("delete route and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/services/200",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create upstream", func() {
+ table.DescribeTable("test route create upstream",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("create upstream", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes":[
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(12)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(4))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(4))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(4))
+ })
+ table.DescribeTable("delete route and upstream",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove upstream", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/upstreams/1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ }),
+ )
+})
Review comment:
done.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] tokers commented on a change in pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#discussion_r611342017
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
Review comment:
Bad title, it not an invalid route, actually it doesn't exist.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
Review comment:
Ditto.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
Review comment:
The title is obsecure.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create service", func() {
+ table.DescribeTable("test route create service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ]
+ }
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "service_id": "200"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ Sleep: base.SleepTime,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(18)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(6))
+ })
+ table.DescribeTable("delete route and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/services/200",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create upstream", func() {
+ table.DescribeTable("test route create upstream",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("create upstream", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes":[
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
Review comment:
Bad title. Should be "create route using the upstream just created".
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create service", func() {
+ table.DescribeTable("test route create service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ]
+ }
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "service_id": "200"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ Sleep: base.SleepTime,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(18)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(6))
+ })
+ table.DescribeTable("delete route and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/services/200",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
Review comment:
Bad title, how can we hit a deleted route?
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
Review comment:
Ditto.
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
Review comment:
The response body should also be checked as we must ensure the `404` is returned by APISIX and caused by "route not found".
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create service", func() {
+ table.DescribeTable("test route create service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ]
+ }
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "service_id": "200"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ Sleep: base.SleepTime,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(18)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(6))
+ })
+ table.DescribeTable("delete route and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/services/200",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create upstream", func() {
+ table.DescribeTable("test route create upstream",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("create upstream", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes":[
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(12)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(4))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(4))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(4))
+ })
+ table.DescribeTable("delete route and upstream",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove upstream", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/upstreams/1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
Review comment:
Bad title, how can we hit a deleted route?
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] netlify[bot] edited a comment on pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
netlify[bot] edited a comment on pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#issuecomment-817441987
Deploy preview for *apisix-dashboard* ready!
Built with commit 0f792882d5e29dc0912cf662f4c29c52454981be
https://deploy-preview-1754--apisix-dashboard.netlify.app
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] netlify[bot] edited a comment on pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
netlify[bot] edited a comment on pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#issuecomment-817441987
Deploy preview for *apisix-dashboard* processing.
Building with commit d01c4403a162f16a5ab668c96b35982031c4a349
https://app.netlify.com/sites/apisix-dashboard/deploys/60746f418f23760007abdccf
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] netlify[bot] commented on pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
netlify[bot] commented on pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#issuecomment-817441987
Deploy preview for *apisix-dashboard* processing.
Building with commit 64ec510d56993c2e0a779935325521a14b34bea0
https://app.netlify.com/sites/apisix-dashboard/deploys/6073b4c82a590b0008dec0e6
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] codecov-io edited a comment on pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#issuecomment-817452936
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1754?src=pr&el=h1) Report
> Merging [#1754](https://codecov.io/gh/apache/apisix-dashboard/pull/1754?src=pr&el=desc) (501bab4) into [master](https://codecov.io/gh/apache/apisix-dashboard/commit/8b6080d2fc87bb5936650a647b67e1480745721a?el=desc) (8b6080d) will **decrease** coverage by `0.96%`.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/1754?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #1754 +/- ##
==========================================
- Coverage 72.45% 71.48% -0.97%
==========================================
Files 132 47 -85
Lines 5721 3128 -2593
Branches 649 0 -649
==========================================
- Hits 4145 2236 -1909
+ Misses 1334 649 -685
- Partials 242 243 +1
```
| Flag | Coverage Δ | |
|---|---|---|
| backend-e2e-test | `62.24% <ø> (-0.48%)` | :arrow_down: |
| backend-e2e-test-ginkgo | `49.36% <ø> (+0.25%)` | :arrow_up: |
| backend-unit-test | `52.29% <ø> (ø)` | |
| frontend-e2e-test | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/apisix-dashboard/pull/1754?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [api/internal/core/storage/etcd.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1754/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmFnZS9ldGNkLmdv) | `45.45% <0.00%> (-5.46%)` | :arrow_down: |
| [api/internal/core/store/storehub.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1754/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmVodWIuZ28=) | `71.02% <0.00%> (-3.74%)` | :arrow_down: |
| [api/internal/core/store/store.go](https://codecov.io/gh/apache/apisix-dashboard/pull/1754/diff?src=pr&el=tree#diff-YXBpL2ludGVybmFsL2NvcmUvc3RvcmUvc3RvcmUuZ28=) | `87.95% <0.00%> (-1.21%)` | :arrow_down: |
| [web/src/services/tool.ts](https://codecov.io/gh/apache/apisix-dashboard/pull/1754/diff?src=pr&el=tree#diff-d2ViL3NyYy9zZXJ2aWNlcy90b29sLnRz) | | |
| [web/src/pages/Setting/service.ts](https://codecov.io/gh/apache/apisix-dashboard/pull/1754/diff?src=pr&el=tree#diff-d2ViL3NyYy9wYWdlcy9TZXR0aW5nL3NlcnZpY2UudHM=) | | |
| [web/src/pages/PluginTemplate/Create.tsx](https://codecov.io/gh/apache/apisix-dashboard/pull/1754/diff?src=pr&el=tree#diff-d2ViL3NyYy9wYWdlcy9QbHVnaW5UZW1wbGF0ZS9DcmVhdGUudHN4) | | |
| [...pages/Route/components/Step1/RequestConfigView.tsx](https://codecov.io/gh/apache/apisix-dashboard/pull/1754/diff?src=pr&el=tree#diff-d2ViL3NyYy9wYWdlcy9Sb3V0ZS9jb21wb25lbnRzL1N0ZXAxL1JlcXVlc3RDb25maWdWaWV3LnRzeA==) | | |
| [web/src/pages/Consumer/List.tsx](https://codecov.io/gh/apache/apisix-dashboard/pull/1754/diff?src=pr&el=tree#diff-d2ViL3NyYy9wYWdlcy9Db25zdW1lci9MaXN0LnRzeA==) | | |
| [web/src/pages/User/Login.tsx](https://codecov.io/gh/apache/apisix-dashboard/pull/1754/diff?src=pr&el=tree#diff-d2ViL3NyYy9wYWdlcy9Vc2VyL0xvZ2luLnRzeA==) | | |
| [...components/PluginOrchestration/components/Page.tsx](https://codecov.io/gh/apache/apisix-dashboard/pull/1754/diff?src=pr&el=tree#diff-d2ViL3NyYy9jb21wb25lbnRzL1BsdWdpbk9yY2hlc3RyYXRpb24vY29tcG9uZW50cy9QYWdlLnRzeA==) | | |
| ... and [78 more](https://codecov.io/gh/apache/apisix-dashboard/pull/1754/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1754?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/1754?src=pr&el=footer). Last update [8b6080d...501bab4](https://codecov.io/gh/apache/apisix-dashboard/pull/1754?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] starsz commented on a change in pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
starsz commented on a change in pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#discussion_r611416540
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ )
Review comment:
Maybe we can test this situation:
`service that contains not-exists-upstream`
##########
File path: api/test/e2enew/route/route_service_upstream_test.go
##########
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package route
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
+ "github.com/onsi/gomega"
+
+ "github.com/apisix/manager-api/test/e2enew/base"
+)
+
+var _ = ginkgo.Describe("route invalid service and service", func() {
+ table.DescribeTable("test route invalid service and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("use service that not exist - dashboard", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("use upstream that not exist", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service and upstream together at the same time", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusBadRequest,
+ }),
+ table.Entry("hit invalid route on data plane", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create service", func() {
+ table.DescribeTable("test route create service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ]
+ }
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "service_id": "200"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ Sleep: base.SleepTime,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(18)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(6))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(6))
+ })
+ table.DescribeTable("delete route and service",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove service", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/services/200",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ }),
+ )
+})
+
+var _ = ginkgo.Describe("route create upstream", func() {
+ table.DescribeTable("test route create upstream",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("create upstream", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes":[
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1980,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1981,
+ "weight": 1
+ },
+ {
+ "host": "` + base.UpstreamIp + `",
+ "port": 1982,
+ "weight": 1
+ }
+ ],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("make sure the route has not created", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ Sleep: base.SleepTime,
+ }),
+ table.Entry("create route using the service just created", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "name": "route1",
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ )
+ ginkgo.It("batch test /server_port api", func() {
+ // sleep for etcd sync
+ time.Sleep(time.Duration(300) * time.Millisecond)
+
+ // batch test /server_port api
+ res := base.BatchTestServerPort(12)
+
+ gomega.Expect(res["1980"]).Should(gomega.Equal(4))
+ gomega.Expect(res["1981"]).Should(gomega.Equal(4))
+ gomega.Expect(res["1982"]).Should(gomega.Equal(4))
+ })
+ table.DescribeTable("delete route and upstream",
+ func(tc base.HttpTestCase) {
+ base.RunTestCase(tc)
+ },
+ table.Entry("delete route", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("remove upstream", base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/upstreams/1",
+ Headers: map[string]string{"Authorization": base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ }),
+ table.Entry("hit deleted route", base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusNotFound,
+ }),
+ )
+})
Review comment:
Maybe we can test this situation:
`service that contains upstream`
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] netlify[bot] edited a comment on pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
netlify[bot] edited a comment on pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#issuecomment-817441987
Deploy preview for *apisix-dashboard* processing.
Building with commit dadc01830ba7b9aeb41e4d6cf2dd833b7c18e55a
https://app.netlify.com/sites/apisix-dashboard/deploys/6075b698195870000a1bee0e
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] netlify[bot] edited a comment on pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
netlify[bot] edited a comment on pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#issuecomment-817441987
Deploy preview for *apisix-dashboard* ready!
Built with commit dadc01830ba7b9aeb41e4d6cf2dd833b7c18e55a
https://deploy-preview-1754--apisix-dashboard.netlify.app
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] netlify[bot] edited a comment on pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
netlify[bot] edited a comment on pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#issuecomment-817441987
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] netlify[bot] edited a comment on pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
netlify[bot] edited a comment on pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#issuecomment-817441987
Deploy preview for *apisix-dashboard* ready!
Built with commit 501bab47baf17e578b498a9573eb082f350d184c
https://deploy-preview-1754--apisix-dashboard.netlify.app
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix-dashboard] netlify[bot] edited a comment on pull request #1754: feat: rewrite e2e test(rewrite-e2e-test-route-service-upstream-test) with ginkgo
Posted by GitBox <gi...@apache.org>.
netlify[bot] edited a comment on pull request #1754:
URL: https://github.com/apache/apisix-dashboard/pull/1754#issuecomment-817441987
Deploy preview for *apisix-dashboard* ready!
Built with commit d01c4403a162f16a5ab668c96b35982031c4a349
https://deploy-preview-1754--apisix-dashboard.netlify.app
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org