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