CI: Test accessing dashboard

Also slightly refactor test-openstack.sh script.

Change-Id: I7f10f073e89d2b66367bbb700201b3cd412fc433
Depends-On: https://review.opendev.org/#/c/674241
Depends-On: https://review.opendev.org/#/c/668410
Depends-On: https://review.opendev.org/#/c/668409
This commit is contained in:
Mark Goddard 2019-08-14 14:54:10 +01:00
parent e8212a3080
commit 90ae7590b6
3 changed files with 61 additions and 19 deletions

View File

@ -2,7 +2,10 @@
- hosts: all
tasks:
# NOTE(yoctozepto): setting vars as facts for all to have them around in all the plays
- set_fact:
- name: set facts for commonly used variables
vars:
api_interface_address: "{{ nodepool.private_ipv4 }}"
set_fact:
kolla_inventory_path: "/etc/kolla/inventory"
logs_dir: "/tmp/logs"
kolla_ansible_src_dir: "{{ ansible_env.PWD }}/src/{{ zuul.project.canonical_hostname }}/openstack/kolla-ansible"
@ -11,6 +14,17 @@
build_image_tag: "change_{{ zuul.change | default('none') }}"
is_upgrade: "{{ 'upgrade' in scenario }}"
is_ceph: "{{ 'ceph' in scenario }}"
api_interface_address: "{{ api_interface_address }}"
# FIXME: in multi node env, api_interface may be different on each node.
api_interface_name: >-
{{ (ansible_interfaces |
map('replace', '-', '_') |
map('extract', ansible_facts) |
selectattr('ipv4.address', 'defined') |
selectattr('ipv4.address', 'equalto', api_interface_address) |
first).device }}
# We use HAProxy and a VIP for single node, not for multinode jobs.
kolla_internal_vip_address: "{{ api_interface_address if hostvars | length > 2 else '169.254.169.10' }}"
- name: Prepare disks for Ceph or LVM
script: "setup_disks.sh {{ disk_type }}"
@ -22,19 +36,6 @@
- hosts: primary
tasks:
# FIXME: in multi node env, api_interface may be different on each node.
- name: detect api_interface_name variable
vars:
ansible_interface_name: "ansible_{{ item.replace('-', '_') }}"
api_interface_address: "{{ hostvars[inventory_hostname]['nodepool']['private_ipv4'] }}"
set_fact:
api_interface_name: "{{ item }}"
api_interface_address: "{{ api_interface_address }}"
when:
- hostvars[inventory_hostname][ansible_interface_name]['ipv4'] is defined
- hostvars[inventory_hostname][ansible_interface_name]['ipv4']['address'] == api_interface_address
with_items: "{{ ansible_interfaces }}"
- name: detect whether need build images
set_fact:
need_build_image: true
@ -206,6 +207,7 @@
chdir: "{{ kolla_ansible_src_dir }}"
environment:
ACTION: "{{ scenario }}"
DASHBOARD_URL: "http://{{ kolla_internal_vip_address }}"
when: scenario not in ['ironic', 'scenario_nfv']
- name: Run test-zun.sh script
@ -345,6 +347,7 @@
chdir: "{{ kolla_ansible_src_dir }}"
environment:
ACTION: "{{ scenario }}"
DASHBOARD_URL: "http://{{ kolla_internal_vip_address }}"
- name: Run test-zun.sh script
shell:

View File

@ -9,7 +9,7 @@ docker_restart_policy: "no"
keepalived_virtual_router_id: "{{ 250 | random(1) }}"
{% if enable_core_openstack | bool %}
kolla_internal_vip_address: "{{ api_interface_address if hostvars | length > 2 else '169.254.169.10' }}"
kolla_internal_vip_address: "{{ kolla_internal_vip_address }}"
enable_haproxy: "{{ 'no' if hostvars | length > 2 else 'yes' }}"
neutron_external_interface: "fake_interface"
openstack_logging_debug: "True"

View File

@ -2,17 +2,17 @@
set -o xtrace
set -o errexit
set -o pipefail
# Enable unbuffered output for Ansible in Jenkins.
export PYTHONUNBUFFERED=1
function test_openstack_logged {
. /etc/kolla/admin-openrc.sh
. ~/openstackclient-venv/bin/activate
function test_smoke {
openstack --debug compute service list
openstack --debug network agent list
}
function test_instance_boot {
echo "TESTING: Server creation"
openstack server create --wait --image cirros --flavor m1.tiny --key-name mykey --network demo-net kolla_boot_test
openstack --debug server list
@ -71,6 +71,45 @@ function test_openstack_logged {
echo "SUCCESS: Server deletion"
}
function check_dashboard {
# Query the dashboard, and check that the returned page looks like a login
# page.
output_path=$1
if ! curl --include --location --fail $DASHBOARD_URL > $output_path; then
return 1
fi
if ! grep Login $output_path >/dev/null; then
return 1
fi
}
function test_dashboard {
echo "TESTING: Dashboard"
# The dashboard has been known to take some time to become accessible, so
# use retries.
output_path=$(mktemp)
attempt=1
while ! check_dashboard $output_path; do
echo "Dashboard not accessible yet"
attempt=$((attempt+1))
if [[ $attempt -eq 10 ]]; then
echo "FAILED: Dashboard did not become accessible. Response:"
cat $output_path
return 1
fi
sleep 10
done
echo "SUCCESS: Dashboard"
}
function test_openstack_logged {
. /etc/kolla/admin-openrc.sh
. ~/openstackclient-venv/bin/activate
test_smoke
test_instance_boot
test_dashboard
}
function test_openstack {
echo "Testing OpenStack"
log_file=/tmp/logs/ansible/test-openstack