-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_k8s.bash
72 lines (54 loc) · 1.76 KB
/
run_k8s.bash
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
#!/bin/bash
set -Eeuo pipefail
source _.bash
bats k8s/lint.bats
declare -A ascii_arts=(
[monolith]="
__ __ _ _ _ _
| \/ | | | (_) | | | |
| \ / | ___ _ __ ___ | | _ | |_ | |__
| |\/| | / _ \ | '_ \ / _ \ | | | | | __| | '_ \
| | | | | (_) | | | | | | (_) | | | | | | |_ | | | |
|_| |_| \___/ |_| |_| \___/ |_| |_| \__| |_| |_|
"
[microservices]="
__ __ _ _
| \/ | (_) (_)
| \ / | _ ___ _ __ ___ ___ ___ _ __ __ __ _ ___ ___ ___
| |\/| | | | / __| | '__| / _ \ / __| / _ \ | '__| \ \ / / | | / __| / _ \ / __|
| | | | | | | (__ | | | (_) | \__ \ | __/ | | \ V / | | | (__ | __/ \__ \
|_| |_| |_| \___| |_| \___/ |___/ \___| |_| \_/ |_| \___| \___| |___/
"
)
export ROCKETCHAT_HOST="bats.rocket.chat"
run_test() {
local type="${1?}"
echo "${ascii_arts[$type]}"
declare -g ip=
local fails=0
while [[ -z $ip ]]; do
if ! ip="$(
\kubectl -n kube-system get svc traefik \
--output "jsonpath={.status.loadBalancer.ingress[0].ip}"
)" || [[ -z "$ip" ]]; then
: $((fails++))
fi
if ((fails == 10)); then
\echo "[ERROR] load balancer IP not found"
exit 1
fi
sleep 10
done
export ROCKETCHAT_URL="http://$ip"
bats pre k8s/$type.bats
bats 'pre,post' ./api_basic/api.bats
bats post k8s/$type.bats
}
if [[ -n ${1:-} ]]; then
echo "Running only $1 tests"
run_test "$1"
exit $?
fi
for type in monolith microservices; do
run_test $type
done