-
Notifications
You must be signed in to change notification settings - Fork 11
/
runTests-dev.sh
executable file
·75 lines (58 loc) · 1.95 KB
/
runTests-dev.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
#!/usr/bin/env bash
set -euo pipefail
runTests() {
local aTests bRunning sAppDirectory sContainerName sServerName sReportDirectory
readonly sContainerName='server'
bRunning=false
dockerStop() {
if [[ "${bRunning:-}" == true ]];then
echo ' -----> Stopping server...'
docker stop "${sContainerName}" > /dev/null || echo 'Could not stop server'
bRunning=false
fi
}
declare -a aTests=('webid-provider' 'solid-crud')
readonly sServerName="${1?Two parameter required: <name> <project-path> [report-directory]}"
readonly sAppDirectory="${2?Two parameter required: <name> <project-path> [report-directory]}"
readonly sReportDirectory="${3:-$PWD}/reports"
trap dockerStop EXIT INT TERM
echo " =====> Running test for ${sServerName} from ${sAppDirectory}"
echo ' -----> Starting server...'
docker run \
-d \
--name=${sContainerName} \
--network=testnet \
--rm \
--volume "${sAppDirectory}:/app" \
"${sServerName}"
bRunning=true
if [[ "${sServerName}" == 'nextcloud-server' ]]; then
echo ' -----> Waiting for Nextcloud server to start ...'
sleep 10
docker logs "${sContainerName}"
echo ' -----> Running init script for Nextcloud server ...'
docker exec -it --user 'www-data' "${sContainerName}" sh /init.sh
docker exec -it --user 'root' "${sContainerName}" service apache2 reload
fi
for sTest in "${aTests[@]}"; do
echo " -----> Running ${sTest} tester..."
{
docker run \
--cap-add=SYS_ADMIN \
--env-file "servers/${sServerName}/env.list" \
--network=testnet \
"${sTest}" \
2> "${sReportDirectory}/${sServerName}-${sTest}.txt"
} || true
done
dockerStop
echo -e "\n =====> Test results\n"
grep 'Tests' "${sReportDirectory}/${sServerName}"-*.txt \
| cut -d ':' -f1,3- | rev | cut -d '/' -f1 | rev
}
if [ "${BASH_SOURCE[0]}" != "$0" ]; then
export -f runTests
else
runTests "${@}"
exit $?
fi