619f3c311853fefca6fd877d764e1eacb9f1ec39
[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 source /tmp/common-functions.sh ${BUNDLEFOLDER}
8
9 echo "#################################################"
10 echo "##         Configure Cluster and Start         ##"
11 echo "#################################################"
12
13 if [ ${CONTROLLERSCOPE} == 'all' ]; then
14     ACTUALFEATURES="odl-integration-compatible-with-all,${CONTROLLERFEATURES}"
15     export CONTROLLERMEM="3072m"
16 else
17     ACTUALFEATURES="odl-infrautils-ready,${CONTROLLERFEATURES}"
18 fi
19 # Some versions of jenkins job builder result in feature list containing spaces
20 # and ending in newline. Remove all that.
21 ACTUALFEATURES=`echo "${ACTUALFEATURES}" | tr -d '\n \r'`
22
23 # Utility function for joining strings.
24 function join {
25     delim=' '
26     final=$1; shift
27
28     for str in "$@" ; do
29         final=${final}${delim}${str}
30     done
31
32     echo ${final}
33 }
34
35 # Create the string for nodes
36 for i in `seq 1 ${NUM_ODL_SYSTEM}` ; do
37     CONTROLLERIP=ODL_SYSTEM_${i}_IP
38     nodes[$i]=${!CONTROLLERIP}
39 done
40
41 nodes_list=$(join "${nodes[@]}")
42
43 echo ${nodes_list}
44
45 run_plan "script"
46
47 # Create the configuration script to be run on controllers.
48 cat > ${WORKSPACE}/configuration-script.sh <<EOF
49 set -x
50 source /tmp/common-functions.sh ${BUNDLEFOLDER}
51
52 echo "Changing to /tmp"
53 cd /tmp
54
55 echo "Downloading the distribution from ${ACTUAL_BUNDLE_URL}"
56 wget --progress=dot:mega  '${ACTUAL_BUNDLE_URL}'
57
58 echo "Extracting the new controller..."
59 unzip -q ${BUNDLE}
60
61 echo "Adding external repositories..."
62 sed -ie "s%org.ops4j.pax.url.mvn.repositories=%org.ops4j.pax.url.mvn.repositories=https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot@id=opendaylight-snapshot@snapshots, https://nexus.opendaylight.org/content/repositories/public@id=opendaylight-mirror, http://repo1.maven.org/maven2@id=central, http://repository.springsource.com/maven/bundles/release@id=spring.ebr.release, http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external, http://zodiac.springsource.com/maven/bundles/release@id=gemini, http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases, https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases%g" ${MAVENCONF}
63 cat ${MAVENCONF}
64
65 echo "Configuring the startup features..."
66 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
67
68 FEATURE_TEST_STRING="features-integration-test"
69 if [[ "$KARAF_VERSION" == "karaf4" ]]; then
70     FEATURE_TEST_STRING="features-test"
71 fi
72
73 sed -ie "s%\(featuresRepositories=\|featuresRepositories =\)%featuresRepositories = mvn:org.opendaylight.integration/\${FEATURE_TEST_STRING}/${BUNDLE_VERSION}/xml/features,mvn:org.apache.karaf.decanter/apache-karaf-decanter/1.0.0/xml/features,%g" ${FEATURESCONF}
74 if [[ ! -z "${REPO_URL}" ]]; then
75    sed -ie "s%featuresRepositories =%featuresRepositories = ${REPO_URL},%g" ${FEATURESCONF}
76 fi
77 cat ${FEATURESCONF}
78
79 configure_karaf_log "${KARAF_VERSION}" "${CONTROLLERDEBUGMAP}"
80
81 set_java_vars "${JAVA_HOME}" "${CONTROLLERMEM}" "${MEMCONF}"
82
83 # Copy shard file if exists
84 if [ -f /tmp/custom_shard_config.txt ]; then
85     echo "Custom shard config exists!!!"
86     echo "Copying the shard config..."
87     cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
88 fi
89
90 echo "Configuring cluster"
91 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
92
93 echo "Dump akka.conf"
94 cat ${AKKACONF}
95
96 echo "Dump modules.conf"
97 cat ${MODULESCONF}
98
99 echo "Dump module-shards.conf"
100 cat ${MODULESHARDSCONF}
101
102 EOF
103
104 # Create the startup script to be run on controllers.
105 cat > ${WORKSPACE}/startup-script.sh <<EOF
106
107 echo "Redirecting karaf console output to karaf_console.log"
108 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
109 mkdir -p /tmp/${BUNDLEFOLDER}/data/log
110
111 echo "Starting controller..."
112 /tmp/${BUNDLEFOLDER}/bin/start
113
114 EOF
115
116 # Copy over the configuration script and configuration files to each controller
117 # Execute the configuration script on each controller.
118 for i in `seq 1 ${NUM_ODL_SYSTEM}`
119 do
120     CONTROLLERIP=ODL_SYSTEM_${i}_IP
121     echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
122     scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
123     ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
124 done
125
126 run_plan "config"
127
128 # Copy over the startup script to each controller and execute it.
129 for i in `seq 1 ${NUM_ODL_SYSTEM}`
130 do
131     CONTROLLERIP=ODL_SYSTEM_${i}_IP
132     echo "Starting member-${i} with IP address ${!CONTROLLERIP}"
133     scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp/
134     ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
135 done
136
137 # vim: ts=4 sw=4 sts=4 et ft=sh :