-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests) test the artifact outputs (#7)
* feat(tests) first pass at testing the resulting Kong asset * misc(tests) re-organize how to setup and run the tests * misc(tests) Makefile refactor and asset naming / versioning * feat(tests) test ubuntu artifact * tests(centos) test the centos package
- Loading branch information
Showing
8 changed files
with
209 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM alpine:3.6 | ||
|
||
ARG KONG_VERSION="0.0.0" | ||
ARG KONG_PACKAGE_NAME="kong-community-edition" | ||
|
||
LABEL maintainer="Kong Core Team <[email protected]>" | ||
|
||
RUN apk add --no-cache --virtual .build-deps tar ca-certificates \ | ||
&& apk add --no-cache libgcc openssl pcre perl tzdata bash | ||
|
||
COPY output/${KONG_PACKAGE_NAME}-${KONG_VERSION}.apk.tar.gz kong.apk.tar.gz | ||
|
||
RUN tar -xzf kong.apk.tar.gz -C /tmp \ | ||
&& rm -f kong.tar.gz \ | ||
&& cp -R /tmp/usr / \ | ||
&& rm -rf /tmp/usr \ | ||
&& cp -R /tmp/etc / \ | ||
&& rm -rf /tmp/etc \ | ||
&& apk del .build-deps | ||
|
||
COPY test/docker-entrypoint.sh /docker-entrypoint.sh | ||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
|
||
EXPOSE 8000 8443 8001 8444 | ||
|
||
STOPSIGNAL SIGTERM | ||
|
||
CMD ["kong", "docker-start"] |
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,20 @@ | ||
FROM centos:7 | ||
|
||
ARG KONG_VERSION="0.0.0" | ||
ARG KONG_PACKAGE_NAME="kong-community-edition" | ||
ARG RESTY_IMAGE_TAG="7" | ||
|
||
RUN yum -y install perl openssl | ||
|
||
COPY output/${KONG_PACKAGE_NAME}-${KONG_VERSION}.el${RESTY_IMAGE_TAG}.noarch.rpm /kong.rpm | ||
|
||
RUN rpm -i kong.rpm | ||
|
||
COPY test/docker-entrypoint.sh /docker-entrypoint.sh | ||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
|
||
EXPOSE 8000 8443 8001 8444 | ||
|
||
STOPSIGNAL SIGTERM | ||
|
||
CMD ["kong", "docker-start"] |
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,20 @@ | ||
FROM ubuntu:xenial | ||
|
||
ARG KONG_VERSION="0.0.0" | ||
ARG KONG_PACKAGE_NAME="kong-community-edition" | ||
ARG RESTY_IMAGE_TAG="xenial" | ||
|
||
RUN apt-get update && apt-get install -y perl openssl | ||
|
||
COPY output/${KONG_PACKAGE_NAME}-${KONG_VERSION}.${RESTY_IMAGE_TAG}.all.deb /kong.deb | ||
|
||
RUN dpkg -i kong.deb | ||
|
||
COPY test/docker-entrypoint.sh /docker-entrypoint.sh | ||
ENTRYPOINT ["/docker-entrypoint.sh"] | ||
|
||
EXPOSE 8000 8443 8001 8444 | ||
|
||
STOPSIGNAL SIGTERM | ||
|
||
CMD ["kong", "docker-start"] |
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,19 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
export KONG_NGINX_DAEMON=off | ||
|
||
if [[ "$1" == "kong" ]]; then | ||
PREFIX=${KONG_PREFIX:=/usr/local/kong} | ||
mkdir -p $PREFIX | ||
|
||
if [[ "$2" == "docker-start" ]]; then | ||
kong prepare -p $PREFIX | ||
|
||
exec /usr/local/openresty/nginx/sbin/nginx \ | ||
-p $PREFIX \ | ||
-c nginx.conf | ||
fi | ||
fi | ||
|
||
exec "$@" |
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,68 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [ "$RESTY_IMAGE_BASE" == "alpine" ]; then | ||
DOCKER_FILE="Dockerfile.alpine" | ||
elif [ "$RESTY_IMAGE_BASE" == "ubuntu" ]; then | ||
DOCKER_FILE="Dockerfile.ubuntu" | ||
elif [ "$RESTY_IMAGE_BASE" == "centos" ]; then | ||
DOCKER_FILE="Dockerfile.centos" | ||
else | ||
echo "Unrecognized base image $RESTY_IMAGE_BASE" | ||
exit 1 | ||
fi | ||
|
||
microk8s.docker build --build-arg RESTY_IMAGE_TAG=$RESTY_IMAGE_TAG -f test/$DOCKER_FILE -t localhost:32000/kong . | ||
|
||
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:32000)" != 200 ]]; do | ||
echo "waiting for K8s registry to be ready" | ||
sleep 5; | ||
done | ||
|
||
microk8s.docker push localhost:32000/kong | ||
|
||
helm init --wait | ||
helm install --name kong --set image.repository=localhost,image.tag=32000/kong stable/kong | ||
|
||
microk8s.kubectl get deployment kong-kong | tail -n +2 | awk '{print $5}' | ||
|
||
while [[ "$(microk8s.kubectl get deployment kong-kong | tail -n +2 | awk '{print $5}')" != 1 ]]; do | ||
echo "waiting for Kong to be ready" | ||
sleep 5; | ||
done | ||
|
||
HOST="https://$(microk8s.kubectl get nodes --namespace default -o jsonpath='{.items[0].status.addresses[0].address}')" | ||
echo $HOST | ||
ADMIN_PORT=$(microk8s.kubectl get svc --namespace default kong-kong-admin -o jsonpath='{.spec.ports[0].nodePort}') | ||
echo $ADMIN_PORT | ||
PROXY_PORT=$(microk8s.kubectl get svc --namespace default kong-kong-proxy -o jsonpath='{.spec.ports[0].nodePort}') | ||
echo $PROXY_PORT | ||
CURL_COMMAND="curl -s -o /dev/null -w %{http_code} --insecure " | ||
echo $CURL_COMMAND | ||
|
||
if ! [ `$CURL_COMMAND$HOST:$ADMIN_PORT` == "200" ]; then | ||
echo "Can't invoke admin API" | ||
exit 1 | ||
fi | ||
|
||
echo "Admin API passed" | ||
|
||
RANDOM_API_NAME="randomapiname" | ||
RESPONSE=`$CURL_COMMAND -d "name=$RANDOM_API_NAME&hosts=$RANDOM_API_NAME.com&upstream_url=http://mockbin.org" $HOST:$ADMIN_PORT/apis/` | ||
if ! [ $RESPONSE == "201" ]; then | ||
echo "Can't create API" | ||
exit 1 | ||
fi | ||
|
||
sleep 3 | ||
|
||
# Proxy Tests | ||
RESPONSE=`$CURL_COMMAND -H "Host: $RANDOM_API_NAME.com" $HOST:$PROXY_PORT/request` | ||
if ! [ $RESPONSE == "200" ]; then | ||
echo "Can't invoke API on HTTP" | ||
exit 1 | ||
fi | ||
|
||
echo "Proxy and Admin smoke tests passed" | ||
exit 0 |