00745aa38c133f393fd02a0a0ab9002f19482a0c
[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 source /tmp/common-functions.sh ${BUNDLEFOLDER}
8
9 echo "#################################################"
10 echo "##         Configure Cluster and Start         ##"
11 echo "#################################################"
12
13 if [ ${CONTROLLERSCOPE} == 'all' ]; then
14     ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
15     export CONTROLLERMEM="3072m"
16 else
17     ACTUALFEATURES="odl-infrautils-ready,${CONTROLLERFEATURES}"
18 fi
19 # Some versions of jenkins job builder result in feature list containing spaces
20 # and ending in newline. Remove all that.
21 ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
22
23 # Utility function for joining strings.
24 function join {
25     delim=' '
26     final=$1; shift
27
28     for str in "$@" ; do
29         final=${final}${delim}${str}
30     done
31
32     echo ${final}
33 }
34
35 # Create the string for nodes
36 for i in `seq 1 ${NUM_ODL_SYSTEM}` ; do
37     CONTROLLERIP=ODL_SYSTEM_${i}_IP
38     nodes[$i]=${!CONTROLLERIP}
39 done
40
41 nodes_list=$(join "${nodes[@]}")
42
43 echo ${nodes_list}
44
45 # Run script plan in case it exists
46 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
47     echo "scriptplan exists!!!"
48     echo "Reading the scriptplan:"
49     cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
50     cat scriptplan.txt
51     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
52         echo "Executing ${line}..."
53         source ${line}
54     done
55 fi
56
57 # Create the configuration script to be run on controllers.
58 cat > ${WORKSPACE}/configuration-script.sh <<EOF
59 set -x
60 source /tmp/common-functions.sh ${BUNDLEFOLDER}
61
62 echo "Changing to /tmp"
63 cd /tmp
64
65 echo "Downloading the distribution from ${ACTUAL_BUNDLE_URL}"
66 wget --progress=dot:mega  '${ACTUAL_BUNDLE_URL}'
67
68 echo "Extracting the new controller..."
69 unzip -q ${BUNDLE}
70
71 echo "Adding external repositories..."
72 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}
73 cat ${MAVENCONF}
74
75 echo "Configuring the startup features..."
76 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
77
78 FEATURE_TEST_STRING="features-integration-test"
79 if [[ "$KARAF_VERSION" == "karaf4" ]]; then
80     FEATURE_TEST_STRING="features-test"
81 fi
82
83 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}
84 cat ${FEATURESCONF}
85
86 echo "Configuring the log..."
87 sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' ${LOGCONF}
88 # FIXME: Make log size limit configurable from build parameter.
89 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=30GB/g' ${LOGCONF}
90 # Add custom logging levels
91 # CONTROLLERDEBUGMAP is expected to be a key:value map of space separated values like "module:level module2:level2"
92 # where module is abbreviated and does not include org.opendaylight
93 unset IFS
94 if [ -n "${CONTROLLERDEBUGMAP}" ]; then
95     for kv in ${CONTROLLERDEBUGMAP}; do
96         module=\${kv%%:*}
97         level=\${kv#*:}
98         if [ -n \${module} ] && [ -n \${level} ]; then
99             echo "log4j.logger.org.opendaylight.\${module} = \${level}" >> \${LOGCONF}
100         fi
101     done
102 fi
103 cat ${LOGCONF}
104
105 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
106   echo "Enable the l3.fwd in custom.properties.."
107   echo "ovsdb.l3.fwd.enabled=yes" >> ${CUSTOMPROP}
108   cat ${CUSTOMPROP}
109 fi
110
111 set_java_vars "${JAVA_HOME}"
112
113 # Copy shard file if exists
114 if [ -f /tmp/custom_shard_config.txt ]; then
115     echo "Custom shard config exists!!!"
116     echo "Copying the shard config..."
117     cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
118 fi
119
120 echo "Configuring cluster"
121 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
122
123 echo "Dump akka.conf"
124 cat ${AKKACONF}
125
126 echo "Dump modules.conf"
127 cat ${MODULESCONF}
128
129 echo "Dump module-shards.conf"
130 cat ${MODULESHARDSCONF}
131
132 EOF
133
134 # Create the startup script to be run on controllers.
135 cat > ${WORKSPACE}/startup-script.sh <<EOF
136
137 echo "Redirecting karaf console output to karaf_console.log"
138 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
139 mkdir -p /tmp/${BUNDLEFOLDER}/data/log
140
141 echo "Starting controller..."
142 /tmp/${BUNDLEFOLDER}/bin/start
143
144 EOF
145
146 # Copy over the configuration script and configuration files to each controller
147 # Execute the configuration script on each controller.
148 for i in `seq 1 ${NUM_ODL_SYSTEM}`
149 do
150     CONTROLLERIP=ODL_SYSTEM_${i}_IP
151     echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
152     scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
153     ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
154 done
155
156 # Run config plan in case it exists
157 configplan_filepath="${WORKSPACE}/test/csit/configplans/${STREAMTESTPLAN}"
158 if [ ! -f "${configplan_filepath}" ]; then
159     configplan_filepath="${WORKSPACE}/test/csit/configplans/${TESTPLAN}"
160 fi
161
162 if [ -f ${configplan_filepath} ]; then
163     echo "configplan exists!!!"
164     echo "Reading the configplan:"
165     cat ${configplan_filepath} | sed "s:integration:${WORKSPACE}:" > configplan.txt
166     cat configplan.txt
167     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
168         echo "Executing ${line}..."
169         source ${line}
170     done
171 fi
172
173 # Copy over the startup script to each controller and execute it.
174 for i in `seq 1 ${NUM_ODL_SYSTEM}`
175 do
176     CONTROLLERIP=ODL_SYSTEM_${i}_IP
177     echo "Starting member-${i} with IP address ${!CONTROLLERIP}"
178     scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp/
179     ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
180 done
181
182 # vim: ts=4 sw=4 sts=4 et ft=sh :