Add external repos during CSIT test
[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 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
20 CONTROLLERMEM="2048m"
21
22
23 if [ ${CONTROLLERSCOPE} == 'all' ]; then
24     ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
25     CONTROLLERMEM="3072m"
26 else
27     ACTUALFEATURES="odl-infrautils-ready,${CONTROLLERFEATURES}"
28 fi
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'`
32
33 # Utility function for joining strings.
34 function join {
35     delim=' '
36     final=$1; shift
37
38     for str in "$@" ; do
39         final=${final}${delim}${str}
40     done
41
42     echo ${final}
43 }
44
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}
49 done
50
51 nodes_list=$(join "${nodes[@]}")
52
53 echo ${nodes_list}
54
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
60     cat scriptplan.txt
61     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
62         echo "Executing ${line}..."
63         source ${line}
64     done
65 fi
66
67 # Create the configuration script to be run on controllers.
68 cat > ${WORKSPACE}/configuration-script.sh <<EOF
69
70 echo "Changing to /tmp"
71 cd /tmp
72
73 echo "Downloading the distribution from ${ACTUAL_BUNDLE_URL}"
74 wget --progress=dot:mega  '${ACTUAL_BUNDLE_URL}'
75
76 echo "Extracting the new controller..."
77 unzip -q ${BUNDLE}
78
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}
81 cat ${MAVENCONF}
82
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}
86 cat ${FEATURESCONF}
87
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
95 unset IFS
96 if [ -n "${CONTROLLERDEBUGMAP}" ]; then
97     for kv in ${CONTROLLERDEBUGMAP}; do
98         module=\${kv%%:*}
99         level=\${kv#*:}
100         if [ -n \${module} ] && [ -n \${level} ]; then
101             echo "log4j.logger.org.opendaylight.\${module} = \${level}" >> \${LOGCONF}
102         fi
103     done
104 fi
105 cat ${LOGCONF}
106
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}
110   cat ${CUSTOMPROP}
111 fi
112
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}
116 cat ${MEMCONF}
117
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 ..."
122 java -version
123
124 echo "Set JAVA_HOME"
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}"
129
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/
135 fi
136
137 echo "Configuring cluster"
138 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
139
140 echo "Dump akka.conf"
141 cat ${AKKACONF}
142
143 echo "Dump modules.conf"
144 cat ${MODULESCONF}
145
146 echo "Dump module-shards.conf"
147 cat ${MODULESHARDSCONF}
148
149 EOF
150
151 # Create the startup script to be run on controllers.
152 cat > ${WORKSPACE}/startup-script.sh <<EOF
153
154 echo "Redirecting karaf console output to karaf_console.log"
155 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
156
157 echo "Starting controller..."
158 /tmp/${BUNDLEFOLDER}/bin/start
159
160 EOF
161
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}`
165 do
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}"
170 done
171
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}"
176 fi
177
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
182     cat configplan.txt
183     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
184         echo "Executing ${line}..."
185         source ${line}
186     done
187 fi
188
189 # Copy over the startup script to each controller and execute it.
190 for i in `seq 1 ${NUM_ODL_SYSTEM}`
191 do
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"
196 done
197
198 # vim: ts=4 sw=4 sts=4 et ft=sh :