This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 619165a  docs: improve E2E test document (#1381)
619165a is described below

commit 619165a26b426502b6a007198214c9ab0bf0e4b3
Author: JinChen <[email protected]>
AuthorDate: Fri Jan 29 11:15:27 2021 +0800

    docs: improve E2E test document (#1381)
---
 docs/back-end-e2e.md | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++
 docs/develop.md      |   4 +-
 2 files changed, 121 insertions(+), 1 deletion(-)

diff --git a/docs/back-end-e2e.md b/docs/back-end-e2e.md
new file mode 100644
index 0000000..a1d2362
--- /dev/null
+++ b/docs/back-end-e2e.md
@@ -0,0 +1,118 @@
+<!--
+#
+# 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.
+#
+-->
+
+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`, `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 `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.
+
+   ```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": "test",
+        "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": "test",
+        "methods": ["GET"],
+        "hosts": ["test.com"],
+        "status": 1,
+        "upstream": {
+            "nodes": {
+                "172.16.238.20:1981": 1
+            },
+            "type": "roundrobin"
+         }
+    }
+   ```
+
+## 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`, `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.
+
+**NOTE:** Sometimes we need to delete the etcd store info. Otherwise, it will 
make the test failed.
+
+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
+   ```
+
+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
+   ```
diff --git a/docs/develop.md b/docs/develop.md
index a2b2595..110fcb6 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, please refer to the [Back End E2E Writing 
Guide](./back-end-e2e.md)
+
 ### web
 
 1. Go to the `web` directory.
@@ -73,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)

Reply via email to