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 2020/11/16 05:09:01 UTC
[GitHub] [apisix-dashboard] EnableAsync opened a new pull request #810: test: add e2e test for config route with service_id or upstream_id
EnableAsync opened a new pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810
Please answer these questions before submitting a pull request
- Why submit this pull request?
- [ ] Bugfix
- [ ] New feature provided
- [ ] Improve performance
- [x] add e2e test cases for route
- Related issues
#630
----------------------------------------------------------------
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 #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#issuecomment-727737894
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=h1) Report
> Merging [#810](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=desc) (210faae) into [v2.0](https://codecov.io/gh/apache/apisix-dashboard/commit/6dae80b5ca6edc71cfdc5dc08bd70af8ccac4a36?el=desc) (6dae80b) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## v2.0 #810 +/- ##
=======================================
Coverage 42.64% 42.64%
=======================================
Files 18 18
Lines 1257 1257
=======================================
Hits 536 536
Misses 630 630
Partials 91 91
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/810?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/810?src=pr&el=footer). Last update [6dae80b...210faae](https://codecov.io/gh/apache/apisix-dashboard/pull/810?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] membphis commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r524978989
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "1980",
Review comment:
> I'm not family with Go test, I'm confused why the response body is only the port number?
here is the reason: https://github.com/apache/apisix-dashboard/pull/810#discussion_r524928100
----------------------------------------------------------------
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] EnableAsync removed a comment on pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
EnableAsync removed a comment on pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#issuecomment-727783600
> @EnableAsync
>
> CI failed. Please have a look.
>
> I think you could try on your local. If you need any help, please tell us, thanks!
Thanks for your review.
When I try to create service and upstream together at the same time[1], I think it deserves `400 Bad Request` but I get `200 OK`[2].
[1] https://github.com/EnableAsync/apisix-dashboard/blob/v2.0/api/test/e2e/route_service_upstream_test.go#L51
[2] https://github.com/apache/apisix-dashboard/pull/810/checks?check_run_id=1404991688#step:5:101
----------------------------------------------------------------
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] idbeta commented on pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
idbeta commented on pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#issuecomment-727739256
I think you better try to delete what you create in the case at last, like "teardown".
----------------------------------------------------------------
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] EnableAsync commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
EnableAsync commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r524924440
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "1980",
Review comment:
After studying the current test sample and realizing that the same response was used here[1], I wrote this as well.
Thanks for your review, I read `nginx.conf`[2] and `docker-compose.yaml`[3] and found that this `server.lua`[4] script is used, there is a `server_port` function in the `server.lua` script, so the printout here is port
[1] https://github.com/apache/apisix-dashboard/blob/v2.0/api/test/e2e/upstream_test.go#L73
[2] https://github.com/apache/apisix-dashboard/blob/v2.0/api/test/docker/upstream.conf#L47
[3] https://github.com/apache/apisix-dashboard/blob/v2.0/api/test/docker/docker-compose.yaml#L116
[4] https://github.com/apache/apisix/blob/master/t/lib/server.lua#L59
----------------------------------------------------------------
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] nic-chen commented on pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
nic-chen commented on pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#issuecomment-727771499
@EnableAsync
CI failed. Please have a look.
I think you could try on your local. If you need any help, please tell us, thanks!
----------------------------------------------------------------
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] membphis commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r524928100
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
Review comment:
if we only enabled one node, please use "/hello". for /server_port, it mainly used to test multiple nodes
----------------------------------------------------------------
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] nic-chen commented on pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
nic-chen commented on pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#issuecomment-727789828
> > @EnableAsync
> > CI failed. Please have a look.
> > I think you could try on your local. If you need any help, please tell us, thanks!
>
> Thanks for your review.
> When I try to create service and upstream together at the same time[1], I think it deserves `400 Bad Request` but I get `200 OK`[2].
>
> [1] https://github.com/EnableAsync/apisix-dashboard/blob/v2.0/api/test/e2e/route_service_upstream_test.go#L51
> [2] https://github.com/apache/apisix-dashboard/pull/810/checks?check_run_id=1404991688#step:5:101
You could try to fix it in another PR, or just remove this part and create an issue about it.
Thanks for your job.
----------------------------------------------------------------
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] moonming commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
moonming commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r524931901
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "1980",
Review comment:
[1] https://github.com/apache/apisix-dashboard/blob/v2.0/api/test/e2e/upstream_test.go#L73 is not a good example, @nic-chen please create issue and fix it.
----------------------------------------------------------------
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 commented on pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#issuecomment-727737894
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=h1) Report
> Merging [#810](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=desc) (12d7041) into [v2.0](https://codecov.io/gh/apache/apisix-dashboard/commit/6dae80b5ca6edc71cfdc5dc08bd70af8ccac4a36?el=desc) (6dae80b) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## v2.0 #810 +/- ##
=======================================
Coverage 42.64% 42.64%
=======================================
Files 18 18
Lines 1257 1257
=======================================
Hits 536 536
Misses 630 630
Partials 91 91
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/810?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/810?src=pr&el=footer). Last update [6dae80b...12d7041](https://codecov.io/gh/apache/apisix-dashboard/pull/810?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] EnableAsync commented on pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
EnableAsync commented on pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#issuecomment-727743289
> I think you better try to delete what you create in the case at last, like "teardown".
Thank you for your suggestion, I should destroy the additions.
----------------------------------------------------------------
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] EnableAsync commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
EnableAsync commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r524924566
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "1980",
Review comment:
After studying the current test sample and realizing that the same response was used here[1], I wrote this as well.
Thanks for your review, I read `nginx.conf`[2] and `docker-compose.yaml`[3] and found that this `server.lua`[4] script is used, there is a `server_port` function in the `server.lua` script, so the printout here is port
[1] https://github.com/apache/apisix-dashboard/blob/v2.0/api/test/e2e/upstream_test.go#L73
[2] https://github.com/apache/apisix-dashboard/blob/v2.0/api/test/docker/upstream.conf#L47
[3] https://github.com/apache/apisix-dashboard/blob/v2.0/api/test/docker/docker-compose.yaml#L116
[4] https://github.com/apache/apisix/blob/master/t/lib/server.lua#L59
----------------------------------------------------------------
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 commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r524831071
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "1980",
Review comment:
I'm not family with Go test, I'm confused why the response body is only the port number?
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "1980",
Review comment:

