Merge "Remove vpnservice carbon and boron jobs"
[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-phys1)
194 # MTU(1440) + VXLAN(50) + VLAN(4) = 1494 < MTU eth0/br-phys1(1500)
195 physical_network_mtus = ${PUBLIC_PHYSICAL_NETWORK}:1440
196 path_mtu = 1490
197
198 [[post-config|/etc/neutron/dhcp_agent.ini]]
199 [DEFAULT]
200 force_metadata = True
201 enable_isolated_metadata = True
202
203 [[post-config|/etc/nova/nova.conf]]
204 [DEFAULT]
205 force_config_drive = False
206
207 EOF
208
209 echo "local.conf Created...."
210 cat ${local_conf_file_name}
211 }
212
213 function create_compute_node_local_conf {
214 HOSTIP=$1
215 #Needs to be removed
216 if [ "${ODL_ML2_BRANCH}" != "stable/ocata" ]; then
217    RECLONE=no
218 else
219    RECLONE=yes
220 fi
221 if [ "${OPENSTACK_BRANCH}" == "master" ] || [ "${OPENSTACK_BRANCH}" == "stable/ocata" ]; then # Ocata+
222     # placement is mandatory for nova since Ocata, note that this requires controller to enable placement-api
223     ENABLED_SERVICES="n-cpu,placement-client"
224 else
225     ENABLED_SERVICES="n-cpu"
226 fi
227
228 local_conf_file_name=${WORKSPACE}/local.conf_compute_${HOSTIP}
229 cat > ${local_conf_file_name} << EOF
230 [[local|localrc]]
231 LOGFILE=stack.sh.log
232 LOG_COLOR=False
233 SCREEN_LOGDIR=/opt/stack/data/log
234 RECLONE=${RECLONE}
235
236 NOVA_VNC_ENABLED=True
237 MULTI_HOST=1
238 ENABLED_SERVICES=${ENABLED_SERVICES}
239 HOST_IP=${HOSTIP}
240 SERVICE_HOST=${OPENSTACK_CONTROL_NODE_IP}
241
242 Q_PLUGIN=ml2
243 ENABLE_TENANT_TUNNELS=True
244 Q_ML2_TENANT_NETWORK_TYPE=vxlan
245
246 Q_HOST=\$SERVICE_HOST
247 MYSQL_HOST=\$SERVICE_HOST
248 RABBIT_HOST=\$SERVICE_HOST
249 GLANCE_HOSTPORT=\$SERVICE_HOST:9292
250 KEYSTONE_AUTH_HOST=\$SERVICE_HOST
251 KEYSTONE_SERVICE_HOST=\$SERVICE_HOST
252
253 MYSQL_PASSWORD=mysql
254 RABBIT_PASSWORD=rabbit
255 SERVICE_TOKEN=service
256 SERVICE_PASSWORD=admin
257 ADMIN_PASSWORD=admin
258
259 ODL_MODE=compute
260 ODL_PORT_BINDING_CONTROLLER=${ODL_ML2_PORT_BINDING}
261 LIBVIRT_TYPE=qemu
262 EOF
263
264 if [[ "${ENABLE_OS_PLUGINS}" =~ networking-odl ]]; then
265 cat >> ${local_conf_file_name} << EOF
266 enable_plugin networking-odl ${ODL_ML2_DRIVER_REPO} ${ODL_ML2_BRANCH}
267 EOF
268 fi
269
270 if [ "${NUM_ODL_SYSTEM}" -gt 1 ]; then
271 odl_list=${ODL_SYSTEM_1_IP}
272 for i in `seq 2 ${NUM_ODL_SYSTEM}`
273 do
274 odlip=ODL_SYSTEM_${i}_IP
275 odl_list=${odl_list},${!odlip}
276 done
277 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
278 HA_PROXY_INDEX=${NUM_OPENSTACK_SYSTEM}
279 odlmgrip=OPENSTACK_COMPUTE_NODE_${HA_PROXY_INDEX}_IP
280 odl_mgr_ip=${!odlmgrip}
281 else
282 odl_mgr_ip=${ODL_SYSTEM_1_IP}
283 fi
284 cat >> ${local_conf_file_name} << EOF
285 ODL_OVS_MANAGERS=${odl_list}
286 ODL_MGR_IP=${odl_mgr_ip}
287 EOF
288 else
289 cat >> ${local_conf_file_name} << EOF
290 ODL_MGR_IP=${ODL_SYSTEM_1_IP}
291 EOF
292 fi
293
294 # if we are using the new netvirt impl, as determined by the feature name
295 # odl-netvirt-openstack (note: old impl is odl-ovsdb-openstack) then we
296 # want PROVIDER_MAPPINGS to be used -- this should be fixed if we want to support
297 # external networks in legacy netvirt
298 if [[ ${CONTROLLERFEATURES} == *"odl-netvirt-openstack"* ]]; then
299   ODL_PROVIDER_MAPPINGS="\${PUBLIC_PHYSICAL_NETWORK}:${PUBLIC_BRIDGE}"
300 else
301   ODL_PROVIDER_MAPPINGS=
302 fi
303
304 if [ "${ODL_ENABLE_L3_FWD}" == "yes" ]; then
305 cat >> ${local_conf_file_name} << EOF
306 # Uncomment lines below if odl-compute is to be used for l3 forwarding
307 Q_L3_ENABLED=True
308 ODL_L3=${ODL_L3}
309 PUBLIC_INTERFACE=br100 # FIXME do we use br100 at all?
310 PUBLIC_BRIDGE=${PUBLIC_BRIDGE}
311 PUBLIC_PHYSICAL_NETWORK=${PUBLIC_PHYSICAL_NETWORK}
312 ODL_PROVIDER_MAPPINGS=${ODL_PROVIDER_MAPPINGS}
313 EOF
314 fi
315 echo "local.conf Created...."
316 cat ${local_conf_file_name}
317 }
318
319 function configure_haproxy_for_neutron_requests () {
320 HA_PROXY_INDEX=${NUM_OPENSTACK_SYSTEM}
321 odlmgrip=OPENSTACK_COMPUTE_NODE_${HA_PROXY_INDEX}_IP
322 ha_proxy_ip=${!odlmgrip}
323
324 cat > ${WORKSPACE}/install_ha_proxy.sh<< EOF
325 sudo systemctl stop firewalld
326 sudo yum -y install policycoreutils-python haproxy
327 EOF
328
329 cat > ${WORKSPACE}/haproxy.cfg << EOF
330 global
331   daemon
332   group  haproxy
333   log  /dev/log local0
334   maxconn  20480
335   pidfile  /tmp/haproxy.pid
336   user  haproxy
337
338 defaults
339   log  global
340   maxconn  4096
341   mode  tcp
342   retries  3
343   timeout  http-request 10s
344   timeout  queue 1m
345   timeout  connect 10s
346   timeout  client 1m
347   timeout  server 1m
348   timeout  check 10s
349
350 listen opendaylight
351   bind ${ha_proxy_ip}:8080
352   balance source
353 EOF
354
355 for i in `seq 1 ${NUM_ODL_SYSTEM}`
356 do
357 odlip=ODL_SYSTEM_${i}_IP
358 cat >> ${WORKSPACE}/haproxy.cfg << EOF
359   server controller-$i ${!odlip}:8080 check fall 5 inter 2000 rise 2
360 EOF
361 done
362
363 cat >> ${WORKSPACE}/haproxy.cfg << EOF
364 listen opendaylight_rest
365   bind ${ha_proxy_ip}:8181
366   balance source
367 EOF
368
369 for i in `seq 1 ${NUM_ODL_SYSTEM}`
370 do
371 odlip=ODL_SYSTEM_${i}_IP
372 cat >> ${WORKSPACE}/haproxy.cfg << EOF
373   server controller-rest-$i ${!odlip}:8181 check fall 5 inter 2000 rise 2
374 EOF
375 done
376
377 cat > ${WORKSPACE}/deploy_ha_proxy.sh<< EOF
378 sudo chown haproxy:haproxy /tmp/haproxy.cfg
379 sudo sed -i 's/\\/etc\\/haproxy\\/haproxy.cfg/\\/tmp\\/haproxy.cfg/g' /usr/lib/systemd/system/haproxy.service
380 sudo /usr/sbin/semanage permissive -a haproxy_t
381 sudo systemctl restart haproxy
382 sleep 3
383 sudo netstat -tunpl
384 sudo systemctl status haproxy
385 true
386 EOF
387 scp ${WORKSPACE}/install_ha_proxy.sh ${ha_proxy_ip}:/tmp
388 ${SSH} ${ha_proxy_ip} "sudo bash /tmp/install_ha_proxy.sh"
389 scp ${WORKSPACE}/haproxy.cfg ${ha_proxy_ip}:/tmp
390 scp ${WORKSPACE}/deploy_ha_proxy.sh ${ha_proxy_ip}:/tmp
391 ${SSH} ${ha_proxy_ip} "sudo bash /tmp/deploy_ha_proxy.sh"
392 }
393
394 function collect_logs_and_exit (){
395 set +e  # We do not want to create red dot just because something went wrong while fetching logs.
396 for i in `seq 1 ${NUM_ODL_SYSTEM}`
397 do
398     CONTROLLERIP=ODL_SYSTEM_${i}_IP
399     echo "killing karaf process..."
400     ${SSH} "${!CONTROLLERIP}" bash -c 'ps axf | grep karaf | grep -v grep | awk '"'"'{print "kill -9 " $1}'"'"' | sh'
401 done
402
403 cat > extra_debug.sh << EOF
404 echo -e "/usr/sbin/lsmod | /usr/bin/grep openvswitch\n"
405 /usr/sbin/lsmod | /usr/bin/grep openvswitch
406 echo -e "\ngrep ct_ /var/log/openvswitch/ovs-vswitchd.log\n"
407 grep ct_ /var/log/openvswitch/ovs-vswitchd.log
408 EOF
409
410 sleep 5
411 # FIXME: Do not create .tar and gzip before copying.
412 for i in `seq 1 ${NUM_ODL_SYSTEM}`
413 do
414     CONTROLLERIP=ODL_SYSTEM_${i}_IP
415     ${SSH} "${!CONTROLLERIP}"  "cp -r /tmp/${BUNDLEFOLDER}/data/log /tmp/odl_log"
416     ${SSH} "${!CONTROLLERIP}"  "tar -cf /tmp/odl${i}_karaf.log.tar /tmp/odl_log/*"
417     scp "${!CONTROLLERIP}:/tmp/odl${i}_karaf.log.tar" "${WORKSPACE}/odl${i}_karaf.log.tar"
418     tar -xvf ${WORKSPACE}/odl${i}_karaf.log.tar -C . --strip-components 2 --transform s/karaf/odl${i}_karaf/g
419     grep "ROBOT MESSAGE\| ERROR " odl${i}_karaf.log > odl${i}_err.log
420     grep "ROBOT MESSAGE\|Exception" odl${i}_karaf.log > odl${i}_exception.log
421     grep "ROBOT MESSAGE\| ERROR \| WARN \|Exception" odl${i}_karaf.log > odl${i}_err_warn_exception.log
422     rm ${WORKSPACE}/odl${i}_karaf.log.tar
423 done
424
425 # Since this log collection work is happening before the archive build macro which also
426 # creates the ${WORKSPACE}/archives dir, we have to do it here first.  The mkdir in the
427 # archives build step will essentially be a noop.
428 mkdir -p ${WORKSPACE}/archives
429
430 # Control Node
431 OS_CTRL_FOLDER="control"
432 mkdir -p ${OS_CTRL_FOLDER}
433 scp ${OPENSTACK_CONTROL_NODE_IP}:/opt/stack/devstack/nohup.out ${OS_CTRL_FOLDER}/stack.log
434 scp ${OPENSTACK_CONTROL_NODE_IP}:/var/log/openvswitch/ovs-vswitchd.log ${OS_CTRL_FOLDER}/ovs-vswitchd.log
435 scp ${OPENSTACK_CONTROL_NODE_IP}:/etc/neutron/neutron.conf ${OS_CTRL_FOLDER}/neutron.conf
436 scp ${OPENSTACK_CONTROL_NODE_IP}:/etc/nova/nova.conf ${OS_CTRL_FOLDER}/nova.conf
437 rsync -avhe ssh ${OPENSTACK_CONTROL_NODE_IP}:/opt/stack/logs/* ${OS_CTRL_FOLDER} # rsync to prevent copying of symbolic links
438 scp extra_debug.sh ${OPENSTACK_CONTROL_NODE_IP}:/tmp
439 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "bash /tmp/extra_debug.sh > /tmp/extra_debug.log"
440 scp ${OPENSTACK_CONTROL_NODE_IP}:/tmp/extra_debug.log ${OS_CTRL_FOLDER}/extra_debug.log
441 mv local.conf_control ${OS_CTRL_FOLDER}/local.conf
442 mv ${OS_CTRL_FOLDER} ${WORKSPACE}/archives/
443
444 # Compute Nodes
445 for i in `seq 1 $((NUM_OPENSTACK_SYSTEM - 1))`
446 do
447     OSIP=OPENSTACK_COMPUTE_NODE_${i}_IP
448     OS_COMPUTE_FOLDER="compute_${i}"
449     mkdir -p ${OS_COMPUTE_FOLDER}
450     scp ${!OSIP}:/opt/stack/devstack/nohup.out ${OS_COMPUTE_FOLDER}/stack.log
451     scp ${!OSIP}:/var/log/openvswitch/ovs-vswitchd.log ${OS_COMPUTE_FOLDER}/ovs-vswitchd.log
452     scp ${!OSIP}:/etc/nova/nova.conf ${OS_COMPUTE_FOLDER}/nova.conf
453     rsync -avhe ssh ${!OSIP}:/opt/stack/logs/* ${OS_COMPUTE_FOLDER} # rsync to prevent copying of symbolic links
454     scp extra_debug.sh ${!OSIP}:/tmp
455     ${SSH} ${!OSIP} "bash /tmp/extra_debug.sh > /tmp/extra_debug.log"
456     scp ${!OSIP}:/tmp/extra_debug.log ${OS_COMPUTE_FOLDER}/extra_debug.log
457     mv local.conf_compute_${!OSIP} ${OS_COMPUTE_FOLDER}/local.conf
458     mv ${OS_COMPUTE_FOLDER} ${WORKSPACE}/archives/
459 done
460
461 ls local.conf* | xargs -I % mv % %.log
462
463 # Tempest
464 DEVSTACK_TEMPEST_DIR="/opt/stack/tempest"
465 if $(ssh ${OPENSTACK_CONTROL_NODE_IP} "sudo sh -c '[ -f ${DEVSTACK_TEMPEST_DIR}/.testrepository/0 ]'"); then # if Tempest results exist
466     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"
467     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'"
468     TEMPEST_LOGS_DIR=${WORKSPACE}/archives/tempest
469     mkdir -p ${TEMPEST_LOGS_DIR}
470     scp ${OPENSTACK_CONTROL_NODE_IP}:${DEVSTACK_TEMPEST_DIR}/tempest_results.html ${TEMPEST_LOGS_DIR}
471     scp ${OPENSTACK_CONTROL_NODE_IP}:${DEVSTACK_TEMPEST_DIR}/tempest.log ${TEMPEST_LOGS_DIR}
472     mv ${WORKSPACE}/tempest_output* ${TEMPEST_LOGS_DIR}
473 fi
474 }
475
476 cat > ${WORKSPACE}/disable_firewall.sh << EOF
477 sudo systemctl stop firewalld
478 sudo systemctl stop iptables
479 true
480 EOF
481
482 cat > ${WORKSPACE}/get_devstack.sh << EOF
483 sudo systemctl stop firewalld
484 sudo yum install bridge-utils -y
485 sudo systemctl stop  NetworkManager
486 #Disable NetworkManager and kill dhclient and dnsmasq
487 sudo systemctl stop NetworkManager
488 sudo killall dhclient
489 sudo killall dnsmasq
490 #Workaround for mysql failure
491 echo "127.0.0.1    localhost \${HOSTNAME}" > /tmp/hosts
492 echo "::1   localhost  \${HOSTNAME}" >> /tmp/hosts
493 sudo mv /tmp/hosts /etc/hosts
494 sudo /usr/sbin/brctl addbr br100
495 #sudo ifconfig eth0 mtu 2000
496 sudo mkdir /opt/stack
497 sudo chmod 777 /opt/stack
498 cd /opt/stack
499 git clone https://git.openstack.org/openstack-dev/devstack
500 cd devstack
501 git checkout $OPENSTACK_BRANCH
502 EOF
503
504 echo "Create HAProxy if needed"
505 if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
506  echo "Need to configure HAProxy"
507  configure_haproxy_for_neutron_requests
508 fi
509
510 os_node_list=()
511 echo "Stack the Control Node"
512 scp ${WORKSPACE}/get_devstack.sh ${OPENSTACK_CONTROL_NODE_IP}:/tmp
513 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "bash /tmp/get_devstack.sh"
514 create_control_node_local_conf
515 scp ${WORKSPACE}/local.conf_control ${OPENSTACK_CONTROL_NODE_IP}:/opt/stack/devstack/local.conf
516
517 cat > "${WORKSPACE}/manual_install_package.sh" << EOF
518 cd /opt/stack
519 git clone "\$1"
520 cd "\$2"
521 git checkout "\$3"
522 sudo python setup.py install
523
524 EOF
525
526
527 # Workworund for successful stacking with  Mitaka
528 if [ "${ODL_ML2_BRANCH}" == "stable/mitaka" ]; then
529
530   # Workaround for problems with latest versions/specified versions in requirements of openstack
531   # Openstacksdk,libvirt-python -> the current version does not work with  Mitaka diue to some requirements
532   # conflict and breaks when trying to stack
533   # paramiko -> Problems with tempest tests due to paramiko incompatibility with pycrypto.
534   # the problem has been solved with  version 1.17. If the latest version of paramiko is used, it causes
535   # other timeout problems
536   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"
537   scp "${WORKSPACE}/manual_install_package.sh"  "${OPENSTACK_CONTROL_NODE_IP}:/tmp"
538   ssh ${OPENSTACK_CONTROL_NODE_IP} "sudo pip install deprecation"
539   # Fix for recent requirements update  in the  master branch of the sdk.The section must be replaced with a better fix.
540   ssh "${OPENSTACK_CONTROL_NODE_IP}" "sh /tmp/manual_install_package.sh https://github.com/openstack/python-openstacksdk python-openstacksdk 0.9.14"
541   ssh "${OPENSTACK_CONTROL_NODE_IP}" "sh /tmp/manual_install_package.sh https://github.com/paramiko/paramiko paramiko 1.17"
542 fi
543
544 ssh ${OPENSTACK_CONTROL_NODE_IP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
545 ssh ${OPENSTACK_CONTROL_NODE_IP} "ps -ef | grep stack.sh"
546 ssh ${OPENSTACK_CONTROL_NODE_IP} "ls -lrt /opt/stack/devstack/nohup.out"
547 os_node_list+=(${OPENSTACK_CONTROL_NODE_IP})
548
549 #Workaround for stable/newton jobs
550 if [ "${ODL_ML2_BRANCH}" == "stable/newton" ]; then
551   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"
552 fi
553
554 for i in `seq 1 $((NUM_OPENSTACK_SYSTEM - 1))`
555 do
556     COMPUTEIP=OPENSTACK_COMPUTE_NODE_${i}_IP
557     scp ${WORKSPACE}/get_devstack.sh  ${!COMPUTEIP}:/tmp
558     ${SSH} ${!COMPUTEIP} "bash /tmp/get_devstack.sh"
559     create_compute_node_local_conf ${!COMPUTEIP}
560     scp ${WORKSPACE}/local.conf_compute_${!COMPUTEIP} ${!COMPUTEIP}:/opt/stack/devstack/local.conf
561     if [ "${ODL_ML2_BRANCH}" == "stable/mitaka" ]; then
562        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"
563     fi
564     ssh ${!COMPUTEIP} "cd /opt/stack/devstack; nohup ./stack.sh > /opt/stack/devstack/nohup.out 2>&1 &"
565     ssh ${!COMPUTEIP} "ps -ef | grep stack.sh"
566     os_node_list+=(${!COMPUTEIP})
567 done
568
569 cat > ${WORKSPACE}/check_stacking.sh << EOF
570 > /tmp/stack_progress
571 ps -ef | grep "stack.sh" | grep -v grep
572 ret=\$?
573 if [ \${ret} -eq 1 ]; then
574   grep "This is your host IP address:" /opt/stack/devstack/nohup.out
575   if [ \$? -eq 0 ]; then
576      echo "Stacking Complete" > /tmp/stack_progress
577   else
578      echo "Stacking Failed" > /tmp/stack_progress
579   fi
580 elif [ \${ret} -eq 0 ]; then
581   echo "Still Stacking" > /tmp/stack_progress
582 fi
583 EOF
584
585 #the checking is repeated for an hour
586 iteration=0
587 in_progress=1
588 while [ ${in_progress} -eq 1 ]; do
589 iteration=$(($iteration + 1))
590 for index in ${!os_node_list[@]}
591 do
592 echo "Check the status of stacking in ${os_node_list[index]}"
593 scp ${WORKSPACE}/check_stacking.sh  ${os_node_list[index]}:/tmp
594 ${SSH} ${os_node_list[index]} "bash /tmp/check_stacking.sh"
595 scp ${os_node_list[index]}:/tmp/stack_progress .
596 #debug
597 cat stack_progress
598 stacking_status=`cat stack_progress`
599 if [ "$stacking_status" == "Still Stacking" ]; then
600   continue
601 elif [ "$stacking_status" == "Stacking Failed" ]; then
602   collect_logs_and_exit
603   exit 1
604 elif [ "$stacking_status" == "Stacking Complete" ]; then
605   unset os_node_list[index]
606   if  [ ${#os_node_list[@]} -eq 0 ]; then
607      in_progress=0
608   fi
609 fi
610 done
611  echo "sleep for a minute before the next check"
612  sleep 60
613  if [ ${iteration} -eq 60 ]; then
614   collect_logs_and_exit
615   exit 1
616  fi
617 done
618
619 #Need to disable firewalld and iptables in control node
620 echo "Stop Firewall in Control Node for compute nodes to be able to reach the ports and add to hypervisor-list"
621 scp ${WORKSPACE}/disable_firewall.sh ${OPENSTACK_CONTROL_NODE_IP}:/tmp
622 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo bash /tmp/disable_firewall.sh"
623 echo "sleep for a minute and print hypervisor-list"
624 sleep 60
625 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "cd /opt/stack/devstack; source openrc admin admin; nova hypervisor-list"
626 # in the case that we are doing openstack (control + compute) all in one node, then the number of hypervisors
627 # will be the same as the number of openstack systems. However, if we are doing multinode openstack then the
628 # assumption is we have a single control node and the rest are compute nodes, so the number of expected hypervisors
629 # is one less than the total number of openstack systems
630 if [ "${NUM_OPENSTACK_SYSTEM}" -eq 1 ]; then
631   expected_num_hypervisors=1
632 else
633   expected_num_hypervisors=$((NUM_OPENSTACK_SYSTEM - 1))
634 fi
635 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")
636 if ! [ "${num_hypervisors}" ] || ! [ ${num_hypervisors} -eq ${expected_num_hypervisors} ]; then
637   echo "Error: Only $num_hypervisors hypervisors detected, expected $expected_num_hypervisors"
638   collect_logs_and_exit
639   exit 1
640 fi
641
642 #Need to disable firewalld and iptables in compute nodes as well
643 for i in `seq 1 $((NUM_OPENSTACK_SYSTEM - 1))`
644 do
645     OSIP=OPENSTACK_COMPUTE_NODE_${i}_IP
646     scp ${WORKSPACE}/disable_firewall.sh "${!OSIP}:/tmp"
647     ${SSH} "${!OSIP}" "sudo bash /tmp/disable_firewall.sh"
648 done
649
650 # upgrading pip, urllib3 and httplib2 so that tempest tests can be run on ${OPENSTACK_CONTROL_NODE_IP}
651 # this needs to happen after devstack runs because it seems devstack is pulling in specific versions
652 # of these libs that are not working for tempest.
653 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo pip install --upgrade pip"
654 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo pip install urllib3 --upgrade"
655 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo pip install httplib2 --upgrade"
656
657 for i in `seq 1 $((NUM_OPENSTACK_SYSTEM - 1))`
658 do
659     IP_VAR=OPENSTACK_COMPUTE_NODE_${i}_IP
660     COMPUTE_IPS[$((i-1))]=${!IP_VAR}
661 done
662
663 # External Network
664 echo "prepare external networks by adding vxlan tunnels between all nodes on a separate bridge..."
665 devstack_index=1
666 for ip in ${OPENSTACK_CONTROL_NODE_IP} ${COMPUTE_IPS[*]}
667 do
668     # 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
669     ${SSH} $ip "sudo ovs-vsctl --if-exists del-port br-int $PUBLIC_BRIDGE"
670     ${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++))"
671 done
672
673 # ipsec support
674 if [ "${IPSEC_VXLAN_TUNNELS_ENABLED}" == "yes" ]; then
675     ALL_NODES=(${OPENSTACK_CONTROL_NODE_IP} ${COMPUTE_IPS[*]})
676     for ((inx_ip1=0; inx_ip1<$((${#ALL_NODES[@]} - 1)); inx_ip1++))
677     do
678         for ((inx_ip2=$((inx_ip1 + 1)); inx_ip2<${#ALL_NODES[@]}; inx_ip2++))
679         do
680             KEY1=0x$(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64)
681             KEY2=0x$(dd if=/dev/urandom count=32 bs=1 2> /dev/null| xxd -p -c 64)
682             ID=0x$(dd if=/dev/urandom count=4 bs=1 2> /dev/null| xxd -p -c 8)
683             ip1=${ALL_NODES[$inx_ip1]}
684             ip2=${ALL_NODES[$inx_ip2]}
685             ${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"
686             ${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"
687             ${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"
688             ${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"
689
690             ${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"
691             ${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"
692             ${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"
693             ${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"
694         done
695     done
696
697     for ip in ${OPENSTACK_CONTROL_NODE_IP} ${COMPUTE_IPS[*]}
698     do
699         echo "ip xfrm configuration for node $ip:"
700         ${SSH} $ip "sudo ip xfrm policy list"
701         ${SSH} $ip "sudo ip xfrm state list"
702     done
703 fi
704
705 # Control Node - PUBLIC_BRIDGE will act as the external router
706 GATEWAY_IP="10.10.10.250" # FIXME this should be a parameter, also shared with integration-test
707 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo ip link add link ${PUBLIC_BRIDGE} name  ${PUBLIC_BRIDGE}.167 type vlan id 167"
708 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo ifconfig  ${PUBLIC_BRIDGE} up"
709 ${SSH} ${OPENSTACK_CONTROL_NODE_IP} "sudo ifconfig   ${PUBLIC_BRIDGE}.167 up ${GATEWAY_IP}/24"
710 compute_index=1
711 for compute_ip in ${COMPUTE_IPS[*]}
712 do
713     # Tunnel from controller to compute
714     PORT_NAME=compute$((compute_index++))_vxlan
715     ${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"
716
717     # Tunnel from compute to controller
718     PORT_NAME=control_vxlan
719     ${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"
720 done
721
722 if [ "${NUM_ODL_SYSTEM}" -gt 1 ]; then
723   HA_PROXY_INDEX=${NUM_OPENSTACK_SYSTEM}
724   odlmgrip=OPENSTACK_COMPUTE_NODE_${HA_PROXY_INDEX}_IP
725   HA_PROXY_IP=${!odlmgrip}
726 else
727   HA_PROXY_IP=${ODL_SYSTEM_IP}
728 fi
729 echo "Locating test plan to use..."
730 testplan_filepath="${WORKSPACE}/test/csit/testplans/${STREAMTESTPLAN}"
731 if [ ! -f "${testplan_filepath}" ]; then
732     testplan_filepath="${WORKSPACE}/test/csit/testplans/${TESTPLAN}"
733 fi
734
735 echo "Changing the testplan path..."
736 cat "${testplan_filepath}" | sed "s:integration:${WORKSPACE}:" > testplan.txt
737 cat testplan.txt
738
739 SUITES=`egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' testplan.txt | tr '\012' ' '`
740
741 echo "Starting Robot test suites ${SUITES} ..."
742 # please add pybot -v arguments on a single line and alphabetized
743 pybot -N ${TESTPLAN} --removekeywords wuks -c critical -e exclude \
744     -v BUNDLEFOLDER:${BUNDLEFOLDER} \
745     -v BUNDLE_URL:${ACTUALBUNDLEURL} \
746     -v CONTROLLER_USER:${USER} \
747     -v DEVSTACK_DEPLOY_PATH:/opt/stack/devstack \
748     -v HA_PROXY_IP:${HA_PROXY_IP} \
749     -v JDKVERSION:${JDKVERSION} \
750     -v NEXUSURL_PREFIX:${NEXUSURL_PREFIX} \
751     -v NUM_ODL_SYSTEM:${NUM_ODL_SYSTEM} \
752     -v NUM_OS_SYSTEM:${NUM_OPENSTACK_SYSTEM} \
753     -v NUM_TOOLS_SYSTEM:${NUM_TOOLS_SYSTEM} \
754     -v ODL_STREAM:${DISTROSTREAM} \
755     -v ODL_SYSTEM_IP:${ODL_SYSTEM_IP} \
756     -v ODL_SYSTEM_1_IP:${ODL_SYSTEM_1_IP} \
757     -v ODL_SYSTEM_2_IP:${ODL_SYSTEM_2_IP} \
758     -v ODL_SYSTEM_3_IP:${ODL_SYSTEM_3_IP} \
759     -v OS_CONTROL_NODE_IP:${OPENSTACK_CONTROL_NODE_IP} \
760     -v OPENSTACK_BRANCH:${OPENSTACK_BRANCH} \
761     -v OS_COMPUTE_1_IP:${OPENSTACK_COMPUTE_NODE_1_IP} \
762     -v OS_COMPUTE_2_IP:${OPENSTACK_COMPUTE_NODE_2_IP} \
763     -v OS_USER:${USER} \
764     -v PUBLIC_PHYSICAL_NETWORK:${PUBLIC_PHYSICAL_NETWORK} \
765     -v SECURITY_GROUP_MODE:${SECURITY_GROUP_MODE} \
766     -v TOOLS_SYSTEM_IP:${TOOLS_SYSTEM_1_IP} \
767     -v TOOLS_SYSTEM_1_IP:${TOOLS_SYSTEM_1_IP} \
768     -v TOOLS_SYSTEM_2_IP:${TOOLS_SYSTEM_2_IP} \
769     -v USER_HOME:${HOME} \
770     -v WORKSPACE:/tmp \
771     ${TESTOPTIONS} ${SUITES} || true
772
773 echo "Examining the files in data/log and checking filesize"
774 ssh ${ODL_SYSTEM_IP} "ls -altr /tmp/${BUNDLEFOLDER}/data/log/"
775 ssh ${ODL_SYSTEM_IP} "du -hs /tmp/${BUNDLEFOLDER}/data/log/*"
776
777 echo "Tests Executed"
778 collect_logs_and_exit
779
780 true  # perhaps Jenkins is testing last exit code
781 # vim: ts=4 sw=4 sts=4 et ft=sh :