From 6fdf6a8e827c6817bf201d25dbe87a1a6b1ca54a Mon Sep 17 00:00:00 2001 From: Jaycean Date: Wed, 27 Jan 2021 15:02:42 +0800 Subject: [PATCH 01/10] Add back end E2E test document --- docs/back-end-e2e.md | 87 ++++++++++++++++++++++++++++++++++++++++++++ docs/develop.md | 2 + 2 files changed, 89 insertions(+) create mode 100644 docs/back-end-e2e.md diff --git a/docs/back-end-e2e.md b/docs/back-end-e2e.md new file mode 100644 index 0000000000..b4a02575b0 --- /dev/null +++ b/docs/back-end-e2e.md @@ -0,0 +1,87 @@ + + +This document describes how to use E2E test locally. + +1. The E2E test using the back end needs to start the manage-API, admin-API, etcd and upstream node. + +2. To start the manage-API project locally, please refer to [develop](./develop.md) web section. + +3. To start the etcd locally, please refer to [etcd start](https://github.com/apache/apisix/blob/master/doc/install-dependencies.md) web section. + +4. To start the admin-API project locally, please refer to [admin-API start](https://github.com/apache/apisix#get-started) web section. + +5. To start the upstream node locally, please install docker in the local environment and execute the command. + + ```sh + docker run -d --name upstream -v /(Your apisix-dashboard folder path)/api/test/docker/upstream.conf:/etc/nginx/conf.d/default.conf:ro -p 80:80 -p 1980:1980 -p 1981:1981 -p 1982:1982 -p 1983:1983 -p 1984:1984 johz/upstream:v2.0 + ``` + +6. After all the services are started, you can start the back-end E2E test. + +7. The upstream node IP is temporarily changed to the local IP address. After the test, it should be changed to GitHub upstream node IP. If the test case does not involve the upstream node, it does not need to be modified. + + ```sh + # Local E2E test create route example + { + "uris": ["/test-test"], + "name": "route_all", + "desc": "所有2", + "methods": ["GET"], + "hosts": ["test.com"], + "status": 1, + "upstream": { + "nodes": { + # upstream node IP is required for local test + "(local ip):1981": 1 + }, + "type": "roundrobin" + } + } + + #GitHub E2E test create route example + { + "uris": ["/test-test"], + "name": "route_all", + "desc": "所有2", + "methods": ["GET"], + "hosts": ["test.com"], + "status": 1, + "upstream": { + "nodes": { + "172.16.238.20:1981": 1 + }, + "type": "roundrobin" + } + } + ``` + +8. Enter the E2E folder and execute the command to test all E2E test files. + + ```sh + cd /(Your apisix-dashboard folder path)/api/test/e2e + go test -v + ``` + +9. You can also do E2E test on a single file. + + ```sh + cd /(Your apisix-dashboard folder path)/api/test/e2e + go test -v E2E-test-file.go base.go + ``` diff --git a/docs/develop.md b/docs/develop.md index cb1d89be63..87e8ae78ef 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -55,6 +55,8 @@ $ make api-stop 4. Please refer to the [FAQ](./FAQ.md) about the problem of displaying exception in the dashboard after adding custom plugins or modifying plugin's schema. +5. If writing an back end E2E test, refer to the [Back End E2E Writing Guide](./back-end-e2e.md) + ### web 1. Go to the `web` directory. From 24c3a29d5fa9fc3b76957e945b045c8dcd0364ff Mon Sep 17 00:00:00 2001 From: Jaycean Date: Wed, 27 Jan 2021 15:22:33 +0800 Subject: [PATCH 02/10] Format modification --- docs/back-end-e2e.md | 60 ++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/docs/back-end-e2e.md b/docs/back-end-e2e.md index b4a02575b0..0919af2168 100644 --- a/docs/back-end-e2e.md +++ b/docs/back-end-e2e.md @@ -19,9 +19,9 @@ This document describes how to use E2E test locally. -1. The E2E test using the back end needs to start the manage-API, admin-API, etcd and upstream node. +1. The E2E test using the back end needs to start the manage-API, admin-API, etcd and upstream node. -2. To start the manage-API project locally, please refer to [develop](./develop.md) web section. +2. To start the manage-API project locally, please refer to [develop](./develop.md) web section. 3. To start the etcd locally, please refer to [etcd start](https://github.com/apache/apisix/blob/master/doc/install-dependencies.md) web section. @@ -40,36 +40,36 @@ This document describes how to use E2E test locally. ```sh # Local E2E test create route example { - "uris": ["/test-test"], - "name": "route_all", - "desc": "所有2", - "methods": ["GET"], - "hosts": ["test.com"], - "status": 1, - "upstream": { - "nodes": { - # upstream node IP is required for local test - "(local ip):1981": 1 - }, - "type": "roundrobin" - } - } + "uris": ["/test-test"], + "name": "route_all", + "desc": "所有2", + "methods": ["GET"], + "hosts": ["test.com"], + "status": 1, + "upstream": { + "nodes": { + # upstream node IP is required for local test + "(local ip):1981": 1 + }, + "type": "roundrobin" + } + } - #GitHub E2E test create route example + # GitHub E2E test create route example { - "uris": ["/test-test"], - "name": "route_all", - "desc": "所有2", - "methods": ["GET"], - "hosts": ["test.com"], - "status": 1, - "upstream": { - "nodes": { - "172.16.238.20:1981": 1 - }, - "type": "roundrobin" - } - } + "uris": ["/test-test"], + "name": "route_all", + "desc": "所有2", + "methods": ["GET"], + "hosts": ["test.com"], + "status": 1, + "upstream": { + "nodes": { + "172.16.238.20:1981": 1 + }, + "type": "roundrobin" + } + } ``` 8. Enter the E2E folder and execute the command to test all E2E test files. From f4ee2a606cc3a95ecf2bbc5ba9a0b1501d559dae Mon Sep 17 00:00:00 2001 From: Jaycean Date: Wed, 27 Jan 2021 15:25:10 +0800 Subject: [PATCH 03/10] Remove the space --- docs/back-end-e2e.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/back-end-e2e.md b/docs/back-end-e2e.md index 0919af2168..af78af1495 100644 --- a/docs/back-end-e2e.md +++ b/docs/back-end-e2e.md @@ -73,7 +73,7 @@ This document describes how to use E2E test locally. ``` 8. Enter the E2E folder and execute the command to test all E2E test files. - + ```sh cd /(Your apisix-dashboard folder path)/api/test/e2e go test -v From 130a16b72ab7027b7dd928a66633bb55cb0234db Mon Sep 17 00:00:00 2001 From: Jaycean Date: Wed, 27 Jan 2021 17:14:23 +0800 Subject: [PATCH 04/10] Format repair --- docs/back-end-e2e.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/back-end-e2e.md b/docs/back-end-e2e.md index af78af1495..542d1b3111 100644 --- a/docs/back-end-e2e.md +++ b/docs/back-end-e2e.md @@ -19,13 +19,13 @@ This document describes how to use E2E test locally. -1. The E2E test using the back end needs to start the manage-API, admin-API, etcd and upstream node. +1. To run back end E2E test, please start the `manager-api`, `admin-api`, etcd and upstream node at first. -2. To start the manage-API project locally, please refer to [develop](./develop.md) web section. +2. To start the `manager-api` project locally, please refer to [develop](./develop.md) web section. 3. To start the etcd locally, please refer to [etcd start](https://github.com/apache/apisix/blob/master/doc/install-dependencies.md) web section. -4. To start the admin-API project locally, please refer to [admin-API start](https://github.com/apache/apisix#get-started) web section. +4. To start the `admin-api` project locally, please refer to [admin-api start](https://github.com/apache/apisix#get-started) web section. 5. To start the upstream node locally, please install docker in the local environment and execute the command. @@ -42,7 +42,7 @@ This document describes how to use E2E test locally. { "uris": ["/test-test"], "name": "route_all", - "desc": "所有2", + "desc": "test", "methods": ["GET"], "hosts": ["test.com"], "status": 1, @@ -50,25 +50,25 @@ This document describes how to use E2E test locally. "nodes": { # upstream node IP is required for local test "(local ip):1981": 1 - }, + }, "type": "roundrobin" - } + } } # GitHub E2E test create route example { "uris": ["/test-test"], "name": "route_all", - "desc": "所有2", + "desc": "test", "methods": ["GET"], "hosts": ["test.com"], "status": 1, "upstream": { "nodes": { "172.16.238.20:1981": 1 - }, + }, "type": "roundrobin" - } + } } ``` From 11037b6e9c4e6a811332784ac42fa10693ca0857 Mon Sep 17 00:00:00 2001 From: Jaycean Date: Wed, 27 Jan 2021 17:45:52 +0800 Subject: [PATCH 05/10] Add the front end field --- docs/develop.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/develop.md b/docs/develop.md index 87e8ae78ef..3235786a25 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -55,7 +55,7 @@ $ make api-stop 4. Please refer to the [FAQ](./FAQ.md) about the problem of displaying exception in the dashboard after adding custom plugins or modifying plugin's schema. -5. If writing an back end E2E test, refer to the [Back End E2E Writing Guide](./back-end-e2e.md) +5. If writing an back end E2E test, please refer to the [Back End E2E Writing Guide](./back-end-e2e.md) ### web @@ -75,4 +75,4 @@ $ yarn install $ yarn start ``` -4. If writing an E2E test, refer to the [E2E Writing Guide](./front-end-e2e.md) +4. If writing an front end E2E test, please refer to the [Front End E2E Writing Guide](./front-end-e2e.md) From 929263ecebfc46dd327cdb09cb9563fee1111052 Mon Sep 17 00:00:00 2001 From: Jaycean Date: Thu, 28 Jan 2021 14:40:39 +0800 Subject: [PATCH 06/10] Add note: delete etcd stroe info --- docs/back-end-e2e.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/back-end-e2e.md b/docs/back-end-e2e.md index 542d1b3111..49da4fb422 100644 --- a/docs/back-end-e2e.md +++ b/docs/back-end-e2e.md @@ -72,6 +72,8 @@ This document describes how to use E2E test locally. } ``` +**NOTE:** Sometimes we need to delete the etcd store info. Otherwise, it will make the test failed. + 8. Enter the E2E folder and execute the command to test all E2E test files. ```sh From aca64a6ea3404fcb7854ec4dffacdb16a9ac2477 Mon Sep 17 00:00:00 2001 From: Jaycean Date: Thu, 28 Jan 2021 19:26:22 +0800 Subject: [PATCH 07/10] add start with docker-compose --- docs/back-end-e2e.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/back-end-e2e.md b/docs/back-end-e2e.md index 49da4fb422..7ce8b69753 100644 --- a/docs/back-end-e2e.md +++ b/docs/back-end-e2e.md @@ -19,6 +19,8 @@ This document describes how to use E2E test locally. +## Start with source code + 1. To run back end E2E test, please start the `manager-api`, `admin-api`, etcd and upstream node at first. 2. To start the `manager-api` project locally, please refer to [develop](./develop.md) web section. @@ -30,7 +32,7 @@ This document describes how to use E2E test locally. 5. To start the upstream node locally, please install docker in the local environment and execute the command. ```sh - docker run -d --name upstream -v /(Your apisix-dashboard folder path)/api/test/docker/upstream.conf:/etc/nginx/conf.d/default.conf:ro -p 80:80 -p 1980:1980 -p 1981:1981 -p 1982:1982 -p 1983:1983 -p 1984:1984 johz/upstream:v2.0 + docker run -d --name upstream -v /(Your apisix-dashboard folder path)/api/test/docker/upstream.conf:/etc/nginx/conf.d/default.conf:ro -p 80:80 -p 1980:1980 -p 1981:1981 -p 1982:1982 -p 1983:1983 -p 1984:1984 --ip 172.16.238.20 johz/upstream:v2.0 ``` 6. After all the services are started, you can start the back-end E2E test. @@ -72,18 +74,35 @@ This document describes how to use E2E test locally. } ``` +## Start with docker-compose + +1. [install docker-compose](https://docs.docker.com/compose/install/) + +2. Use docker-compose to run services such as `manager-api`, `admin-api`, etcd and upstream node. run the command. + + ```sh + cd /(Your apisix-dashboard folder path)/api/test/docker + docker-compose up -d + ``` + +## Start test + +1. After all the services are started, you can start the back-end E2E test. + **NOTE:** Sometimes we need to delete the etcd store info. Otherwise, it will make the test failed. -8. Enter the E2E folder and execute the command to test all E2E test files. +2. Enter the E2E folder and execute the command to test all E2E test files. ```sh cd /(Your apisix-dashboard folder path)/api/test/e2e go test -v ``` -9. You can also do E2E test on a single file. +3. You can also do E2E test on a single file. ```sh cd /(Your apisix-dashboard folder path)/api/test/e2e go test -v E2E-test-file.go base.go ``` + + From 36ec8624801341c8879fdbbfd6eba87e0066e003 Mon Sep 17 00:00:00 2001 From: Jaycean Date: Thu, 28 Jan 2021 19:41:15 +0800 Subject: [PATCH 08/10] Modify format --- docs/back-end-e2e.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/back-end-e2e.md b/docs/back-end-e2e.md index 7ce8b69753..bdc86e1c13 100644 --- a/docs/back-end-e2e.md +++ b/docs/back-end-e2e.md @@ -104,5 +104,3 @@ This document describes how to use E2E test locally. cd /(Your apisix-dashboard folder path)/api/test/e2e go test -v E2E-test-file.go base.go ``` - - From f975342da65c695a5888b04ded78ad615c6c94ae Mon Sep 17 00:00:00 2001 From: Jaycean Date: Fri, 29 Jan 2021 09:12:51 +0800 Subject: [PATCH 09/10] Update document --- docs/back-end-e2e.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/back-end-e2e.md b/docs/back-end-e2e.md index bdc86e1c13..b7f62746e8 100644 --- a/docs/back-end-e2e.md +++ b/docs/back-end-e2e.md @@ -21,23 +21,23 @@ This document describes how to use E2E test locally. ## Start with source code -1. To run back end E2E test, please start the `manager-api`, `admin-api`, etcd and upstream node at first. +1. To run back end E2E test, please start the `manager-api`, `apisix`, `etcd` and `upstream-node` at first. 2. To start the `manager-api` project locally, please refer to [develop](./develop.md) web section. 3. To start the etcd locally, please refer to [etcd start](https://github.com/apache/apisix/blob/master/doc/install-dependencies.md) web section. -4. To start the `admin-api` project locally, please refer to [admin-api start](https://github.com/apache/apisix#get-started) web section. +4. To start the `apisix` project locally, please refer to [apisix start](https://github.com/apache/apisix#get-started) web section. -5. To start the upstream node locally, please install docker in the local environment and execute the command. +5. To start the `upstream-node` locally, please install docker in the local environment and execute the command. ```sh - docker run -d --name upstream -v /(Your apisix-dashboard folder path)/api/test/docker/upstream.conf:/etc/nginx/conf.d/default.conf:ro -p 80:80 -p 1980:1980 -p 1981:1981 -p 1982:1982 -p 1983:1983 -p 1984:1984 --ip 172.16.238.20 johz/upstream:v2.0 + docker run -d --name upstream -v /(Your apisix-dashboard folder path)/api/test/docker/upstream.conf:/etc/nginx/conf.d/default.conf:ro -p 80:80 -p 1980:1980 -p 1981:1981 -p 1982:1982 -p 1983:1983 -p 1984:1984 johz/upstream:v2.0 ``` 6. After all the services are started, you can start the back-end E2E test. -7. The upstream node IP is temporarily changed to the local IP address. After the test, it should be changed to GitHub upstream node IP. If the test case does not involve the upstream node, it does not need to be modified. +7. The `upstream-node` IP is temporarily changed to the local IP address. After the test, it should be changed to GitHub upstream node IP. If the test case does not involve the upstream node, it does not need to be modified. ```sh # Local E2E test create route example @@ -78,13 +78,25 @@ This document describes how to use E2E test locally. 1. [install docker-compose](https://docs.docker.com/compose/install/) -2. Use docker-compose to run services such as `manager-api`, `admin-api`, etcd and upstream node. run the command. +2. Use docker-compose to run services such as `manager-api`, `apisix`, `etcd` and `upstream-node`, run the command. ```sh cd /(Your apisix-dashboard folder path)/api/test/docker docker-compose up -d ``` +3. When you use `docker-compose` to run the local E2E test and need to update the main code, you need to execute the command to close the cluster. + + ```sh + cd /(Your apisix-dashboard folder path)/api/test/docker + # -v: Remove links to mount volumes and volumes + docker-compose down -v + # If you don't want to remove the link between mount volume and volume, you can use + docker-compose stop [serviceName] + ``` + +4. Then you need to delete the image of the `manage-api`, rebuild the image of the `manage-api`, and start the cluster after the image is successfully built. + ## Start test 1. After all the services are started, you can start the back-end E2E test. From 88d04ba05b399b912456e4c2179d863062d856af Mon Sep 17 00:00:00 2001 From: Jaycean Date: Fri, 29 Jan 2021 09:16:51 +0800 Subject: [PATCH 10/10] update doc --- docs/back-end-e2e.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/back-end-e2e.md b/docs/back-end-e2e.md index b7f62746e8..a1d2362a01 100644 --- a/docs/back-end-e2e.md +++ b/docs/back-end-e2e.md @@ -78,7 +78,7 @@ This document describes how to use E2E test locally. 1. [install docker-compose](https://docs.docker.com/compose/install/) -2. Use docker-compose to run services such as `manager-api`, `apisix`, `etcd` and `upstream-node`, run the command. +2. Use `docker-compose` to run services such as `manager-api`, `apisix`, `etcd` and `upstream-node`, run the command. ```sh cd /(Your apisix-dashboard folder path)/api/test/docker