Merge "Trim combinations"
[releng/builder.git] / jjb / integration / integration-deploy-openstack-run-test.sh
1 #!/bin/bash
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 PYTHON="${ROBOT_VENV}/bin/python"
8 SSH="ssh -t -t"
9 ADMIN_PASSWORD="admin"
10 OPENSTACK_MASTER_CLIENTS_VERSION="pike"
11
12 # TODO: remove this work to run changes.py if/when it's moved higher up to be visible at the Robot level
13 echo "showing recent changes that made it in to the distribution used by this job"
14 $PYTHON -m pip install --upgrade urllib3
15 python ${WORKSPACE}/test/tools/distchanges/changes.py -d /tmp/distribution_folder \
16                   -u ${ACTUAL_BUNDLE_URL} -b ${DISTROBRANCH} \
17                   -r ssh://jenkins-${SILO}@git.opendaylight.org:29418 || true
18 cat << EOF
19 #################################################
20 ##         Deploy Openstack 3-node             ##
21 #################################################
22 EOF
23
24 # Catch command errors and collect logs.
25 # This ensures logs are collected when script commands fail rather than simply exiting.
26 function trap_handler() {
27     local prog="$0"
28     local lastline="$1"
29     local lasterr="$2"
30     echo "trap_hanlder: ${prog}: line ${lastline}: exit status of last command: ${lasterr}"
31     echo "trap_handler: command: ${BASH_COMMAND}"
32     collect_logs
33     exit 1
34 } # trap_handler()
35
36 trap 'trap_handler ${LINENO} ${$?}' ERR
37
38 function print_job_parameters() {
39     cat << EOF
40
41 Job parameters:
42 DISTROBRANCH: ${DISTROBRANCH}
43 DISTROSTREAM: ${DISTROSTREAM}
44 BUNDLE_URL: ${BUNDLE_URL}
45 CONTROLLERFEATURES: ${CONTROLLERFEATURES}
46 CONTROLLERDEBUGMAP: ${CONTROLLERDEBUGMAP}
47 TESTPLAN: ${TESTPLAN}
48 SUITES: ${SUITES}
49 PATCHREFSPEC: ${PATCHREFSPEC}
50 OPENSTACK_BRANCH: ${OPENSTACK_BRANCH}
51 DEVSTACK_HASH: ${DEVSTACK_HASH}
52 ODL_ML2_DRIVER_REPO: ${ODL_ML2_DRIVER_REPO}
53 ODL_ML2_BRANCH: ${ODL_ML2_BRANCH}
54 ODL_ML2_DRIVER_VERSION: ${ODL_ML2_DRIVER_VERSION}
55 ODL_ML2_PORT_BINDING: ${ODL_ML2_PORT_BINDING}
56 DEVSTACK_KUBERNETES_PLUGIN_REPO: ${DEVSTACK_KUBERNETES_PLUGIN_REPO}
57 DEVSTACK_LBAAS_PLUGIN_REPO: ${DEVSTACK_LBAAS_PLUGIN_REPO}
58 DEVSTACK_NETWORKING_SFC_PLUGIN_REPO: ${DEVSTACK_NETWORKING_SFC_PLUGIN_REPO}
59 ODL_ENABLE_L3_FWD: ${ODL_ENABLE_L3_FWD}
60 IPSEC_VXLAN_TUNNELS_ENABLED: ${IPSEC_VXLAN_TUNNELS_ENABLED}
61 PUBLIC_BRIDGE: ${PUBLIC_BRIDGE}
62 ENABLE_HAPROXY_FOR_NEUTRON: ${ENABLE_HAPROXY_FOR_NEUTRON}
63 ENABLE_OS_SERVICES: ${ENABLE_OS_SERVICES}
64 ENABLE_OS_COMPUTE_SERVICES: ${ENABLE_OS_COMPUTE_SERVICES}
65 ENABLE_OS_NETWORK_SERVICES: ${ENABLE_OS_NETWORK_SERVICES}
66 ENABLE_OS_PLUGINS: ${ENABLE_OS_PLUGINS}
67 DISABLE_OS_SERVICES: ${DISABLE_OS_SERVICES}
68 TENANT_NETWORK_TYPE: ${TENANT_NETWORK_TYPE}
69 SECURITY_GROUP_MODE: ${SECURITY_GROUP_MODE}
70 PUBLIC_PHYSICAL_NETWORK: ${PUBLIC_PHYSICAL_NETWORK}
71 ENABLE_NETWORKING_L2GW: ${ENABLE_NETWORKING_L2GW}
72 CREATE_INITIAL_NETWORKS: ${CREATE_INITIAL_NETWORKS}
73 LBAAS_SERVICE_PROVIDER: ${LBAAS_SERVICE_PROVIDER}
74 NUM_OPENSTACK_SITES: ${NUM_OPENSTACK_SITES}
75 ODL_SFC_DRIVER: ${ODL_SFC_DRIVER}
76 ODL_SNAT_MODE: ${ODL_SNAT_MODE}
77
78 EOF
79 }
80
81 print_job_parameters
82
83 function create_etc_hosts() {
84     NODE_IP=$1
85     CTRL_IP=$2
86     : > ${WORKSPACE}/hosts_file
87     for iter in `seq 1 ${NUM_OPENSTACK_COMPUTE_NODES}`
88     do
89         COMPUTE_IP=OPENSTACK_COMPUTE_NODE_${iter}_IP
90         if [ "${!COMPUTE_IP}" == "${NODE_IP}" ]; then
91            CONTROL_HNAME=$(${SSH}  ${CTRL_IP}  "hostname")
92            echo "${CTRL_IP}   ${CONTROL_HNAME}" >> ${WORKSPACE}/hosts_file
93         else
94            COMPUTE_HNAME=$(${SSH}  ${!COMPUTE_IP}  "hostname")
95            echo "${!COMPUTE_IP}   ${COMPUTE_HNAME}" >> ${WORKSPACE}/hosts_file
96         fi
97     done
98
99     echo "Created the hosts file for ${NODE_IP}:"
100     cat ${WORKSPACE}/hosts_file
101 } # create_etc_hosts()
102
103 #function to install Openstack Clients for Testing
104 #This will pull the latest versions compatiable with the
105 # openstack release
106 function install_openstack_clients_in_robot_vm() {
107     packages=("python-novaclient" "python-neutronclient" "python-openstackclient")
108     for plugin_name in ${ENABLE_OS_PLUGINS}; do
109         if [ "$plugin_name" == "networking-sfc" ]; then
110             packages+=("networking-sfc")
111         fi
112     done
113     openstack_version=$(echo ${OPENSTACK_BRANCH} | cut -d/ -f2)
114     #If the job tests "master", we will use the clients from previous released stable version to avoid failures
115     if [ "${openstack_version}" == "master" ]; then
116        openstack_version=${OPENSTACK_MASTER_CLIENTS_VERSION}
117     fi
118     for package in ${packages[*]}; do
119        echo "Get the current support version of the package ${package}"
120        wget https://raw.githubusercontent.com/openstack/requirements/stable/${openstack_version}/upper-constraints.txt -O /tmp/constraints.txt 2>/dev/null
121        echo "$PYTHON -m pip install --upgrade --no-deps ${package} --no-cache-dir -c /tmp/constraints.txt"
122        $PYTHON -m pip install --upgrade --no-deps ${package} --no-cache-dir -c /tmp/constraints.txt
123        echo "$PYTHON -m pip install ${package} --no-cache-dir -c /tmp/constraints.txt"
124        $PYTHON -m pip install ${package} --no-cache-dir -c /tmp/constraints.txt
125     done
126
127     if [ "${ENABLE_NETWORKING_L2GW}" == "yes" ]; then
128         #networking-l2gw is not officially available in any release yet. Gettting the latest stable version.
129         $PYTHON -m pip install networking-l2gw==11.0.0
130     fi
131 }
132
133
134
135 # convert commas in csv strings to spaces (ssv)
136 function csv2ssv() {
137     local csv=$1
138     if [ -n "${csv}" ]; then
139         ssv=$(echo ${csv} | sed 's/,/ /g' | sed 's/\ \ */\ /g')
140     fi
141
142     echo "${ssv}"
143 } # csv2ssv
144
145 function is_openstack_feature_enabled() {
146     local feature=$1
147     for enabled_feature in $(csv2ssv ${ENABLE_OS_SERVICES})
148     do
149         if [ "${enabled_feature}" == "${feature}" ]; then
150            echo 1
151            return
152         fi
153     done
154     echo 0
155 }
156
157 function fix_libvirt_version_n_cpu_ocata() {
158     local ip=$1
159     ${SSH} ${ip} "
160         cd /opt/stack;
161         git clone https://git.openstack.org/openstack/requirements;
162         cd requirements;
163         git checkout stable/ocata;
164         sed -i s/libvirt-python===2.5.0/libvirt-python===3.2.0/ upper-constraints.txt
165    "
166 }
167
168 # Add enable_services and disable_services to the local.conf
169 function add_os_services() {
170     local core_services=$1
171     local enable_services=$2
172     local disable_services=$3
173     local local_conf_file_name=$4
174     local enable_network_services=$5
175
176     cat >> ${local_conf_file_name} << EOF
177 enable_service $(csv2ssv "${core_services}")
178 EOF
179     if [ -n "${enable_services}" ]; then
180         cat >> ${local_conf_file_name} << EOF
181 enable_service $(csv2ssv "${enable_services}")
182 EOF
183     fi
184     if [ -n "${disable_services}" ]; then
185         cat >> ${local_conf_file_name} << EOF
186 disable_service $(csv2ssv "${disable_services}")
187 EOF
188     fi
189     if [ -n "${enable_network_services}" ]; then
190         cat >> ${local_conf_file_name} << EOF
191 enable_service $(csv2ssv "${enable_network_services}")
192 EOF
193     fi
194 }
195
196 function create_control_node_local_conf() {
197     HOSTIP=$1
198     MGRIP=$2
199     ODL_OVS_MANAGERS="$3"
200
201     local_conf_file_name=${WORKSPACE}/local.conf_control_${HOSTIP}
202     cat > ${local_conf_file_name} << EOF
203 [[local|localrc]]
204 LOGFILE=stack.sh.log
205 USE_SCREEN=True
206 SCREEN_LOGDIR=/opt/stack/data/log
207 LOG_COLOR=False
208 RECLONE=${RECLONE}
209
210 disable_all_services
211 EOF
212
213     add_os_services "${CORE_OS_CONTROL_SERVICES}" "${ENABLE_OS_SERVICES}" "${DISABLE_OS_SERVICES}" "${local_conf_file_name}" "${ENABLE_OS_NETWORK_SERVICES}"
214
215     cat >> ${local_conf_file_name} << EOF
216
217 HOST_IP=${HOSTIP}
218 SERVICE_HOST=\$HOST_IP
219 Q_ML2_TENANT_NETWORK_TYPE=${TENANT_NETWORK_TYPE}
220 NEUTRON_CREATE_INITIAL_NETWORKS=${CREATE_INITIAL_NETWORKS}
221
222 ODL_MODE=manual
223 ODL_MGR_IP=${MGRIP}
224 ODL_PORT=${ODL_PORT}
225 ODL_PORT_BINDING_CONTROLLER=${ODL_ML2_PORT_BINDING}
226 ODL_OVS_MANAGERS=${ODL_OVS_MANAGERS}
227
228 MYSQL_HOST=\$SERVICE_HOST
229 RABBIT_HOST=\$SERVICE_HOST
230 GLANCE_HOSTPORT=\$SERVICE_HOST:9292
231 KEYSTONE_AUTH_HOST=\$SERVICE_HOST
232 KEYSTONE_SERVICE_HOST=\$SERVICE_HOST
233
234 ADMIN_PASSWORD=${ADMIN_PASSWORD}
235 DATABASE_PASSWORD=${ADMIN_PASSWORD}
236 RABBIT_PASSWORD=${ADMIN_PASSWORD}
237 SERVICE_TOKEN=${ADMIN_PASSWORD}
238 SERVICE_PASSWORD=${ADMIN_PASSWORD}
239
240 NEUTRON_LBAAS_SERVICE_PROVIDERV2=${LBAAS_SERVICE_PROVIDER} # Only relevant if neutron-lbaas plugin is enabled
241 NEUTRON_SFC_DRIVERS=${ODL_SFC_DRIVER} # Only relevant if networking-sfc plugin is enabled
242 NEUTRON_FLOWCLASSIFIER_DRIVERS=${ODL_SFC_DRIVER} # Only relevant if networking-sfc plugin is enabled
243 ETCD_PORT=2379
244 EOF
245     if [ "${TENANT_NETWORK_TYPE}" == "local" ]; then
246         cat >> ${local_conf_file_name} << EOF
247 ENABLE_TENANT_TUNNELS=false
248 EOF
249     fi
250
251     if [ "${ODL_ML2_DRIVER_VERSION}" == "v2" ]; then
252         echo "ODL_V2DRIVER=True" >> ${local_conf_file_name}
253     fi
254
255     IFS=,
256     for plugin_name in ${ENABLE_OS_PLUGINS}; do
257         if [ "$plugin_name" == "networking-odl" ]; then
258             ENABLE_PLUGIN_ARGS="${ODL_ML2_DRIVER_REPO} ${ODL_ML2_BRANCH}"
259         elif [ "$plugin_name" == "kuryr-kubernetes" ]; then
260             ENABLE_PLUGIN_ARGS="${DEVSTACK_KUBERNETES_PLUGIN_REPO} master" # note: kuryr-kubernetes only exists in master at the moment
261         elif [ "$plugin_name" == "neutron-lbaas" ]; then
262             ENABLE_PLUGIN_ARGS="${DEVSTACK_LBAAS_PLUGIN_REPO} ${OPENSTACK_BRANCH}"
263             IS_LBAAS_PLUGIN_ENABLED="yes"
264         elif [ "$plugin_name" == "networking-sfc" ]; then
265             ENABLE_PLUGIN_ARGS="${DEVSTACK_NETWORKING_SFC_PLUGIN_REPO} ${OPENSTACK_BRANCH}"
266         else
267             echo "Error: Invalid plugin $plugin_name, unsupported"
268             continue
269         fi
270         cat >> ${local_conf_file_name} << EOF
271
272 enable_plugin ${plugin_name} ${ENABLE_PLUGIN_ARGS}
273 EOF
274     done
275     unset IFS
276
277     if [ "${ENABLE_NETWORKING_L2GW}" == "yes" ]; then
278         cat >> ${local_conf_file_name} << EOF
279
280 enable_plugin networking-l2gw ${NETWORKING_L2GW_DRIVER} ${ODL_ML2_BRANCH}
281 NETWORKING_L2GW_SERVICE_DRIVER=L2GW:OpenDaylight:networking_odl.l2gateway.driver_v2.OpenDaylightL2gwDriver:default
282 EOF
283     fi
284
285     if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
286         cat >> ${local_conf_file_name} << EOF
287
288 PUBLIC_BRIDGE=${PUBLIC_BRIDGE}
289 PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK}
290 ML2_VLAN_RANGES=${PUBLIC_PHYSICAL_NETWORK}
291 ODL_PROVIDER_MAPPINGS=${ODL_PROVIDER_MAPPINGS}
292 EOF
293
294         if [ "${ODL_ML2_DRIVER_VERSION}" == "v2" ]; then
295            SERVICE_PLUGINS="odl-router_v2"
296         else
297            SERVICE_PLUGINS="odl-router"
298         fi
299         if [ "${ENABLE_NETWORKING_L2GW}" == "yes" ]; then
300             SERVICE_PLUGINS+=", networking_l2gw.services.l2gateway.plugin.L2GatewayPlugin"
301         fi
302         if [ "${IS_LBAAS_PLUGIN_ENABLED}" == "yes" ]; then
303             SERVICE_PLUGINS+=", lbaasv2"
304         fi
305     fi #check for ODL_ENABLE_L3_FWD
306
307     cat >> ${local_conf_file_name} << EOF
308
309 [[post-config|\$NEUTRON_CONF]]
310 [DEFAULT]
311 service_plugins = ${SERVICE_PLUGINS}
312
313 [[post-config|/etc/neutron/plugins/ml2/ml2_conf.ini]]
314 [agent]
315 minimize_polling=True
316
317 [ml2]
318 # Needed for VLAN provider tests - because our provider networks are always encapsulated in VXLAN (br-physnet1)
319 # MTU(1400) + VXLAN(50) + VLAN(4) = 1454 < MTU eth0/br-physnet1(1458)
320 physical_network_mtus = ${PUBLIC_PHYSICAL_NETWORK}:1400
321 path_mtu = 1458
322
323 [[post-config|/etc/neutron/dhcp_agent.ini]]
324 [DEFAULT]
325 force_metadata = True
326 enable_isolated_metadata = True
327
328 [[post-config|/etc/nova/nova.conf]]
329 [DEFAULT]
330 force_config_drive = False
331 force_raw_images = False
332
333 [scheduler]
334 discover_hosts_in_cells_interval = 30
335 EOF
336
337     echo "Control local.conf created:"
338     cat ${local_conf_file_name}
339 } # create_control_node_local_conf()
340
341 function create_compute_node_local_conf() {
342     HOSTIP=$1
343     SERVICEHOST=$2
344     MGRIP=$3
345     ODL_OVS_MANAGERS="$4"
346
347     local_conf_file_name=${WORKSPACE}/local.conf_compute_${HOSTIP}
348     cat > ${local_conf_file_name} << EOF
349 [[local|localrc]]
350 LOGFILE=stack.sh.log
351 LOG_COLOR=False
352 USE_SCREEN=True
353 SCREEN_LOGDIR=/opt/stack/data/log
354 RECLONE=${RECLONE}
355
356 disable_all_services
357 EOF
358
359     add_os_services "${CORE_OS_COMPUTE_SERVICES}" "${ENABLE_OS_COMPUTE_SERVICES}" "${DISABLE_OS_SERVICES}" "${local_conf_file_name}"
360
361     cat >> ${local_conf_file_name} << EOF
362 #Added to make Nova wait until nova in control node is ready.
363 NOVA_READY_TIMEOUT=1800
364 HOST_IP=${HOSTIP}
365 SERVICE_HOST=${SERVICEHOST}
366 Q_ML2_TENANT_NETWORK_TYPE=${TENANT_NETWORK_TYPE}
367
368 ODL_MODE=manual
369 ODL_MGR_IP=${MGRIP}
370 ODL_PORT=${ODL_PORT}
371 ODL_PORT_BINDING_CONTROLLER=${ODL_ML2_PORT_BINDING}
372 ODL_OVS_MANAGERS=${ODL_OVS_MANAGERS}
373
374 Q_HOST=\$SERVICE_HOST
375 MYSQL_HOST=\$SERVICE_HOST
376 RABBIT_HOST=\$SERVICE_HOST
377 GLANCE_HOSTPORT=\$SERVICE_HOST:9292
378 KEYSTONE_AUTH_HOST=\$SERVICE_HOST
379 KEYSTONE_SERVICE_HOST=\$SERVICE_HOST
380
381 ADMIN_PASSWORD=${ADMIN_PASSWORD}
382 DATABASE_PASSWORD=${ADMIN_PASSWORD}
383 RABBIT_PASSWORD=${ADMIN_PASSWORD}
384 SERVICE_TOKEN=${ADMIN_PASSWORD}
385 SERVICE_PASSWORD=${ADMIN_PASSWORD}
386 EOF
387
388     if [[ "${ENABLE_OS_PLUGINS}" =~ networking-odl ]]; then
389         cat >> ${local_conf_file_name} << EOF
390
391 enable_plugin networking-odl ${ODL_ML2_DRIVER_REPO} ${ODL_ML2_BRANCH}
392 EOF
393     fi
394
395     if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
396         cat >> ${local_conf_file_name} << EOF
397
398 PUBLIC_BRIDGE=${PUBLIC_BRIDGE}
399 PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK}
400 ODL_PROVIDER_MAPPINGS=${ODL_PROVIDER_MAPPINGS}
401 Q_L3_ENABLED=True
402 ODL_L3=${ODL_L3}
403 EOF
404     fi
405
406     cat >> ${local_conf_file_name} << EOF
407
408 [[post-config|/etc/nova/nova.conf]]
409 [api]
410 auth_strategy = keystone
411 [DEFAULT]
412 use_neutron = True
413 force_raw_images = False
414 EOF
415
416     echo "Compute local.conf created:"
417     cat ${local_conf_file_name}
418 } # create_compute_node_local_conf()
419
420 function configure_haproxy_for_neutron_requests() {
421     MGRIP=$1
422     # shellcheck disable=SC2206
423     ODL_IPS=(${2//,/ })
424
425     cat > ${WORKSPACE}/install_ha_proxy.sh<< EOF
426 sudo systemctl stop firewalld
427 sudo yum -y install policycoreutils-python haproxy
428 EOF
429
430 cat > ${WORKSPACE}/haproxy.cfg << EOF
431 global
432   daemon
433   group  haproxy
434   log  /dev/log local0
435   maxconn  20480
436   pidfile  /tmp/haproxy.pid
437   user  haproxy
438
439 defaults
440   log  global
441   maxconn  4096
442   mode  tcp
443   retries  3
444   timeout  http-request 10s
445   timeout  queue 1m
446   timeout  connect 10s
447   timeout  client 1m
448   timeout  server 1m
449   timeout  check 10s
450
451 listen opendaylight
452   bind ${MGRIP}:8080
453   balance source
454 EOF
455
456     odlindex=1
457     for odlip in ${ODL_IPS[*]}; do
458         cat >> ${WORKSPACE}/haproxy.cfg << EOF
459   server controller-${odlindex} ${odlip}:8080 check fall 5 inter 2000 rise 2
460 EOF
461         odlindex=$((odlindex+1))
462     done
463
464     cat >> ${WORKSPACE}/haproxy.cfg << EOF
465 listen opendaylight_rest
466   bind ${MGRIP}:8181
467   balance source
468 EOF
469
470     odlindex=1
471     for odlip in ${ODL_IPS[*]}; do
472         cat >> ${WORKSPACE}/haproxy.cfg << EOF
473   server controller-rest-${odlindex} ${odlip}:8181 check fall 5 inter 2000 rise 2
474 EOF
475         odlindex=$((odlindex+1))
476     done
477
478     echo "Dump haproxy.cfg"
479     cat ${WORKSPACE}/haproxy.cfg
480
481     cat > ${WORKSPACE}/deploy_ha_proxy.sh<< EOF
482 sudo chown haproxy:haproxy /tmp/haproxy.cfg
483 sudo sed -i 's/\\/etc\\/haproxy\\/haproxy.cfg/\\/tmp\\/haproxy.cfg/g' /usr/lib/systemd/system/haproxy.service
484 sudo /usr/sbin/semanage permissive -a haproxy_t
485 sudo systemctl restart haproxy
486 sleep 3
487 sudo netstat -tunpl
488 sudo systemctl status haproxy
489 true
490 EOF
491
492     scp ${WORKSPACE}/install_ha_proxy.sh ${MGRIP}:/tmp
493     ${SSH} ${MGRIP} "sudo bash /tmp/install_ha_proxy.sh"
494     scp ${WORKSPACE}/haproxy.cfg ${MGRIP}:/tmp
495     scp ${WORKSPACE}/deploy_ha_proxy.sh ${MGRIP}:/tmp
496     ${SSH} ${MGRIP} "sudo bash /tmp/deploy_ha_proxy.sh"
497 } # configure_haproxy_for_neutron_requests()
498
499 # Collect the list of files on the hosts
500 function collect_files () {
501     local -r ip=$1
502     local -r folder=$2
503     finddir=/tmp/finder
504     ${SSH} ${ip} "mkdir -p ${finddir}"
505     ${SSH} ${ip} "sudo find /etc > ${finddir}/find.etc.txt"
506     ${SSH} ${ip} "sudo find /opt/stack > ${finddir}/find.opt.stack.txt"
507     ${SSH} ${ip} "sudo find /var > ${finddir}/find2.txt"
508     ${SSH} ${ip} "sudo find /var > ${finddir}/find.var.txt"
509     ${SSH} ${ip} "sudo tar -cf - -C /tmp finder | xz -T 0 > /tmp/find.tar.xz"
510     scp ${ip}:/tmp/find.tar.xz ${folder}
511     mkdir -p ${finddir}
512     rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/etc/ > ${finddir}/rsync.etc.txt
513     rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/opt/stack/ > ${finddir}/rsync.opt.stack.txt
514     rsync --rsync-path="sudo rsync" --list-only -arvhe ssh ${ip}:/var/ > ${finddir}/rsync.var.txt
515     tar -cf - -C /tmp finder | xz -T 0 > /tmp/rsync.tar.xz
516     cp /tmp/rsync.tar.xz ${folder}
517 }
518
519 function collect_logs () {
520     set +e  # We do not want to create red dot just because something went wrong while fetching logs.
521
522     cat > extra_debug.sh << EOF
523 echo -e "/usr/sbin/lsmod | /usr/bin/grep openvswitch\n"
524 /usr/sbin/lsmod | /usr/bin/grep openvswitch
525 echo -e "\ngrep ct_ /var/log/openvswitch/ovs-vswitchd.log\n"
526 grep "Datapath supports" /var/log/openvswitch/ovs-vswitchd.log
527 echo -e "\nsudo netstat -punta\n"
528 sudo netstat -punta
529 echo -e "\nsudo getenforce\n"
530 sudo getenforce
531 echo -e "\nsudo systemctl status httpd\n"
532 sudo systemctl status httpd
533 echo -e "\nenv\n"
534 env
535 source /opt/stack/devstack/openrc admin admin
536 echo -e "\nenv after openrc\n"
537 env
538 echo -e "\nsudo du -hs /opt/stack"
539 sudo du -hs /opt/stack
540 echo -e "\nsudo mount"
541 sudo mount
542 echo -e "\ndmesg -T > /tmp/dmesg.log"
543 dmesg -T > /tmp/dmesg.log
544 echo -e "\njournalctl > /tmp/journalctl.log\n"
545 sudo journalctl > /tmp/journalctl.log
546 echo -e "\novsdb-tool -mm show-log > /tmp/ovsdb-tool.log"
547 ovsdb-tool -mm show-log > /tmp/ovsdb-tool.log
548 EOF
549
550     # Since this log collection work is happening before the archive build macro which also
551     # creates the ${WORKSPACE}/archives dir, we have to do it here first.  The mkdir in the
552     # archives build step will essentially be a noop.
553     mkdir -p ${WORKSPACE}/archives
554
555     mv /tmp/changes.txt ${WORKSPACE}/archives
556
557     sleep 5
558     # FIXME: Do not create .tar and gzip before copying.
559     for i in `seq 1 ${NUM_ODL_SYSTEM}`; do
560         CONTROLLERIP=ODL_SYSTEM_${i}_IP
561         echo "collect_logs: for opendaylight controller ip: ${!CONTROLLERIP}"
562         NODE_FOLDER="odl_${i}"
563         mkdir -p ${NODE_FOLDER}
564         echo "Lets's take the karaf thread dump again..."
565         ssh ${!CONTROLLERIP} "sudo ps aux" > ${WORKSPACE}/ps_after.log
566         pid=$(grep org.apache.karaf.main.Main ${WORKSPACE}/ps_after.log | grep -v grep | tr -s ' ' | cut -f2 -d' ')
567         echo "karaf main: org.apache.karaf.main.Main, pid:${pid}"
568         ssh ${!CONTROLLERIP} "jstack ${pid}" > ${WORKSPACE}/karaf_${i}_${pid}_threads_after.log || true
569         echo "killing karaf process..."
570         ${SSH} "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
571         ${SSH} ${!CONTROLLERIP} "sudo journalctl > /tmp/journalctl.log"
572         scp ${!CONTROLLERIP}:/tmp/journalctl.log ${NODE_FOLDER}
573         ${SSH} ${!CONTROLLERIP} "dmesg -T > /tmp/dmesg.log"
574         scp ${!CONTROLLERIP}:/tmp/dmesg.log ${NODE_FOLDER}
575         ${SSH} ${!CONTROLLERIP} "tar -cf - -C /tmp/${BUNDLEFOLDER} etc | xz -T 0 > /tmp/etc.tar.xz"
576         scp ${!CONTROLLERIP}:/tmp/etc.tar.xz ${NODE_FOLDER}
577         ${SSH} ${!CONTROLLERIP} "cp -r /tmp/${BUNDLEFOLDER}/data/log /tmp/odl_log"
578         ${SSH} ${!CONTROLLERIP} "tar -cf /tmp/odl${i}_karaf.log.tar /tmp/odl_log/*"
579         scp ${!CONTROLLERIP}:/tmp/odl${i}_karaf.log.tar ${NODE_FOLDER}
580         ${SSH} ${!CONTROLLERIP} "tar -cf /tmp/odl${i}_zrpcd.log.tar /tmp/zrpcd.init.log"
581         scp ${!CONTROLLERIP}:/tmp/odl${i}_zrpcd.log.tar ${NODE_FOLDER}
582         tar -xvf ${NODE_FOLDER}/odl${i}_karaf.log.tar -C ${NODE_FOLDER} --strip-components 2 --transform s/karaf/odl${i}_karaf/g
583         grep "ROBOT MESSAGE\| ERROR " ${NODE_FOLDER}/odl${i}_karaf.log > ${NODE_FOLDER}/odl${i}_err.log
584         grep "ROBOT MESSAGE\| ERROR \| WARN \|Exception" \
585             ${NODE_FOLDER}/odl${i}_karaf.log > ${NODE_FOLDER}/odl${i}_err_warn_exception.log
586         # Print ROBOT lines and print Exception lines. For exception lines also print the previous line for context
587         sed -n -e '/ROBOT MESSAGE/P' -e '$!N;/Exception/P;D' ${NODE_FOLDER}/odl${i}_karaf.log > ${NODE_FOLDER}/odl${i}_exception.log
588         rm ${NODE_FOLDER}/odl${i}_karaf.log.tar
589         mv *_threads* ${NODE_FOLDER}
590         mv ps_* ${NODE_FOLDER}
591         mv ${NODE_FOLDER} ${WORKSPACE}/archives/
592     done
593
594     print_job_parameters > ${WORKSPACE}/archives/params.txt
595
596     # Control Node
597     for i in `seq 1 ${NUM_OPENSTACK_CONTROL_NODES}`; do
598         OSIP=OPENSTACK_CONTROL_NODE_${i}_IP
599         echo "collect_logs: for openstack control node ip: ${!OSIP}"
600         NODE_FOLDER="control_${i}"
601         mkdir -p ${NODE_FOLDER}
602         scp extra_debug.sh ${!OSIP}:/tmp
603         ${SSH} ${!OSIP} "bash /tmp/extra_debug.sh > /tmp/extra_debug.log"
604         scp ${!OSIP}:/etc/dnsmasq.conf ${NODE_FOLDER}
605         scp ${!OSIP}:/etc/keystone/keystone.conf ${NODE_FOLDER}
606         scp ${!OSIP}:/etc/keystone/keystone-uwsgi-admin.ini ${NODE_FOLDER}
607         scp ${!OSIP}:/etc/keystone/keystone-uwsgi-public.ini ${NODE_FOLDER}
608         scp ${!OSIP}:/etc/kuryr/kuryr.conf ${NODE_FOLDER}
609         scp ${!OSIP}:/etc/neutron/dhcp_agent.ini ${NODE_FOLDER}
610         scp ${!OSIP}:/etc/neutron/metadata_agent.ini ${NODE_FOLDER}
611         scp ${!OSIP}:/etc/neutron/neutron.conf ${NODE_FOLDER}
612         scp ${!OSIP}:/etc/neutron/neutron_lbaas.conf ${NODE_FOLDER}
613         scp ${!OSIP}:/etc/neutron/plugins/ml2/ml2_conf.ini ${NODE_FOLDER}
614         scp ${!OSIP}:/etc/neutron/services/loadbalancer/haproxy/lbaas_agent.ini ${NODE_FOLDER}
615         scp ${!OSIP}:/etc/nova/nova.conf ${NODE_FOLDER}
616         scp ${!OSIP}:/etc/nova/nova-api-uwsgi.ini ${NODE_FOLDER}
617         scp ${!OSIP}:/etc/nova/nova_cell1.conf ${NODE_FOLDER}
618         scp ${!OSIP}:/etc/nova/nova-cpu.conf ${NODE_FOLDER}
619         scp ${!OSIP}:/etc/nova/placement-uwsgi.ini ${NODE_FOLDER}
620         scp ${!OSIP}:/etc/openstack/clouds.yaml ${NODE_FOLDER}
621         scp ${!OSIP}:/opt/stack/devstack/.stackenv ${NODE_FOLDER}
622         scp ${!OSIP}:/opt/stack/devstack/nohup.out ${NODE_FOLDER}/stack.log
623         scp ${!OSIP}:/opt/stack/devstack/openrc ${NODE_FOLDER}
624         scp ${!OSIP}:/opt/stack/requirements/upper-constraints.txt ${NODE_FOLDER}
625         scp ${!OSIP}:/opt/stack/tempest/etc/tempest.conf ${NODE_FOLDER}
626         scp ${!OSIP}:/tmp/*.xz ${NODE_FOLDER}
627         scp ${!OSIP}:/tmp/dmesg.log ${NODE_FOLDER}
628         scp ${!OSIP}:/tmp/extra_debug.log ${NODE_FOLDER}
629         scp ${!OSIP}:/tmp/get_devstack.sh.txt ${NODE_FOLDER}
630         scp ${!OSIP}:/tmp/journalctl.log ${NODE_FOLDER}
631         scp ${!OSIP}:/tmp/ovsdb-tool.log ${NODE_FOLDER}
632         scp ${!OSIP}:/var/log/openvswitch/ovs-vswitchd.log ${NODE_FOLDER}
633         scp ${!OSIP}:/var/log/openvswitch/ovsdb-server.log ${NODE_FOLDER}
634         collect_files "${!OSIP}" "${NODE_FOLDER}"
635         ${SSH} ${!OSIP} "sudo tar -cf - -C /var/log rabbitmq | xz -T 0 > /tmp/rabbitmq.tar.xz "
636         scp ${!OSIP}:/tmp/rabbitmq.tar.xz ${NODE_FOLDER}
637         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/etc/hosts ${NODE_FOLDER}
638         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/usr/lib/systemd/system/haproxy.service ${NODE_FOLDER}
639         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/audit/audit.log ${NODE_FOLDER}
640         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/httpd/keystone_access.log ${NODE_FOLDER}
641         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/httpd/keystone.log ${NODE_FOLDER}
642         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/messages ${NODE_FOLDER}
643         rsync -avhe ssh ${!OSIP}:/opt/stack/logs/* ${NODE_FOLDER} # rsync to prevent copying of symbolic links
644         mv local.conf_control_${!OSIP} ${NODE_FOLDER}/local.conf
645         # qdhcp files are created by robot tests and copied into /tmp/qdhcp during the test
646         tar -cf - -C /tmp qdhcp | xz -T 0 > /tmp/qdhcp.tar.xz
647         mv /tmp/qdhcp.tar.xz ${NODE_FOLDER}
648         mv ${NODE_FOLDER} ${WORKSPACE}/archives/
649     done
650
651     # Compute Nodes
652     for i in `seq 1 ${NUM_OPENSTACK_COMPUTE_NODES}`; do
653         OSIP=OPENSTACK_COMPUTE_NODE_${i}_IP
654         echo "collect_logs: for openstack compute node ip: ${!OSIP}"
655         NODE_FOLDER="compute_${i}"
656         mkdir -p ${NODE_FOLDER}
657         scp extra_debug.sh ${!OSIP}:/tmp
658         ${SSH} ${!OSIP} "bash /tmp/extra_debug.sh > /tmp/extra_debug.log"
659         scp ${!OSIP}:/etc/nova/nova.conf ${NODE_FOLDER}
660         scp ${!OSIP}:/etc/nova/nova-cpu.conf ${NODE_FOLDER}
661         scp ${!OSIP}:/etc/openstack/clouds.yaml ${NODE_FOLDER}
662         scp ${!OSIP}:/opt/stack/devstack/.stackenv ${NODE_FOLDER}
663         scp ${!OSIP}:/opt/stack/devstack/nohup.out ${NODE_FOLDER}/stack.log
664         scp ${!OSIP}:/opt/stack/devstack/openrc ${NODE_FOLDER}
665         scp ${!OSIP}:/opt/stack/requirements/upper-constraints.txt ${NODE_FOLDER}
666         scp ${!OSIP}:/tmp/*.xz ${NODE_FOLDER}/
667         scp ${!OSIP}:/tmp/dmesg.log ${NODE_FOLDER}
668         scp ${!OSIP}:/tmp/extra_debug.log ${NODE_FOLDER}
669         scp ${!OSIP}:/tmp/get_devstack.sh.txt ${NODE_FOLDER}
670         scp ${!OSIP}:/tmp/journalctl.log ${NODE_FOLDER}
671         scp ${!OSIP}:/tmp/ovsdb-tool.log ${NODE_FOLDER}
672         scp ${!OSIP}:/var/log/openvswitch/ovs-vswitchd.log ${NODE_FOLDER}
673         scp ${!OSIP}:/var/log/openvswitch/ovsdb-server.log ${NODE_FOLDER}
674         collect_files "${!OSIP}" "${NODE_FOLDER}"
675         ${SSH} ${!OSIP} "sudo tar -cf - -C /var/log libvirt | xz -T 0 > /tmp/libvirt.tar.xz "
676         scp ${!OSIP}:/tmp/libvirt.tar.xz ${NODE_FOLDER}
677         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/etc/hosts ${NODE_FOLDER}
678         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/audit/audit.log ${NODE_FOLDER}
679         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/messages ${NODE_FOLDER}
680         rsync --rsync-path="sudo rsync" -avhe ssh ${!OSIP}:/var/log/nova-agent.log ${NODE_FOLDER}
681         rsync -avhe ssh ${!OSIP}:/opt/stack/logs/* ${NODE_FOLDER} # rsync to prevent copying of symbolic links
682         mv local.conf_compute_${!OSIP} ${NODE_FOLDER}/local.conf
683         mv ${NODE_FOLDER} ${WORKSPACE}/archives/
684     done
685
686     # Tempest
687     DEVSTACK_TEMPEST_DIR="/opt/stack/tempest"
688     TESTREPO=".stestr"
689     TEMPEST_LOGS_DIR=${WORKSPACE}/archives/tempest
690     # Look for tempest test results in the $TESTREPO dir and copy if found
691     if ${SSH} ${OPENSTACK_CONTROL_NODE_1_IP} "sudo sh -c '[ -f ${DEVSTACK_TEMPEST_DIR}/${TESTREPO}/0 ]'"; then
692         ${SSH} ${OPENSTACK_CONTROL_NODE_1_IP} "for I in \$(sudo ls ${DEVSTACK_TEMPEST_DIR}/${TESTREPO}/ | grep -E '^[0-9]+$'); do sudo sh -c \"${DEVSTACK_TEMPEST_DIR}/.tox/tempest/bin/subunit-1to2 < ${DEVSTACK_TEMPEST_DIR}/${TESTREPO}/\${I} >> ${DEVSTACK_TEMPEST_DIR}/subunit_log.txt\"; done"
693         ${SSH} ${OPENSTACK_CONTROL_NODE_1_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'"
694         mkdir -p ${TEMPEST_LOGS_DIR}
695         scp ${OPENSTACK_CONTROL_NODE_1_IP}:${DEVSTACK_TEMPEST_DIR}/tempest_results.html ${TEMPEST_LOGS_DIR}
696         scp ${OPENSTACK_CONTROL_NODE_1_IP}:${DEVSTACK_TEMPEST_DIR}/tempest.log ${TEMPEST_LOGS_DIR}
697         if [ "$(echo ${OPENSTACK_BRANCH} | cut -d/ -f2)" != "master" ]; then
698            mv ${WORKSPACE}/tempest_output* ${TEMPEST_LOGS_DIR}
699         fi
700     else
701         echo "tempest results not found in ${DEVSTACK_TEMPEST_DIR}/${TESTREPO}/0"
702     fi
703 } # collect_logs()
704
705 # Following three functions are debugging helpers when debugging devstack changes.
706 # Keeping them for now so we can simply call them when needed.
707 ctrlhn=""
708 comp1hn=""
709 comp2hn=""
710 function get_hostnames () {
711     set +e
712     local ctrlip=${OPENSTACK_CONTROL_NODE_1_IP}
713     local comp1ip=${OPENSTACK_COMPUTE_NODE_1_IP}
714     local comp2ip=${OPENSTACK_COMPUTE_NODE_2_IP}
715     ctrlhn=$(${SSH} ${ctrlip} "hostname")
716     comp1hn=$(${SSH} ${comp1ip} "hostname")
717     comp2hn=$(${SSH} ${comp2ip} "hostname")
718     echo "hostnames: ${ctrlhn}, ${comp1hn}, ${comp2hn}"
719     set -e
720 }
721
722 function check_firewall() {
723     set +e
724     echo $-
725     local ctrlip=${OPENSTACK_CONTROL_NODE_1_IP}
726     local comp1ip=${OPENSTACK_COMPUTE_NODE_1_IP}
727     local comp2ip=${OPENSTACK_COMPUTE_NODE_2_IP}
728
729     echo "check_firewall on control"
730     ${SSH} ${ctrlip} "
731         sudo systemctl status firewalld
732         sudo systemctl -l status iptables
733         sudo iptables --line-numbers -nvL
734     " || true
735     echo "check_firewall on compute 1"
736     ${SSH} ${comp1ip} "
737         sudo systemctl status firewalld
738         sudo systemctl -l status iptables
739         sudo iptables --line-numbers -nvL
740     " || true
741     echo "check_firewall on compute 2"
742     ${SSH} ${comp2ip} "
743         sudo systemctl status firewalld
744         sudo systemctl -l status iptables
745         sudo iptables --line-numbers -nvL
746     " || true
747 }
748
749 function get_service () {
750     set +e
751     local iter=$1
752     #local idx=$2
753     local ctrlip=${OPENSTACK_CONTROL_NODE_1_IP}
754     local comp1ip=${OPENSTACK_COMPUTE_NODE_1_IP}
755
756     #if [ ${idx} -eq 1 ]; then
757         if [ ${iter} -eq 1 ] || [ ${iter} -gt 16 ]; then
758             curl http://${ctrlip}:5000
759             curl http://${ctrlip}:35357
760             curl http://${ctrlip}/identity
761             ${SSH} ${ctrlip} "
762                 source /opt/stack/devstack/openrc admin admin;
763                 env
764                 openstack configuration show --unmask;
765                 openstack service list
766                 openstack --os-cloud devstack-admin --os-region RegionOne compute service list
767                 openstack hypervisor list;
768             " || true
769             check_firewall
770         fi
771     #fi
772     set -e
773 }
774
775 # Check if rabbitmq is ready by looking for a pid in it's status.
776 # The function returns the status of the grep command which callers can check.
777 function is_rabbitmq_ready() {
778     local -r ip=$1
779     rm -f rabbit.txt
780     ${SSH} ${ip} "sudo rabbitmqctl list_vhosts" > rabbit.txt
781     grep nova_cell1 rabbit.txt
782 }
783
784 # retry the given command ($3) until success for a number of iterations ($1)
785 # sleeping ($2) between tries.
786 function retry() {
787     local -r -i max_tries=${1}
788     local -r -i sleep_time=${2}
789     local -r cmd=${3}
790     local -i retries=1
791     local -i rc=1
792     while true; do
793         echo "retry ${cmd}: attempt: ${retries}"
794         ${cmd}
795         rc=$?
796         if ((${rc} == 0)); then
797             break;
798         else
799             if ((${retries} == ${max_tries})); then
800                 break
801             else
802                 ((retries++))
803                 sleep ${sleep_time}
804             fi
805         fi
806     done
807     return ${rc}
808 }
809
810 # if we are using the new netvirt impl, as determined by the feature name
811 # odl-netvirt-openstack (note: old impl is odl-ovsdb-openstack) then we
812 # want PROVIDER_MAPPINGS to be used -- this should be fixed if we want to support
813 # external networks in legacy netvirt
814 if [[ ${CONTROLLERFEATURES} == *"odl-netvirt-openstack"* ]]; then
815   ODL_PROVIDER_MAPPINGS="\${PUBLIC_PHYSICAL_NETWORK}:${PUBLIC_BRIDGE}"
816 else
817   ODL_PROVIDER_MAPPINGS=
818 fi
819
820 # if we are using the old netvirt impl, as determined by the feature name
821 # odl-ovsdb-openstack (note: new impl is odl-netvirt-openstack) then we
822 # want ODL_L3 to be True.  New impl wants it False
823 if [[ ${CONTROLLERFEATURES} == *"odl-ovsdb-openstack"* ]]; then
824     ODL_L3=True
825 else
826     ODL_L3=False
827 fi
828
829 RECLONE=False
830 ODL_PORT=8181
831
832 # Always compare the lists below against the devstack upstream ENABLED_SERVICES in
833 # https://github.com/openstack-dev/devstack/blob/master/stackrc#L52
834 # ODL CSIT does not use vnc, cinder, q-agt, q-l3 or horizon so they are not included below.
835 # collect performance stats
836 CORE_OS_CONTROL_SERVICES="dstat"
837 # Glance
838 CORE_OS_CONTROL_SERVICES+=",g-api,g-reg"
839 # Keystone
840 CORE_OS_CONTROL_SERVICES+=",key"
841 # Nova - services to support libvirt
842 CORE_OS_CONTROL_SERVICES+=",n-api,n-api-meta,n-cauth,n-cond,n-crt,n-obj,n-sch"
843 # ODL - services to connect to ODL
844 CORE_OS_CONTROL_SERVICES+=",odl-compute,odl-neutron"
845 # Additional services
846 CORE_OS_CONTROL_SERVICES+=",mysql,rabbit"
847
848 # collect performance stats
849 CORE_OS_COMPUTE_SERVICES="dstat"
850 # computes only need nova and odl
851 CORE_OS_COMPUTE_SERVICES+=",n-cpu,odl-compute"
852
853 cat > ${WORKSPACE}/disable_firewall.sh << EOF
854 sudo systemctl stop firewalld
855 # Open these ports to match the tutorial vms
856 # http/https (80/443), samba (445), netbios (137,138,139)
857 sudo iptables -I INPUT -p tcp -m multiport --dports 80,443,139,445 -j ACCEPT
858 sudo iptables -I INPUT -p udp -m multiport --dports 137,138 -j ACCEPT
859 # OpenStack services as well as vxlan tunnel ports 4789 and 9876
860 # identity public/admin (5000/35357), ampq (5672), vnc (6080), nova (8774), glance (9292), neutron (9696)
861 sudo sudo iptables -I INPUT -p tcp -m multiport --dports 5000,5672,6080,8774,9292,9696,35357 -j ACCEPT
862 sudo sudo iptables -I INPUT -p udp -m multiport --dports 4789,9876 -j ACCEPT
863 sudo iptables-save > /etc/sysconfig/iptables
864 sudo systemctl restart iptables
865 sudo iptables --line-numbers -nvL
866 true
867 EOF
868
869 cat > ${WORKSPACE}/get_devstack.sh << EOF
870 sudo systemctl stop firewalld
871 sudo yum install bridge-utils python-pip -y
872 #sudo systemctl stop  NetworkManager
873 #Disable NetworkManager and kill dhclient and dnsmasq
874 sudo systemctl stop NetworkManager
875 sudo killall dhclient
876 sudo killall dnsmasq
877 #Workaround for mysql failure
878 echo "127.0.0.1   localhost \${HOSTNAME}" >> /tmp/hosts
879 echo "::1         localhost \${HOSTNAME}" >> /tmp/hosts
880 sudo mv /tmp/hosts /etc/hosts
881 sudo mkdir /opt/stack
882 echo "Create RAM disk for /opt/stack"
883 sudo mount -t tmpfs -o size=2G tmpfs /opt/stack
884 sudo chmod 777 /opt/stack
885 cd /opt/stack
886 echo "git clone https://git.openstack.org/openstack-dev/devstack --branch ${OPENSTACK_BRANCH}"
887 git clone https://git.openstack.org/openstack-dev/devstack --branch ${OPENSTACK_BRANCH}
888 cd devstack
889 if [ -n "${DEVSTACK_HASH}" ]; then
890     echo "git checkout ${DEVSTACK_HASH}"
891     git checkout ${DEVSTACK_HASH}
892 fi
893 git --no-pager log --pretty=format:'%h %<(13)%ar%<(13)%cr %<(20,trunc)%an%d %s\n%b' -n20
894 echo "workaround: adjust wait from 60s to 1800s (30m)"
895 sed -i 's/wait_for_compute 60/wait_for_compute 1800/g' /opt/stack/devstack/lib/nova
896 # TODO: modify sleep 1 to sleep 60, search wait_for_compute, then first sleep 1
897 # that would just reduce the number of logs in the compute stack.log
898
899 #Install qemu-img command in Control Node for Pike
900 echo "Install qemu-img application"
901 sudo yum install -y qemu-img
902 EOF
903
904 cat > "${WORKSPACE}/setup_host_cell_mapping.sh" << EOF
905 sudo nova-manage cell_v2 map_cell0
906 sudo nova-manage cell_v2 simple_cell_setup
907 sudo nova-manage db sync
908 sudo nova-manage cell_v2 discover_hosts
909 EOF
910
911 NUM_OPENSTACK_SITES=${NUM_OPENSTACK_SITES:-1}
912 compute_index=1
913 odl_index=1
914 os_node_list=()
915 os_interval=$(( ${NUM_OPENSTACK_SYSTEM} / ${NUM_OPENSTACK_SITES} ))
916 ha_proxy_index=${os_interval}
917
918 for i in `seq 1 ${NUM_OPENSTACK_SITES}`; do
919     if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
920         echo "Configure HAProxy"
921         ODL_HAPROXYIP_PARAM=OPENSTACK_HAPROXY_${i}_IP
922         ha_proxy_index=$(( $ha_proxy_index + $os_interval ))
923         odl_index=$(((i - 1) * 3 + 1))
924         ODL_IP_PARAM1=ODL_SYSTEM_$((odl_index++))_IP
925         ODL_IP_PARAM2=ODL_SYSTEM_$((odl_index++))_IP
926         ODL_IP_PARAM3=ODL_SYSTEM_$((odl_index++))_IP
927         ODLMGRIP[$i]=${!ODL_HAPROXYIP_PARAM} # ODL Northbound uses HAProxy VIP
928         ODL_OVS_MGRS[$i]="${!ODL_IP_PARAM1},${!ODL_IP_PARAM2},${!ODL_IP_PARAM3}" # OVSDB connects to all ODL IPs
929         configure_haproxy_for_neutron_requests ${!ODL_HAPROXYIP_PARAM} "${ODL_OVS_MGRS[$i]}"
930     else
931         ODL_IP_PARAM=ODL_SYSTEM_${i}_IP
932         ODL_OVS_MGRS[$i]="${!ODL_IP_PARAM}" # ODL Northbound uses ODL IP
933         ODLMGRIP[$i]=${!ODL_IP_PARAM} # OVSDB connects to ODL IP
934     fi
935 done
936
937 # Begin stacking the nodes, starting with the controller(s) and then the compute(s)
938
939 for i in `seq 1 ${NUM_OPENSTACK_CONTROL_NODES}`; do
940     CONTROLIP=OPENSTACK_CONTROL_NODE_${i}_IP
941     echo "Configure the stack of the control node ${i} of ${NUM_OPENSTACK_CONTROL_NODES}: ${!CONTROLIP}"
942     scp ${WORKSPACE}/disable_firewall.sh ${!CONTROLIP}:/tmp
943     ${SSH} ${!CONTROLIP} "sudo bash /tmp/disable_firewall.sh"
944     create_etc_hosts ${!CONTROLIP}
945     scp ${WORKSPACE}/hosts_file ${!CONTROLIP}:/tmp/hosts
946     scp ${WORKSPACE}/get_devstack.sh ${!CONTROLIP}:/tmp
947     # devstack Master is yet to migrate fully to lib/neutron, there are some ugly hacks that is
948     # affecting the stacking.
949     #Workaround For Queens, Make the physical Network as physnet1 in lib/neutron
950     #Workaround Comment out creating initial Networks in lib/neutron
951     ${SSH} ${!CONTROLIP} "bash /tmp/get_devstack.sh > /tmp/get_devstack.sh.txt 2>&1"
952     if [ "${ODL_ML2_BRANCH}" == "master" ]; then
953        ssh ${!CONTROLIP} "sed -i 's/flat_networks public/flat_networks public,physnet1/' /opt/stack/devstack/lib/neutron"
954        ssh ${!CONTROLIP} "sed -i '186i iniset \$NEUTRON_CORE_PLUGIN_CONF ml2_type_vlan network_vlan_ranges public:1:4094,physnet1:1:4094' /opt/stack/devstack/lib/neutron"
955     fi
956     if [[ "${ODL_ML2_BRANCH}" == "stable/ocata" && "$(is_openstack_feature_enabled n-cpu)" == "1" ]]; then
957         echo "Updating requirements for ${ODL_ML2_BRANCH}"
958         echo "Workaround for https://review.openstack.org/#/c/491032/"
959         echo "Modify upper-constraints to use libvirt-python 3.2.0"
960         fix_libvirt_version_n_cpu_ocata ${!CONTROLIP}
961     fi
962     create_control_node_local_conf ${!CONTROLIP} ${ODLMGRIP[$i]} "${ODL_OVS_MGRS[$i]}"
963     scp ${WORKSPACE}/local.conf_control_${!CONTROLIP} ${!CONTROLIP}:/opt/stack/devstack/local.conf
964     echo "Stack the control node ${i} of ${NUM_OPENSTACK_CONTROL_NODES}: ${CONTROLIP}"
965     ssh ${!CONTROLIP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
966     ssh ${!CONTROLIP} "ps -ef | grep stack.sh"
967     ssh ${!CONTROLIP} "ls -lrt /opt/stack/devstack/nohup.out"
968     os_node_list+=("${!CONTROLIP}")
969 done
970
971 # This is a backup to the CELLSV2_SETUP=singleconductor workaround. Keeping it here as an easy lookup
972 # if needed.
973 # Let the control node get started to avoid a race condition where the computes start and try to access
974 # the nova_cell1 on the control node before it is created. If that happens, the nova-compute service on the
975 # compute exits and does not attempt to restart.
976 # 180s is chosen because in test runs the control node usually finished in 17-20 minutes and the computes finished
977 # in 17 minutes, so take the max difference of 3 minutes and the jobs should still finish around the same time.
978 # one of the following errors is seen in the compute n-cpu.log:
979 # Unhandled error: NotAllowed: Connection.open: (530) NOT_ALLOWED - access to vhost 'nova_cell1' refused for user 'stackrabbit'
980 # AccessRefused: (0, 0): (403) ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN. For details see the broker logfile.
981 # Compare that timestamp to this log in the control stack.log: sudo rabbitmqctl set_permissions -p nova_cell1 stackrabbit
982 # If the n-cpu.log is earlier than the control stack.log timestamp then the failure condition is likely hit.
983 if [ ${NUM_OPENSTACK_COMPUTE_NODES} -gt 99 ]; then
984     WAIT_FOR_RABBITMQ_MINUTES=60
985     echo "Wait a maximum of ${WAIT_FOR_RABBITMQ_MINUTES}m until rabbitmq is ready to allow the controller to create nova_cell1 before the computes need it"
986     set +e
987     retry ${WAIT_FOR_RABBITMQ_MINUTES} 60 "is_rabbitmq_ready ${OPENSTACK_CONTROL_NODE_1_IP}"
988     rc=$?
989     set -e
990     if ((${rc} == 0)); then
991       echo "rabbitmq is ready, starting ${NUM_OPENSTACK_COMPUTE_NODES} compute(s)"
992     else
993       echo "rabbitmq was not ready in ${WAIT_FOR_RABBITMQ_MINUTES}m"
994       collect_logs
995       exit 1
996     fi
997 fi
998
999 for i in `seq 1 ${NUM_OPENSTACK_COMPUTE_NODES}`; do
1000     NUM_COMPUTES_PER_SITE=$((NUM_OPENSTACK_COMPUTE_NODES / NUM_OPENSTACK_SITES))
1001     SITE_INDEX=$((((i - 1) / NUM_COMPUTES_PER_SITE) + 1)) # We need the site index to infer the control node IP for this compute
1002     COMPUTEIP=OPENSTACK_COMPUTE_NODE_${i}_IP
1003     CONTROLIP=OPENSTACK_CONTROL_NODE_${SITE_INDEX}_IP
1004     echo "Configure the stack of the compute node ${i} of ${NUM_OPENSTACK_COMPUTE_NODES}: ${!COMPUTEIP}"
1005     scp ${WORKSPACE}/disable_firewall.sh "${!COMPUTEIP}:/tmp"
1006     ${SSH} "${!COMPUTEIP}" "sudo bash /tmp/disable_firewall.sh"
1007     create_etc_hosts ${!COMPUTEIP} ${!CONTROLIP}
1008     scp ${WORKSPACE}/hosts_file ${!COMPUTEIP}:/tmp/hosts
1009     scp ${WORKSPACE}/get_devstack.sh  ${!COMPUTEIP}:/tmp
1010     ${SSH} ${!COMPUTEIP} "bash /tmp/get_devstack.sh > /tmp/get_devstack.sh.txt 2>&1"
1011     if [ "${ODL_ML2_BRANCH}" == "stable/ocata" ]; then
1012         echo "Updating requirements for ${ODL_ML2_BRANCH}"
1013         echo "Workaround for https://review.openstack.org/#/c/491032/"
1014         echo "Modify upper-constraints to use libvirt-python 3.2.0"
1015         fix_libvirt_version_n_cpu_ocata ${!COMPUTEIP}
1016     fi
1017     create_compute_node_local_conf ${!COMPUTEIP} ${!CONTROLIP} ${ODLMGRIP[$SITE_INDEX]} "${ODL_OVS_MGRS[$SITE_INDEX]}"
1018     scp ${WORKSPACE}/local.conf_compute_${!COMPUTEIP} ${!COMPUTEIP}:/opt/stack/devstack/local.conf
1019     echo "Stack the compute node ${i} of ${NUM_OPENSTACK_COMPUTE_NODES}: ${COMPUTEIP}"
1020     ssh ${!COMPUTEIP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
1021     ssh ${!COMPUTEIP} "ps -ef | grep stack.sh"
1022     os_node_list+=("${!COMPUTEIP}")
1023 done
1024
1025 echo "nodelist: ${os_node_list[*]}"
1026
1027 # This script runs on the openstack nodes. It greps for a string that devstack writes when stacking is complete.
1028 # The script then writes a status depending on the grep output that is later scraped by the robot vm to control
1029 # the status polling.
1030 cat > ${WORKSPACE}/check_stacking.sh << EOF
1031 > /tmp/stack_progress
1032 ps -ef | grep "stack.sh" | grep -v grep
1033 ret=\$?
1034 if [ \${ret} -eq 1 ]; then
1035     grep "This is your host IP address:" /opt/stack/devstack/nohup.out
1036     if [ \$? -eq 0 ]; then
1037         echo "Stacking Complete" > /tmp/stack_progress
1038     else
1039         echo "Stacking Failed" > /tmp/stack_progress
1040     fi
1041 elif [ \${ret} -eq 0 ]; then
1042     echo "Still Stacking" > /tmp/stack_progress
1043 fi
1044 EOF
1045
1046 # devstack debugging
1047 # get_hostnames
1048
1049 # Check if the stacking is finished. Poll all nodes every 60s for one hour.
1050 iteration=0
1051 in_progress=1
1052 while [ ${in_progress} -eq 1 ]; do
1053     iteration=$(($iteration + 1))
1054     for index in "${!os_node_list[@]}"; do
1055         echo "node $index ${os_node_list[index]}: checking stacking status attempt ${iteration} of 60"
1056         scp ${WORKSPACE}/check_stacking.sh  ${os_node_list[index]}:/tmp
1057         ${SSH} ${os_node_list[index]} "bash /tmp/check_stacking.sh"
1058         scp ${os_node_list[index]}:/tmp/stack_progress .
1059         cat stack_progress
1060         stacking_status=`cat stack_progress`
1061         # devstack debugging
1062         # get_service "${iteration}" "${index}"
1063         if [ "$stacking_status" == "Still Stacking" ]; then
1064             continue
1065         elif [ "$stacking_status" == "Stacking Failed" ]; then
1066             echo "node $index ${os_node_list[index]}: stacking has failed"
1067             collect_logs
1068             exit 1
1069         elif [ "$stacking_status" == "Stacking Complete" ]; then
1070             echo "node $index ${os_node_list[index]}: stacking complete"
1071             unset 'os_node_list[index]'
1072             if  [ ${#os_node_list[@]} -eq 0 ]; then
1073                 in_progress=0
1074             fi
1075         fi
1076     done
1077     echo "sleep for a minute before the next check"
1078     sleep 60
1079     if [ ${iteration} -eq 60 ]; then
1080         echo "stacking has failed - took longer than 60m"
1081         collect_logs
1082         exit 1
1083     fi
1084 done
1085
1086 # Further configuration now that stacking is complete.
1087 NUM_COMPUTES_PER_SITE=$((NUM_OPENSTACK_COMPUTE_NODES / NUM_OPENSTACK_SITES))
1088 for i in `seq 1 ${NUM_OPENSTACK_SITES}`; do
1089     echo "Configure the Control Node"
1090     CONTROLIP=OPENSTACK_CONTROL_NODE_${i}_IP
1091     # Gather Compute IPs for the site
1092     for j in `seq 1 ${NUM_COMPUTES_PER_SITE}`; do
1093         COMPUTE_INDEX=$(((i-1) * NUM_COMPUTES_PER_SITE + j))
1094         IP_VAR=OPENSTACK_COMPUTE_NODE_${COMPUTE_INDEX}_IP
1095         COMPUTE_IPS[$((j-1))]=${!IP_VAR}
1096     done
1097
1098     echo "sleep for 60s and print hypervisor-list"
1099     sleep 60
1100     # In Ocata if we do not enable the n-cpu in control node then
1101     # we need to discover hosts manually and ensure that they are mapped to cells.
1102     # reference: https://ask.openstack.org/en/question/102256/how-to-configure-placement-service-for-compute-node-on-ocata/
1103     if [ "${OPENSTACK_BRANCH}" == "stable/ocata" ]; then
1104         scp ${WORKSPACE}/setup_host_cell_mapping.sh  ${!CONTROLIP}:/tmp
1105         ${SSH} ${!CONTROLIP} "sudo bash /tmp/setup_host_cell_mapping.sh"
1106     fi
1107     ${SSH} ${!CONTROLIP} "cd /opt/stack/devstack; source openrc admin admin; nova hypervisor-list"
1108     # in the case that we are doing openstack (control + compute) all in one node, then the number of hypervisors
1109     # will be the same as the number of openstack systems. However, if we are doing multinode openstack then the
1110     # assumption is we have a single control node and the rest are compute nodes, so the number of expected hypervisors
1111     # is one less than the total number of openstack systems
1112     if [ $((NUM_OPENSTACK_SYSTEM / NUM_OPENSTACK_SITES)) -eq 1 ]; then
1113         expected_num_hypervisors=1
1114     else
1115         expected_num_hypervisors=${NUM_COMPUTES_PER_SITE}
1116     fi
1117     num_hypervisors=$(${SSH} ${!CONTROLIP} "cd /opt/stack/devstack; source openrc admin admin; openstack hypervisor list -f value | wc -l" | tail -1 | tr -d "\r")
1118     if ! [ "${num_hypervisors}" ] || ! [ ${num_hypervisors} -eq ${expected_num_hypervisors} ]; then
1119         echo "Error: Only $num_hypervisors hypervisors detected, expected $expected_num_hypervisors"
1120         collect_logs
1121         exit 1
1122     fi
1123
1124     # upgrading pip, urllib3 and httplib2 so that tempest tests can be run on openstack control node
1125     # this needs to happen after devstack runs because it seems devstack is pulling in specific versions
1126     # of these libs that are not working for tempest.
1127     ${SSH} ${!CONTROLIP} "sudo pip install --upgrade pip"
1128     ${SSH} ${!CONTROLIP} "sudo pip install urllib3 --upgrade"
1129     ${SSH} ${!CONTROLIP} "sudo pip install httplib2 --upgrade"
1130
1131     # Gather Compute IPs for the site
1132     for j in `seq 1 ${NUM_COMPUTES_PER_SITE}`; do
1133         COMPUTE_INDEX=$(((i-1) * NUM_COMPUTES_PER_SITE + j))
1134         IP_VAR=OPENSTACK_COMPUTE_NODE_${COMPUTE_INDEX}_IP
1135         COMPUTE_IPS[$((j-1))]=${!IP_VAR}
1136     done
1137
1138     # External Network
1139     echo "prepare external networks by adding vxlan tunnels between all nodes on a separate bridge..."
1140     # FIXME Should there be a unique gateway IP and devstack index for each site?
1141     devstack_index=1
1142     for ip in ${!CONTROLIP} ${COMPUTE_IPS[*]}; do
1143         # 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
1144         ${SSH} $ip "sudo ovs-vsctl --if-exists del-port br-int $PUBLIC_BRIDGE"
1145         ${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++))"
1146     done
1147
1148     # ipsec support
1149     if [ "${IPSEC_VXLAN_TUNNELS_ENABLED}" == "yes" ]; then
1150         # shellcheck disable=SC2206
1151         ALL_NODES=(${!CONTROLIP} ${COMPUTE_IPS[*]})
1152         for ((inx_ip1=0; inx_ip1<$((${#ALL_NODES[@]} - 1)); inx_ip1++)); do
1153             for ((inx_ip2=$((inx_ip1 + 1)); inx_ip2<${#ALL_NODES[@]}; inx_ip2++)); do
1154                 KEY1=0x$(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64)
1155                 KEY2=0x$(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64)
1156                 ID=0x$(dd if=/dev/urandom count=4 bs=1 2> /dev/null| xxd -p -c 8)
1157                 ip1=${ALL_NODES[$inx_ip1]}
1158                 ip2=${ALL_NODES[$inx_ip2]}
1159                 ${SSH} $ip1 "sudo ip xfrm state add src $ip1 dst $ip2 proto esp spi $ID reqid $ID mode transport auth sha256 $KEY1 enc aes $KEY2"
1160                 ${SSH} $ip1 "sudo ip xfrm state add src $ip2 dst $ip1 proto esp spi $ID reqid $ID mode transport auth sha256 $KEY1 enc aes $KEY2"
1161                 ${SSH} $ip1 "sudo ip xfrm policy add src $ip1 dst $ip2 proto udp dir out tmpl src $ip1 dst $ip2 proto esp reqid $ID mode transport"
1162                 ${SSH} $ip1 "sudo ip xfrm policy add src $ip2 dst $ip1 proto udp dir in tmpl src $ip2 dst $ip1 proto esp reqid $ID mode transport"
1163
1164                 ${SSH} $ip2 "sudo ip xfrm state add src $ip2 dst $ip1 proto esp spi $ID reqid $ID mode transport auth sha256 $KEY1 enc aes $KEY2"
1165                 ${SSH} $ip2 "sudo ip xfrm state add src $ip1 dst $ip2 proto esp spi $ID reqid $ID mode transport auth sha256 $KEY1 enc aes $KEY2"
1166                 ${SSH} $ip2 "sudo ip xfrm policy add src $ip2 dst $ip1 proto udp dir out tmpl src $ip2 dst $ip1 proto esp reqid $ID mode transport"
1167                 ${SSH} $ip2 "sudo ip xfrm policy add src $ip1 dst $ip2 proto udp dir in tmpl src $ip1 dst $ip2 proto esp reqid $ID mode transport"
1168             done
1169         done
1170
1171         for ip in ${!CONTROLIP} ${COMPUTE_IPS[*]}; do
1172             echo "ip xfrm configuration for node $ip:"
1173             ${SSH} $ip "sudo ip xfrm policy list"
1174             ${SSH} $ip "sudo ip xfrm state list"
1175         done
1176     fi
1177
1178     # Control Node - PUBLIC_BRIDGE will act as the external router
1179     # Parameter values below are used in integration/test - changing them requires updates in intergration/test as well
1180     EXTNET_GATEWAY_IP="10.10.10.250"
1181     EXTNET_INTERNET_IP="10.9.9.9"
1182     EXTNET_PNF_IP="10.10.10.253"
1183     ${SSH} ${!CONTROLIP} "sudo ifconfig ${PUBLIC_BRIDGE} up ${EXTNET_GATEWAY_IP}/24"
1184
1185     # Control Node - external net PNF simulation
1186     ${SSH} ${!CONTROLIP} "
1187         sudo ip netns add pnf_ns;
1188         sudo ip link add pnf_veth0 type veth peer name pnf_veth1;
1189         sudo ip link set pnf_veth1 netns pnf_ns;
1190         sudo ip link set pnf_veth0 up;
1191         sudo ip netns exec pnf_ns ifconfig pnf_veth1 up ${EXTNET_PNF_IP}/24;
1192         sudo ovs-vsctl add-port ${PUBLIC_BRIDGE} pnf_veth0;
1193     "
1194
1195     # Control Node - external net internet address simulation
1196     ${SSH} ${!CONTROLIP} "
1197         sudo ip tuntap add dev internet_tap mode tap;
1198         sudo ifconfig internet_tap up ${EXTNET_INTERNET_IP}/24;
1199     "
1200
1201     # Computes
1202     compute_index=1
1203     for compute_ip in ${COMPUTE_IPS[*]}; do
1204         # Tunnel from controller to compute
1205         COMPUTEPORT=compute$(( compute_index++ ))_vxlan
1206         ${SSH} ${!CONTROLIP} "
1207             sudo ovs-vsctl add-port $PUBLIC_BRIDGE $COMPUTEPORT -- set interface $COMPUTEPORT type=vxlan options:local_ip=${!CONTROLIP} options:remote_ip=$compute_ip options:dst_port=9876 options:key=flow
1208         "
1209         # Tunnel from compute to controller
1210         CONTROLPORT="control_vxlan"
1211         ${SSH} $compute_ip "
1212             sudo ovs-vsctl add-port $PUBLIC_BRIDGE $CONTROLPORT -- set interface $CONTROLPORT type=vxlan options:local_ip=$compute_ip options:remote_ip=${!CONTROLIP} options:dst_port=9876 options:key=flow
1213         "
1214     done
1215 done
1216
1217 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
1218     odlmgrip=OPENSTACK_HAPROXY_1_IP
1219     HA_PROXY_IP=${!odlmgrip}
1220     HA_PROXY_1_IP=${!odlmgrip}
1221     odlmgrip2=OPENSTACK_HAPROXY_2_IP
1222     HA_PROXY_2_IP=${!odlmgrip2}
1223     odlmgrip3=OPENSTACK_HAPROXY_1_IP
1224     HA_PROXY_3_IP=${!odlmgrip3}
1225 else
1226     HA_PROXY_IP=${ODL_SYSTEM_IP}
1227     HA_PROXY_1_IP=${ODL_SYSTEM_1_IP}
1228     HA_PROXY_2_IP=${ODL_SYSTEM_2_IP}
1229     HA_PROXY_3_IP=${ODL_SYSTEM_3_IP}
1230 fi
1231
1232 echo "Locating test plan to use..."
1233 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
1234 if [ ! -f "${testplan_filepath}" ]; then
1235     testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
1236 fi
1237
1238 echo "Changing the testplan path..."
1239 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
1240 cat testplan.txt
1241
1242 # Use the testplan if specific SUITES are not defined.
1243 if [ -z "${SUITES}" ]; then
1244     SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
1245 else
1246     newsuites=""
1247     workpath="${WORKSPACE}/test/csit/suites"
1248     for suite in ${SUITES}; do
1249         fullsuite="${workpath}/${suite}"
1250         if [ -z "${newsuites}" ]; then
1251             newsuites+=${fullsuite}
1252         else
1253             newsuites+=" "${fullsuite}
1254         fi
1255     done
1256     SUITES=${newsuites}
1257 fi
1258
1259 #install all client versions required for this job testing
1260 install_openstack_clients_in_robot_vm
1261
1262 # TODO: run openrc on control node and then scrape the vars from it
1263 # Environment Variables Needed to execute Openstack Client for NetVirt Jobs
1264 cat > /tmp/os_netvirt_client_rc << EOF
1265 export OS_USERNAME=admin
1266 export OS_PASSWORD=admin
1267 export OS_PROJECT_NAME=admin
1268 export OS_USER_DOMAIN_NAME=default
1269 export OS_PROJECT_DOMAIN_NAME=default
1270 export OS_AUTH_URL="http://${!CONTROLIP}/identity"
1271 export OS_IDENTITY_API_VERSION=3
1272 export OS_IMAGE_API_VERSION=2
1273 export OS_TENANT_NAME=admin
1274 unset OS_CLOUD
1275 EOF
1276
1277 source /tmp/os_netvirt_client_rc
1278
1279 echo "Get all versions before executing pybot"
1280 echo "openstack --version"
1281 which openstack
1282 openstack --version
1283 echo "nova --version"
1284 which nova
1285 nova --version
1286 echo "neutron --version"
1287 which neutron
1288 neutron --version
1289
1290 echo "Starting Robot test suites ${SUITES} ..."
1291 # please add pybot -v arguments on a single line and alphabetized
1292 suite_num=0
1293 for suite in ${SUITES}; do
1294     # prepend an incremental counter to the suite name so that the full robot log combining all the suites as is done
1295     # in the rebot step below will list all the suites in chronological order as rebot seems to alphabetize them
1296     let "suite_num = suite_num + 1"
1297     suite_index="$(printf %02d ${suite_num})"
1298     suite_name="$(basename ${suite} | cut -d. -f1)"
1299     log_name="${suite_index}_${suite_name}"
1300     pybot -N ${log_name} \
1301     -c critical -e exclude -e skip_if_${DISTROSTREAM} \
1302     --log log_${log_name}.html --report None --output output_${log_name}.xml \
1303     --removekeywords wuks \
1304     --removekeywords name:SetupUtils.Setup_Utils_For_Setup_And_Teardown \
1305     --removekeywords name:SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing \
1306     --removekeywords name:OpenStackOperations.Add_OVS_Logging_On_All_OpenStack_Nodes \
1307     -v BUNDLEFOLDER:${BUNDLEFOLDER} \
1308     -v BUNDLE_URL:${ACTUAL_BUNDLE_URL} \
1309     -v CONTROLLERFEATURES:"${CONTROLLERFEATURES}" \
1310     -v CONTROLLER_USER:${USER} \
1311     -v DEVSTACK_DEPLOY_PATH:/opt/stack/devstack \
1312     -v HA_PROXY_IP:${HA_PROXY_IP} \
1313     -v HA_PROXY_1_IP:${HA_PROXY_1_IP} \
1314     -v HA_PROXY_2_IP:${HA_PROXY_2_IP} \
1315     -v HA_PROXY_3_IP:${HA_PROXY_3_IP} \
1316     -v JDKVERSION:${JDKVERSION} \
1317     -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
1318     -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
1319     -v NUM_OPENSTACK_SITES:${NUM_OPENSTACK_SITES} \
1320     -v NUM_OS_SYSTEM:${NUM_OPENSTACK_SYSTEM} \
1321     -v NUM_TOOLS_SYSTEM:${NUM_TOOLS_SYSTEM} \
1322     -v ODL_SNAT_MODE:${ODL_SNAT_MODE} \
1323     -v ODL_ENABLE_L3_FWD:${ODL_ENABLE_L3_FWD} \
1324     -v ODL_STREAM:${DISTROSTREAM} \
1325     -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
1326     -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_1_IP} \
1327     -v ODL_SYSTEM_2_IP:${ODL_SYSTEM_2_IP} \
1328     -v ODL_SYSTEM_3_IP:${ODL_SYSTEM_3_IP} \
1329     -v ODL_SYSTEM_4_IP:${ODL_SYSTEM_4_IP} \
1330     -v ODL_SYSTEM_5_IP:${ODL_SYSTEM_5_IP} \
1331     -v ODL_SYSTEM_6_IP:${ODL_SYSTEM_6_IP} \
1332     -v ODL_SYSTEM_7_IP:${ODL_SYSTEM_7_IP} \
1333     -v ODL_SYSTEM_8_IP:${ODL_SYSTEM_8_IP} \
1334     -v ODL_SYSTEM_9_IP:${ODL_SYSTEM_9_IP} \
1335     -v OS_CONTROL_NODE_IP:${OPENSTACK_CONTROL_NODE_1_IP} \
1336     -v OS_CONTROL_NODE_1_IP:${OPENSTACK_CONTROL_NODE_1_IP} \
1337     -v OS_CONTROL_NODE_2_IP:${OPENSTACK_CONTROL_NODE_2_IP} \
1338     -v OS_CONTROL_NODE_3_IP:${OPENSTACK_CONTROL_NODE_3_IP} \
1339     -v OPENSTACK_BRANCH:${OPENSTACK_BRANCH} \
1340     -v OS_COMPUTE_1_IP:${OPENSTACK_COMPUTE_NODE_1_IP} \
1341     -v OS_COMPUTE_2_IP:${OPENSTACK_COMPUTE_NODE_2_IP} \
1342     -v OS_COMPUTE_3_IP:${OPENSTACK_COMPUTE_NODE_3_IP} \
1343     -v OS_COMPUTE_4_IP:${OPENSTACK_COMPUTE_NODE_4_IP} \
1344     -v OS_COMPUTE_5_IP:${OPENSTACK_COMPUTE_NODE_5_IP} \
1345     -v OS_COMPUTE_6_IP:${OPENSTACK_COMPUTE_NODE_6_IP} \
1346     -v OS_USER:${USER} \
1347     -v PUBLIC_PHYSICAL_NETWORK:${PUBLIC_PHYSICAL_NETWORK} \
1348     -v SECURITY_GROUP_MODE:${SECURITY_GROUP_MODE} \
1349     -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_1_IP} \
1350     -v TOOLS_SYSTEM_1_IP:${TOOLS_SYSTEM_1_IP} \
1351     -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
1352     -v USER_HOME:${HOME} \
1353     -v WORKSPACE:/tmp \
1354     ${TESTOPTIONS} ${suite} || true
1355 done
1356 #rebot exit codes seem to be different
1357 rebot --output ${WORKSPACE}/output.xml --log log_full.html --report None -N openstack output_*.xml || true
1358
1359 echo "Examining the files in data/log and checking file size"
1360 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
1361 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
1362
1363 echo "Tests Executed"
1364 collect_logs
1365
1366 true  # perhaps Jenkins is testing last exit code
1367 # vim: ts=4 sw=4 sts=4 et ft=sh :