1 #@IgnoreInspection BashAddShebang
2 # Activate robotframework virtualenv
3 # ${ROBOT_VENV} comes from the integration-install-robotframework.sh
5 # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
6 source ${ROBOT_VENV}/bin/activate
8 echo "#################################################"
9 echo "## Configure Cluster and Start ##"
10 echo "#################################################"
12 AKKACONF=/tmp/${BUNDLEFOLDER}/configuration/initial/akka.conf
13 MODULESCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/modules.conf
14 MODULESHARDSCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/module-shards.conf
17 if [ ${CONTROLLERSCOPE} == 'all' ]; then
18 ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
21 ACTUALFEATURES="${CONTROLLERFEATURES}"
23 # Some versions of jenkins job builder result in feature list containing spaces
24 # and ending in newline. Remove all that.
25 ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
27 # Utility function for joining strings.
33 final=${final}${delim}${str}
39 # Create the string for nodes
40 for i in `seq 1 ${NUM_ODL_SYSTEM}` ; do
41 CONTROLLERIP=ODL_SYSTEM_${i}_IP
42 nodes[$i]=${!CONTROLLERIP}
45 nodes_list=$(join "${nodes[@]}")
49 # Run script plan in case it exists
50 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
51 echo "scriptplan exists!!!"
52 echo "Reading the scriptplan:"
53 cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
55 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
56 echo "Executing ${line}..."
61 # Create the configuration script to be run on controllers.
62 cat > ${WORKSPACE}/configuration-script.sh <<EOF
64 echo "Changing to /tmp"
67 echo "Downloading the distribution from ${ACTUAL_BUNDLE_URL}"
68 wget --progress=dot:mega '${ACTUAL_BUNDLE_URL}'
70 echo "Extracting the new controller..."
73 echo "Configuring the startup features..."
74 FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
75 CUSTOMPROP=/tmp/${BUNDLEFOLDER}/etc/custom.properties
76 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" \${FEATURESCONF}
77 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,mvn:org.apache.karaf.decanter/apache-karaf-decanter/1.0.0/xml/features%g" \${FEATURESCONF}
80 echo "Configuring the log..."
81 LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
82 sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' \${LOGCONF}
83 # FIXME: Make log size limit configurable from build parameter.
84 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=30GB/g' \${LOGCONF}
87 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
88 echo "Enable the l3.fwd in custom.properties.."
89 echo "ovsdb.l3.fwd.enabled=yes" >> \${CUSTOMPROP}
93 echo "Configure java home and max memory..."
94 MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
95 sed -ie 's%^# export JAVA_HOME%export JAVA_HOME="\${JAVA_HOME:-${JAVA_HOME}}"%g' \${MEMCONF}
96 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
99 echo "Set Java version"
100 sudo /usr/sbin/alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 1
101 sudo /usr/sbin/alternatives --set java ${JAVA_HOME}/bin/java
102 echo "JDK default version ..."
106 export JAVA_HOME="${JAVA_HOME}"
107 # Did you know that in HERE documents, single quote is an ordinary character, but backticks are still executing?
108 JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
109 echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
111 # Copy shard file if exists
112 if [ -f /tmp/custom_shard_config.txt ]; then
113 echo "Custom shard config exists!!!"
114 echo "Copying the shard config..."
115 cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
118 echo "Configuring cluster"
119 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
121 echo "Dump akka.conf"
124 echo "Dump modules.conf"
127 echo "Dump module-shards.conf"
128 cat ${MODULESHARDSCONF}
132 # Create the startup script to be run on controllers.
133 cat > ${WORKSPACE}/startup-script.sh <<EOF
135 echo "Redirecting karaf console output to karaf_console.log"
136 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
138 echo "Starting controller..."
139 /tmp/${BUNDLEFOLDER}/bin/start
143 # Copy over the configuration script and configuration files to each controller
144 # Execute the configuration script on each controller.
145 for i in `seq 1 ${NUM_ODL_SYSTEM}`
147 CONTROLLERIP=ODL_SYSTEM_${i}_IP
148 echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
149 scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
150 ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
153 # Run config plan in case it exists
154 configplan_filepath="${WORKSPACE}/test/csit/configplans/${STREAMTESTPLAN}"
155 if [ ! -f "${configplan_filepath}" ]; then
156 configplan_filepath="${WORKSPACE}/test/csit/configplans/${TESTPLAN}"
159 if [ -f ${configplan_filepath} ]; then
160 echo "configplan exists!!!"
161 echo "Reading the configplan:"
162 cat ${configplan_filepath} | sed "s:integration:${WORKSPACE}:" > configplan.txt
164 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
165 echo "Executing ${line}..."
170 # Copy over the startup script to each controller and execute it.
171 for i in `seq 1 ${NUM_ODL_SYSTEM}`
173 CONTROLLERIP=ODL_SYSTEM_${i}_IP
174 echo "Starting member-${i} with IP address ${!CONTROLLERIP}"
175 scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp/
176 ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
179 # vim: ts=4 sw=4 sts=4 et ft=sh :