Merge "Remove COE openstack based CSIT"
[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 if [ ${CONTROLLERSCOPE} == 'all' ]; then
13     ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
14     export CONTROLLERMEM="3072m"
15 else
16     ACTUALFEATURES="odl-infrautils-ready,${CONTROLLERFEATURES}"
17 fi
18 # Some versions of jenkins job builder result in feature list containing spaces
19 # and ending in newline. Remove all that.
20 ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
21
22 # Utility function for joining strings.
23 function join {
24     delim=' '
25     final=$1; shift
26
27     for str in "$@" ; do
28         final=${final}${delim}${str}
29     done
30
31     echo ${final}
32 }
33
34 # Create the string for nodes
35 for i in `seq 1 ${NUM_ODL_SYSTEM}` ; do
36     CONTROLLERIP=ODL_SYSTEM_${i}_IP
37     nodes[$i]=${!CONTROLLERIP}
38 done
39
40 nodes_list=$(join "${nodes[@]}")
41
42 echo ${nodes_list}
43
44 # Run script plan in case it exists
45 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
46     echo "scriptplan exists!!!"
47     echo "Reading the scriptplan:"
48     cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
49     cat scriptplan.txt
50     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
51         echo "Executing ${line}..."
52         source ${line}
53     done
54 fi
55
56 # Create the configuration script to be run on controllers.
57 cat > ${WORKSPACE}/configuration-script.sh <<EOF
58
59 echo "Changing to /tmp"
60 cd /tmp
61
62 echo "Downloading the distribution from ${ACTUAL_BUNDLE_URL}"
63 wget --progress=dot:mega  '${ACTUAL_BUNDLE_URL}'
64
65 echo "Extracting the new controller..."
66 unzip -q ${BUNDLE}
67
68 echo "Adding external repositories..."
69 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}
70 cat ${MAVENCONF}
71
72 echo "Configuring the startup features..."
73 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
74
75 FEATURE_TEST_STRING="features-integration-test"
76 if [[ "$KARAF_VERSION" == "karaf4" ]]; then
77     FEATURE_TEST_STRING="features-test"
78 fi
79
80 sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = mvn:org.opendaylight.integration/\${FEATURE_TEST_STRING}/${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 set_java_vars
109
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/
115 fi
116
117 echo "Configuring cluster"
118 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
119
120 echo "Dump akka.conf"
121 cat ${AKKACONF}
122
123 echo "Dump modules.conf"
124 cat ${MODULESCONF}
125
126 echo "Dump module-shards.conf"
127 cat ${MODULESHARDSCONF}
128
129 EOF
130
131 # Create the startup script to be run on controllers.
132 cat > ${WORKSPACE}/startup-script.sh <<EOF
133
134 echo "Redirecting karaf console output to karaf_console.log"
135 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
136 mkdir -p /tmp/${BUNDLEFOLDER}/data/log
137
138 echo "Starting controller..."
139 /tmp/${BUNDLEFOLDER}/bin/start
140
141 EOF
142
143 # Copy over the configuration script and configuration files to each controller
144 # Execute the configuration script on each controller.
145 for i in `seq 1 ${NUM_ODL_SYSTEM}`
146 do
147     CONTROLLERIP=ODL_SYSTEM_${i}_IP
148     echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
149     scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
150     ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
151 done
152
153 # Run config plan in case it exists
154 configplan_filepath="${WORKSPACE}/test/csit/configplans/${STREAMTESTPLAN}"
155 if [ ! -f "${configplan_filepath}" ]; then
156     configplan_filepath="${WORKSPACE}/test/csit/configplans/${TESTPLAN}"
157 fi
158
159 if [ -f ${configplan_filepath} ]; then
160     echo "configplan exists!!!"
161     echo "Reading the configplan:"
162     cat ${configplan_filepath} | sed "s:integration:${WORKSPACE}:" > configplan.txt
163     cat configplan.txt
164     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
165         echo "Executing ${line}..."
166         source ${line}
167     done
168 fi
169
170 # Copy over the startup script to each controller and execute it.
171 for i in `seq 1 ${NUM_ODL_SYSTEM}`
172 do
173     CONTROLLERIP=ODL_SYSTEM_${i}_IP
174     echo "Starting member-${i} with IP address ${!CONTROLLERIP}"
175     scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp/
176     ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
177 done
178
179 # vim: ts=4 sw=4 sts=4 et ft=sh :