From 95789376a33b645cf0ed8718796ada77da6e8552 Mon Sep 17 00:00:00 2001 From: Zeping Bai Date: Mon, 29 Nov 2021 12:02:04 +0800 Subject: [PATCH] ci: clean up the E2E test environment (#2225) --- api/test/docker/docker-compose.yaml | 143 +++++++++++----------------- api/test/docker/upstream.conf | 55 ++++++++--- 2 files changed, 100 insertions(+), 98 deletions(-) diff --git a/api/test/docker/docker-compose.yaml b/api/test/docker/docker-compose.yaml index 8403efcd99..7473e69952 100644 --- a/api/test/docker/docker-compose.yaml +++ b/api/test/docker/docker-compose.yaml @@ -17,8 +17,19 @@ version: "3.6" services: - node1: - image: gcr.io/etcd-development/etcd:v3.4.0 + etcd1: + image: bitnami/etcd:3.5.1 + environment: + - ALLOW_NONE_AUTHENTICATION=yes + - ETCD_DATA_DIR=/etcd-data + - ETCD_NAME=etcd1 + - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://172.16.238.10:2380 + - ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380 + - ETCD_ADVERTISE_CLIENT_URLS=http://172.16.238.10:2379 + - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 + - ETCD_INITIAL_CLUSTER=etcd1=http://172.16.238.10:2380,etcd2=http://172.16.238.11:2380,etcd3=http://172.16.238.12:2380 + - ETCD_INITIAL_CLUSTER_STATE=new + - ETCD_INITIAL_CLUSTER_TOKEN=docker-etcd ports: - "2379:2379" expose: @@ -27,93 +38,52 @@ services: 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: gcr.io/etcd-development/etcd:v3.4.0 - networks: - apisix_dashboard_e2e: - ipv4_address: 172.16.238.11 + etcd2: + image: bitnami/etcd:3.5.1 environment: - - ETCDCTL_API=3 + - ALLOW_NONE_AUTHENTICATION=yes + - ETCD_DATA_DIR=/etcd-data + - ETCD_NAME=etcd2 + - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://172.16.238.11:2380 + - ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380 + - ETCD_ADVERTISE_CLIENT_URLS=http://172.16.238.11:2379 + - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 + - ETCD_INITIAL_CLUSTER=etcd1=http://172.16.238.10:2380,etcd2=http://172.16.238.11:2380,etcd3=http://172.16.238.12:2380 + - ETCD_INITIAL_CLUSTER_STATE=new + - ETCD_INITIAL_CLUSTER_TOKEN=docker-etcd 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: gcr.io/etcd-development/etcd:v3.4.0 networks: apisix_dashboard_e2e: - ipv4_address: 172.16.238.12 + ipv4_address: 172.16.238.11 + + etcd3: + image: bitnami/etcd:3.5.1 environment: - - ETCDCTL_API=3 + - ALLOW_NONE_AUTHENTICATION=yes + - ETCD_DATA_DIR=/etcd-data + - ETCD_NAME=etcd3 + - ETCD_INITIAL_ADVERTISE_PEER_URLS=http://172.16.238.12:2380 + - ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380 + - ETCD_ADVERTISE_CLIENT_URLS=http://172.16.238.12:2379 + - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 + - ETCD_INITIAL_CLUSTER=etcd1=http://172.16.238.10:2380,etcd2=http://172.16.238.11:2380,etcd3=http://172.16.238.12:2380 + - ETCD_INITIAL_CLUSTER_STATE=new + - ETCD_INITIAL_CLUSTER_TOKEN=docker-etcd 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 + networks: + apisix_dashboard_e2e: + ipv4_address: 172.16.238.12 upstream: image: johz/upstream:v2.0 restart: always volumes: - - ./upstream.conf:/etc/nginx/conf.d/default.conf:ro + - ./upstream.conf:/usr/local/openresty/nginx/conf/nginx.conf:ro ports: - '80:80/tcp' - '1980:1980/tcp' @@ -121,6 +91,8 @@ services: - '1982:1982/tcp' - '1983:1983/tcp' - '1984:1984/tcp' + - '1991:1991/tcp' + - '1992:1992/udp' networks: apisix_dashboard_e2e: ipv4_address: 172.16.238.20 @@ -147,7 +119,7 @@ services: apisix: hostname: apisix_server1 - image: apache/apisix:2.10.0-alpine + image: apache/apisix:2.10.2-alpine restart: always volumes: - ./apisix_config.yaml:/usr/local/apisix/conf/config.yaml:ro @@ -155,9 +127,9 @@ services: - ../certs/apisix.key:/usr/local/apisix/certs/apisix.key:ro - ./apisix_logs:/usr/local/apisix/logs depends_on: - - node1 - - node2 - - node3 + - etcd1 + - etcd2 + - etcd3 ports: - '9080:9080/tcp' - '9090:9090/tcp' @@ -174,16 +146,16 @@ services: apisix2: hostname: apisix_server2 - image: apache/apisix:2.7-alpine + image: apache/apisix:2.10.2-alpine restart: always volumes: - ./apisix_config2.yaml:/usr/local/apisix/conf/config.yaml:ro - ../certs/apisix.crt:/usr/local/apisix/certs/apisix.crt:ro - ../certs/apisix.key:/usr/local/apisix/certs/apisix.key:ro depends_on: - - node1 - - node2 - - node3 + - etcd1 + - etcd2 + - etcd3 ports: - '9081:9080/tcp' networks: @@ -199,9 +171,9 @@ services: - ../../conf/conf.yaml:/go/manager-api/conf/conf.yaml:ro - ../testdata:/go/manager-api/testdata depends_on: - - node1 - - node2 - - node3 + - etcd1 + - etcd2 + - etcd3 ports: - '9000:9000/tcp' networks: @@ -225,5 +197,4 @@ networks: ipam: driver: default config: - - - subnet: 172.16.238.0/24 + - subnet: 172.16.238.0/24 diff --git a/api/test/docker/upstream.conf b/api/test/docker/upstream.conf index ff223b4afb..db0518ac69 100644 --- a/api/test/docker/upstream.conf +++ b/api/test/docker/upstream.conf @@ -15,23 +15,35 @@ # limitations under the License. # -log_format main '$remote_addr - $remote_user [$time_local] $request "$status" $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" "$request_time" "$upstream_response_time" '; +pcre_jit on; -lua_package_path "/usr/local/openresty/nginx/conf/lua/?.lua;;"; +events { + worker_connections 1024; +} -server { - listen 80; - server_name localhost; +http { + include mime.types; + default_type application/octet-stream; - access_log off; + log_format main '$remote_addr - $remote_user [$time_local] $request "$status" $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" "$request_time" "$upstream_response_time" '; + lua_package_path "/usr/local/openresty/nginx/conf/lua/?.lua;;"; - location / { - default_type text/html; - content_by_lua_block { - ngx.say(ngx.var.uri) + sendfile on; + keepalive_timeout 65; + + server { + listen 80; + server_name localhost; + + access_log off; + + location / { + default_type text/html; + content_by_lua_block { + ngx.say(ngx.var.uri) + } } } -} server { listen 1980; @@ -39,7 +51,6 @@ server { listen 1982; listen 5044; - server_tokens off; location / { @@ -67,6 +78,26 @@ server { more_clear_headers Date; } } +} +stream { + server { + listen 1991; + content_by_lua_block { + local sock = ngx.req.socket() + local data = sock:receive() + sock:send(data) + } + } + server { + listen 1992 udp; + + content_by_lua_block { + local sock = ngx.req.socket() + local data = sock:receive() + sock:send(data) + } + } +}