-
Notifications
You must be signed in to change notification settings - Fork 5
/
e2etest-3-train-ticket.sh
executable file
·114 lines (102 loc) · 3.72 KB
/
e2etest-3-train-ticket.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
108
109
110
111
112
113
114
#!/usr/bin/env bash
# https://kind.sigs.k8s.io/docs/user/ingress/
# https://kind.sigs.k8s.io/docs/user/local-registry/
reg_name='kind-registry'
reg_port='5001'
echo 'start'
echo 'some info'
kind version
kubectl version
kubectl get pods
move2kube version -l
echo 'delete any existing clusters'
kind delete cluster
kind get clusters
echo 'check if local container registry is running'
if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then
echo 'start local container registry'
docker run -d --restart=always -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" registry:2
docker ps -a
fi
echo 'start a new cluster with the proper config'
kind create cluster --config=config.yaml
echo 'apply the ingress controller'
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
echo 'check if the local container registry is connected to the cluster'
if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${reg_name}")" = 'null' ]; then
echo 'connect the local container registry to the cluster'
docker network connect "kind" "${reg_name}"
fi
echo 'wait for ingress controller to come online'
sleep 2
until kubectl wait --namespace ingress-nginx --for=condition=ready pod --selector=app.kubernetes.io/component=controller --timeout=90s; do sleep 1; done
echo $?
echo 'after ingress controller comes online'
kubectl get pods
kubectl get pods --namespace ingress-nginx
echo 'before transforming using move2kube'
rm -rf temp && mkdir temp
cd temp || exit
echo 'clone the train ticket app'
git clone https://github.com/FudanSELab/train-ticket.git
ls
cd train-ticket/ && git status && git checkout 350f62000e6658e0e543730580c599d8558253e7 && git status && cd ..
move2kube plan -s train-ticket || exit
cat m2k.plan
rm m2k.plan
cp ../e2etest-3-train-ticket-m2k.plan m2k.plan
move2kube transform --config ../e2etest-3-train-ticket-m2kconfig.yaml --qa-skip || exit
ls
ls myproject
cd myproject/scripts || exit
echo 'before building images generated by move2kube'
./buildimages.sh
echo 'before pushing images generated by move2kube'
./pushimages.sh
cd ..
echo 'before applying K8s yamls generated by move2kube'
rm deploy/yamls/my-network-networkpolicy.yaml
kubectl apply -f deploy/yamls
sleep 2
kubectl get all
echo 'wait for pods to start'
kubectl wait --for=condition=ready pod --timeout=90s --selector=move2kube.konveyor.io/service=ts-admin-basic-info-service || exit
kubectl get pods
echo 'after admin basic info service pods come online'
kubectl wait --for=condition=ready pod --timeout=90s --selector=move2kube.konveyor.io/service=ts-news-service || exit
kubectl get pods
echo 'after news service pods come online'
kubectl wait --for=condition=ready pod --timeout=90s --selector=move2kube.konveyor.io/service=ts-payment-service || exit
kubectl get pods
echo 'after payment service pods come online'
echo 'before ingress gets assigned an address'
sleep 2
until kubectl wait ingress/myproject --for=jsonpath='status.loadBalancer.ingress[0].hostname'=localhost; do sleep 1; done
kubectl get ingress
echo 'after ingress gets assigned an address'
echo 'before deploying to the kind cluster'
function check_url() {
local status_code
status_code="$(curl -LI "$1" -o /dev/null -w '%{http_code}\n' -s)"
if [[ "$status_code" == '200' ]]; then
echo ✅ "$status_code" "$1"
return 0
fi
echo ❌ "$status_code" "$1"
return 1
}
function all_tests() {
echo 'Running End-to-End tests:'
local passed=0
check_url localhost/ || passed=1
return "$passed"
}
function main() {
if all_tests; then
echo '✅ All tests passed!'
else
echo '❌ Some tests failed!'
fi
}
main | tee -a results.txt
cd ../..