-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathtests.sh
107 lines (77 loc) · 2.19 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
#/usr/bin/env bash
NORMAL=$(tput sgr0)
GREEN=$(
tput setaf 2
tput bold
)
YELLOW=$(tput setaf 3)
RED=$(tput setaf 1)
function red() {
echo -e "$RED$*$NORMAL"
}
function green() {
echo -e "$GREEN$*$NORMAL"
}
function yellow() {
echo -e "$YELLOW$*$NORMAL"
}
kubectl create ns captain-system
rm -rf /tmp/captain-test
git clone https://github.com/alauda/captain-test-charts /tmp/captain-test
cd /tmp/captain-test || exit
## Test chartrepo
yellow "[0] TEST CHARTREPO"
# for mac add a .bak...
sed -i .bak 's/alauda-system/captain-system/g' chartrepo.yaml
kubectl apply -f chartrepo.yaml -n captain-system
until [ $(kubectl get ctr -n captain-system | grep captain-test | awk '{print $3}') == "Synced" ]
do
green "Wating chartrepo to be ready...."
sleep 1
done
yellow "ChartRepo captain-test synced"
## Test false dep
yellow "[1] TEST FALSE DEP"
kubectl apply -f hr/dep/dep.yaml
until kubectl describe hr dep-jenkins |grep "FailedSync" |grep "not found"
do
green "Wating for dep check error ..."
sleep 1
done
## Test basic
yellow "[2] TEST BASIC"
kubectl apply -f hr/basic/basic.yaml
until [ $(kubectl get hr basic-nginx-ingress -o json | jq -r .status.phase) == "Synced" ]
do
green "Wating for hr/basic-nginx-ingress synced..."
sleep 1
done
yellow "HelmRequest basic-nginx-ingress synced"
## Test crd-install
yellow "[3] TEST CRD-INSTALL"
kubectl apply -f hr/crd-cr/cr.yaml
until [ $(kubectl get hr tomcat-crd-install -o json | jq -r .status.phase) == "Synced" ]
do
green "Wating for hr/tomcat-crd-install synced..."
sleep 1
done
yellow "HelmRequest tomcat-crd-install synced..."
# delete the crd
kubectl delete -f hr/crd-cr/cr.yaml
# kubectl delete crd
kubectl delete crd crontabs.stable.example.com
## Test cr install (without CRD)
yellow "[4] TEST ONLY CR INSTALL"
kubectl apply -f hr/bad-cr/bad-cr.yaml
until [ $(kubectl get hr ghost-bad-cr -o json | jq -r .status.phase) == "Failed" ]
do
green "Wating for hr/ghost-bad-cr faild..."
sleep 1
done
yellow "Helmrequest ghost-bad-cr failed..."
kubectl delete ctr captain-test -n captain-system
kubectl delete -f hr/basic/
kubectl delete -f hr/dep/
kubectl delete -f hr/bad-cr
rm -rf /tmp/captain-test