Merge "Also install netifaces to robot system on CSIT start"
[releng/builder.git] / jjb / integration / include-raw-integration-start-cluster-run-test.sh
1 # Activate robotframework virtualenv
2 # ${ROBOT_VENV} comes from the include-raw-integration-install-robotframework.sh
3 # script.
4 source ${ROBOT_VENV}/bin/activate
5
6 echo "#################################################"
7 echo "##         Verify Cluster is UP                ##"
8 echo "#################################################"
9
10 cat > ${WORKSPACE}/verify-cluster-is-up.sh <<EOF
11
12 CONTROLLERID="member-\$1"
13 ODL_SYSTEM_IP_PATH=\$2
14
15 echo "Waiting for controller to come up..."
16 COUNT="0"
17 while true; do
18     RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
19     echo \$RESP
20     SHARD="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/jolokia/read/org.opendaylight.controller:Category=Shards,name=\$CONTROLLERID-shard-inventory-config,type=DistributedConfigDatastore)"
21     echo \$SHARD
22     if ([[ \$RESP == *"200"* ]] && [[ \$SHARD  == *'"status":200'* ]]); then
23         echo Controller is UP
24         break
25     elif (( "\$COUNT" > "600" )); then
26         echo Timeout Controller DOWN
27         echo "Dumping Karaf log..."
28         cat /tmp/${BUNDLEFOLDER}/data/log/karaf.log
29         echo "Listing all open ports on controller system"
30         netstat -natu
31         exit 1
32     else
33         COUNT=\$(( \${COUNT} + 5 ))
34         sleep 5
35         echo waiting \$COUNT secs...
36     fi
37 done
38
39 echo "Checking OSGi bundles..."
40 sshpass -p karaf /tmp/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
41
42 echo "Listing all open ports on controller system"
43 netstat -natu
44
45 # checking for any bind exceptions in log which could indicate a port conflict
46 if grep --quiet 'BindException: Address already in use' /tmp/${BUNDLEFOLDER}/data/log/karaf.log; then
47     echo BindException found: Possible port conflict
48     echo "Dumping Karaf log..."
49     cat /tmp/${BUNDLEFOLDER}/data/log/karaf.log
50     exit 1
51 fi
52
53 EOF
54
55 ODL_SYSTEM_IPS=(${ODL_SYSTEM_1_IP} ${ODL_SYSTEM_2_IP} ${ODL_SYSTEM_3_IP})
56 for i in "${!ODL_SYSTEM_IPS[@]}"
57 do
58     echo "Verifying member-$((i+1)) with IP address ${ODL_SYSTEM_IPS[$i]} is UP"
59     scp ${WORKSPACE}/verify-cluster-is-up.sh ${ODL_SYSTEM_IPS[$i]}:/tmp
60     ssh ${ODL_SYSTEM_IPS[$i]} "bash /tmp/verify-cluster-is-up.sh $((i+1)) ${ODL_SYSTEM_IPS[$i]}"
61 done
62
63 echo "Cool down for 1 min :)..."
64 sleep 60
65
66 echo "Changing the testplan path..."
67 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
68 cat testplan.txt
69
70 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
71
72 echo "Starting Robot test suites ${SUITES} ..."
73 pybot -N ${TESTPLAN} -c critical -e exclude -v BUNDLEFOLDER:${BUNDLEFOLDER} -v WORKSPACE:/tmp \
74 -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} -v CONTROLLER:${ODL_SYSTEM_IP} -v CONTROLLER1:${ODL_SYSTEM_2_IP} \
75 -v CONTROLLER2:${ODL_SYSTEM_3_IP} -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} -v ODL_SYSTEM_2_IP:${ODL_SYSTEM_2_IP} \
76 -v ODL_SYSTEM_3_IP:${ODL_SYSTEM_3_IP} -v CONTROLLER_USER:${USER} -v ODL_SYSTEM_USER:${USER} \
77 -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_IP} -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} -v TOOLS_SYSTEM_3_IP:${TOOLS_SYSTEM_3_IP} \
78 -v TOOLS_SYSTEM_USER:${USER} \
79 -v MININET:${TOOLS_SYSTEM_IP} -v MININET1:${TOOLS_SYSTEM_2_IP} -v MININET2:${TOOLS_SYSTEM_3_IP} -v MININET_USER:${USER} \
80 -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES} || true
81
82 echo "Fetching Karaf log"
83 scp $ODL_SYSTEM_IP:/tmp/$BUNDLEFOLDER/data/log/karaf.log controller0-karaf.log
84 scp $ODL_SYSTEM_2_IP:/tmp/$BUNDLEFOLDER/data/log/karaf.log controller1-karaf.log
85 scp $ODL_SYSTEM_3_IP:/tmp/$BUNDLEFOLDER/data/log/karaf.log controller2-karaf.log
86
87 # vim: ts=4 sw=4 sts=4 et ft=sh :
88