Merge "Fix genius CSIT jobs"
[releng/builder.git] / jjb / integration / integration-deploy-controller-run-test.sh
index ed82e35d28be06622bfc6272d32b97ece8b6715d..c222ed2fc184b6680090b5103ee3b0fd6de050cc 100644 (file)
@@ -4,13 +4,7 @@
 # script.
 # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
 source ${ROBOT_VENV}/bin/activate
-
-MAVENCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.url.mvn.cfg
-FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
-CUSTOMPROP=/tmp/${BUNDLEFOLDER}/etc/custom.properties
-LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
-MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
-CONTROLLERMEM="2048m"
+source /tmp/common-functions.sh ${BUNDLEFOLDER}
 
 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
     echo "Configure cluster"
@@ -21,7 +15,7 @@ fi
 
 if [ ${CONTROLLERSCOPE} == 'all' ]; then
     ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
-    CONTROLLERMEM="3072m"
+    export CONTROLLERMEM="3072m"
     COOLDOWN_PERIOD="180"
 else
     ACTUALFEATURES="odl-infrautils-ready,${CONTROLLERFEATURES}"
@@ -51,6 +45,8 @@ if [ -f "${WORKSPACE}/test/csit/scriptplans/${TESTPLAN}" ]; then
 fi
 
 cat > ${WORKSPACE}/configuration-script.sh <<EOF
+set -x
+source /tmp/common-functions.sh ${BUNDLEFOLDER}
 
 echo "Changing to /tmp"
 cd /tmp
@@ -70,14 +66,12 @@ if [[ "$USEFEATURESBOOT" == "True" ]]; then
     sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
 fi
 
-FEATURE_INDEX_STRING="features-integration-index"
 FEATURE_TEST_STRING="features-integration-test"
 if [[ "$KARAF_VERSION" == "karaf4" ]]; then
-    FEATURE_INDEX_STRING="features-index"
     FEATURE_TEST_STRING="features-test"
 fi
 
-sed -ie "s%mvn:org.opendaylight.integration/\${FEATURE_INDEX_STRING}/${BUNDLEVERSION}/xml/features%mvn:org.opendaylight.integration/\${FEATURE_INDEX_STRING}/${BUNDLEVERSION}/xml/features,mvn:org.opendaylight.integration/\${FEATURE_TEST_STRING}/${BUNDLEVERSION}/xml/features,mvn:org.apache.karaf.decanter/apache-karaf-decanter/1.0.0/xml/features%g" ${FEATURESCONF}
+sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = mvn:org.opendaylight.integration/\${FEATURE_TEST_STRING}/${BUNDLEVERSION}/xml/features,mvn:org.apache.karaf.decanter/apache-karaf-decanter/1.0.0/xml/features,%g" ${FEATURESCONF}
 cat ${FEATURESCONF}
 
 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
@@ -86,46 +80,13 @@ if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
 fi
 cat ${CUSTOMPROP}
 
-echo "Configuring the log..."
-sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' ${LOGCONF}
-# FIXME: Make log size limit configurable from build parameter.
-sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=30GB/g' ${LOGCONF}
-echo "log4j.logger.org.opendaylight.yangtools.yang.parser.repo.YangTextSchemaContextResolver = WARN" >> ${LOGCONF}
-# Add custom logging levels
-# CONTROLLERDEBUGMAP is expected to be a key:value map of space separated values like "module:level module2:level2"
-# where module is abbreviated and does not include org.opendaylight
-unset IFS
-if [ -n "${CONTROLLERDEBUGMAP}" ]; then
-    for kv in ${CONTROLLERDEBUGMAP}; do
-        module=\${kv%%:*}
-        level=\${kv#*:}
-        if [ -n \${module} ] && [ -n \${level} ]; then
-            echo "log4j.logger.org.opendaylight.\${module} = \${level}" >> ${LOGCONF}
-        fi
-    done
-fi
-cat ${LOGCONF}
+configure_karaf_log "${KARAF_VERSION}" "${CONTROLLERDEBUGMAP}"
 
-echo "Configure java home and max memory..."
-sed -ie 's%^# export JAVA_HOME%export JAVA_HOME="\${JAVA_HOME:-${JAVA_HOME}}"%g' ${MEMCONF}
-sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' ${MEMCONF}
-cat ${MEMCONF}
+set_java_vars "${JAVA_HOME}" "${CONTROLLERMEM}"
 
 echo "Listing all open ports on controller system..."
 netstat -pnatu
 
-echo "Set Java version"
-sudo /usr/sbin/alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 1
-sudo /usr/sbin/alternatives --set java ${JAVA_HOME}/bin/java
-echo "JDK default version..."
-java -version
-
-echo "Set JAVA_HOME"
-export JAVA_HOME="${JAVA_HOME}"
-# Did you know that in HERE documents, single quote is an ordinary character, but backticks are still executing?
-JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
-echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
-
 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
 
     # Copy shard file if exists
@@ -149,17 +110,20 @@ if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
 fi
 
 EOF
+# cat > ${WORKSPACE}/configuration-script.sh <<EOF
 
 # Create the startup script to be run on controller.
 cat > ${WORKSPACE}/startup-script.sh <<EOF
 
 echo "Redirecting karaf console output to karaf_console.log"
 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
+mkdir -p /tmp/${BUNDLEFOLDER}/data/log
 
 echo "Starting controller..."
 /tmp/${BUNDLEFOLDER}/bin/start
 
 EOF
+# cat > ${WORKSPACE}/startup-script.sh <<EOF
 
 cat > ${WORKSPACE}/post-startup-script.sh <<EOF
 
@@ -239,6 +203,7 @@ exit_on_log_file_message 'BindException: Address already in use'
 exit_on_log_file_message 'server is unhealthy'
 
 EOF
+# cat > ${WORKSPACE}/post-startup-script.sh <<EOF
 
 [ "$NUM_OPENSTACK_SITES" ] || NUM_OPENSTACK_SITES=1
 NUM_ODLS_PER_SITE=$((NUM_ODL_SYSTEM / NUM_OPENSTACK_SITES))
@@ -337,7 +302,23 @@ fi
 echo "Changing the testplan path..."
 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
 cat testplan.txt
-SUITES=$( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' ' )
+
+# Use the testplan if specific SUITES are not defined.
+if [ -z "${SUITES}" ]; then
+    SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
+else
+    newsuites=""
+    workpath="${WORKSPACE}/test/csit/suites"
+    for suite in ${SUITES}; do
+        fullsuite="${workpath}/${suite}"
+        if [ -z "${newsuites}" ]; then
+            newsuites+=${fullsuite}
+        else
+            newsuites+=" "${fullsuite}
+        fi
+    done
+    SUITES=${newsuites}
+fi
 
 echo "Starting Robot test suites ${SUITES} ..."
 pybot -N ${TESTPLAN} --removekeywords wuks -c critical -e exclude -e skip_if_${DISTROSTREAM} -v BUNDLEFOLDER:${BUNDLEFOLDER} -v WORKSPACE:/tmp \