1365e9bfde32dfd60d0021030441316264ebb6e6
[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 nodes_list=$(get_nodes_list)
24
25 run_plan "script"
26
27 # Create the configuration script to be run on controllers.
28 cat > ${WORKSPACE}/configuration-script.sh <<EOF
29 set -x
30 source /tmp/common-functions.sh ${BUNDLEFOLDER}
31
32 echo "Changing to /tmp"
33 cd /tmp
34
35 echo "Downloading the distribution from ${ACTUAL_BUNDLE_URL}"
36 wget --progress=dot:mega  '${ACTUAL_BUNDLE_URL}'
37
38 echo "Extracting the new controller..."
39 unzip -q ${BUNDLE}
40
41 echo "Adding external repositories..."
42 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}
43 cat ${MAVENCONF}
44
45 echo "Configuring the startup features..."
46 sed -ie "s/\(featuresBoot=\|featuresBoot =\)/featuresBoot = ${ACTUALFEATURES},/g" ${FEATURESCONF}
47
48 FEATURE_TEST_STRING="features-integration-test"
49 if [[ "$KARAF_VERSION" == "karaf4" ]]; then
50     FEATURE_TEST_STRING="features-test"
51 fi
52
53 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}
54 if [[ ! -z "${REPO_URL}" ]]; then
55    sed -ie "s%featuresRepositories =%featuresRepositories = ${REPO_URL},%g" ${FEATURESCONF}
56 fi
57 cat ${FEATURESCONF}
58
59 configure_karaf_log "${KARAF_VERSION}" "${CONTROLLERDEBUGMAP}"
60
61 set_java_vars "${JAVA_HOME}" "${CONTROLLERMEM}" "${MEMCONF}"
62
63 # Copy shard file if exists
64 if [ -f /tmp/custom_shard_config.txt ]; then
65     echo "Custom shard config exists!!!"
66     echo "Copying the shard config..."
67     cp /tmp/custom_shard_config.txt /tmp/${BUNDLEFOLDER}/bin/
68 fi
69
70 echo "Configuring cluster"
71 /tmp/${BUNDLEFOLDER}/bin/configure_cluster.sh \$1 ${nodes_list}
72
73 echo "Dump akka.conf"
74 cat ${AKKACONF}
75
76 echo "Dump modules.conf"
77 cat ${MODULESCONF}
78
79 echo "Dump module-shards.conf"
80 cat ${MODULESHARDSCONF}
81
82 EOF
83
84 # Create the startup script to be run on controllers.
85 cat > ${WORKSPACE}/startup-script.sh <<EOF
86
87 echo "Redirecting karaf console output to karaf_console.log"
88 export KARAF_REDIRECT="/tmp/${BUNDLEFOLDER}/data/log/karaf_console.log"
89 mkdir -p /tmp/${BUNDLEFOLDER}/data/log
90
91 echo "Starting controller..."
92 /tmp/${BUNDLEFOLDER}/bin/start
93
94 EOF
95
96 # Copy over the configuration script and configuration files to each controller
97 # Execute the configuration script on each controller.
98 for i in `seq 1 ${NUM_ODL_SYSTEM}`
99 do
100     CONTROLLERIP=ODL_SYSTEM_${i}_IP
101     echo "Configuring member-${i} with IP address ${!CONTROLLERIP}"
102     scp ${WORKSPACE}/configuration-script.sh ${!CONTROLLERIP}:/tmp/
103     ssh ${!CONTROLLERIP} "bash /tmp/configuration-script.sh ${i}"
104 done
105
106 run_plan "config"
107
108 # Copy over the startup script to each controller and execute it.
109 for i in `seq 1 ${NUM_ODL_SYSTEM}`
110 do
111     CONTROLLERIP=ODL_SYSTEM_${i}_IP
112     echo "Starting member-${i} with IP address ${!CONTROLLERIP}"
113     scp ${WORKSPACE}/startup-script.sh ${!CONTROLLERIP}:/tmp/
114     ssh ${!CONTROLLERIP} "bash /tmp/startup-script.sh"
115 done
116
117 # vim: ts=4 sw=4 sts=4 et ft=sh :