Merge "Fix indent for scm, triggers and publisher sub-sections"
[releng/builder.git] / jjb / integration / include-raw-integration-configure-clustering.sh
1 #@IgnoreInspection BashAddShebang
2 # Activate robotframework virtualenv
3 # ${ROBOT_VENV} comes from the include-raw-integration-install-robotframework.sh
4 # script.
5 source ${ROBOT_VENV}/bin/activate
6
7 echo "#################################################"
8 echo "##         Configure Cluster and Start         ##"
9 echo "#################################################"
10
11 AKKACONF=/tmp/${BUNDLEFOLDER}/configuration/initial/akka.conf
12 MODULESCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/modules.conf
13 MODULESHARDSCONF=/tmp/${BUNDLEFOLDER}/configuration/initial/module-shards.conf
14 CONTROLLERMEM="2048m"
15
16 if [ ${CONTROLLERSCOPE} == 'all' ]; then
17     ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
18     CONTROLLERMEM="3072m"
19 else
20     ACTUALFEATURES="${CONTROLLERFEATURES}"
21 fi
22 # Some versions of jenkins job builder result in feature list containing spaces
23 # and ending in newline. Remove all that.
24 ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
25
26 # Utility function for joining strings.
27 function join {
28     delim=' '
29     final=$1; shift
30
31     for str in $* ; do
32         final=${final}${delim}${str}
33     done
34
35     echo ${final}
36 }
37
38 # Create the string for nodes
39 for i in `seq 1 ${NUM_ODL_SYSTEM}` ; do
40     CONTROLLERIP=ODL_SYSTEM_${i}_IP
41     nodes[$i]=${!CONTROLLERIP}
42 done
43
44 nodes_list=$(join ${nodes[@]})
45
46 echo ${nodes_list}
47
48 # Run script plan in case it exists
49 if [ -f ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} ]; then
50     echo "scriptplan exists!!!"
51     echo "Reading the scriptplan:"
52     cat ${WORKSPACE}/test/csit/scriptplans/${TESTPLAN} | sed "s:integration:${WORKSPACE}:" > scriptplan.txt
53     cat scriptplan.txt
54     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' scriptplan.txt ); do
55         echo "Executing ${line}..."
56         source ${line}
57     done
58 fi
59
60 # Create the configuration script to be run on controllers.
61 cat > ${WORKSPACE}/configuration-script.sh <<EOF
62
63 echo "Changing to /tmp"
64 cd /tmp
65
66 echo "Downloading the distribution from ${ACTUALBUNDLEURL}"
67 wget --progress=dot:mega  '${ACTUALBUNDLEURL}'
68
69 echo "Extracting the new controller..."
70 unzip -q ${BUNDLE}
71
72 echo "Configuring the startup features..."
73 FEATURESCONF=/tmp/${BUNDLEFOLDER}/etc/org.apache.karaf.features.cfg
74 CUSTOMPROP=/tmp/${BUNDLEFOLDER}/etc/custom.properties
75 sed -ie "s/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${ACTUALFEATURES}/g" \${FEATURESCONF}
76 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}
77 cat \${FEATURESCONF}
78
79 echo "Configuring the log..."
80 LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
81 sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' \${LOGCONF}
82 # FIXME: Make log size limit configurable from build parameter.
83 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=30GB/g' \${LOGCONF}
84 cat \${LOGCONF}
85
86 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
87   echo "Enable the l3.fwd in custom.properties.."
88   echo "ovsdb.l3.fwd.enabled=yes" >> \${CUSTOMPROP}
89   cat \${CUSTOMPROP}
90 fi
91
92 echo "Configure java home and max memory..."
93 MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
94 sed -ie 's%^# export JAVA_HOME%export JAVA_HOME="\${JAVA_HOME:-${JAVA_HOME}}"%g' \${MEMCONF}
95 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
96 cat \${MEMCONF}
97
98 echo "Set Java version"
99 sudo /usr/sbin/alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 1
100 sudo /usr/sbin/alternatives --set java ${JAVA_HOME}/bin/java
101 echo "JDK default version ..."
102 java -version
103
104 echo "Set JAVA_HOME"
105 export JAVA_HOME="${JAVA_HOME}"
106 # Did you know that in HERE documents, single quote is an ordinary character, but backticks are still executing?
107 JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
108 echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
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 "Starting controller..."
135 /tmp/${BUNDLEFOLDER}/bin/start
136
137 EOF
138
139 # Copy over the configuration script and configuration files to each controller
140 # Execute the configuration script on each controller.
141 for i in `seq 1 ${NUM_ODL_SYSTEM}`
142 do
143     CONTROLLERIP=ODL_SYSTEM_${i}_IP
144     echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
145     scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
146     ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
147 done
148
149 # Run config plan in case it exists
150 configplan_filepath="${WORKSPACE}/test/csit/configplans/${STREAMTESTPLAN}"
151 if [ ! -f "${configplan_filepath}" ]; then
152     configplan_filepath="${WORKSPACE}/test/csit/configplans/${TESTPLAN}"
153 fi
154
155 if [ -f ${configplan_filepath} ]; then
156     echo "configplan exists!!!"
157     echo "Reading the configplan:"
158     cat ${configplan_filepath} | sed "s:integration:${WORKSPACE}:" > configplan.txt
159     cat configplan.txt
160     for line in $( egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' configplan.txt ); do
161         echo "Executing ${line}..."
162         source ${line}
163     done
164 fi
165
166 # Copy over the startup script to each controller and execute it.
167 for i in `seq 1 ${NUM_ODL_SYSTEM}`
168 do
169     CONTROLLERIP=ODL_SYSTEM_${i}_IP
170     echo "Starting member-${i} with IP address ${!CONTROLLERIP}"
171     scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp/
172     ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
173 done
174
175 # vim: ts=4 sw=4 sts=4 et ft=sh :