Merge "Replace pip freeze with pipdeptree"
[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 CONTROLLERMEM="2048m"
16
17 if [ ${CONTROLLERSCOPE} == 'all' ]; then
18     ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
19     CONTROLLERMEM="3072m"
20 else
21     ACTUALFEATURES="${CONTROLLERFEATURES}"
22 fi
23 # Some versions of jenkins job builder result in feature list containing spaces
24 # and ending in newline. Remove all that.
25 ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
26
27 # Utility function for joining strings.
28 function join {
29     delim=' '
30     final=$1; shift
31
32     for str in "$@" ; do
33         final=${final}${delim}${str}
34     done
35
36     echo ${final}
37 }
38
39 # Create the string for nodes
40 for i in `seq 1 ${NUM_ODL_SYSTEM}` ; do
41     CONTROLLERIP=ODL_SYSTEM_${i}_IP
42     nodes[$i]=${!CONTROLLERIP}
43 done
44
45 nodes_list=$(join "${nodes[@]}")
46
47 echo ${nodes_list}
48
49 # Run script plan in case it exists
50 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
51     echo "scriptplan exists!!!"
52     echo "Reading the scriptplan:"
53     cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
54     cat scriptplan.txt
55     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
56         echo "Executing ${line}..."
57         source ${line}
58     done
59 fi
60
61 # Create the configuration script to be run on controllers.
62 cat > ${WORKSPACE}/configuration-script.sh <<EOF
63
64 echo "Changing to /tmp"
65 cd /tmp
66
67 echo "Downloading the distribution from ${ACTUAL_BUNDLE_URL}"
68 wget --progress=dot:mega  '${ACTUAL_BUNDLE_URL}'
69
70 echo "Extracting the new controller..."
71 unzip -q ${BUNDLE}
72
73 echo "Configuring the startup features..."
74 FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
75 CUSTOMPROP=/tmp/${BUNDLEFOLDER}/etc/custom.properties
76 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" \${FEATURESCONF}
77 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}
78 cat \${FEATURESCONF}
79
80 echo "Configuring the log..."
81 LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
82 sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' \${LOGCONF}
83 # FIXME: Make log size limit configurable from build parameter.
84 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=30GB/g' \${LOGCONF}
85 cat \${LOGCONF}
86
87 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
88   echo "Enable the l3.fwd in custom.properties.."
89   echo "ovsdb.l3.fwd.enabled=yes" >> \${CUSTOMPROP}
90   cat \${CUSTOMPROP}
91 fi
92
93 echo "Configure java home and max memory..."
94 MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
95 sed -ie 's%^# export JAVA_HOME%export JAVA_HOME="\${JAVA_HOME:-${JAVA_HOME}}"%g' \${MEMCONF}
96 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
97 cat \${MEMCONF}
98
99 echo "Set Java version"
100 sudo /usr/sbin/alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 1
101 sudo /usr/sbin/alternatives --set java ${JAVA_HOME}/bin/java
102 echo "JDK default version ..."
103 java -version
104
105 echo "Set JAVA_HOME"
106 export JAVA_HOME="${JAVA_HOME}"
107 # Did you know that in HERE documents, single quote is an ordinary character, but backticks are still executing?
108 JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
109 echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
110
111 # Copy shard file if exists
112 if [ -f /tmp/custom_shard_config.txt ]; then
113     echo "Custom shard config exists!!!"
114     echo "Copying the shard config..."
115     cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
116 fi
117
118 echo "Configuring cluster"
119 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
120
121 echo "Dump akka.conf"
122 cat ${AKKACONF}
123
124 echo "Dump modules.conf"
125 cat ${MODULESCONF}
126
127 echo "Dump module-shards.conf"
128 cat ${MODULESHARDSCONF}
129
130 EOF
131
132 # Create the startup script to be run on controllers.
133 cat > ${WORKSPACE}/startup-script.sh <<EOF
134
135 echo "Redirecting karaf console output to karaf_console.log"
136 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.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 :