diff --git a/.gitignore b/.gitignore index 2b2d4bff..f53c564f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ kong docker-kong id_rsa.private kong_license.private +*.deb +*.rpm diff --git a/test/kong-tests-compose.yaml b/test/kong-tests-compose.yaml index f0781ca0..aafd254e 100644 --- a/test/kong-tests-compose.yaml +++ b/test/kong-tests-compose.yaml @@ -15,6 +15,8 @@ services: KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong} KONG_PG_USER: ${KONG_PG_USER:-kong} restart: on-failure + networks: + - kong-net kong-migrations-up: image: "${KONG_TEST_IMAGE_NAME:-kong:latest}" @@ -29,6 +31,8 @@ services: KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong} KONG_PG_USER: ${KONG_PG_USER:-kong} restart: on-failure + networks: + - kong-net kong: image: "${KONG_TEST_IMAGE_NAME:-kong:latest}" @@ -40,23 +44,31 @@ services: environment: KONG_ADMIN_ACCESS_LOG: /dev/stdout KONG_ADMIN_ERROR_LOG: /dev/stderr + KONG_PROXY_LISTEN: "0.0.0.0:8000" + KONG_ADMIN_LISTEN: "0.0.0.0:8001" KONG_PLUGINS: "${KONG_PLUGINS:-bundled}" KONG_CASSANDRA_CONTACT_POINTS: db KONG_DATABASE: postgres KONG_PG_DATABASE: ${KONG_PG_DATABASE:-kong} - KONG_PG_HOST: 127.0.0.1 + KONG_PG_HOST: db KONG_PG_PASSWORD: ${KONG_PG_PASSWORD:-kong} KONG_PG_USER: ${KONG_PG_USER:-kong} KONG_PROXY_ACCESS_LOG: /dev/stdout KONG_PROXY_ERROR_LOG: /dev/stderr - network_mode: "host" healthcheck: test: ["CMD", "kong", "health"] interval: 10s timeout: 10s retries: 10 restart: on-failure - + networks: + - kong-net + ports: + - "8000:8000/tcp" + - "127.0.0.1:8001:8001/tcp" + - "8443:8443/tcp" + - "127.0.0.1:8444:8444/tcp" + db: image: postgres:9.5 ports: @@ -80,3 +92,10 @@ services: interval: 5s timeout: 10s retries: 10 + networks: + - kong-net + +networks: + kong-net: + external: false + diff --git a/test/run_tests.sh b/test/run_tests.sh index f78dbbfe..8656f83e 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -13,7 +13,7 @@ fi USE_TTY="-t" test -t 1 && USE_TTY="-it" -for dir in test/tests/*; do +for dir in test/tests/02-*; do msg_test "Running '$dir' tests..." msg_test "======================================================================" diff --git a/test/tests/02-api/Dockerfile.test_runner b/test/tests/02-api/Dockerfile.test_runner deleted file mode 100644 index 8fceaba0..00000000 --- a/test/tests/02-api/Dockerfile.test_runner +++ /dev/null @@ -1,7 +0,0 @@ -FROM python:3.7-stretch - -RUN mkdir /app -COPY requirements.txt /app -WORKDIR /app - -RUN pip install -r requirements.txt diff --git a/test/tests/02-api/down.sh b/test/tests/02-api/down.sh index b6b73286..c3660db5 100644 --- a/test/tests/02-api/down.sh +++ b/test/tests/02-api/down.sh @@ -1,6 +1,3 @@ stop_kong -# update cache image -$UPDATE_CACHE_COMMAND kong/kong-build-tools:test-runner-$TEST_SHA - diff --git a/test/tests/02-api/pytest.ini b/test/tests/02-api/pytest.ini deleted file mode 100644 index dcdf3e12..00000000 --- a/test/tests/02-api/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -log_cli = true \ No newline at end of file diff --git a/test/tests/02-api/requirements.txt b/test/tests/02-api/requirements.txt deleted file mode 100644 index 73499806..00000000 --- a/test/tests/02-api/requirements.txt +++ /dev/null @@ -1,27 +0,0 @@ -atomicwrites==1.4.0 -attrs==20.3.0 -backports.functools-lru-cache==1.6.1 -certifi==2020.11.8 -chardet==3.0.4 -contextlib2==0.6.0.post1 -docopt==0.6.2 -future==0.18.2 -idna==2.10 -importlib-metadata==2.0.0 -jmespath==0.10.0 -more-itertools==8.5.0 -pbr==5.5.1 -pluggy==0.13.1 -py==1.9.0 -PyJWT==1.7.1 -pykwalify==1.7.0 -python-box==5.1.1 -python-dateutil==2.8.1 -PyYAML==5.3.1 -requests==2.25.0 -six==1.15.0 -stevedore==3.2.2 -tavern==0.34.0 -urllib3==1.26.2 -wcwidth==0.2.5 -zipp==3.4.0 diff --git a/test/tests/02-api/run.sh b/test/tests/02-api/run.sh index 09ab3b69..8095c062 100644 --- a/test/tests/02-api/run.sh +++ b/test/tests/02-api/run.sh @@ -1,10 +1,19 @@ -docker run \ - --rm \ - -t --network host \ - -e RESTY_VERSION=$RESTY_VERSION \ - -e KONG_VERSION=$KONG_VERSION \ - -e ADMIN_URI=$KONG_ADMIN_URI \ - -e PROXY_URI=$KONG_PROXY_URI \ - -v $PWD:/app \ - kong/kong-build-tools:test-runner-$TEST_SHA \ - /bin/bash -c "py.test -p no:logging -p no:warnings test_*.tavern.yaml" +set pipefail + +echo "Check admin API is alive" +assert_response "$KONG_ADMIN_URI" "200" + +echo "Create a service" +assert_response "-d name=testservice -d url=http://httpbin.org $KONG_ADMIN_URI/services" "201" + +echo "List services" +assert_response "$KONG_ADMIN_URI/services" "200" + +echo "Create a route" +assert_response "-d name=testroute -d paths=/ $KONG_ADMIN_URI/services/testservice/routes" "201" + +echo "List services" +assert_response "$KONG_ADMIN_URI/services" "200" + +echo "Proxy a request" +assert_response "$KONG_PROXY_URI/anything" "200" diff --git a/test/tests/02-api/up.sh b/test/tests/02-api/up.sh index 4d4c3e18..f05ff8c3 100644 --- a/test/tests/02-api/up.sh +++ b/test/tests/02-api/up.sh @@ -1,9 +1,4 @@ - start_kong wait_kong -# build API tests docker image -$CACHE_COMMAND kong/kong-build-tools:test-runner-$TEST_SHA || \ - docker build -t kong/kong-build-tools:test-runner-$TEST_SHA -f Dockerfile.test_runner . - diff --git a/test/util.sh b/test/util.sh index b40ab521..28906eb2 100644 --- a/test/util.sh +++ b/test/util.sh @@ -42,3 +42,7 @@ wait_kong() { done } +assert_response() { + RES=`curl -s -o /dev/null -w %{http_code} $1` + [ $RES == $2 ] +}