-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestrig-setup.sh
105 lines (92 loc) · 2.7 KB
/
testrig-setup.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
#!/bin/bash
cd /root
IPS_PATH=/vagrant/.machine_ips.txt
WGET_TIMEOUT=20
declare -A addrs
for arg in `cat $IPS_PATH`
do
# expecting machine=1.2.3.4
MACH=`echo $arg | cut -f1 -d=`
ADDR=`echo $arg | cut -f2 -d=`
addrs[$MACH]=$ADDR
done
# returns: 0 if server is up, 1 if no response from server, 2 if response
# received but it was not 2xx
function check_httpserv_up {
NAME=$1
URL=$2
echo check_httpserv_up: $NAME: $URL
RES=`wget -O /dev/null -T ${WGET_TIMEOUT} --no-check-certificate --server-response $URL 2>&1 | awk '/^ HTTP/{print $2}' | tail -n 1`
if [ "$RES" == "" ]
then
echo check_httpserv_up: No response from server
return 1
fi
if [ "$RES" -ge 300 ]
then
echo check_httpserv_up: ERROR: $RES response from server
return 2
fi
echo check_httpserv_up: SUCCESS: $RES response from server
return 0
}
declare -A tested
tested_count=0
installed_pydeps=
function try_tests {
#echo keys=${!addrs[@]}
for machine in ${!addrs[@]}
do
echo machine=$machine
if [ -z ${tested[machine]} ]
then
check_httpserv_up $machine "https://${addrs[$machine]}/share/page"
ERR=$?
if [ $ERR = 0 ]
then
# run the tests
echo $machine is up and ready, running the tests
#pushd tests-${machine}
if [ -z $installed_pydeps ]
then
./install.sh | awk -vwhich=tests_${machine} '{print which ": " $0}'
installed_pydeps=/root/tests-${machine}
fi
./runtests.sh ${installed_pydeps}/testing_virt/venv/bin | awk -vwhich=tests_${machine} '{print which ": " $0}'
TRES=$? # 0 if all was well TODO: shall we do something with this info?
tested[$machine]=1
tested_count=$(( $tested_count + 1 ))
fi
if [ $ERR = 2 ] # if we get a response >=300 that is probably not going to change so say we have tested
then
tested[$machine]=1
tested_count=$(( $tested_count + 1 ))
fi
fi
done
# return the number remaining to do
return $(( ${#addrs[@]} - $tested_count))
}
###########################################
# First... really quick and dirty, clone tests once for each machine
# and modify the config file (replace 'localhost' with the ip address)
for machine in ${!addrs[@]}
do
git clone https://github.com/digcat/alfresco-tests.git tests-${machine}
cat tests-${machine}/config.yml | sed "s/localhost/${addrs[$machine]}/" > .tmp.config.yml
mv .tmp.config.yml tests-${machine}/config.yml
done
while true
do
echo Looping to look for available machines to test
try_tests
RES=$?
if [ $RES == 0 ]
then
echo All tests have been run
exit 0
fi
echo Some tests still to do, $RES remaining
echo sleeping 30 seconds
sleep 30
done