Configure tep-ip for genius auto tunnels
[releng/builder.git] / jjb / integration / integration-configure-clustering.sh
1 #@IgnoreInspection BashAddShebang
2 # Activate robotframework virtualenv
3 # ${ROBOT_VENV} comes from the integration-install-robotframework.sh
4 # script.
5 # shellcheck source=${ROBOT_VENV}/bin/activate disable=SC1091
6 source ${ROBOT_VENV}/bin/activate
7
8 echo "#################################################"
9 echo "##         Configure Cluster and Start         ##"
10 echo "#################################################"
11
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
19 CONTROLLERMEM="2048m"
20
21
22 if [ ${CONTROLLERSCOPE} == 'all' ]; then
23     ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
24     CONTROLLERMEM="3072m"
25 else
26     ACTUALFEATURES="odl-infrautils-ready,${CONTROLLERFEATURES}"
27 fi
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'`
31
32 # Utility function for joining strings.
33 function join {
34     delim=' '
35     final=$1; shift
36
37     for str in "$@" ; do
38         final=${final}${delim}${str}
39     done
40
41     echo ${final}
42 }
43
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}
48 done
49
50 nodes_list=$(join "${nodes[@]}")
51
52 echo ${nodes_list}
53
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
59     cat scriptplan.txt
60     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
61         echo "Executing ${line}..."
62         source ${line}
63     done
64 fi
65
66 # Create the configuration script to be run on controllers.
67 cat > ${WORKSPACE}/configuration-script.sh <<EOF
68
69 echo "Changing to /tmp"
70 cd /tmp
71
72 echo "Downloading the distribution from ${ACTUAL_BUNDLE_URL}"
73 wget --progress=dot:mega  '${ACTUAL_BUNDLE_URL}'
74
75 echo "Extracting the new controller..."
76 unzip -q ${BUNDLE}
77
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}
81 cat ${FEATURESCONF}
82
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
90 unset IFS
91 if [ -n "${CONTROLLERDEBUGMAP}" ]; then
92     for kv in ${CONTROLLERDEBUGMAP}; do
93         module=\${kv%%:*}
94         level=\${kv#*:}
95         if [ -n \${module} ] && [ -n \${level} ]; then
96             echo "log4j.logger.org.opendaylight.\${module} = \${level}" >> \${LOGCONF}
97         fi
98     done
99 fi
100 cat ${LOGCONF}
101
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}
105   cat ${CUSTOMPROP}
106 fi
107
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}
111 cat ${MEMCONF}
112
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 ..."
117 java -version
118
119 echo "Set JAVA_HOME"
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}"
124
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/
130 fi
131
132 echo "Configuring cluster"
133 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
134
135 echo "Dump akka.conf"
136 cat ${AKKACONF}
137
138 echo "Dump modules.conf"
139 cat ${MODULESCONF}
140
141 echo "Dump module-shards.conf"
142 cat ${MODULESHARDSCONF}
143
144 EOF
145
146 # Create the startup script to be run on controllers.
147 cat > ${WORKSPACE}/startup-script.sh <<EOF
148
149 echo "Redirecting karaf console output to karaf_console.log"
150 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
151
152 echo "Starting controller..."
153 /tmp/${BUNDLEFOLDER}/bin/start
154
155 EOF
156
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}`
160 do
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}"
165 done
166
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}"
171 fi
172
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
177     cat configplan.txt
178     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
179         echo "Executing ${line}..."
180         source ${line}
181     done
182 fi
183
184 # Copy over the startup script to each controller and execute it.
185 for i in `seq 1 ${NUM_ODL_SYSTEM}`
186 do
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"
191 done
192
193 # vim: ts=4 sw=4 sts=4 et ft=sh :