Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
a3a7853
feat: ETCD cluster and APISIX cluster for CI
johzchen Oct 25, 2020
2719106
feat: add test cases
johzchen Oct 27, 2020
72d346d
feat: add upstream service in docker compose
johzchen Oct 27, 2020
cfe992f
fix: comment
johzchen Oct 27, 2020
29baf39
test: add test cases
johzchen Oct 28, 2020
279c9f0
fix: code format
johzchen Oct 28, 2020
837252e
test: add ci
johzchen Oct 29, 2020
45ff22c
fix ci
johzchen Oct 29, 2020
13e6115
fix ci
johzchen Oct 29, 2020
9c0bc0d
fix ci
johzchen Oct 29, 2020
d7f2b7f
fix: remove consumer test
johzchen Oct 29, 2020
699b078
test: sleep for sync
johzchen Oct 29, 2020
ce3a1e1
test: e2e as an independent subproject
johzchen Oct 29, 2020
c78e882
fix CI error
johzchen Oct 29, 2020
0e92420
test: run docker
johzchen Oct 29, 2020
35cfea2
fix: remove json schema generate script in docker build
johzchen Oct 29, 2020
a1496db
fix: check host and hosts config together
johzchen Oct 29, 2020
403fe3c
fix ci
johzchen Oct 29, 2020
cd41a44
test: add test cases for `host` in route
johzchen Oct 29, 2020
d5077e9
remove useless code
johzchen Oct 29, 2020
6667e4f
fix: using relative path to read conf (#617)
nic-chen Oct 28, 2020
df84649
fix conf path
johzchen Oct 29, 2020
c8c9488
fix ci error
johzchen Oct 29, 2020
7f34d39
fix etcd ip
johzchen Oct 29, 2020
bfd7393
fix: code format
johzchen Oct 30, 2020
bf019c6
Merge branch 'v2.0' into e2e-test
johzchen Oct 30, 2020
6637d82
run backend e2e test ci on v2 branch
johzchen Oct 30, 2020
8665571
fix: code format
johzchen Oct 30, 2020
5f1946f
fix: code format
johzchen Oct 30, 2020
d003cd2
fix: CI error
johzchen Oct 30, 2020
33df086
test: remove deploy CI again
johzchen Oct 30, 2020
b37d44a
remove useless codes
johzchen Oct 30, 2020
d934b86
fix: go fmt
johzchen Oct 30, 2020
f4e7eaf
test: don't use `go fmt`
johzchen Oct 30, 2020
2f7dc48
fix: code format
johzchen Oct 30, 2020
5e8bfb1
fix: var name
johzchen Oct 30, 2020
48e7d23
fix lint
johzchen Oct 30, 2020
5cbee07
fix CI error
johzchen Oct 30, 2020
fea0cbe
debug
johzchen Oct 30, 2020
b646565
fix: docker container name
johzchen Oct 30, 2020
b3aa489
fix CI error
johzchen Oct 30, 2020
23d2477
fix CI error
johzchen Oct 30, 2020
7d6116f
test: add more test cases
johzchen Oct 30, 2020
73d7c01
fix CI error
johzchen Oct 30, 2020
ec597ab
chore: remove useless code
johzchen Oct 30, 2020
0b48daf
fix: go fmt
johzchen Oct 30, 2020
574ed83
fix: refactor test code
johzchen Nov 2, 2020
ea99394
fix: check body
johzchen Nov 2, 2020
109f6ef
fix small issue
johzchen Nov 2, 2020
e4ebd73
fix: update docker compose
johzchen Nov 2, 2020
b2fbc01
fix CI
johzchen Nov 2, 2020
a84ec34
test
johzchen Nov 2, 2020
71b6636
test
johzchen Nov 2, 2020
4fddb26
test: build image first
johzchen Nov 2, 2020
c3f4b25
test: revert subnet ip in docker compose
johzchen Nov 2, 2020
bdc92af
fix by review
johzchen Nov 2, 2020
0b4c109
fix: docker compose
johzchen Nov 2, 2020
92e3d02
test: add test cases
johzchen Nov 2, 2020
d76ee2a
fix: remove useless code
johzchen Nov 2, 2020
fda136e
fix: code format
johzchen Nov 2, 2020
c58b375
test: code format
johzchen Nov 2, 2020
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
37 changes: 37 additions & 0 deletions .github/workflows/e2e-test-backend.yml
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
Comment thread
juzhiyuan marked this conversation as resolved.
- 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
2 changes: 1 addition & 1 deletion .github/workflows/test-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

- name: run test
working-directory: ./api
run: go test ./...
run: go test $(go list ./... | grep -v /e2e)

- name: run with custom port
working-directory: ./api
Expand Down
14 changes: 1 addition & 13 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ RUN mkdir -p /go/manager-api \
&& mv /go/src/github.com/apisix/manager-api/entry.sh /go/manager-api/ \
&& mv /go/src/github.com/apisix/manager-api/build-tools/* /go/manager-api/build-tools/ \
&& mv /go/src/github.com/apisix/manager-api/conf/conf_preview.json /go/manager-api/conf.json \
&& mv /go/src/github.com/apisix/manager-api/conf/schema.json /go/manager-api/schema.json \
&& rm -rf /go/src/github.com/apisix/manager-api \
&& rm -rf /etc/localtime \
&& ln -s /usr/share/zoneinfo/Hongkong /etc/localtime \
Expand All @@ -37,13 +38,6 @@ RUN wget https://github.com/api7/dag-to-lua/archive/v1.1.tar.gz \
&& mkdir -p /go/manager-api/dag-to-lua \
&& mv -u ./dag-to-lua-1.1/lib/* /go/manager-api/dag-to-lua/

RUN wget https://github.com/apache/apisix/archive/master.zip \
&& apt-get update && apt-get install zip -y \
&& unzip master.zip \
&& rm -rf /go/manager-api/build-tools/apisix/ \
&& mkdir -p /go/manager-api/build-tools/apisix \
&& mv ./apisix-master/apisix/* /go/manager-api/build-tools/apisix/

FROM alpine:3.11

RUN mkdir -p /go/manager-api \
Expand All @@ -60,12 +54,6 @@ WORKDIR /go/manager-api
COPY --from=build-env /go/manager-api/ /go/manager-api/
COPY --from=build-env /usr/share/zoneinfo/Hongkong /etc/localtime

RUN cd /go/manager-api/build-tools \
&& lua schema-sync.lua > /go/manager-api/schema.json \
&& cd /go/manager-api/ \
&& rm -rf /go/manager-api/build-tools/
ADD ./dist /go/manager-api

EXPOSE 8080

RUN chmod +x ./entry.sh
Expand Down
6 changes: 3 additions & 3 deletions api/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const (
EnvDEV = "dev"
EnvLOCAL = "local"

confPath = "/go/manager-api/conf.json"
schemaPath = "/go/manager-api/schema.json"
confJsonPath = "/go/manager-api/conf.json"
Comment thread
nic-chen marked this conversation as resolved.
schemaPath = "/go/manager-api/schema.json"
)

var (
Expand Down Expand Up @@ -103,7 +103,7 @@ func configurationPath() string {
} else if ENV == EnvLOCAL {
return filepath.Join(filepath.Dir(basePath), "conf.json")
} else {
return confPath
return confJsonPath
}
}

Expand Down
18 changes: 1 addition & 17 deletions api/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@
# limitations under the License.
#

pwd=`pwd`

# config
cp ${pwd}/api/conf/conf_preview.json ${pwd}/conf.json

# export APIX_DAG_LIB_PATH="${pwd}/dag-to-lua-1.1/lib/"
# export APIX_ETCD_ENDPOINTS="127.0.0.1:2379"

export SYSLOG_HOST=127.0.0.1

if [[ "$unamestr" == 'Darwin' ]]; then
sed -i '' -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
else
sed -i -e "s%#syslogAddress#%`echo $SYSLOG_HOST`%g" ${pwd}/conf.json
fi

cp ${pwd}/conf.json ${pwd}/api/conf/conf.json
export ENV=prod

exec ./manager-api
226 changes: 0 additions & 226 deletions api/go.sum

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions api/internal/handler/route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ func (h *Handler) Update(c droplet.Context) (interface{}, error) {
input.Route.ID = input.ID
}

if input.Route.Host != "" && len(input.Route.Hosts) > 0 {
Comment thread
nic-chen marked this conversation as resolved.
return &data.SpecCodeResponse{StatusCode: http.StatusBadRequest},
fmt.Errorf("only one of host or hosts is allowed")
}

//check depend
if input.ServiceID != "" {
_, err := h.svcStore.Get(input.ServiceID)
Expand Down
35 changes: 35 additions & 0 deletions api/test/docker/apisix_config.yaml
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.
183 changes: 183 additions & 0 deletions api/test/docker/docker-compose.yaml
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
31 changes: 31 additions & 0 deletions api/test/docker/manager-api-conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
Comment thread
nic-chen marked this conversation as resolved.
"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"
},
{
Comment thread
membphis marked this conversation as resolved.
"username": "user",
"password": "user"
}
]
}
}
Loading