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
69 echo "Create RAM disk"
70 sudo mount -t tmpfs -o size=2G tmpfs /tmp
72 echo "Changing to /tmp"
75 echo "Downloading the distribution from ${ACTUAL_BUNDLE_URL}"
76 wget --progress=dot:mega '${ACTUAL_BUNDLE_URL}'
78 echo "Extracting the new controller..."
81 echo "Adding external repositories..."
82 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}
85 echo "Configuring the startup features..."
86 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
87 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}
90 echo "Configuring the log..."
91 sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' ${LOGCONF}
92 # FIXME: Make log size limit configurable from build parameter.
93 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=30GB/g' ${LOGCONF}
94 # Add custom logging levels
95 # CONTROLLERDEBUGMAP is expected to be a key:value map of space separated values like "module:level module2:level2"
96 # where module is abbreviated and does not include org.opendaylight
98 if [ -n "${CONTROLLERDEBUGMAP}" ]; then
99 for kv in ${CONTROLLERDEBUGMAP}; do
102 if [ -n \${module} ] && [ -n \${level} ]; then
103 echo "log4j.logger.org.opendaylight.\${module} = \${level}" >> \${LOGCONF}
109 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
110 echo "Enable the l3.fwd in custom.properties.."
111 echo "ovsdb.l3.fwd.enabled=yes" >> ${CUSTOMPROP}
115 echo "Configure java home and max memory..."
116 sed -ie 's%^# export JAVA_HOME%export JAVA_HOME="\${JAVA_HOME:-${JAVA_HOME}}"%g' ${MEMCONF}
117 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' ${MEMCONF}
120 echo "Set Java version"
121 sudo /usr/sbin/alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 1
122 sudo /usr/sbin/alternatives --set java ${JAVA_HOME}/bin/java
123 echo "JDK default version ..."
127 export JAVA_HOME="${JAVA_HOME}"
128 # Did you know that in HERE documents, single quote is an ordinary character, but backticks are still executing?
129 JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
130 echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
132 # Copy shard file if exists
133 if [ -f /tmp/custom_shard_config.txt ]; then
134 echo "Custom shard config exists!!!"
135 echo "Copying the shard config..."
136 cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
139 echo "Configuring cluster"
140 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
142 echo "Dump akka.conf"
145 echo "Dump modules.conf"
148 echo "Dump module-shards.conf"
149 cat ${MODULESHARDSCONF}
153 # Create the startup script to be run on controllers.
154 cat > ${WORKSPACE}/startup-script.sh <<EOF
156 echo "Redirecting karaf console output to karaf_console.log"
157 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
159 echo "Starting controller..."
160 /tmp/${BUNDLEFOLDER}/bin/start
164 # Copy over the configuration script and configuration files to each controller
165 # Execute the configuration script on each controller.
166 for i in `seq 1 ${NUM_ODL_SYSTEM}`
168 CONTROLLERIP=ODL_SYSTEM_${i}_IP
169 echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
170 scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
171 ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
174 # Run config plan in case it exists
175 configplan_filepath="${WORKSPACE}/test/csit/configplans/${STREAMTESTPLAN}"
176 if [ ! -f "${configplan_filepath}" ]; then
177 configplan_filepath="${WORKSPACE}/test/csit/configplans/${TESTPLAN}"
180 if [ -f ${configplan_filepath} ]; then
181 echo "configplan exists!!!"
182 echo "Reading the configplan:"
183 cat ${configplan_filepath} | sed "s:integration:${WORKSPACE}:" > configplan.txt
185 for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
186 echo "Executing ${line}..."
191 # Copy over the startup script to each controller and execute it.
192 for i in `seq 1 ${NUM_ODL_SYSTEM}`
194 CONTROLLERIP=ODL_SYSTEM_${i}_IP
195 echo "Starting member-${i} with IP address ${!CONTROLLERIP}"
196 scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp/
197 ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
200 # vim: ts=4 sw=4 sts=4 et ft=sh :