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
15 FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
16 CUSTOMPROP=/tmp/${BUNDLEFOLDER}/etc/custom.properties
17 LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
18 MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
22 if [ ${CONTROLLERSCOPE} == 'all' ]; then
23 ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
26 ACTUALFEATURES="odl-infrautils-ready,${CONTROLLERFEATURES}"
28 # Some versions of jenkins job builder result in feature list containing spaces
29 # and ending in newline. Remove all that.
30 ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
32 # Utility function for joining strings.
38 final=${final}${delim}${str}
44 # Create the string for nodes
45 for i in `seq 1 ${NUM_ODL_SYSTEM}` ; do
46 CONTROLLERIP=ODL_SYSTEM_${i}_IP
47 nodes[$i]=${!CONTROLLERIP}
50 nodes_list=$(join "${nodes[@]}")
54 # Run script plan in case it exists
55 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
56 echo "scriptplan exists!!!"
57 echo "Reading the scriptplan:"
58 cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
60 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
61 echo "Executing ${line}..."
66 # Create the configuration script to be run on controllers.
67 cat > ${WORKSPACE}/configuration-script.sh <<EOF
69 echo "Changing to /tmp"
72 echo "Downloading the distribution from ${ACTUAL_BUNDLE_URL}"
73 wget --progress=dot:mega '${ACTUAL_BUNDLE_URL}'
75 echo "Extracting the new controller..."
78 echo "Configuring the startup features..."
79 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
80 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}
83 echo "Configuring the log..."
84 sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' ${LOGCONF}
85 # FIXME: Make log size limit configurable from build parameter.
86 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=30GB/g' ${LOGCONF}
87 # Add custom logging levels
88 # CONTROLLERDEBUGMAP is expected to be a key:value map of space separated values like "module:level module2:level2"
89 # where module is abbreviated and does not include org.opendaylight
91 if [ -n "${CONTROLLERDEBUGMAP}" ]; then
92 for kv in ${CONTROLLERDEBUGMAP}; do
95 if [ -n \${module} ] && [ -n \${level} ]; then
96 echo "log4j.logger.org.opendaylight.\${module} = \${level}" >> \${LOGCONF}
102 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
103 echo "Enable the l3.fwd in custom.properties.."
104 echo "ovsdb.l3.fwd.enabled=yes" >> ${CUSTOMPROP}
108 echo "Configure java home and max memory..."
109 sed -ie 's%^# export JAVA_HOME%export JAVA_HOME="\${JAVA_HOME:-${JAVA_HOME}}"%g' ${MEMCONF}
110 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' ${MEMCONF}
113 echo "Set Java version"
114 sudo /usr/sbin/alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 1
115 sudo /usr/sbin/alternatives --set java ${JAVA_HOME}/bin/java
116 echo "JDK default version ..."
120 export JAVA_HOME="${JAVA_HOME}"
121 # Did you know that in HERE documents, single quote is an ordinary character, but backticks are still executing?
122 JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
123 echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
125 # Copy shard file if exists
126 if [ -f /tmp/custom_shard_config.txt ]; then
127 echo "Custom shard config exists!!!"
128 echo "Copying the shard config..."
129 cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
132 echo "Configuring cluster"
133 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
135 echo "Dump akka.conf"
138 echo "Dump modules.conf"
141 echo "Dump module-shards.conf"
142 cat ${MODULESHARDSCONF}
146 # Create the startup script to be run on controllers.
147 cat > ${WORKSPACE}/startup-script.sh <<EOF
149 echo "Redirecting karaf console output to karaf_console.log"
150 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
152 echo "Starting controller..."
153 /tmp/${BUNDLEFOLDER}/bin/start
157 # Copy over the configuration script and configuration files to each controller
158 # Execute the configuration script on each controller.
159 for i in `seq 1 ${NUM_ODL_SYSTEM}`
161 CONTROLLERIP=ODL_SYSTEM_${i}_IP
162 echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
163 scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
164 ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
167 # Run config plan in case it exists
168 configplan_filepath="${WORKSPACE}/test/csit/configplans/${STREAMTESTPLAN}"
169 if [ ! -f "${configplan_filepath}" ]; then
170 configplan_filepath="${WORKSPACE}/test/csit/configplans/${TESTPLAN}"
173 if [ -f ${configplan_filepath} ]; then
174 echo "configplan exists!!!"
175 echo "Reading the configplan:"
176 cat ${configplan_filepath} | sed "s:integration:${WORKSPACE}:" > configplan.txt
178 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
179 echo "Executing ${line}..."
184 # Copy over the startup script to each controller and execute it.
185 for i in `seq 1 ${NUM_ODL_SYSTEM}`
187 CONTROLLERIP=ODL_SYSTEM_${i}_IP
188 echo "Starting member-${i} with IP address ${!CONTROLLERIP}"
189 scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp/
190 ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
193 # vim: ts=4 sw=4 sts=4 et ft=sh :