Merge "Add stable/lithium jobs for aaa"
[releng/builder.git] / jjb / integration / include-raw-integration-deploy-controller.sh
1 echo "#################################################"
2 echo "##   include-raw-integration-deploy-controller ##"
3 echo "#################################################"
4
5 set -x
6
7
8 cat > ${WORKSPACE}/deploy-controller-script.sh <<EOF
9 echo "Downloading the distribution from ${ACTUALBUNDLEURL}"
10 cd /tmp
11 wget --no-verbose  ${ACTUALBUNDLEURL}
12
13 echo "Extracting the new controller..."
14 unzip -q ${BUNDLE}
15
16 echo "Configuring the startup features..."
17 cd ${BUNDLEFOLDER}/etc
18 CFG=org.apache.karaf.features.cfg
19 cp \${CFG} \${CFG}.bak
20 cat \${CFG}.bak | sed "s/^featuresBoot=.*/featuresBoot=config,standard,region,package,kar,ssh,management,${CONTROLLERFEAT}/" > \${CFG}.1
21 cat \${CFG}.1 | sed "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%" > \${CFG}
22 cat \${CFG}
23
24 echo "Configuring the log..."
25 LOG=org.ops4j.pax.logging.cfg
26 cp \${LOG} \${LOG}.bak
27 cat \${LOG}.bak | sed 's/log4j.appender.out.maxFileSize=1MB/log4j.appender.out.maxFileSize=20MB/' > \${LOG}
28 cat \${LOG}
29
30 echo "Configure max memory..."
31 MEM=setenv
32 cd ../bin
33 cp \${MEM} \${MEM}.bak
34 cat \${MEM}.bak | sed 's/JAVA_MAX_MEM="2048m"/JAVA_MAX_MEM="${CONTROLLERMEM}"/' > \${MEM}
35 cat \${MEM}
36
37 echo "Starting deploy controller..."
38 ./start
39
40 EOF
41
42 cat > ${WORKSPACE}/deploy-sanitytest-controller-script.sh <<EOF
43 set -x
44
45 echo "Waiting for controller to come up..."
46 cd /tmp
47 cd ${BUNDLEFOLDER}/bin
48
49 COUNT="0"
50
51
52 while true; do
53     RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
54     echo \$RESP
55     if [[ \$RESP == *"200"* ]]; then
56         echo Controller is UP
57         break
58     elif (( "\$COUNT" > "600" )); then
59         echo Timeout Controller DOWN
60
61         cd /tmp/${BUNDLEFOLDER}/data/
62         cat karaf.log
63         exit 1
64     else
65         COUNT=\$(( \${COUNT} + 5 ))
66         sleep 5
67         echo waiting \$COUNT secs...
68     fi
69 done
70
71
72 cd /tmp/${BUNDLEFOLDER}/bin/
73
74 echo "Checking OSGi bundles..."
75 sshpass -p karaf ./client -u karaf 'bundle:list'
76
77 pkill java
78
79 set +x
80
81 EOF
82
83
84 set +x
85
86
87
88
89 ###############################################################
90 ##  Define a function to run controller-script on controller  #
91 ###############################################################
92
93 function runcontrollerscript
94 {
95   local CONTROLLERIP=$1
96   echo "running controller $CONTROLLERIP"
97   scp ${WORKSPACE}/deploy-controller-script.sh $CONTROLLERIP:/tmp
98   ssh $CONTROLLERIP 'bash /tmp/deploy-controller-script.sh'
99 }
100
101 function sanitytestcontroller
102 {
103   local CONTROLLERIP=$1
104   echo "sanity testing controller $CONTROLLERIP"
105   scp ${WORKSPACE}/deploy-sanitytest-controller-script.sh $CONTROLLERIP:/tmp
106   ssh $CONTROLLERIP 'bash /tmp/deploy-sanitytest-controller-script.sh'
107 }
108
109 echo "##################################"
110 echo "##  Loop through controller IPs  #"
111 echo "##################################"
112
113 declare CONTROLLERIPS=($(cat slave_addresses.txt | grep CONTROLLER | awk -F = '{print $2}'))
114
115 for  i in "${CONTROLLERIPS[@]}"
116 do
117    echo "IP address is: $i"
118    runcontrollerscript $i
119 done
120
121 for  i in "${CONTROLLERIPS[@]}"
122 do
123    echo "IP address is: $i"
124    sanitytestcontroller $i
125 done
126
127 echo "###################################################"
128 echo "## END include-raw-integration-deploy-controller ##"
129 echo "###################################################"
130
131 # vim: ts=4 sw=4 sts=4 et ft=sh :
132