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 MAVENCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.url.mvn.cfg
16 FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
17 CUSTOMPROP=/tmp/${BUNDLEFOLDER}/etc/custom.properties
18 LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
19 MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
23 if [ ${CONTROLLERSCOPE} == 'all' ]; then
24 ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
27 ACTUALFEATURES="odl-infrautils-ready,${CONTROLLERFEATURES}"
29 # Some versions of jenkins job builder result in feature list containing spaces
30 # and ending in newline. Remove all that.
31 ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
33 # Utility function for joining strings.
39 final=${final}${delim}${str}
45 # Create the string for nodes
46 for i in `seq 1 ${NUM_ODL_SYSTEM}` ; do
47 CONTROLLERIP=ODL_SYSTEM_${i}_IP
48 nodes[$i]=${!CONTROLLERIP}
51 nodes_list=$(join "${nodes[@]}")
55 # Run script plan in case it exists
56 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
57 echo "scriptplan exists!!!"
58 echo "Reading the scriptplan:"
59 cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
61 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
62 echo "Executing ${line}..."
67 # Create the configuration script to be run on controllers.
68 cat > ${WORKSPACE}/configuration-script.sh <<EOF
70 echo "Changing to /tmp"
73 echo "Downloading the distribution from ${ACTUAL_BUNDLE_URL}"
74 wget --progress=dot:mega '${ACTUAL_BUNDLE_URL}'
76 echo "Extracting the new controller..."
79 echo "Adding external repositories..."
80 sed -ie "s%org.ops4j.pax.url.mvn.repositories=%org.ops4j.pax.url.mvn.repositories=http://repo1.maven.org/maven2@id=central, http://repository.springsource.com/maven/bundles/release@id=spring.ebr.release, http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external, http://zodiac.springsource.com/maven/bundles/release@id=gemini, http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases, https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases%g" ${MAVENCONF}
83 echo "Configuring the startup features..."
84 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
85 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}
88 echo "Configuring the log..."
89 sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' ${LOGCONF}
90 # FIXME: Make log size limit configurable from build parameter.
91 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=30GB/g' ${LOGCONF}
92 # Add custom logging levels
93 # CONTROLLERDEBUGMAP is expected to be a key:value map of space separated values like "module:level module2:level2"
94 # where module is abbreviated and does not include org.opendaylight
96 if [ -n "${CONTROLLERDEBUGMAP}" ]; then
97 for kv in ${CONTROLLERDEBUGMAP}; do
100 if [ -n \${module} ] && [ -n \${level} ]; then
101 echo "log4j.logger.org.opendaylight.\${module} = \${level}" >> \${LOGCONF}
107 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
108 echo "Enable the l3.fwd in custom.properties.."
109 echo "ovsdb.l3.fwd.enabled=yes" >> ${CUSTOMPROP}
113 echo "Configure java home and max memory..."
114 sed -ie 's%^# export JAVA_HOME%export JAVA_HOME="\${JAVA_HOME:-${JAVA_HOME}}"%g' ${MEMCONF}
115 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' ${MEMCONF}
118 echo "Set Java version"
119 sudo /usr/sbin/alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 1
120 sudo /usr/sbin/alternatives --set java ${JAVA_HOME}/bin/java
121 echo "JDK default version ..."
125 export JAVA_HOME="${JAVA_HOME}"
126 # Did you know that in HERE documents, single quote is an ordinary character, but backticks are still executing?
127 JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
128 echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
130 # Copy shard file if exists
131 if [ -f /tmp/custom_shard_config.txt ]; then
132 echo "Custom shard config exists!!!"
133 echo "Copying the shard config..."
134 cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
137 echo "Configuring cluster"
138 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
140 echo "Dump akka.conf"
143 echo "Dump modules.conf"
146 echo "Dump module-shards.conf"
147 cat ${MODULESHARDSCONF}
151 # Create the startup script to be run on controllers.
152 cat > ${WORKSPACE}/startup-script.sh <<EOF
154 echo "Redirecting karaf console output to karaf_console.log"
155 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
157 echo "Starting controller..."
158 /tmp/${BUNDLEFOLDER}/bin/start
162 # Copy over the configuration script and configuration files to each controller
163 # Execute the configuration script on each controller.
164 for i in `seq 1 ${NUM_ODL_SYSTEM}`
166 CONTROLLERIP=ODL_SYSTEM_${i}_IP
167 echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
168 scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
169 ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
172 # Run config plan in case it exists
173 configplan_filepath="${WORKSPACE}/test/csit/configplans/${STREAMTESTPLAN}"
174 if [ ! -f "${configplan_filepath}" ]; then
175 configplan_filepath="${WORKSPACE}/test/csit/configplans/${TESTPLAN}"
178 if [ -f ${configplan_filepath} ]; then
179 echo "configplan exists!!!"
180 echo "Reading the configplan:"
181 cat ${configplan_filepath} | sed "s:integration:${WORKSPACE}:" > configplan.txt
183 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
184 echo "Executing ${line}..."
189 # Copy over the startup script to each controller and execute it.
190 for i in `seq 1 ${NUM_ODL_SYSTEM}`
192 CONTROLLERIP=ODL_SYSTEM_${i}_IP
193 echo "Starting member-${i} with IP address ${!CONTROLLERIP}"
194 scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp/
195 ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
198 # vim: ts=4 sw=4 sts=4 et ft=sh :