-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add e2e test for field hosts in
route
api (#612)
* feat: ETCD cluster and APISIX cluster for CI * feat: add test cases * feat: add upstream service in docker compose * fix: comment * test: add test cases * fix: code format * test: add ci * fix ci * fix ci * fix ci * fix: remove consumer test * test: sleep for sync * test: e2e as an independent subproject * fix CI error * test: run docker * fix: remove json schema generate script in docker build * fix: check host and hosts config together * fix ci * test: add test cases for `host` in route * remove useless code * fix: using relative path to read conf (#617) * fix: using relative path * fix path * fix path * fix conf path * fix ci error * fix etcd ip * fix: code format * run backend e2e test ci on v2 branch * fix: code format * fix: code format * fix: CI error * test: remove deploy CI again * remove useless codes * fix: go fmt * test: don't use `go fmt` * fix: code format * fix: var name * fix lint * fix CI error * debug * fix: docker container name * fix CI error * fix CI error * test: add more test cases * fix CI error * chore: remove useless code * fix: go fmt * fix: refactor test code * fix: check body * fix small issue * fix: update docker compose * fix CI * test * test * test: build image first * test: revert subnet ip in docker compose * fix by review * fix: docker compose * test: add test cases * fix: remove useless code * fix: code format * test: code format
- Loading branch information
Showing
15 changed files
with
887 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Backend E2E Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
- v2.0 | ||
|
||
jobs: | ||
run-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: install runtime | ||
run: | | ||
sudo apt-get update | ||
sudo add-apt-repository ppa:longsleep/golang-backports | ||
sudo apt update | ||
export GO111MOUDULE=on | ||
sudo apt install golang-1.14-go | ||
- name: run docker compose | ||
working-directory: ./api/test/docker | ||
run: | | ||
docker-compose up -d | ||
sleep 5 | ||
docker logs docker_managerapi_1 | ||
- name: run test | ||
working-directory: ./api/test/e2e | ||
run: | | ||
go test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# 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. | ||
# | ||
# If you want to set the specified configuration value, you can set the new | ||
# in this file. For example if you want to specify the etcd address: | ||
# | ||
etcd: | ||
host: | ||
- "http://172.16.238.10:2379" | ||
- "http://172.16.238.11:2379" | ||
- "http://172.16.238.12:2379" | ||
|
||
apisix: | ||
admin_key: | ||
- | ||
name: "admin" | ||
key: edd1c9f034335f136f87ad84b625c8f1 # using fixed API token has security risk, please | ||
# update it when you deploy to production environment | ||
role: admin | ||
|
||
allow_admin: # http://nginx.org/en/docs/http/ngx_http_access_module.html#allow | ||
- 0.0.0.0/0 # If we don't set any IP list, then any IP access is allowed by default. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
# | ||
# 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. | ||
# | ||
version: "3.6" | ||
|
||
services: | ||
node1: | ||
image: quay.io/coreos/etcd:v3.4.0 | ||
ports: | ||
- "2379:2379" | ||
expose: | ||
- 2379 | ||
- 2380 | ||
networks: | ||
apisix_dashboard_e2e: | ||
ipv4_address: 172.16.238.10 | ||
environment: | ||
- ETCDCTL_API=3 | ||
command: | ||
- /usr/local/bin/etcd | ||
- --data-dir=/etcd-data | ||
- --name | ||
- node1 | ||
- --initial-advertise-peer-urls | ||
- http://172.16.238.10:2380 | ||
- --listen-peer-urls | ||
- http://0.0.0.0:2380 | ||
- --advertise-client-urls | ||
- http://172.16.238.10:2379 | ||
- --listen-client-urls | ||
- http://0.0.0.0:2379 | ||
- --initial-cluster | ||
- node1=http://172.16.238.10:2380,node2=http://172.16.238.11:2380,node3=http://172.16.238.12:2380 | ||
- --initial-cluster-state | ||
- new | ||
- --initial-cluster-token | ||
- docker-etcd | ||
|
||
node2: | ||
image: quay.io/coreos/etcd:v3.4.0 | ||
networks: | ||
apisix_dashboard_e2e: | ||
ipv4_address: 172.16.238.11 | ||
environment: | ||
- ETCDCTL_API=3 | ||
expose: | ||
- 2379 | ||
- 2380 | ||
command: | ||
- /usr/local/bin/etcd | ||
- --data-dir=/etcd-data | ||
- --name | ||
- node2 | ||
- --initial-advertise-peer-urls | ||
- http://172.16.238.11:2380 | ||
- --listen-peer-urls | ||
- http://0.0.0.0:2380 | ||
- --advertise-client-urls | ||
- http://172.16.238.11:2379 | ||
- --listen-client-urls | ||
- http://0.0.0.0:2379 | ||
- --initial-cluster | ||
- node1=http://172.16.238.10:2380,node2=http://172.16.238.11:2380,node3=http://172.16.238.12:2380 | ||
- --initial-cluster-state | ||
- new | ||
- --initial-cluster-token | ||
- docker-etcd | ||
|
||
node3: | ||
image: quay.io/coreos/etcd:v3.4.0 | ||
networks: | ||
apisix_dashboard_e2e: | ||
ipv4_address: 172.16.238.12 | ||
environment: | ||
- ETCDCTL_API=3 | ||
expose: | ||
- 2379 | ||
- 2380 | ||
command: | ||
- /usr/local/bin/etcd | ||
- --data-dir=/etcd-data | ||
- --name | ||
- node3 | ||
- --initial-advertise-peer-urls | ||
- http://172.16.238.12:2380 | ||
- --listen-peer-urls | ||
- http://0.0.0.0:2380 | ||
- --advertise-client-urls | ||
- http://172.16.238.12:2379 | ||
- --listen-client-urls | ||
- http://0.0.0.0:2379 | ||
- --initial-cluster | ||
- node1=http://172.16.238.10:2380,node2=http://172.16.238.11:2380,node3=http://172.16.238.12:2380 | ||
- --initial-cluster-state | ||
- new | ||
- --initial-cluster-token | ||
- docker-etcd | ||
|
||
upstream: | ||
image: johz/upstream:v2.0 | ||
restart: always | ||
volumes: | ||
- ./upstream.conf:/etc/nginx/conf.d/default.conf:ro | ||
ports: | ||
- '80:80/tcp' | ||
- '1980:1980/tcp' | ||
- '1981:1981/tcp' | ||
- '1982:1982/tcp' | ||
- '1983:1983/tcp' | ||
- '1984:1984/tcp' | ||
networks: | ||
apisix_dashboard_e2e: | ||
ipv4_address: 172.16.238.20 | ||
|
||
apisix: | ||
image: apache/apisix:dev | ||
restart: always | ||
volumes: | ||
- ./apisix_config.yaml:/usr/local/apisix/conf/config.yaml:ro | ||
depends_on: | ||
- node1 | ||
- node2 | ||
- node3 | ||
ports: | ||
- '9080:9080/tcp' | ||
- '9443:9443/tcp' | ||
networks: | ||
apisix_dashboard_e2e: | ||
ipv4_address: 172.16.238.30 | ||
|
||
apisix2: | ||
image: apache/apisix:dev | ||
restart: always | ||
volumes: | ||
- ./apisix_config.yaml:/usr/local/apisix/conf/config.yaml:ro | ||
depends_on: | ||
- node1 | ||
- node2 | ||
- node3 | ||
ports: | ||
- '9081:9080/tcp' | ||
networks: | ||
apisix_dashboard_e2e: | ||
ipv4_address: 172.16.238.31 | ||
|
||
managerapi: | ||
build: | ||
context: ../../ | ||
dockerfile: Dockerfile | ||
restart: always | ||
volumes: | ||
- ./manager-api-conf.json:/go/manager-api/conf.json:ro | ||
depends_on: | ||
- node1 | ||
- node2 | ||
- node3 | ||
ports: | ||
- '8080:8080/tcp' | ||
networks: | ||
apisix_dashboard_e2e: | ||
ipv4_address: 172.16.238.40 | ||
|
||
networks: | ||
apisix_dashboard_e2e: | ||
driver: bridge | ||
ipam: | ||
driver: default | ||
config: | ||
- | ||
subnet: 172.16.238.0/24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"conf": { | ||
"syslog": { | ||
"host": "127.0.0.1" | ||
}, | ||
"listen": { | ||
"host": "0.0.0.0", | ||
"port": 8080 | ||
}, | ||
"dag-lib-path": "", | ||
"etcd": { | ||
"endpoints": "172.16.238.10:2379,172.16.238.11:2379,172.16.238.12:2379" | ||
} | ||
}, | ||
"authentication": { | ||
"session": { | ||
"secret": "secret", | ||
"expireTime": 3600 | ||
}, | ||
"user": [ | ||
{ | ||
"username": "admin", | ||
"password": "admin" | ||
}, | ||
{ | ||
"username": "user", | ||
"password": "user" | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.