#!/bin/bash
+echo "common-functions.sh is being sourced"
+
+BUNDLEFOLDER=$1
+
# Basic controller configuration settings
export MAVENCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.url.mvn.cfg
export FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
export MODULESCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/modules.conf
export MODULESHARDSCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/module-shards.conf
+function print_common_env() {
+ cat << EOF
+common-functions environment:
+MAVENCONF: ${MAVENCONF}
+FEATURESCONF: ${FEATURESCONF}
+CUSTOMPROP: ${CUSTOMPROP}
+LOGCONF: ${LOGCONF}
+MEMCONF: ${MEMCONF}
+CONTROLLERMEM: ${CONTROLLERMEM}
+AKKACONF: ${AKKACONF}
+MODULESCONF: ${MODULESCONF}
+MODULESHARDSCONF: ${MODULESHARDSCONF}
+
+EOF
+}
+print_common_env
+
# Setup JAVA_HOME and MAX_MEM Value in ODL startup config file
function set_java_vars() {
+ local JAVA_HOME=$1
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}
+ 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}
+ echo "cat ${MEMCONF}"
cat ${MEMCONF}
echo "Set Java version"
echo "Set JAVA_HOME"
export JAVA_HOME="${JAVA_HOME}"
# shellcheck disable=SC2037
- JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
- echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
+ JAVA_RESOLVED=$(readlink -e "${JAVA_HOME}/bin/java")
+ echo "Java binary pointed at by JAVA_HOME: ${JAVA_RESOLVED}"
} # set_java_vars()
--- /dev/null
+#!/bin/bash
+
+# Copy the whole script to /tmp/common-functions.sh and to remote nodes but
+# only if this script itself is executing and not sourced. jenkins prepends this
+# script to the common-functions.sh script when adding it to the robot minion.
+# jenkins with then execute the script. The if check below checks that the
+# script is executing rather than being sourced. When executed the condition
+# is true and copies the script. In the false path this copy below is skipped
+# and the common-function.sh ends up sourced.
+if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
+ echo "Copying common-functions.sh to /tmp"
+ cp "${0}" /tmp/common-functions.sh
+
+ [ "$NUM_OPENSTACK_SITES" ] || NUM_OPENSTACK_SITES=1
+ NUM_ODLS_PER_SITE=$((NUM_ODL_SYSTEM / NUM_OPENSTACK_SITES))
+ for i in `seq 1 ${NUM_OPENSTACK_SITES}`; do
+ for j in `seq 1 ${NUM_ODLS_PER_SITE}`; do
+ odl_ip=ODL_SYSTEM_$(((i - 1) * NUM_ODLS_PER_SITE + j))_IP
+ echo "Copying common-functions.sh to ${!odl_ip}:/tmp"
+ scp /tmp/common-functions.sh ${!odl_ip}:/tmp
+ done
+ done
+ # TODO: add copy to openstack systems when needed
+ exit 0
+fi
# script.
# shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
source ${ROBOT_VENV}/bin/activate
+source /tmp/common-functions.sh ${BUNDLEFOLDER}
echo "#################################################"
echo "## Configure Cluster and Start ##"
# Create the configuration script to be run on controllers.
cat > ${WORKSPACE}/configuration-script.sh <<EOF
+set -x
+source /tmp/common-functions.sh ${BUNDLEFOLDER}
echo "Changing to /tmp"
cd /tmp
cat ${CUSTOMPROP}
fi
-set_java_vars
+set_java_vars "${JAVA_HOME}"
# Copy shard file if exists
if [ -f /tmp/custom_shard_config.txt ]; then
# script.
# shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
source ${ROBOT_VENV}/bin/activate
-
+source /tmp/common-functions.sh ${BUNDLEFOLDER}
if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
echo "Configure cluster"
fi
cat > ${WORKSPACE}/configuration-script.sh <<EOF
+set -x
+source /tmp/common-functions.sh ${BUNDLEFOLDER}
echo "Changing to /tmp"
cd /tmp
fi
done
fi
+echo "cat ${LOGCONF}"
cat ${LOGCONF}
-set_java_vars
+set_java_vars "${JAVA_HOME}"
echo "Listing all open ports on controller system..."
netstat -pnatu
fi
EOF
+# cat > ${WORKSPACE}/configuration-script.sh <<EOF
# Create the startup script to be run on controller.
cat > ${WORKSPACE}/startup-script.sh <<EOF
/tmp/${BUNDLEFOLDER}/bin/start
EOF
+# cat > ${WORKSPACE}/startup-script.sh <<EOF
cat > ${WORKSPACE}/post-startup-script.sh <<EOF
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))
- builder:
name: integration-deploy-controller-run-test
builders:
- - shell: !include-raw:
- - common-functions.sh
- - integration-deploy-controller-run-test.sh
+ - shell: !include-raw: integration-deploy-controller-run-test.sh
# Macro: integration-configure-clustering
# Operation: this macro configures the clustering
- builder:
name: integration-configure-clustering
builders:
- - shell: !include-raw:
- - common-functions.sh
- - integration-configure-clustering.sh
+ - shell: !include-raw: integration-configure-clustering.sh
# Macro: integration-start-cluster-run-test
# Operation: this macro starts the 3-node cluster and runs test
builders:
- shell: !include-raw: integration-rebase-gerrit-patch.sh
+# Macro: integration-install-common-functions
+# Operation: Copy the common-functions.sh script to csit nodes
+# Used by: *-csit-* job templates
+- builder:
+ name: integration-install-common-functions
+ builders:
+ - shell: !include-raw:
+ - copy-common-functions.sh
+ - common-functions.sh
+
- builder:
name: integration-deploy-openstack-run-test
builders:
- - shell: !include-raw: integration-deploy-openstack-run-test.sh
+ - shell: !include-raw:
+ - integration-deploy-openstack-run-test.sh
- builder:
name: integration-compare-distributions
- inject:
properties-file: 'slave_addresses.txt'
- integration-detect-variables
+ - integration-install-common-functions
- integration-deploy-controller-run-test
- integration-cleanup-tmp
- inject:
properties-file: 'slave_addresses.txt'
- integration-detect-variables
+ - integration-install-common-functions
- integration-deploy-controller-run-test
- integration-cleanup-tmp
- inject:
properties-file: 'slave_addresses.txt'
- integration-detect-variables
+ - integration-install-common-functions
- integration-deploy-controller-run-test
- integration-cleanup-tmp
- inject:
properties-file: 'slave_addresses.txt'
- integration-detect-variables
+ - integration-install-common-functions
- integration-deploy-controller-run-test
- integration-deploy-openstack-run-test
- integration-cleanup-tmp
- inject:
properties-file: 'slave_addresses.txt'
- integration-detect-variables
+ - integration-install-common-functions
- integration-deploy-controller-run-test
- integration-deploy-openstack-run-test
- integration-cleanup-tmp
- inject:
properties-file: 'slave_addresses.txt'
- integration-detect-variables
+ - integration-install-common-functions
- integration-deploy-controller-run-test
- integration-cleanup-tmp