forked from Kong/docker-kong
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.sh
executable file
·86 lines (72 loc) · 2.12 KB
/
tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
set -e
# Test the proper version was buid
pushd $BASE
version_given="$(grep 'ENV KONG_VERSION' Dockerfile | awk '{print $3}' | tr -d '[:space:]')"
version_built="$(docker run -ti --rm kong-$BASE kong version | tr -d '[:space:]')"
if [[ "$version_given" != "$version_built" ]]; then
echo "Kong version mismatch:";
echo "\tVersion given is $version_given";
echo "\tVersion built is $version_built";
exit 1;
fi
# Test LuaRocks is functional for installing rocks
docker run -ti kong-$BASE /bin/sh -c "luarocks install version"
popd
# Docker swarm test
pushd swarm
docker swarm init
KONG_DOCKER_TAG=kong:1.0 docker stack deploy -c docker-compose.yml kong
until docker ps | grep kong:1.0 | grep -q healthy; do
docker stack ps kong
docker service ps kong_kong
sleep 20
done
KONG_DOCKER_TAG=${KONG_DOCKER_TAG} docker stack deploy -c docker-compose.yml kong
sleep 20
until docker ps | grep ${KONG_DOCKER_TAG}:latest | grep -q healthy; do
docker stack ps kong
docker service ps kong_kong
sleep 20
done
sleep 20
curl -I localhost:8001 | grep 'Server: openresty'
docker stack rm kong
sleep 20
docker swarm leave --force
docker volume prune -f
popd
# Validate Kong is running as the Kong user
pushd compose
docker-compose up -d
until docker-compose ps | grep compose_kong_1 | grep -q "Up"; do sleep 1; done
sleep 20
docker-compose exec kong ps aux | sed -n 2p | grep -q kong
if [ $? -ne 0 ]; then
echo "Kong is not running as the Kong user";
echo "\tRunning instead as ";
docker-compose exec kong ps aux | sed -n 2p
exit 1;
fi
popd
# Run Kong functional tests
git clone https://github.com/Kong/kong.git
pushd kong
git checkout $version_given
popd
pushd kong-build-tools
TEST_HOST='127.0.1.1' KONG_VERSION=$version_given make run_tests
popd
pushd compose
docker-compose stop
KONG_USER=1001 docker-compose up -d
until docker-compose ps | grep compose_kong_1 | grep -q "Up"; do sleep 1; done
sleep 20
docker-compose exec kong ps aux | sed -n 2p | grep -q 1001
if [ $? -ne 0 ]; then
echo "Kong is not running as the overridden 1001 user";
echo "\tRunning instead as ";
docker-compose exec kong ps aux | sed -n 2p
exit 1;
fi
popd