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