bf0fc2ce4780ef86d7847040aca85cde92c005ca
[releng/builder.git] / jjb / integration / include-raw-integration-deploy-openstack-run-test.sh
1 #@IgnoreInspection BashAddShebang
2 # Activate robotframework virtualenv
3 # ${ROBOT_VENV} comes from the include-raw-integration-install-robotframework.sh
4 # script.
5 source ${ROBOT_VENV}/bin/activate
6
7 # TODO: remove this work to run changes.py if/when it's moved higher up to be visible at the Robot level
8 echo "showing recent changes that made it in to the distribution used by this job"
9 pip install --upgrade urllib3
10 python ${WORKSPACE}/test/tools/distchanges/changes.py -d /tmp/distribution_folder \
11                   -u ${ACTUALBUNDLEURL} -b ${DISTROBRANCH} \
12                   -r ssh://jenkins-${SILO}@git.opendaylight.org:29418 || true
13
14 echo "#################################################"
15 echo "##         Deploy Openstack 3-node             ##"
16 echo "#################################################"
17
18
19 SSH="ssh -t -t"
20
21 function create_control_node_local_conf {
22 local_conf_file_name=${WORKSPACE}/local.conf_control
23 #Needs to be removed
24 if [ "${ODL_ML2_BRANCH}" != "stable/ocata" ]; then
25    RECLONE=no
26 else
27    RECLONE=yes
28 fi
29 cat > ${local_conf_file_name} << EOF
30 [[local|localrc]]
31 LOGFILE=stack.sh.log
32 SCREEN_LOGDIR=/opt/stack/data/log
33 LOG_COLOR=False
34 RECLONE=${RECLONE}
35 EOF
36
37 IFS=,
38 for service_name in ${DISABLE_OS_SERVICES}
39 do
40 cat >> ${local_conf_file_name} << EOF
41 disable_service ${service_name}
42 EOF
43 done
44 for service_name in ${ENABLE_OS_SERVICES}
45 do
46 cat >> ${local_conf_file_name} << EOF
47 enable_service ${service_name}
48 EOF
49 done
50 for plugin_name in ${ENABLE_OS_PLUGINS}
51 do
52 if [ "$plugin_name" == "networking-odl" ]; then
53     ENABLE_PLUGIN_ARGS="${ODL_ML2_DRIVER_REPO} ${ODL_ML2_BRANCH}"
54 elif [ "$plugin_name" == "kuryr-kubernetes" ]; then
55     ENABLE_PLUGIN_ARGS="${DEVSTACK_KUBERNETES_PLUGIN_REPO} master" # note: kuryr-kubernetes only exists in master at the moment
56 elif [ "$plugin_name" == "neutron-lbaas" ]; then
57     ENABLE_PLUGIN_ARGS="${DEVSTACK_LBAAS_PLUGIN_REPO} ${OPENSTACK_BRANCH}"
58 else
59     echo "Error: Invalid plugin $plugin_name, unsupported"
60     continue
61 fi
62 cat >> ${local_conf_file_name} << EOF
63 enable_plugin ${plugin_name} ${ENABLE_PLUGIN_ARGS}
64 EOF
65 done
66 unset IFS
67 if [ "${OPENSTACK_BRANCH}" == "master" ] || [ "${OPENSTACK_BRANCH}" == "stable/ocata" ]; then # Ocata+
68     # placement is mandatory for nova since Ocata, note that this requires computes to enable placement-client
69     # this should be moved into enabled_services for each job (but only for Ocata)
70     echo "enable_service placement-api" >> ${local_conf_file_name}
71 fi
72 cat >> ${local_conf_file_name} << EOF
73 HOST_IP=$OPENSTACK_CONTROL_NODE_IP
74 SERVICE_HOST=\$HOST_IP
75
76 NEUTRON_CREATE_INITIAL_NETWORKS=${CREATE_INITIAL_NETWORKS}
77 Q_PLUGIN=ml2
78 Q_ML2_TENANT_NETWORK_TYPE=${TENANT_NETWORK_TYPE}
79 Q_OVS_USE_VETH=True
80
81 ENABLE_TENANT_TUNNELS=True
82
83 MYSQL_HOST=\$SERVICE_HOST
84 RABBIT_HOST=\$SERVICE_HOST
85 GLANCE_HOSTPORT=\$SERVICE_HOST:9292
86 KEYSTONE_AUTH_HOST=\$SERVICE_HOST
87 KEYSTONE_SERVICE_HOST=\$SERVICE_HOST
88
89 MYSQL_PASSWORD=mysql
90 RABBIT_PASSWORD=rabbit
91 SERVICE_TOKEN=service
92 SERVICE_PASSWORD=admin
93 ADMIN_PASSWORD=admin
94
95 ODL_PORT=8080
96 ODL_MODE=externalodl
97 ODL_PORT_BINDING_CONTROLLER=${ODL_ML2_PORT_BINDING}
98
99 LIBVIRT_TYPE=qemu
100
101 NEUTRON_LBAAS_SERVICE_PROVIDERV2=${LBAAS_SERVICE_PROVIDER} # Only relevant if neutron-lbaas plugin is enabled
102 EOF
103
104 if [ "${ENABLE_NETWORKING_L2GW}" == "yes" ]; then
105 cat >> ${local_conf_file_name} << EOF
106
107 enable_plugin networking-l2gw ${NETWORKING_L2GW_DRIVER} ${ODL_ML2_BRANCH}
108 NETWORKING_L2GW_SERVICE_DRIVER=L2GW:OpenDaylight:networking_odl.l2gateway.driver.OpenDaylightL2gwDriver:default
109 ENABLED_SERVICES+=,neutron,q-svc,nova,q-meta
110
111 EOF
112 fi
113
114 if [ "${ODL_ML2_DRIVER_VERSION}" == "v2" ]; then
115     echo "ODL_V2DRIVER=True" >> ${local_conf_file_name}
116 fi
117
118 if [ "${NUM_ODL_SYSTEM}" -gt 1 ]; then
119 odl_list=${ODL_SYSTEM_1_IP}
120 for i in `seq 2 ${NUM_ODL_SYSTEM}`
121 do
122 odlip=ODL_SYSTEM_${i}_IP
123 odl_list=${odl_list},${!odlip}
124 done
125 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
126 HA_PROXY_INDEX=${NUM_OPENSTACK_SYSTEM}
127 odlmgrip=OPENSTACK_COMPUTE_NODE_${HA_PROXY_INDEX}_IP
128 odl_mgr_ip=${!odlmgrip}
129 else
130 odl_mgr_ip=${ODL_SYSTEM_1_IP}
131 fi
132 cat >> ${local_conf_file_name} << EOF
133 ODL_OVS_MANAGERS=${odl_list}
134 ODL_MGR_IP=${odl_mgr_ip}
135 EOF
136 else
137 cat >> ${local_conf_file_name} << EOF
138 ODL_MGR_IP=${ODL_SYSTEM_1_IP}
139 EOF
140 fi
141
142 # if we are using the old netvirt impl, as determined by the feature name
143 # odl-ovsdb-openstack (note: new impl is odl-netvirt-openstack) then we
144 # want ODL_L3 to be True.  New impl wants it False
145 if [[ ${CONTROLLERFEATURES} == *"odl-ovsdb-openstack"* ]]; then
146   ODL_L3=True
147 else
148   ODL_L3=False
149 fi
150
151 # if we are using the new netvirt impl, as determined by the feature name
152 # odl-netvirt-openstack (note: old impl is odl-ovsdb-openstack) then we
153 # want PROVIDER_MAPPINGS to be used -- this should be fixed if we want to support
154 # external networks in legacy netvirt
155 if [[ ${CONTROLLERFEATURES} == *"odl-netvirt-openstack"* ]]; then
156   ODL_PROVIDER_MAPPINGS="\${PUBLIC_PHYSICAL_NETWORK}:${PUBLIC_BRIDGE}"
157 else
158   ODL_PROVIDER_MAPPINGS=
159 fi
160
161 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
162 cat >> ${local_conf_file_name} << EOF
163 PUBLIC_BRIDGE=${PUBLIC_BRIDGE}
164 PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK}
165 ML2_VLAN_RANGES=${PUBLIC_PHYSICAL_NETWORK}
166 ODL_PROVIDER_MAPPINGS=${ODL_PROVIDER_MAPPINGS}
167
168 disable_service q-l3
169 PUBLIC_INTERFACE=br100
170 EOF
171
172 if [ -z ${DISABLE_ODL_L3_PLUGIN} ] || [ "${DISABLE_ODL_L3_PLUGIN}" == "no" ]; then
173 if [ "${ODL_ML2_BRANCH}" == "stable/mitaka" ]; then
174 cat >> ${local_conf_file_name} << EOF
175 Q_L3_ENABLED=True
176 ODL_L3=${ODL_L3}
177 [[post-config|\$NEUTRON_CONF]]
178 [DEFAULT]
179 service_plugins = networking_odl.l3.l3_odl.OpenDaylightL3RouterPlugin
180
181 EOF
182 fi #check for ODL_ML2_BRANCH
183 fi #check for DISABLE_ODL_L3_PLUGIN
184
185 fi #ODL_ENABLE_L3_FWD check
186
187 cat >> ${local_conf_file_name} << EOF
188 [[post-config|/etc/neutron/plugins/ml2/ml2_conf.ini]]
189 [agent]
190 minimize_polling=True
191
192 [ml2]
193 # Needed for VLAN provider tests - because our provider networks are always encapsulated in VXLAN (br-physnet1)
194 # MTU(1440) + VXLAN(50) + VLAN(4) = 1494 < MTU eth0/br-physnet1(1500)
195 physical_network_mtus = ${PUBLIC_PHYSICAL_NETWORK}:1440
196
197 [[post-config|/etc/neutron/dhcp_agent.ini]]
198 [DEFAULT]
199 force_metadata = True
200 enable_isolated_metadata = True
201
202 [[post-config|/etc/nova/nova.conf]]
203 [DEFAULT]
204 force_config_drive = False
205
206 EOF
207
208 echo "local.conf Created...."
209 cat ${local_conf_file_name}
210 }
211
212 function create_compute_node_local_conf {
213 HOSTIP=$1
214 #Needs to be removed
215 if [ "${ODL_ML2_BRANCH}" != "stable/ocata" ]; then
216    RECLONE=no
217 else
218    RECLONE=yes
219 fi
220 if [ "${OPENSTACK_BRANCH}" == "master" ] || [ "${OPENSTACK_BRANCH}" == "stable/ocata" ]; then # Ocata+
221     # placement is mandatory for nova since Ocata, note that this requires controller to enable placement-api
222     ENABLED_SERVICES="n-cpu,placement-client"
223 else
224     ENABLED_SERVICES="n-cpu"
225 fi
226
227 local_conf_file_name=${WORKSPACE}/local.conf_compute_${HOSTIP}
228 cat > ${local_conf_file_name} << EOF
229 [[local|localrc]]
230 LOGFILE=stack.sh.log
231 LOG_COLOR=False
232 SCREEN_LOGDIR=/opt/stack/data/log
233 RECLONE=${RECLONE}
234
235 NOVA_VNC_ENABLED=True
236 MULTI_HOST=1
237 ENABLED_SERVICES=${ENABLED_SERVICES}
238 HOST_IP=${HOSTIP}
239 SERVICE_HOST=${OPENSTACK_CONTROL_NODE_IP}
240
241 Q_PLUGIN=ml2
242 ENABLE_TENANT_TUNNELS=True
243 Q_ML2_TENANT_NETWORK_TYPE=vxlan
244
245 Q_HOST=\$SERVICE_HOST
246 MYSQL_HOST=\$SERVICE_HOST
247 RABBIT_HOST=\$SERVICE_HOST
248 GLANCE_HOSTPORT=\$SERVICE_HOST:9292
249 KEYSTONE_AUTH_HOST=\$SERVICE_HOST
250 KEYSTONE_SERVICE_HOST=\$SERVICE_HOST
251
252 MYSQL_PASSWORD=mysql
253 RABBIT_PASSWORD=rabbit
254 SERVICE_TOKEN=service
255 SERVICE_PASSWORD=admin
256 ADMIN_PASSWORD=admin
257
258 ODL_MODE=compute
259 ODL_PORT_BINDING_CONTROLLER=${ODL_ML2_PORT_BINDING}
260 LIBVIRT_TYPE=qemu
261 EOF
262
263 if [[ "${ENABLE_OS_PLUGINS}" =~ networking-odl ]]; then
264 cat >> ${local_conf_file_name} << EOF
265 enable_plugin networking-odl ${ODL_ML2_DRIVER_REPO} ${ODL_ML2_BRANCH}
266 EOF
267 fi
268
269 if [ "${NUM_ODL_SYSTEM}" -gt 1 ]; then
270 odl_list=${ODL_SYSTEM_1_IP}
271 for i in `seq 2 ${NUM_ODL_SYSTEM}`
272 do
273 odlip=ODL_SYSTEM_${i}_IP
274 odl_list=${odl_list},${!odlip}
275 done
276 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
277 HA_PROXY_INDEX=${NUM_OPENSTACK_SYSTEM}
278 odlmgrip=OPENSTACK_COMPUTE_NODE_${HA_PROXY_INDEX}_IP
279 odl_mgr_ip=${!odlmgrip}
280 else
281 odl_mgr_ip=${ODL_SYSTEM_1_IP}
282 fi
283 cat >> ${local_conf_file_name} << EOF
284 ODL_OVS_MANAGERS=${odl_list}
285 ODL_MGR_IP=${odl_mgr_ip}
286 EOF
287 else
288 cat >> ${local_conf_file_name} << EOF
289 ODL_MGR_IP=${ODL_SYSTEM_1_IP}
290 EOF
291 fi
292
293 # if we are using the new netvirt impl, as determined by the feature name
294 # odl-netvirt-openstack (note: old impl is odl-ovsdb-openstack) then we
295 # want PROVIDER_MAPPINGS to be used -- this should be fixed if we want to support
296 # external networks in legacy netvirt
297 if [[ ${CONTROLLERFEATURES} == *"odl-netvirt-openstack"* ]]; then
298   ODL_PROVIDER_MAPPINGS="\${PUBLIC_PHYSICAL_NETWORK}:${PUBLIC_BRIDGE}"
299 else
300   ODL_PROVIDER_MAPPINGS=
301 fi
302
303 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
304 cat >> ${local_conf_file_name} << EOF
305 # Uncomment lines below if odl-compute is to be used for l3 forwarding
306 Q_L3_ENABLED=True
307 ODL_L3=${ODL_L3}
308 PUBLIC_INTERFACE=br100 # FIXME do we use br100 at all?
309 PUBLIC_BRIDGE=${PUBLIC_BRIDGE}
310 PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK}
311 ODL_PROVIDER_MAPPINGS=${ODL_PROVIDER_MAPPINGS}
312 EOF
313 fi
314 echo "local.conf Created...."
315 cat ${local_conf_file_name}
316 }
317
318 function configure_haproxy_for_neutron_requests () {
319 HA_PROXY_INDEX=${NUM_OPENSTACK_SYSTEM}
320 odlmgrip=OPENSTACK_COMPUTE_NODE_${HA_PROXY_INDEX}_IP
321 ha_proxy_ip=${!odlmgrip}
322
323 cat > ${WORKSPACE}/install_ha_proxy.sh<< EOF
324 sudo systemctl stop firewalld
325 sudo yum -y install policycoreutils-python haproxy
326 EOF
327
328 cat > ${WORKSPACE}/haproxy.cfg << EOF
329 global
330   daemon
331   group  haproxy
332   log  /dev/log local0
333   maxconn  20480
334   pidfile  /tmp/haproxy.pid
335   user  haproxy
336
337 defaults
338   log  global
339   maxconn  4096
340   mode  tcp
341   retries  3
342   timeout  http-request 10s
343   timeout  queue 1m
344   timeout  connect 10s
345   timeout  client 1m
346   timeout  server 1m
347   timeout  check 10s
348
349 listen opendaylight
350   bind ${ha_proxy_ip}:8080
351   balance source
352 EOF
353
354 for i in `seq 1 ${NUM_ODL_SYSTEM}`
355 do
356 odlip=ODL_SYSTEM_${i}_IP
357 cat >> ${WORKSPACE}/haproxy.cfg << EOF
358   server controller-$i ${!odlip}:8080 check fall 5 inter 2000 rise 2
359 EOF
360 done
361
362 cat >> ${WORKSPACE}/haproxy.cfg << EOF
363 listen opendaylight_rest
364   bind ${ha_proxy_ip}:8181
365   balance source
366 EOF
367
368 for i in `seq 1 ${NUM_ODL_SYSTEM}`
369 do
370 odlip=ODL_SYSTEM_${i}_IP
371 cat >> ${WORKSPACE}/haproxy.cfg << EOF
372   server controller-rest-$i ${!odlip}:8181 check fall 5 inter 2000 rise 2
373 EOF
374 done
375
376 cat > ${WORKSPACE}/deploy_ha_proxy.sh<< EOF
377 sudo chown haproxy:haproxy /tmp/haproxy.cfg
378 sudo sed -i 's/\\/etc\\/haproxy\\/haproxy.cfg/\\/tmp\\/haproxy.cfg/g' /usr/lib/systemd/system/haproxy.service
379 sudo /usr/sbin/semanage permissive -a haproxy_t
380 sudo systemctl restart haproxy
381 sleep 3
382 sudo netstat -tunpl
383 sudo systemctl status haproxy
384 true
385 EOF
386 scp ${WORKSPACE}/install_ha_proxy.sh ${ha_proxy_ip}:/tmp
387 ${SSH} ${ha_proxy_ip} "sudo bash /tmp/install_ha_proxy.sh"
388 scp ${WORKSPACE}/haproxy.cfg ${ha_proxy_ip}:/tmp
389 scp ${WORKSPACE}/deploy_ha_proxy.sh ${ha_proxy_ip}:/tmp
390 ${SSH} ${ha_proxy_ip} "sudo bash /tmp/deploy_ha_proxy.sh"
391 }
392
393 function collect_logs_and_exit (){
394 set +e  # We do not want to create red dot just because something went wrong while fetching logs.
395 for i in `seq 1 ${NUM_ODL_SYSTEM}`
396 do
397     CONTROLLERIP=ODL_SYSTEM_${i}_IP
398     echo "killing karaf process..."
399     ${SSH} "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
400 done
401
402 cat > extra_debug.sh << EOF
403 echo -e "/usr/sbin/lsmod | /usr/bin/grep openvswitch\n"
404 /usr/sbin/lsmod | /usr/bin/grep openvswitch
405 echo -e "\ngrep ct_ /var/log/openvswitch/ovs-vswitchd.log\n"
406 grep ct_ /var/log/openvswitch/ovs-vswitchd.log
407 EOF
408
409 sleep 5
410 # FIXME: Do not create .tar and gzip before copying.
411 for i in `seq 1 ${NUM_ODL_SYSTEM}`
412 do
413     CONTROLLERIP=ODL_SYSTEM_${i}_IP
414     ${SSH} "${!CONTROLLERIP}"  "cp -r /tmp/${BUNDLEFOLDER}/data/log /tmp/odl_log"
415     ${SSH} "${!CONTROLLERIP}"  "tar -cf /tmp/odl${i}_karaf.log.tar /tmp/odl_log/*"
416     scp "${!CONTROLLERIP}:/tmp/odl${i}_karaf.log.tar" "${WORKSPACE}/odl${i}_karaf.log.tar"
417     tar -xvf ${WORKSPACE}/odl${i}_karaf.log.tar -C . --strip-components 2 --transform s/karaf/odl${i}_karaf/g
418     grep "ROBOT MESSAGE\| ERROR " odl${i}_karaf.log > odl${i}_err.log
419     grep "ROBOT MESSAGE\|Exception" odl${i}_karaf.log > odl${i}_exception.log
420     grep "ROBOT MESSAGE\| ERROR \| WARN \|Exception" odl${i}_karaf.log > odl${i}_err_warn_exception.log
421     rm ${WORKSPACE}/odl${i}_karaf.log.tar
422 done
423
424 # Since this log collection work is happening before the archive build macro which also
425 # creates the ${WORKSPACE}/archives dir, we have to do it here first.  The mkdir in the
426 # archives build step will essentially be a noop.
427 mkdir -p ${WORKSPACE}/archives
428
429 # Control Node
430 OS_CTRL_FOLDER="control"
431 mkdir -p ${OS_CTRL_FOLDER}
432 scp ${OPENSTACK_CONTROL_NODE_IP}:/opt/stack/devstack/nohup.out ${OS_CTRL_FOLDER}/stack.log
433 scp ${OPENSTACK_CONTROL_NODE_IP}:/var/log/openvswitch/ovs-vswitchd.log ${OS_CTRL_FOLDER}/ovs-vswitchd.log
434 scp ${OPENSTACK_CONTROL_NODE_IP}:/etc/neutron/neutron.conf ${OS_CTRL_FOLDER}/neutron.conf
435 rsync -avhe ssh ${OPENSTACK_CONTROL_NODE_IP}:/opt/stack/logs/* ${OS_CTRL_FOLDER} # rsync to prevent copying of symbolic links
436 scp extra_debug.sh ${OPENSTACK_CONTROL_NODE_IP}:/tmp
437 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "bash /tmp/extra_debug.sh > /tmp/extra_debug.log"
438 scp ${OPENSTACK_CONTROL_NODE_IP}:/tmp/extra_debug.log ${OS_CTRL_FOLDER}/extra_debug.log
439 mv local.conf_control ${OS_CTRL_FOLDER}/local.conf
440 mv ${OS_CTRL_FOLDER} ${WORKSPACE}/archives/
441
442 # Compute Nodes
443 for i in `seq 1 $((NUM_OPENSTACK_SYSTEM - 1))`
444 do
445     OSIP=OPENSTACK_COMPUTE_NODE_${i}_IP
446     OS_COMPUTE_FOLDER="compute_${i}"
447     mkdir -p ${OS_COMPUTE_FOLDER}
448     scp ${!OSIP}:/opt/stack/devstack/nohup.out ${OS_COMPUTE_FOLDER}/stack.log
449     scp ${!OSIP}:/var/log/openvswitch/ovs-vswitchd.log ${OS_COMPUTE_FOLDER}/ovs-vswitchd.log
450     scp ${!OSIP}:/etc/nova/nova.conf ${OS_COMPUTE_FOLDER}/nova.conf
451     rsync -avhe ssh ${!OSIP}:/opt/stack/logs/* ${OS_COMPUTE_FOLDER} # rsync to prevent copying of symbolic links
452     scp extra_debug.sh ${!OSIP}:/tmp
453     ${SSH} ${!OSIP} "bash /tmp/extra_debug.sh > /tmp/extra_debug.log"
454     scp ${!OSIP}:/tmp/extra_debug.log ${OS_COMPUTE_FOLDER}/extra_debug.log
455     mv local.conf_compute_${!OSIP} ${OS_COMPUTE_FOLDER}/local.conf
456     mv ${OS_COMPUTE_FOLDER} ${WORKSPACE}/archives/
457 done
458
459 ls local.conf* | xargs -I % mv % %.log
460
461 # Tempest
462 DEVSTACK_TEMPEST_DIR="/opt/stack/tempest"
463 if $(ssh ${OPENSTACK_CONTROL_NODE_IP} "sudo sh -c '[ -f ${DEVSTACK_TEMPEST_DIR}/.testrepository/0 ]'"); then # if Tempest results exist
464     ssh ${OPENSTACK_CONTROL_NODE_IP} "for I in \$(sudo ls ${DEVSTACK_TEMPEST_DIR}/.testrepository/ | grep -E '^[0-9]+$'); do sudo sh -c \"${DEVSTACK_TEMPEST_DIR}/.tox/tempest/bin/subunit-1to2 < ${DEVSTACK_TEMPEST_DIR}/.testrepository/\${I} >> ${DEVSTACK_TEMPEST_DIR}/subunit_log.txt\"; done"
465     ssh ${OPENSTACK_CONTROL_NODE_IP} "sudo sh -c '${DEVSTACK_TEMPEST_DIR}/.tox/tempest/bin/python ${DEVSTACK_TEMPEST_DIR}/.tox/tempest/lib/python2.7/site-packages/os_testr/subunit2html.py ${DEVSTACK_TEMPEST_DIR}/subunit_log.txt ${DEVSTACK_TEMPEST_DIR}/tempest_results.html'"
466     TEMPEST_LOGS_DIR=${WORKSPACE}/archives/tempest
467     mkdir -p ${TEMPEST_LOGS_DIR}
468     scp ${OPENSTACK_CONTROL_NODE_IP}:${DEVSTACK_TEMPEST_DIR}/tempest_results.html ${TEMPEST_LOGS_DIR}
469     scp ${OPENSTACK_CONTROL_NODE_IP}:${DEVSTACK_TEMPEST_DIR}/tempest.log ${TEMPEST_LOGS_DIR}
470     mv ${WORKSPACE}/tempest_output* ${TEMPEST_LOGS_DIR}
471 fi
472 }
473
474 cat > ${WORKSPACE}/disable_firewall.sh << EOF
475 sudo systemctl stop firewalld
476 sudo systemctl stop iptables
477 true
478 EOF
479
480 cat > ${WORKSPACE}/get_devstack.sh << EOF
481 sudo systemctl stop firewalld
482 sudo yum install bridge-utils -y
483 sudo systemctl stop  NetworkManager
484 #Disable NetworkManager and kill dhclient and dnsmasq
485 sudo systemctl stop NetworkManager
486 sudo killall dhclient
487 sudo killall dnsmasq
488 #Workaround for mysql failure
489 echo "127.0.0.1    localhost \${HOSTNAME}" > /tmp/hosts
490 echo "::1   localhost  \${HOSTNAME}" >> /tmp/hosts
491 sudo mv /tmp/hosts /etc/hosts
492 sudo /usr/sbin/brctl addbr br100
493 #sudo ifconfig eth0 mtu 2000
494 sudo mkdir /opt/stack
495 sudo chmod 777 /opt/stack
496 cd /opt/stack
497 git clone https://git.openstack.org/openstack-dev/devstack
498 cd devstack
499 git checkout $OPENSTACK_BRANCH
500 EOF
501
502 echo "Create HAProxy if needed"
503 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
504  echo "Need to configure HAProxy"
505  configure_haproxy_for_neutron_requests
506 fi
507
508 os_node_list=()
509 echo "Stack the Control Node"
510 scp ${WORKSPACE}/get_devstack.sh ${OPENSTACK_CONTROL_NODE_IP}:/tmp
511 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "bash /tmp/get_devstack.sh"
512 create_control_node_local_conf
513 scp ${WORKSPACE}/local.conf_control ${OPENSTACK_CONTROL_NODE_IP}:/opt/stack/devstack/local.conf
514
515 cat > "${WORKSPACE}/manual_install_package.sh" << EOF
516 cd /opt/stack
517 git clone "\$1"
518 cd "\$2"
519 git checkout "\$3"
520 sudo python setup.py install
521
522 EOF
523
524
525 # Workworund for successful stacking with  Mitaka
526 if [ "${ODL_ML2_BRANCH}" == "stable/mitaka" ]; then
527
528   # Workaround for problems with latest versions/specified versions in requirements of openstack
529   # Openstacksdk,libvirt-python -> the current version does not work with  Mitaka diue to some requirements
530   # conflict and breaks when trying to stack
531   # paramiko -> Problems with tempest tests due to paramiko incompatibility with pycrypto.
532   # the problem has been solved with  version 1.17. If the latest version of paramiko is used, it causes
533   # other timeout problems
534   ssh ${OPENSTACK_CONTROL_NODE_IP} "cd /opt/stack; git clone https://git.openstack.org/openstack/requirements; cd requirements; git checkout stable/mitaka; sed -i /openstacksdk/d upper-constraints.txt; sed -i /libvirt-python/d upper-constraints.txt; sed -i /paramiko/d upper-constraints.txt"
535   scp "${WORKSPACE}/manual_install_package.sh"  "${OPENSTACK_CONTROL_NODE_IP}:/tmp"
536   ssh ${OPENSTACK_CONTROL_NODE_IP} "sudo pip install deprecation"
537   # Fix for recent requirements update  in the  master branch of the sdk.The section must be replaced with a better fix.
538   ssh "${OPENSTACK_CONTROL_NODE_IP}" "sh /tmp/manual_install_package.sh https://github.com/openstack/python-openstacksdk python-openstacksdk 0.9.14"
539   ssh "${OPENSTACK_CONTROL_NODE_IP}" "sh /tmp/manual_install_package.sh https://github.com/paramiko/paramiko paramiko 1.17"
540 fi
541
542 ssh ${OPENSTACK_CONTROL_NODE_IP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
543 ssh ${OPENSTACK_CONTROL_NODE_IP} "ps -ef | grep stack.sh"
544 ssh ${OPENSTACK_CONTROL_NODE_IP} "ls -lrt /opt/stack/devstack/nohup.out"
545 os_node_list+=(${OPENSTACK_CONTROL_NODE_IP})
546
547 #Workaround for stable/newton jobs
548 if [ "${ODL_ML2_BRANCH}" == "stable/newton" ]; then
549   ssh ${OPENSTACK_CONTROL_NODE_IP} "cd /opt/stack; git clone https://git.openstack.org/openstack/requirements; cd requirements; git checkout stable/newton; sed -i /appdirs/d upper-constraints.txt"
550 fi
551
552 for i in `seq 1 $((NUM_OPENSTACK_SYSTEM - 1))`
553 do
554     COMPUTEIP=OPENSTACK_COMPUTE_NODE_${i}_IP
555     scp ${WORKSPACE}/get_devstack.sh  ${!COMPUTEIP}:/tmp
556     ${SSH} ${!COMPUTEIP} "bash /tmp/get_devstack.sh"
557     create_compute_node_local_conf ${!COMPUTEIP}
558     scp ${WORKSPACE}/local.conf_compute_${!COMPUTEIP} ${!COMPUTEIP}:/opt/stack/devstack/local.conf
559     if [ "${ODL_ML2_BRANCH}" == "stable/mitaka" ]; then
560        ssh ${!COMPUTEIP} "cd /opt/stack; git clone https://git.openstack.org/openstack/requirements; cd requirements; git checkout stable/mitaka; sed -i /libvirt-python/d upper-constraints.txt"
561     fi
562     ssh ${!COMPUTEIP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
563     ssh ${!COMPUTEIP} "ps -ef | grep stack.sh"
564     os_node_list+=(${!COMPUTEIP})
565 done
566
567 cat > ${WORKSPACE}/check_stacking.sh << EOF
568 > /tmp/stack_progress
569 ps -ef | grep "stack.sh" | grep -v grep
570 ret=\$?
571 if [ \${ret} -eq 1 ]; then
572   grep "This is your host IP address:" /opt/stack/devstack/nohup.out
573   if [ \$? -eq 0 ]; then
574      echo "Stacking Complete" > /tmp/stack_progress
575   else
576      echo "Stacking Failed" > /tmp/stack_progress
577   fi
578 elif [ \${ret} -eq 0 ]; then
579   echo "Still Stacking" > /tmp/stack_progress
580 fi
581 EOF
582
583 #the checking is repeated for an hour
584 iteration=0
585 in_progress=1
586 while [ ${in_progress} -eq 1 ]; do
587 iteration=$(($iteration + 1))
588 for index in ${!os_node_list[@]}
589 do
590 echo "Check the status of stacking in ${os_node_list[index]}"
591 scp ${WORKSPACE}/check_stacking.sh  ${os_node_list[index]}:/tmp
592 ${SSH} ${os_node_list[index]} "bash /tmp/check_stacking.sh"
593 scp ${os_node_list[index]}:/tmp/stack_progress .
594 #debug
595 cat stack_progress
596 stacking_status=`cat stack_progress`
597 if [ "$stacking_status" == "Still Stacking" ]; then
598   continue
599 elif [ "$stacking_status" == "Stacking Failed" ]; then
600   collect_logs_and_exit
601   exit 1
602 elif [ "$stacking_status" == "Stacking Complete" ]; then
603   unset os_node_list[index]
604   if  [ ${#os_node_list[@]} -eq 0 ]; then
605      in_progress=0
606   fi
607 fi
608 done
609  echo "sleep for a minute before the next check"
610  sleep 60
611  if [ ${iteration} -eq 60 ]; then
612   collect_logs_and_exit
613   exit 1
614  fi
615 done
616
617 #Need to disable firewalld and iptables in control node
618 echo "Stop Firewall in Control Node for compute nodes to be able to reach the ports and add to hypervisor-list"
619 scp ${WORKSPACE}/disable_firewall.sh ${OPENSTACK_CONTROL_NODE_IP}:/tmp
620 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo bash /tmp/disable_firewall.sh"
621 echo "sleep for a minute and print hypervisor-list"
622 sleep 60
623 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "cd /opt/stack/devstack; source openrc admin admin; nova hypervisor-list"
624 # in the case that we are doing openstack (control + compute) all in one node, then the number of hypervisors
625 # will be the same as the number of openstack systems. However, if we are doing multinode openstack then the
626 # assumption is we have a single control node and the rest are compute nodes, so the number of expected hypervisors
627 # is one less than the total number of openstack systems
628 if [ "${NUM_OPENSTACK_SYSTEM}" -eq 1 ]; then
629   expected_num_hypervisors=1
630 else
631   expected_num_hypervisors=$((NUM_OPENSTACK_SYSTEM - 1))
632 fi
633 num_hypervisors=$(${SSH} ${OPENSTACK_CONTROL_NODE_IP} "cd /opt/stack/devstack; source openrc admin admin; openstack hypervisor list -f value | wc -l" | tail -1 | tr -d "\r")
634 if ! [ "${num_hypervisors}" ] || ! [ ${num_hypervisors} -eq ${expected_num_hypervisors} ]; then
635   echo "Error: Only $num_hypervisors hypervisors detected, expected $expected_num_hypervisors"
636   collect_logs_and_exit
637   exit 1
638 fi
639
640 #Need to disable firewalld and iptables in compute nodes as well
641 for i in `seq 1 $((NUM_OPENSTACK_SYSTEM - 1))`
642 do
643     OSIP=OPENSTACK_COMPUTE_NODE_${i}_IP
644     scp ${WORKSPACE}/disable_firewall.sh "${!OSIP}:/tmp"
645     ${SSH} "${!OSIP}" "sudo bash /tmp/disable_firewall.sh"
646 done
647
648 # upgrading pip, urllib3 and httplib2 so that tempest tests can be run on ${OPENSTACK_CONTROL_NODE_IP}
649 # this needs to happen after devstack runs because it seems devstack is pulling in specific versions
650 # of these libs that are not working for tempest.
651 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo pip install --upgrade pip"
652 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo pip install urllib3 --upgrade"
653 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo pip install httplib2 --upgrade"
654
655 for i in `seq 1 $((NUM_OPENSTACK_SYSTEM - 1))`
656 do
657     IP_VAR=OPENSTACK_COMPUTE_NODE_${i}_IP
658     COMPUTE_IPS[$((i-1))]=${!IP_VAR}
659 done
660
661 # External Network
662 echo "prepare external networks by adding vxlan tunnels between all nodes on a separate bridge..."
663 devstack_index=1
664 for ip in ${OPENSTACK_CONTROL_NODE_IP} ${COMPUTE_IPS[*]}
665 do
666     # FIXME - Workaround, ODL (new netvirt) currently adds PUBLIC_BRIDGE as a port in br-int since it doesn't see such a bridge existing when we stack
667     ${SSH} $ip "sudo ovs-vsctl --if-exists del-port br-int $PUBLIC_BRIDGE"
668     ${SSH} $ip "sudo ovs-vsctl --may-exist add-br $PUBLIC_BRIDGE -- set bridge $PUBLIC_BRIDGE other-config:disable-in-band=true other_config:hwaddr=f6:00:00:ff:01:0$((devstack_index++))"
669 done
670
671 # Control Node - PUBLIC_BRIDGE will act as the external router
672 GATEWAY_IP="10.10.10.250" # FIXME this should be a parameter, also shared with integration-test
673 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo ifconfig $PUBLIC_BRIDGE up ${GATEWAY_IP}/24"
674 compute_index=1
675 for compute_ip in ${COMPUTE_IPS[*]}
676 do
677     # Tunnel from controller to compute
678     PORT_NAME=compute$((compute_index++))_vxlan
679     ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo ovs-vsctl add-port $PUBLIC_BRIDGE $PORT_NAME -- set interface $PORT_NAME type=vxlan options:local_ip="${OPENSTACK_CONTROL_NODE_IP}" options:remote_ip="$compute_ip" options:dst_port=9876 options:key=flow"
680
681     # Tunnel from compute to controller
682     PORT_NAME=control_vxlan
683     ${SSH} ${compute_ip} "sudo ovs-vsctl add-port $PUBLIC_BRIDGE $PORT_NAME -- set interface $PORT_NAME type=vxlan options:local_ip="$compute_ip" options:remote_ip="${OPENSTACK_CONTROL_NODE_IP}" options:dst_port=9876 options:key=flow"
684 done
685
686 if [ "${NUM_ODL_SYSTEM}" -gt 1 ]; then
687   HA_PROXY_INDEX=${NUM_OPENSTACK_SYSTEM}
688   odlmgrip=OPENSTACK_COMPUTE_NODE_${HA_PROXY_INDEX}_IP
689   HA_PROXY_IP=${!odlmgrip}
690 else
691   HA_PROXY_IP=${ODL_SYSTEM_IP}
692 fi
693 echo "Locating test plan to use..."
694 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
695 if [ ! -f "${testplan_filepath}" ]; then
696     testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
697 fi
698
699 echo "Changing the testplan path..."
700 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
701 cat testplan.txt
702
703 SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
704
705 echo "Starting Robot test suites ${SUITES} ..."
706 # please add pybot -v arguments on a single line and alphabetized
707 pybot -N ${TESTPLAN} --removekeywords wuks -c critical -e exclude \
708     -v BUNDLEFOLDER:${BUNDLEFOLDER} \
709     -v BUNDLE_URL:${ACTUALBUNDLEURL} \
710     -v CONTROLLER_USER:${USER} \
711     -v DEVSTACK_DEPLOY_PATH:/opt/stack/devstack \
712     -v HA_PROXY_IP:${HA_PROXY_IP} \
713     -v JDKVERSION:${JDKVERSION} \
714     -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
715     -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
716     -v NUM_OS_SYSTEM:${NUM_OPENSTACK_SYSTEM} \
717     -v NUM_TOOLS_SYSTEM:${NUM_TOOLS_SYSTEM} \
718     -v ODL_STREAM:${DISTROSTREAM} \
719     -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
720     -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_1_IP} \
721     -v ODL_SYSTEM_2_IP:${ODL_SYSTEM_2_IP} \
722     -v ODL_SYSTEM_3_IP:${ODL_SYSTEM_3_IP} \
723     -v OS_CONTROL_NODE_IP:${OPENSTACK_CONTROL_NODE_IP} \
724     -v OPENSTACK_BRANCH:${OPENSTACK_BRANCH} \
725     -v OS_COMPUTE_1_IP:${OPENSTACK_COMPUTE_NODE_1_IP} \
726     -v OS_COMPUTE_2_IP:${OPENSTACK_COMPUTE_NODE_2_IP} \
727     -v OS_USER:${USER} \
728     -v PUBLIC_PHYSICAL_NETWORK:${PUBLIC_PHYSICAL_NETWORK} \
729     -v SECURITY_GROUP_MODE:${SECURITY_GROUP_MODE} \
730     -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_1_IP} \
731     -v TOOLS_SYSTEM_1_IP:${TOOLS_SYSTEM_1_IP} \
732     -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
733     -v USER_HOME:${HOME} \
734     -v WORKSPACE:/tmp \
735     ${TESTOPTIONS} ${SUITES} || true
736
737 echo "Examining the files in data/log and checking filesize"
738 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
739 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
740
741 echo "Tests Executed"
742 collect_logs_and_exit
743
744 true  # perhaps Jenkins is testing last exit code
745 # vim: ts=4 sw=4 sts=4 et ft=sh :