-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.sh
executable file
·85 lines (74 loc) · 2.04 KB
/
test.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
#!/bin/bash
set -o errexit # -e
set -o errtrace # -E
set -o nounset # -u
set -o pipefail
shopt -s inherit_errexit
# ctrl-c
trap "exit 2" SIGINT
trap "exit 3" SIGQUIT
show_context () {
{
kubectl get -A networkpolicies.networking.k8s.io
kubectl get -A pods
kubectl describe -A pods
} | tee "${TMP}/context"
}
fail () {
touch "${TMP}/fail"
exit 0
}
if ! helm upgrade --install app hello --wait
then
show_context
fi
# wait a bit for the network policy to be ready
sleep 5
TMP=/tmp/out
mkdir -p "${TMP}"
clk k8s cert-manager install-local-certificate --client ca-certificates
curl https://hello.localtest.me/ > "${TMP}/out"
if ! grep -q 'Welcome to nginx' "${TMP}/out"
then
echo "Failed to connect to the example"
cat "${TMP}/out"
show_context
fail
fi
kubectl delete --wait networkpolicies.networking.k8s.io ingress-to-app-hello
curl https://hello.localtest.me/ > "${TMP}/out"
if ! grep -q '502 Bad Gateway\|504 Gateway Time-out' "${TMP}/out"
then
echo "Removing the network policy did not block the connection"
cat "${TMP}/out"
show_context
fail
fi
helm upgrade --install app hello --wait
curl https://hello.localtest.me/ > "${TMP}/out"
if ! grep -q 'Welcome to nginx' "${TMP}/out"
then
echo "Putting back the network policy did not restore the connection"
cat "${TMP}/out"
show_context
fail
fi
helm upgrade --install app hello --wait
curl https://hello.localtest.me/somepath/somefile > "${TMP}/out"
if test "$(cat "${TMP}/out")" != "somecontent"
then
echo "The content of the config map is not correct before running the test of reloader"
cat "${TMP}/out"
show_context
fail
fi
sed -i 's/somefile: somecontent/somefile: someothercontent/' hello/templates/configmap.yaml
helm upgrade --install app hello --wait
curl https://hello.localtest.me/somepath/somefile > "${TMP}/out"
if test "$(cat "${TMP}/out")" != "someothercontent"
then
echo "The content of the config map is not correct after running the test of reloader"
cat "${TMP}/out"
show_context
fail
fi