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