Adding CSIT for NetIDE project
[releng/builder.git] / jjb / integration / include-raw-integration-deploy-controller-run-test.sh
index 33bff71d5a7ee5df2cfb95894809f772d4e1cb62..865c31a693b36a30ca1875910cd3a89890c433ba 100644 (file)
@@ -1,60 +1,59 @@
-# Create a script to run controller inside a dynamic jenkins slave
+# Activate robotframework virtualenv
+# ${ROBOT_VENV} comes from the include-raw-integration-install-robotframework.sh
+# script.
+source ${ROBOT_VENV}/bin/activate
+
 CONTROLLERMEM="2048m"
+
 if [ ${CONTROLLERSCOPE} == 'all' ]; then
-    CONTROLLERFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
+    ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
     CONTROLLERMEM="3072m"
+else
+    ACTUALFEATURES="${CONTROLLERFEATURES}"
 fi
 
-if [ ${BUNDLEURL} == 'last' ]; then
-    NEXUSPATH="https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/distribution-karaf"
-    # Extract the BUNDLEVERSION from the pom.xml
-    BUNDLEVERSION=`xpath pom.xml '/project/version/text()' 2> /dev/null`
-    echo Bundle version is $BUNDLEVERSION
-    # Acquire the timestamp information from maven-metadata.xml
-    wget ${NEXUSPATH}/${BUNDLEVERSION}/maven-metadata.xml
-    TIMESTAMP=`xpath maven-metadata.xml "//snapshotVersion[extension='zip'][1]/value/text()" 2>/dev/null`
-    echo Nexus timestamp is $TIMESTAMP
-    BUNDLEFOLDER="distribution-karaf-${BUNDLEVERSION}"
-    BUNDLE="distribution-karaf-${TIMESTAMP}.zip"
-    BUNDLEURL="${NEXUSPATH}/${BUNDLEVERSION}/${BUNDLE}"
-    echo Distribution bundle URL is ${BUNDLEURL}
-else
-    BUNDLE="$(echo "$BUNDLEURL" | awk -F '/' '{ print $(NF) }')"
-    BUNDLEFOLDER="${BUNDLE//.zip}"
+if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
+    echo "scriptplan exists!!!"
+    echo "Changing the scriptplan path..."
+    cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
+    cat scriptplan.txt
+    for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
+        echo "Executing ${line}..."
+        source ${line}
+    done
 fi
 
 cat > ${WORKSPACE}/controller-script.sh <<EOF
-echo Downloading the distribution from ${BUNDLEURL}
+
+echo "Changing to /tmp"
 cd /tmp
-wget --no-verbose  ${BUNDLEURL}
 
-echo Extracting the new controller...
+echo "Downloading the distribution..."
+wget --no-verbose '${ACTUALBUNDLEURL}'
+
+echo "Extracting the new controller..."
 unzip -q ${BUNDLE}
 
-echo Configuring the startup features...
-cd ${BUNDLEFOLDER}/etc
-export CFG=org.apache.karaf.features.cfg
-cp \${CFG} \${CFG}.bak
-cat \${CFG}.bak | sed "s/^featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${CONTROLLERFEATURES}/" > \${CFG}
-cat \${CFG}
-
-echo Configuring the log...
-export LOG=org.ops4j.pax.logging.cfg
-cp \${LOG} \${LOG}.bak
-cat \${LOG}.bak | sed 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/' > \${LOG}
-cat \${LOG}
-
-echo Configure max memory...
-export MEM=setenv
-cd ../bin
-cp \${MEM} \${MEM}.bak
-cat \${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > \${MEM}
-cat \${MEM}
-
-echo Starting controller...
-./start &
-
-echo Waiting for controller to come up...
+echo "Configuring the startup features..."
+FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
+sed -ie "s/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${ACTUALFEATURES}/g" \${FEATURESCONF}
+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}
+cat \${FEATURESCONF}
+
+echo "Configuring the log..."
+LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
+sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/g' \${LOGCONF}
+cat \${LOGCONF}
+
+echo "Configure max memory..."
+MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
+sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
+cat \${MEMCONF}
+
+echo "Starting controller..."
+/tmp/${BUNDLEFOLDER}/bin/start
+
+echo "Waiting for controller to come up..."
 COUNT="0"
 while true; do
     RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
@@ -64,7 +63,9 @@ while true; do
         break
     elif (( "\$COUNT" > "600" )); then
         echo Timeout Controller DOWN
-        break
+        echo "Dumping Karaf log..."
+        cat /tmp/${BUNDLEFOLDER}/data/log/karaf.log
+        exit 1
     else
         COUNT=\$(( \${COUNT} + 5 ))
         sleep 5
@@ -72,28 +73,34 @@ while true; do
     fi
 done
 
-echo Cool down for 1 min...
+echo "Cool down for 1 min :)..."
 sleep 60
 
-echo Checking OSGi bundles
-./client 'bundle:list'
+echo "Checking OSGi bundles..."
+sshpass -p karaf /tmp/${BUNDLEFOLDER}/bin/client -u karaf 'bundle:list'
 
 EOF
 
-scp ${WORKSPACE}/controller-script.sh $CONTROLLER0:/tmp
-ssh $CONTROLLER0 'bash /tmp/controller-script.sh'
+scp ${WORKSPACE}/controller-script.sh ${ODL_SYSTEM_IP}:/tmp
+ssh ${ODL_SYSTEM_IP} 'bash /tmp/controller-script.sh'
 
-echo Changing the testplan path...
+echo "Changing the testplan path..."
 cat ${WORKSPACE}/test/csit/testplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > testplan.txt
 cat testplan.txt
 
 SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
 
-echo Starting Robot test suites "${SUITES}" ...
-pybot -N ${TESTPLAN} -c critical -e exclude -v CONTROLLER:${CONTROLLER0} -v MININET:${MININET0} -v MININET_USER:${USER} -v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES}
-
-echo Fetching Karaf log
-scp $CONTROLLER0:/tmp/$BUNDLEFOLDER/data/log/karaf.log .
+echo "Starting Robot test suites ${SUITES} ..."
+pybot -N ${TESTPLAN} -c critical -e exclude -v BUNDLEFOLDER:${BUNDLEFOLDER} -v WORKSPACE:/tmp \
+-v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
+-v CONTROLLER:${ODL_SYSTEM_IP} -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} -v CONTROLLER_USER:${USER} -v ODL_SYSTEM_USER:${USER} \
+-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} \
+-v TOOLS_SYSTEM_USER:${USER} \
+-v MININET:${TOOLS_SYSTEM_IP} -v MININET1:${TOOLS_SYSTEM_2_IP} -v MININET2:${TOOLS_SYSTEM_3_IP} -v MININET_USER:${USER} \
+-v USER_HOME:${HOME} ${TESTOPTIONS} ${SUITES} || true
+
+echo "Fetching Karaf log"
+scp ${ODL_SYSTEM_IP}:/tmp/${BUNDLEFOLDER}/data/log/karaf.log .
 
 # vim: ts=4 sw=4 sts=4 et ft=sh :