adding netstat deployment before and after controller deployment
[releng/builder.git] / jjb / integration / include-raw-integration-deploy-controller-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 CONTROLLERMEM="2048m"
7
8 if [ ${CONTROLLERSCOPE} == 'all' ]; then
9     ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
10     CONTROLLERMEM="3072m"
11 else
12     ACTUALFEATURES="${CONTROLLERFEATURES}"
13 fi
14
15 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
16     echo "scriptplan exists!!!"
17     echo "Changing the scriptplan path..."
18     cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
19     cat scriptplan.txt
20     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
21         echo "Executing ${line}..."
22         source ${line}
23     done
24 fi
25
26 cat > ${WORKSPACE}/controller-script.sh <<EOF
27
28 echo "Changing to /tmp"
29 cd /tmp
30
31 echo "Downloading the distribution..."
32 wget --no-verbose '${ACTUALBUNDLEURL}'
33
34 echo "Extracting the new controller..."
35 unzip -q ${BUNDLE}
36
37 echo "Configuring the startup features..."
38 FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
39 sed -ie "s/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${ACTUALFEATURES}/g" \${FEATURESCONF}
40 sed -ie "s%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features%mvn:org.opendaylight.integration/features-integration-index/${BUNDLEVERSION}/xml/features,mvn:org.opendaylight.integration/features-integration-test/${BUNDLEVERSION}/xml/features%g" \${FEATURESCONF}
41 cat \${FEATURESCONF}
42
43 echo "Configuring the log..."
44 LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
45 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' \${LOGCONF}
46 cat \${LOGCONF}
47
48 echo "Configure max memory..."
49 MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
50 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
51 cat \${MEMCONF}
52
53 echo "Listing all open ports on controller system"
54 netstat -natu
55
56 echo "Starting controller..."
57 /tmp/${BUNDLEFOLDER}/bin/start
58
59 echo "Waiting for controller to come up..."
60 COUNT="0"
61 while true; do
62     RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
63     echo \$RESP
64     if [[ \$RESP == *"200"* ]]; then
65         echo Controller is UP
66         break
67     elif (( "\$COUNT" > "600" )); then
68         echo Timeout Controller DOWN
69         echo "Dumping Karaf log..."
70         cat /tmp/${BUNDLEFOLDER}/data/log/karaf.log
71         echo "Listing all open ports on controller system"
72         netstat -natu
73         exit 1
74     else
75         COUNT=\$(( \${COUNT} + 5 ))
76         sleep 5
77         echo waiting \$COUNT secs...
78     fi
79 done
80
81 echo "Cool down for 1 min :)..."
82 sleep 60
83
84 echo "Checking OSGi bundles..."
85 sshpass -p karaf /tmp/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
86
87 echo "Listing all open ports on controller system"
88 netstat -natu
89
90 # checking for any bind exceptions in log which could indicate a port conflict
91 if grep --quiet 'BindException: Address already in use' /tmp/${BUNDLEFOLDER}/data/log/karaf.log; then
92     echo BindException found: Possible port conflict
93     echo "Dumping Karaf log..."
94     cat /tmp/${BUNDLEFOLDER}/data/log/karaf.log
95     exit 1
96 fi
97
98 EOF
99
100 scp ${WORKSPACE}/controller-script.sh ${CONTROLLER0}:/tmp
101 ssh ${CONTROLLER0} 'bash /tmp/controller-script.sh'
102
103 echo "Changing the testplan path..."
104 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
105 cat testplan.txt
106
107 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
108
109 echo "Starting Robot test suites ${SUITES} ..."
110 pybot -N ${TESTPLAN} -c critical -e exclude -v BUNDLEFOLDER:${BUNDLEFOLDER} -v WORKSPACE:/tmp \
111 -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} -v CONTROLLER:${CONTROLLER0} -v CONTROLLER_USER:${USER} \
112 -v MININET:${MININET0} -v MININET1:${MININET1} -v MININET2:${MININET2} -v MININET_USER:${USER} \
113 -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES} || true
114
115 echo "Fetching Karaf log"
116 scp ${CONTROLLER0}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log .
117
118 # vim: ts=4 sw=4 sts=4 et ft=sh :
119