I'm not sure if Golang will convert this type?
----------------------------------------------------------------
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 #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
juzhiyuan merged pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810
----------------------------------------------------------------
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] EnableAsync commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
EnableAsync commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r525605876
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,304 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist - dashboard",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "hit invalid route on data plane",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectCode: http.StatusNotFound,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "hit invalid route on data plane",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectCode: http.StatusNotFound,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "hit invalid route on data plane",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectCode: http.StatusNotFound,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create service",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [
+ {
+ "host": "172.16.238.20",
Review comment:
Thanks for your suggestion, I learned something new, the current e2e uses the docker container provided by github action.
----------------------------------------------------------------
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 #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#issuecomment-727737894
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=h1) Report
> Merging [#810](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=desc) (ed9babb) into [v2.0](https://codecov.io/gh/apache/apisix-dashboard/commit/6dae80b5ca6edc71cfdc5dc08bd70af8ccac4a36?el=desc) (6dae80b) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## v2.0 #810 +/- ##
=======================================
Coverage 42.64% 42.64%
=======================================
Files 18 18
Lines 1257 1257
=======================================
Hits 536 536
Misses 630 630
Partials 91 91
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/810?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/810?src=pr&el=footer). Last update [6dae80b...ed9babb](https://codecov.io/gh/apache/apisix-dashboard/pull/810?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] nic-chen commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r523955300
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "1980",
+ Sleep: sleepTime,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create service",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }]
+ }
Review comment:
Bad indentation.
----------------------------------------------------------------
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 #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#issuecomment-727737894
# [Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=h1) Report
> Merging [#810](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=desc) (ce62474) into [v2.0](https://codecov.io/gh/apache/apisix-dashboard/commit/6dae80b5ca6edc71cfdc5dc08bd70af8ccac4a36?el=desc) (6dae80b) will **not change** coverage.
> The diff coverage is `n/a`.
[](https://codecov.io/gh/apache/apisix-dashboard/pull/810?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## v2.0 #810 +/- ##
=======================================
Coverage 42.64% 42.64%
=======================================
Files 18 18
Lines 1257 1257
=======================================
Hits 536 536
Misses 630 630
Partials 91 91
```
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-dashboard/pull/810?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/810?src=pr&el=footer). Last update [6dae80b...ce62474](https://codecov.io/gh/apache/apisix-dashboard/pull/810?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] nic-chen commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r524955494
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "1980",
Review comment:
> [1] https://github.com/apache/apisix-dashboard/blob/v2.0/api/test/e2e/upstream_test.go#L73 is not a good example, @nic-chen please create issue and fix it.
OK
----------------------------------------------------------------
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] moonming commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
moonming commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r524826642
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
Review comment:
only test controller plane(MangerApiExpect) is not enough, we MUST test data plane(APISIXExpect) at the same time.
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
Review comment:
ditto
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "1980",
+ Sleep: sleepTime,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create service",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }]
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the service just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r2",
+ Body: `{
+ "uri": "/hello",
+ "service_id": "200"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/hello",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "hello world\n",
+ Sleep: sleepTime,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Delete_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "delete route",
+ Object: MangerApiExpect(t),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "remove upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/upstreams/1",
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Delete_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "delete route",
+ Object: MangerApiExpect(t),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r2",
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "remove service",
+ Object: MangerApiExpect(t),
Review comment:
ditto
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
Review comment:
ditto
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "1980",
Review comment:
the response body is `1980`?
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
Review comment:
we need to check nodes, not only one node.
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
Review comment:
We need to check whether this route is valid on the data plane
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the upstream just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/server_port",
+ "upstream_id": "1"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/server_port",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "1980",
+ Sleep: sleepTime,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create service",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }]
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "create route using the service just created",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r2",
+ Body: `{
+ "uri": "/hello",
+ "service_id": "200"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ Sleep: sleepTime,
+ },
+ {
+ caseDesc: "hit the route just created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/hello",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "hello world\n",
+ Sleep: sleepTime,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Delete_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "delete route",
+ Object: MangerApiExpect(t),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r1",
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
+ },
+ {
+ caseDesc: "remove upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/upstreams/1",
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusOK,
Review comment:
We need to check whether this route deleted on the data plane
----------------------------------------------------------------
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] nic-chen commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r523984677
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,209 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Upstream(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create upstream",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/upstreams/1",
+ Body: `{
+ "nodes": [{
+ "host": "172.16.238.20",
+ "port": 1980,
+ "weight": 1
+ }],
+ "type": "roundrobin"
+ }`,
Review comment:
Bad indentation.
----------------------------------------------------------------
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] EnableAsync commented on pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
EnableAsync commented on pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#issuecomment-727783600
> @EnableAsync
>
> CI failed. Please have a look.
>
> I think you could try on your local. If you need any help, please tell us, thanks!
Thanks for your review.
When I try to create service and upstream together at the same time[1], I think it deserves `400 Bad Request` but I get `200 OK`[2].
[1] https://github.com/EnableAsync/apisix-dashboard/blob/v2.0/api/test/e2e/route_service_upstream_test.go#L51
[2] https://github.com/apache/apisix-dashboard/pull/810/checks?check_run_id=1404991688#step:5:101
----------------------------------------------------------------
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] gxthrj commented on a change in pull request #810: test: add e2e test for config route with service_id or upstream_id
Posted by GitBox <gi...@apache.org>.
gxthrj commented on a change in pull request #810:
URL: https://github.com/apache/apisix-dashboard/pull/810#discussion_r525300715
##########
File path: api/test/e2e/route_service_upstream_test.go
##########
@@ -0,0 +1,304 @@
+/*
+ * 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 e2e
+
+import (
+ "net/http"
+ "testing"
+)
+
+func TestRoute_Invalid_Service_And_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "use service that not exist - dashboard",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "hit invalid route on data plane",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectCode: http.StatusNotFound,
+ },
+ {
+ caseDesc: "use upstream that not exist",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "upstream_id": "not-exists"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "hit invalid route on data plane",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectCode: http.StatusNotFound,
+ },
+ {
+ caseDesc: "create service and upstream together at the same time",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/routes/r1",
+ Body: `{
+ "uri": "/hello_",
+ "service_id": "not-exists-service",
+ "upstream_id": "not-exists-upstream"
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ },
+ {
+ caseDesc: "hit invalid route on data plane",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectCode: http.StatusNotFound,
+ },
+ }
+ for _, tc := range tests {
+ testCaseCheck(tc)
+ }
+}
+
+func TestRoute_Create_Service(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create service",
+ Object: MangerApiExpect(t),
+ Method: http.MethodPut,
+ Path: "/apisix/admin/services/200",
+ Body: `{
+ "upstream": {
+ "type": "roundrobin",
+ "nodes": [
+ {
+ "host": "172.16.238.20",
Review comment:
the IP `172.16.238.20` is so obscure, it is defined in docker-compose.yaml.
If we do not test in docker container, it is recommended to use port mapping and use IP `127.0.0.1` to prevent network segment conflicts.
----------------------------------------------------------------
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