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