-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsystest.sh
226 lines (206 loc) · 7.8 KB
/
systest.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/bin/bash
#
set -u -e
#
# Defaults
readlinkf(){ readlink -f "$1"; }
SCRIPTPATH="$(cd "$(dirname "$(readlinkf "${BASH_SOURCE[@]}")")" ; pwd)"
INSTALL_VARIABLES="(fuel-11|fuel-10|fuel-9.0|fuel-9.1|fuel-9.2|fuel-ccp-k8s)"
USR=$(whoami)
show_help() {
if [ -t 1 ]; then
echo -e "\e[34m### System Tests Script ###\e[0m "
echo -e " "
echo -e " \e[1m -i \e[0m (str) - Specify that you want to install. "
echo -e " Possible options: "
echo -e " \e[33m ${INSTALL_VARIABLES} \e[0m "
echo -e " \e[1m -h \e[0m - Show this help page. "
echo -e " "
echo -e "\e[34m### System Tests Script ###\e[0m "
else
echo "### System Tests Script ### "
echo " "
echo " -i (str) - Specify that you want to install. "
echo " Possible options: "
echo " ${INSTALL_VARIABLES} "
echo " -h - Show this help page. "
echo " "
echo "### System Tests Script ### "
fi
}
getopts_variables() {
while getopts ":i:h" opt; do
case ${opt} in
i)
TO_INSTALL="${OPTARG}"
;;
h)
show_help
exit 0
;;
\?)
if [ -t 1 ]; then
echo -e " "
echo -e " \e[31m Invalid option: -${OPTARG} \e[0m "
echo -e " "
show_help
exit 1
else
echo " "
echo " Invalid option: -${OPTARG} "
echo " "
show_help
exit 1
fi
;;
:)
if [ -t 1 ]; then
echo -e " "
echo -e " \e[31m Option -${OPTARG} requires an argument. \e[0m "
echo -e " "
show_help
exit 1
else
echo " "
echo " Option -${OPTARG} requires an argument. "
echo " "
show_help
exit 1
fi
;;
esac
done
}
check_variables() {
if [[ ! ${TO_INSTALL:-} ]]; then
if [ -t 1 ]; then
echo -e " "
echo -e " \e[31m Error! TO_INSTALL is not set! \e[0m "
echo -e " "
show_help
exit 1
else
echo " "
echo " Error! TO_INSTALL is not set! "
echo " "
show_help
exit 1
fi
else
if [[ "${TO_INSTALL}" =~ ^${INSTALL_VARIABLES}$ ]]; then
if [ -t 1 ]; then
echo -e " "
echo -e " \e[32m You want to install ${TO_INSTALL} \e[0m "
echo -e " "
else
echo " "
echo " You want to install ${TO_INSTALL} "
echo " "
fi
else
if [ -t 1 ]; then
echo -e " "
echo -e " \e[31m Error! Specify that you want to install. \e[0m "
echo -e " "
show_help
exit 1
else
echo " "
echo " Error! Specify that you want to install. "
echo " "
show_help
exit 1
fi
fi
fi
if [[ ! ${POOL_DEFAULT:-} ]]; then
if [ -t 1 ]; then
echo -e " "
echo -e " \e[31m Error! POOL_DEFAULT is not set! Something's wrong with your profile or lab. \e[0m "
echo -e " "
exit 1
else
echo " "
echo " Error! POOL_DEFAULT is not set! Something's wrong with your profile or lab. "
echo " "
exit 1
fi
fi
}
global_and_specific_variables() {
source "${SCRIPTPATH}/testsrc"
}
check_and_cd_fuel_ccp_installer() {
if [ ! -d "${HOME}/fuel-ccp-workspace" ]; then
if [ -t 1 ]; then
echo -e " "
echo -e " \e[31m Error! Directory ${HOME}/fuel-ccp-workspace doesn't exist. \e[0m "
echo -e " "
exit 1
else
echo " "
echo " Error! Directory ${HOME}/fuel-ccp-workspace doesn't exist. "
echo " "
exit 1
fi
fi
if [[ ! ${CCP_INSTALLER_DIR:-} ]]; then
if [ -t 1 ]; then
echo -e " "
echo -e " \e[31m Error! CCP_INSTALLER_DIR is not set! \e[0m "
echo -e " "
exit 1
else
echo " "
echo " Error! CCP_INSTALLER_DIR is not set! "
echo " "
exit 1
fi
else
cd "${CCP_INSTALLER_DIR}"
ec=$?
if [ "${ec}" -gt "0" ]; then
if [ -t 1 ]; then
echo -e " "
echo -e " \e[31m Error! Cannot cd to ${CCP_INSTALLER_DIR} \e[0m "
echo -e " "
exit 1
else
echo " "
echo " Error! Cannot cd to ${CCP_INSTALLER_DIR} "
echo " "
exit 1
fi
fi
fi
}
run_test() {
case ${1} in
fuel-ccp-k8s)
check_and_cd_fuel_ccp_installer
bash -x "${CCP_INSTALLER_DIR}/utils/jenkins/run_k8s_deploy_test.sh"
;;
*)
if [ -t 1 ]; then
echo -e " "
echo -e " \e[33m ATTENTION! Logs will be saved in ${LOGS_DIR} \e[0m "
echo -e " "
sh -x "${FUEL_QA}/utils/jenkins/system_tests.sh" -w "${FUEL_QA}" -j "${USR}-venv" -i "${ISO_PATH}" -V "${VENV_PATH}" -l "${LOGS_DIR}" -o --group="${MY_GROUP}"
else
echo " "
echo " ATTENTION! Logs will be saved in ${LOGS_DIR} "
echo " "
sh -x "${FUEL_QA}/utils/jenkins/system_tests.sh" -w "${FUEL_QA}" -j "${USR}-venv" -i "${ISO_PATH}" -V "${VENV_PATH}" -l "${LOGS_DIR}" -o --group="${MY_GROUP}"
fi
;;
esac
}
### MAIN ###
# first we want to get variable from command line options
getopts_variables "${@}"
# check do we have all critical variables set
check_variables
# then we define global and specific variables
global_and_specific_variables
# run the test
run_test "${TO_INSTALL}"