-
Notifications
You must be signed in to change notification settings - Fork 2
/
runTestsDocker.sh
executable file
·296 lines (277 loc) · 9.93 KB
/
runTestsDocker.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
288
289
290
291
292
293
294
295
296
#!/usr/bin/env bash
WAIT_FOR_DB_SEC=10
if [ "$TRAVIS" = "true" ]; then
WAIT_FOR_DB_SEC=40
fi
print_test_header () {
echo
echo " ##### "
echo $1
echo " ##### "
echo
}
# Build theo test image
docker build --target builder -t theo-tester .
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker build FAILED"
exit ${RETVAL}
fi
# Build theo server image
docker build -t theo:test .
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker build FAILED"
exit ${RETVAL}
fi
source ./docker-compose/test_env
test_standalone () {
print_test_header Standalone
docker run --rm --name theo-tester theo-tester npm run test:standalone
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR test:standalone FAILED"
exit ${RETVAL}
fi
}
test_sqlite () {
# sqlite
print_test_header sqlite
docker-compose -p theotests -f docker-compose/docker-compose-test.yml up -d
docker run --network theotests_default --rm --link theo \
-e "THEO_URL=http://theo:9100" \
-e "ADMIN_TOKEN=${ADMIN_TOKEN}" \
-e "CLIENT_TOKENS=${CLIENT_TOKENS}" \
theo-tester npm run test:api
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
docker logs --tail 30 theo
fi
docker-compose -p theotests -f docker-compose/docker-compose-test.yml down
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker-compose-test FAILED"
exit ${RETVAL}
fi
}
test_sqlite_audit () {
# sqlite
print_test_header "sqlite audit"
docker-compose -p theotests -f docker-compose/docker-compose-test-audit.yml up -d
docker run --network theotests_default --rm --link theo \
-e "THEO_URL=http://theo:9100" \
-e "ADMIN_TOKEN=${ADMIN_TOKEN_AUDIT}" \
-e "CLIENT_TOKENS=${CLIENT_TOKENS}" \
theo-tester npm run test:api
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
docker logs --tail 30 theo
else
docker logs --tail 20 theo
fi
docker-compose -p theotests -f docker-compose/docker-compose-test-audit.yml down
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker-compose-test FAILED"
exit ${RETVAL}
fi
}
test_sqlite_signed () {
# sqlite + REQUIRE_SIGNED_KEY
print_test_header "sqlite + REQUIRE_SIGNED_KEY"
docker-compose -p theotests -f docker-compose/docker-compose-test-signed.yml up -d
docker run --network theotests_default --rm --link theo \
-e "THEO_URL=http://theo:9100" \
-e "ADMIN_TOKEN=${ADMIN_TOKEN}" \
-e "CLIENT_TOKENS=${CLIENT_TOKENS}" \
theo-tester npm run test:api:signed
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
docker logs --tail 30 theo
fi
docker-compose -p theotests -f docker-compose/docker-compose-test-signed.yml down
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker-compose-test-signed FAILED"
exit ${RETVAL}
fi
}
test_sqlite_inmemory () {
# sqlite + inmemory
print_test_header "sqlite + inmemory"
docker-compose -p theotests -f docker-compose/docker-compose-test-inmemory.yml up -d
docker run --network theotests_default --rm --link theo \
-e "THEO_URL=http://theo:9100" \
-e "ADMIN_TOKEN=${ADMIN_TOKEN}" \
-e "CLIENT_TOKENS=${CLIENT_TOKENS}" \
-e "THEO_USE_CACHE=1" \
theo-tester npm run test:api
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
docker logs --tail 30 theo
fi
docker-compose -p theotests -f docker-compose/docker-compose-test-inmemory.yml down
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker-compose-test-inmemory FAILED"
exit ${RETVAL}
fi
}
test_sqlite_memcached () {
# sqlite + memcached
print_test_header "sqlite + memcached"
docker-compose -p theotests -f docker-compose/docker-compose-test-memcached.yml up -d
docker run --network theotests_default --rm --link theo \
-e "THEO_URL=http://theo:9100" \
-e "ADMIN_TOKEN=${ADMIN_TOKEN}" \
-e "CLIENT_TOKENS=${CLIENT_TOKENS}" \
-e "THEO_USE_CACHE=1" \
theo-tester npm run test:api
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
docker logs --tail 30 theo
fi
docker-compose -p theotests -f docker-compose/docker-compose-test-memcached.yml down
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker-compose-test-memcached FAILED"
exit ${RETVAL}
fi
}
test_mariadb () {
# mariadb
print_test_header mariadb
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb.yml up -d
echo ${WAIT_FOR_DB_SEC}s Waiting for db to start..
sleep $WAIT_FOR_DB_SEC
docker run --network theotests_default --rm --link theo \
-e "THEO_URL=http://theo:9100" \
-e "ADMIN_TOKEN=${ADMIN_TOKEN}" \
-e "CLIENT_TOKENS=${CLIENT_TOKENS}" \
theo-tester npm run test:api
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
docker logs --tail 30 theo
fi
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb.yml down
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker-compose-test-mariadb FAILED"
exit ${RETVAL}
fi
}
test_mariadb_redis () {
# mariadb + redis
print_test_header "mariadb + redis"
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb-redis.yml up -d
echo ${WAIT_FOR_DB_SEC}s Waiting for db to start..
sleep $WAIT_FOR_DB_SEC
docker run --network theotests_default --rm --link theo \
-e "THEO_URL=http://theo:9100" \
-e "ADMIN_TOKEN=${ADMIN_TOKEN}" \
-e "CLIENT_TOKENS=${CLIENT_TOKENS}" \
-e "THEO_USE_CACHE=1" \
theo-tester npm run test:api
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
docker logs theo | tail -n 20
fi
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb-redis.yml down
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker-compose-test-mariadb-redis FAILED"
exit ${RETVAL}
fi
}
test_mysql () {
# mysql
print_test_header "mysql"
docker-compose -p theotests -f docker-compose/docker-compose-test-mysql.yml up -d
echo ${WAIT_FOR_DB_SEC}s Waiting for db to start..
# On travis it takes a lot to start...
sleep 30
docker-compose -p theotests -f docker-compose/docker-compose-test-mysql.yml \
exec -T db mysql -uroot -p${MYSQL_ROOT_PASSWORD} \
-e "create database ${MYSQL_DATABASE}; create user ${MYSQL_USER}@'%' identified by '${MYSQL_PASSWORD}'; grant all on ${MYSQL_DATABASE}.* to ${MYSQL_USER}@'%';"
docker-compose -p theotests -f docker-compose/docker-compose-test-mysql.yml restart theo
sleep $WAIT_FOR_DB_SEC
docker run --network theotests_default --rm --link theo \
-e "THEO_URL=http://theo:9100" \
-e "ADMIN_TOKEN=${ADMIN_TOKEN}" \
-e "CLIENT_TOKENS=${CLIENT_TOKENS}" \
theo-tester npm run test:api
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
docker logs theo | tail -n 20
fi
docker-compose -p theotests -f docker-compose/docker-compose-test-mysql.yml down
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker-compose-test-mysql FAILED"
exit ${RETVAL}
fi
}
test_mariadb_redis_core_noassignee () {
# mariadb + redis CORE
print_test_header "mariadb + redis CORE no assignee"
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb-redis-core.yml up -d
echo ${WAIT_FOR_DB_SEC}s Waiting for db to start..
sleep $WAIT_FOR_DB_SEC
docker run --network theotests_default --rm --link theo \
-e "CORE_TOKEN=${CORE_TOKEN}" \
-e "THEO_URL=http://theo:9100" \
theo-tester npm run test:core:noassignee
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb-redis-core.yml down
echo "ERR docker-compose-test-mariadb-redis-core FAILED"
exit ${RETVAL}
fi
print_test_header "mariadb + redis CORE no assignee AFTER RESTART"
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb-redis-core.yml restart theo
docker run --network theotests_default --rm --link theo \
-e "THEO_URL=http://theo:9100" \
-e "CORE_TOKEN=${CORE_TOKEN}" \
theo-tester npm run test:core:restart:noassignee
RETVAL=$?
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb-redis-core.yml down
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker-compose-test-mariadb-redis-core restart FAILED "
exit ${RETVAL}
fi
}
test_mariadb_redis_core () {
# mariadb + redis CORE
print_test_header "mariadb + redis CORE"
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb-redis-core.yml up -d
echo ${WAIT_FOR_DB_SEC}s Waiting for db to start..
sleep $WAIT_FOR_DB_SEC
docker run --network theotests_default --rm --link theo \
-e "CORE_TOKEN=${CORE_TOKEN}" \
-e "THEO_URL=http://theo:9100" \
theo-tester npm run test:core
RETVAL=$?
if [[ ${RETVAL} -gt 0 ]]; then
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb-redis-core.yml down
echo "ERR docker-compose-test-mariadb-redis-core FAILED"
exit ${RETVAL}
fi
print_test_header "mariadb + redis CORE AFTER RESTART"
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb-redis-core.yml restart theo
docker run --network theotests_default --rm --link theo \
-e "THEO_URL=http://theo:9100" \
-e "CORE_TOKEN=${CORE_TOKEN}" \
theo-tester npm run test:core:restart
RETVAL=$?
docker-compose -p theotests -f docker-compose/docker-compose-test-mariadb-redis-core.yml down
if [[ ${RETVAL} -gt 0 ]]; then
echo "ERR docker-compose-test-mariadb-redis-core restart FAILED "
exit ${RETVAL}
fi
}
if [[ "$1" = "" ]]; then
test_standalone
test_sqlite
test_sqlite_audit
test_sqlite_signed
test_sqlite_inmemory
test_sqlite_memcached
test_mariadb
test_mariadb_redis
test_mysql
test_mariadb_redis_core
else
test_${1}
fi