This repository has been archived by the owner on Mar 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtestbox
executable file
·131 lines (121 loc) · 3.41 KB
/
testbox
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
function print_help() {
echo " $0 [command]
Test Toolbox
Available Commands:
minikube [command] download, start, clean
rook_install
build
e2e
lint
unit
codegen
operator-sdk_install
" >&2
}
function wait_condition {
cond=$1
timeout=$2
for ((i=0; i<timeout; i+=5)) do
echo "Waiting for ${i}s condition: \"$cond\""
if eval $cond > /dev/null 2>&1; then echo "Conditon met"; return 0; fi;
sleep 5
kubectl get pods -A
done
echo "Condition timeout"
return 1
}
function minikube_command() {
case "${1:-}" in
download)
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
chmod +x minikube
sudo mkdir -p /usr/local/bin/
sudo install minikube /usr/local/bin/
sudo snap install kubectl --classic
sudo apt-get install conntrack
;;
start)
CHANGE_MINIKUBE_NONE_USER=true sudo -E minikube start --driver=none --kubernetes-version=v1.18.8
sleep 3
;;
clean)
CHANGE_MINIKUBE_NONE_USER=true sudo -E minikube delete
sudo rm -rf /var/lib/rook
;;
*)
print_help
;;
esac
}
function rook_install_command() {
kubectl apply -f deploy/rook-ceph/common.yaml
kubectl apply -f deploy/rook-ceph/operator.yaml
kubectl apply -f deploy/rook-ceph/cluster-test.yaml
wait_condition "kubectl get cephclusters.ceph.rook.io -n rook-ceph | grep Created" 300
kubectl apply -f deploy/rook-ceph/storageclass-test.yaml
kubectl apply -f deploy/rook-ceph/snapshot_crds.yaml
kubectl apply -f deploy/rook-ceph/snapshot-controller-rbac.yaml
kubectl apply -f deploy/rook-ceph/snapshot-controller.yaml
kubectl apply -f deploy/rook-ceph/snapshotclass.yaml
kubectl apply -f deploy/rook-ceph/object-test.yaml
kubectl apply -f deploy/rook-ceph/object-storageclass.yaml
}
function codegen() {
echo "Check go mod verify"
gomodsha=$(sha512sum go.mod)
gosumsha=$(sha512sum go.sum)
go mod verify
if [[ $gomodsha != $(sha512sum go.mod) ]]; then
echo "ERROR: go.mod was modified by 'go mod verify'"
exit 1
fi
if [[ $gosumsha != $(sha512sum go.sum) ]]; then
echo "ERROR: go.sum was modified by 'go mod verify'"
exit 1
fi
echo "Check operator-sdk generate"
operator-sdk generate crds
operator-sdk generate k8s
if [[ $(git status --porcelain 2>/dev/null | wc -l) != 0 ]]; then
echo "ERROR: The source code was modified by 'operator-sdk generate'"
echo "If you haven't committed yet, Please commit and re-run it again"
exit 1
fi
}
case "${1:-}" in
minikube)
minikube_command $2
;;
rook_install)
rook_install_command
;;
operator-sdk_install)
curl -Lo operator-sdk https://github.com/operator-framework/operator-sdk/releases/download/v0.17.1/operator-sdk-v0.17.1-x86_64-linux-gnu
chmod +x operator-sdk && sudo mv operator-sdk /usr/local/bin
;;
build)
operator-sdk build quay.io/tmaxanc/kubevirt-image-service:canary
docker push quay.io/tmaxanc/kubevirt-image-service:canary
;;
lint)
golangci-lint run ./... -v
;;
unit)
go test -v ./pkg/... -ginkgo.v -ginkgo.failFast
;;
codegen)
codegen
;;
e2e)
kubectl create -f ./deploy/namespace.yaml
operator-sdk test local --operator-namespace kis ./e2e --debug --verbose --image quay.io/tmaxanc/kubevirt-image-service:canary
kubectl delete -f ./deploy/namespace.yaml
# Will not be necessary when sdk version goes up
kubectl delete -f ./deploy/role.yaml
kubectl delete -f ./deploy/role_binding.yaml
;;
*)
print_help
;;
esac