0950622f247c4f18cbc0c65d209cf996c2fd418b
[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 sed -ie "s/featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${ACTUALFEATURES}/g" \${FEATURESCONF}
69 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}
70 cat \${FEATURESCONF}
71
72 echo "Configuring the log..."
73 LOGCONF=/tmp/${BUNDLEFOLDER}/etc/org.ops4j.pax.logging.cfg
74 sed -ie 's/log4j.appender.out.maxBackupIndex=10/log4j.appender.out.maxBackupIndex=1/g' \${LOGCONF}
75 # FIXME: Make log size limit configurable from build parameter.
76 sed -ie 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=100GB/g' \${LOGCONF}
77 cat \${LOGCONF}
78
79 echo "Configure java home and max memory..."
80 MEMCONF=/tmp/${BUNDLEFOLDER}/bin/setenv
81 sed -ie 's%^# export JAVA_HOME%export JAVA_HOME="\${JAVA_HOME:-${JAVA_HOME}}"%g' \${MEMCONF}
82 sed -ie 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/g' \${MEMCONF}
83 cat \${MEMCONF}
84
85 echo "Set Java version"
86 sudo /usr/sbin/alternatives --install /usr/bin/java java ${JAVA_HOME}/bin/java 1
87 sudo /usr/sbin/alternatives --set java ${JAVA_HOME}/bin/java
88 echo "JDK default version ..."
89 java -version
90
91 echo "Set JAVA_HOME"
92 export JAVA_HOME="${JAVA_HOME}"
93 # Did you know that in HERE documents, single quote is an ordinary character, but backticks are still executing?
94 JAVA_RESOLVED=\`readlink -e "\${JAVA_HOME}/bin/java"\`
95 echo "Java binary pointed at by JAVA_HOME: \${JAVA_RESOLVED}"
96
97 # Copy shard file if exists
98 if [ -f /tmp/custom_shard_config.txt ]; then
99     echo "Custom shard config exists!!!"
100     echo "Copying the shard config..."
101     cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
102 fi
103
104 echo "Configuring cluster"
105 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
106
107 echo "Dump akka.conf"
108 cat ${AKKACONF}
109
110 echo "Dump modules.conf"
111 cat ${MODULESCONF}
112
113 echo "Dump module-shards.conf"
114 cat ${MODULESHARDSCONF}
115
116 echo "Starting controller..."
117 /tmp/${BUNDLEFOLDER}/bin/start
118
119 EOF
120
121 # Copy over the configuration script and configuration files to each controller
122 # Execute the configuration script on each controller.
123 for i in `seq 1 ${NUM_ODL_SYSTEM}`
124 do
125     CONTROLLERIP=ODL_SYSTEM_${i}_IP
126     echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
127     scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
128     ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
129 done
130
131 # vim: ts=4 sw=4 sts=4 et ft=sh :