Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add back end E2E test document #1381

Merged
merged 10 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions docs/back-end-e2e.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<!--
#
# 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.
juzhiyuan marked this conversation as resolved.
Show resolved Hide resolved

## 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.

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.
nic-chen marked this conversation as resolved.
Show resolved Hide resolved

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
```

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jaycean Since within this step, developers are required to change every single occurrence for IP address of upstream nodes. Cause I believe that we need to cover all test cases even for only few changes. So I'm afraid this is not a rather practical way. How about just guide developers to setup docker-compose environment for local e2e testing? Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use docker-compose to run local e2e testing. when I update the main code, just delete the image of Manager API and let it rebuild. building the image of Manager API only takes a little time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use docker-compose to run local e2e testing. when I update the main code, just delete the image of Manager API and let it rebuild. building the image of Manager API only takes a little time.

@nic-chen yep, from my perspective, yours is much better and even easier. Thanks for sharing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the steps of using docker compose for E2E testing. It's really unfriendly to start the method locally according to the source code, so is this method left for developers to choose, or is it just run with docker compose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good. Using docker-compose for E2E is a better way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jaycean current doc is awesome. Thanks for the update.


```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`, `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.

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
```
liuxiran marked this conversation as resolved.
Show resolved Hide resolved


4 changes: 3 additions & 1 deletion docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)