-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-qgis-test.sh
executable file
·287 lines (221 loc) · 7.19 KB
/
docker-qgis-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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
#!/usr/bin/env bash
set -e
SRCDIR=${CTEST_SOURCE_DIR-/root/QGIS}
cd ${SRCDIR}
# This is needed for `git status` to work, see
# https://github.com/qgis/QGIS/runs/6733585841?check_suite_focus=true#step:13:89
git config --global --add safe.directory ${SRCDIR}
usage() {
echo "Usage; $(basename $0) [<TEST_BATCHNAME>]"
echo "TEST_BATCHNAME can be any of:"
echo " HANA Test the HANA provider"
echo " POSTGRES Test the PostgreSQL provider"
echo " ORACLE Test the Oracle provider"
echo " SQLSERVER Test the SQL Server provider"
echo " ALL_BUT_PROVIDERS Skip all providers tests"
echo " ALL (default) Run all tests"
}
if [ $# -eq 1 ] && [ $1 = "HANA" ]; then
LABELS_TO_RUN="HANA"
RUN_HANA=YES
elif [ $# -eq 1 ] && [ $1 = "POSTGRES" ]; then
LABELS_TO_RUN="POSTGRES"
RUN_POSTGRES=YES
elif [ $# -eq 1 ] && [ $1 = "ORACLE" ]; then
LABELS_TO_RUN="ORACLE"
RUN_ORACLE=YES
elif [ $# -eq 1 ] && [ $1 = "SQLSERVER" ]; then
LABELS_TO_RUN="SQLSERVER"
RUN_SQLSERVER=YES
elif [ $# -eq 1 ] && [ $1 = "ALL_BUT_PROVIDERS" ]; then
LABELS_TO_EXCLUDE="HANA|POSTGRES|ORACLE|SQLSERVER"
elif [ $# -gt 0 ] && [ $1 != "ALL" ]; then
echo "Invalid argument"
usage >&2
exit 1
else
RUN_HANA=YES
RUN_POSTGRES=YES
RUN_ORACLE=YES
RUN_SQLSERVER=YES
fi
# Debug env
echo "::group::Print env"
env
echo "::endgroup::"
# Temporarily uncomment to debug ccache issues
# cat /tmp/cache.debug
if [ -n "$LABELS_TO_RUN" ]; then
echo "Only following test labels will be run: $LABELS_TO_RUN"
CTEST_OPTIONS="-L $LABELS_TO_RUN"
fi
if [ -n "$LABELS_TO_EXCLUDE" ]; then
echo "Following test labels will be excluded: $LABELS_TO_EXCLUDE"
CTEST_OPTIONS="$CTEST_OPTIONS -LE $LABELS_TO_EXCLUDE"
fi
if [ ${RUN_HANA:-"NO"} == "YES" ]; then
##################################
# Prepare HANA database connection
##################################
echo "::group::hana"
echo "${bold}Load HANA database...${endbold}"
export HANA_HOST=917df316-4e01-4a10-be54-eac1b6ab15fb.hana.prod-us10.hanacloud.ondemand.com
export HANA_PORT=443
export HANA_USER=QGISCI
export HANA_PASSWORD="tQ&7W3Klr9!p"
export QGIS_HANA_TEST_DB='driver='/usr/sap/hdbclient/libodbcHDB.so' host='${HANA_HOST}' port='${HANA_PORT}' user='${HANA_USER}' password='${HANA_PASSWORD}' sslEnabled=true sslValidateCertificate=False'
# wait for the DB to be available
echo "Wait a moment while trying to connect to a HANA database."
while ! echo exit | hdbsql -n '${HANA_HOST}:${HANA_PORT}' -u '${HANA_USER}' -p '${HANA_PASSWORD}' &> /dev/null
do
printf "⚘"
sleep 1
done
echo "🌊 done"
echo "::endgroup::"
fi
if [ ${RUN_POSTGRES:-"NO"} == "YES" ]; then
echo "::group::Setup PostgreSQL"
############################
# Restore postgres test data
############################
echo "${bold}Load Postgres database...🐘${endbold}"
printf "[qgis_test]\nhost=postgres\nport=5432\ndbname=qgis_test\nuser=docker\npassword=docker" > ~/.pg_service.conf
export PGUSER=docker
export PGHOST=postgres
export PGPASSWORD=docker
export PGDATABASE=qgis_test
# wait for the DB to be available
echo "Wait a moment while loading PostGreSQL database."
while ! PGPASSWORD='docker' psql -h postgres -U docker -p 5432 -l &> /dev/null
do
printf "🐘"
sleep 1
done
echo " done 🥩"
pushd ${SRCDIR} > /dev/null
echo "Restoring postgres test data ..."
${SRCDIR}/tests/testdata/provider/testdata_pg.sh
echo "Postgres test data restored ..."
popd > /dev/null # /root/QGIS
echo "::endgroup::"
fi
if [ ${RUN_ORACLE:-"NO"} == "YES" ]; then
echo "::group::Setup Oracle"
##############################
# Restore Oracle test data
##############################
echo "${bold}Load Oracle database...🙏${endbold}"
export ORACLE_HOST="oracle"
export ORACLE_PDB="XEPDB1"
export QGIS_ORACLETEST_DBNAME="${ORACLE_HOST}/${ORACLE_PDB}"
export QGIS_ORACLETEST_DB="host=${ORACLE_HOST} dbname=${ORACLE_PDB} port=1521 user='QGIS' password='qgis'"
echo "Wait a moment while loading Oracle database."
COUNT=0
while ! echo exit | sqlplus -L SYSTEM/adminpass@$QGIS_ORACLETEST_DBNAME &> /dev/null
do
printf "🙏"
sleep 5
if [[ $(( COUNT++ )) -eq 40 ]]; then
break
fi
done
if [[ ${COUNT} -eq 41 ]]; then
echo "timeout, no oracle, no 🙏"
else
echo " done 👀"
pushd ${SRCDIR} > /dev/null
${SRCDIR}/tests/testdata/provider/testdata_oracle.sh $ORACLE_HOST
popd > /dev/null # /root/QGIS
fi
echo "::endgroup::"
fi
if [ ${RUN_SQLSERVER:-"NO"} == "YES" ]; then
echo "::group::Setup SQL Server"
##############################
# Restore SQL Server test data
##############################
echo "Importing SQL Server test data..."
export SQLUSER=sa
export SQLHOST=mssql
export SQLPORT=1433
export SQLPASSWORD='<YourStrong!Passw0rd>'
export SQLDATABASE=qgis_test
export PATH=$PATH:/opt/mssql-tools/bin
pushd ${SRCDIR} > /dev/null
${SRCDIR}/tests/testdata/provider/testdata_mssql.sh
popd > /dev/null # ${SRCDIR}
echo "Setting up DSN for test SQL Server"
cat <<EOT > /etc/odbc.ini
[ODBC Data Sources]
testsqlserver = ODBC Driver 17 for SQL Server
[testsqlserver]
Driver = ODBC Driver 17 for SQL Server
Description = Test SQL Server
Server = mssql
EOT
echo "::endgroup::"
fi
#######################################
# Wait for Minio container to be ready
#######################################
if [ $# -eq 0 ] || [ $1 = "ALL_BUT_PROVIDERS" ] || [ $1 = "ALL" ] ; then
echo "::group::Setup Minio"
echo "Wait for minio to be ready..."
COUNT=0
while ! curl http://$QGIS_MINIO_HOST:$QGIS_MINIO_PORT &> /dev/null;
do
printf "."
sleep 5
if [[ $(( COUNT++ )) -eq 40 ]]; then
break
fi
done
if [[ ${COUNT} -eq 41 ]]; then
echo "Error: Minio docker timeout!!!"
else
echo "done"
fi
echo "::endgroup::"
fi
#######################################
# Wait for WebDAV container to be ready
#######################################
if [ $# -eq 0 ] || [ $1 = "ALL_BUT_PROVIDERS" ] || [ $1 = "ALL" ] ; then
echo "::group::Setup WebDAV"
echo "Wait for webdav to be ready..."
COUNT=0
while ! curl -f -X GET -u qgis:myPasswd! http://$QGIS_WEBDAV_HOST:$QGIS_WEBDAV_PORT/webdav_tests/ &> /dev/null;
do
printf "."
sleep 5
if [[ $(( COUNT++ )) -eq 40 ]]; then
break
fi
done
if [[ ${COUNT} -eq 41 ]]; then
echo "Error: WebDAV docker timeout!!!"
else
echo "done"
fi
echo "::endgroup::"
fi
###########
# Run tests
###########
EXCLUDE_TESTS=$(cat ${SRCDIR}/.ci/test_blocklist_qt${QT_VERSION}.txt | sed -r '/^(#.*?)?$/d' | paste -sd '|' -)
if ! [[ ${RUN_FLAKY_TESTS} == true ]]; then
echo "Flaky tests are skipped!"
EXCLUDE_TESTS=${EXCLUDE_TESTS}"|"$(cat ${SRCDIR}/.ci/test_flaky.txt | sed -r '/^(#.*?)?$/d' | paste -sd '|' -)
else
echo "Flaky tests are run!"
fi
echo "List of skipped tests: $EXCLUDE_TESTS"
echo "::group::Print disk space before running tests"
df -h
echo "::endgroup::"
export QTWEBENGINE_DISABLE_SANDBOX=1
python3 ${SRCDIR}/.ci/ctest2ci.py xvfb-run ctest -V $CTEST_OPTIONS -E "${EXCLUDE_TESTS}" -S ${SRCDIR}/.ci/config_test.ctest --output-on-failure
echo "::group::Print disk space after running tests"
df -h
echo "::endgroup::"