aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--roles/kolla-ansible-test-dashboard/tasks/main.yml21
-rw-r--r--tests/run.yml22
-rwxr-xr-xtests/test-dashboard.sh68
3 files changed, 25 insertions, 86 deletions
diff --git a/roles/kolla-ansible-test-dashboard/tasks/main.yml b/roles/kolla-ansible-test-dashboard/tasks/main.yml
new file mode 100644
index 000000000..561867aed
--- /dev/null
+++ b/roles/kolla-ansible-test-dashboard/tasks/main.yml
@@ -0,0 +1,21 @@
+---
+- name: Get contents of clouds.yaml
+ ansible.builtin.slurp:
+ src: /etc/kolla/clouds.yaml
+ register: clouds_yaml
+
+- name: Query dashboard and check that the returned page looks like a login page
+ vars:
+ clouds: "{{ clouds_yaml['content'] | b64decode | from_yaml }}"
+ url_scheme: "{{ clouds.clouds['kolla-admin'].auth.auth_url | urlsplit('scheme') }}"
+ url_host: "{{ kolla_external_vip_address | default(kolla_internal_vip_address) }}"
+ ansible.builtin.uri:
+ url: "{{ url_scheme + '://' + url_host }}"
+ ca_path: "{{ clouds.clouds['kolla-admin'].cacert | default(omit) }}"
+ follow_redirects: "all"
+ return_content: true
+ validate_certs: "{{ 'false' if scenario == 'lets-encrypt' else 'true' }}"
+ register: dashboard_output
+ until: dashboard_output.content.find('Login') != -1
+ retries: 30
+ delay: 10
diff --git a/tests/run.yml b/tests/run.yml
index 9178300be..46aae8cea 100644
--- a/tests/run.yml
+++ b/tests/run.yml
@@ -397,14 +397,8 @@
# NOTE(yoctozepto): this is nice as the first step after the deployment
# because it waits for the services to stabilize well enough so that
# the dashboard is able to show the login prompt
- - name: Run test-dashboard.sh script
- script:
- cmd: test-dashboard.sh
- executable: /bin/bash
- chdir: "{{ kolla_ansible_src_dir }}"
- environment:
- TLS_ENABLED: "{{ tls_enabled }}"
- LE_ENABLED: "{{ le_enabled }}"
+ - import_role:
+ name: kolla-ansible-test-dashboard
when: dashboard_enabled
- name: Run init-core-openstack.sh script
@@ -739,16 +733,8 @@
KOLLA_ANSIBLE_VENV_PATH: "{{ kolla_ansible_venv_path }}"
SCENARIO: "{{ scenario }}"
- # NOTE(yoctozepto): this is nice as the first step after the upgrade
- # because it waits for the services to stabilize well enough so that
- # the dashboard is able to show the login prompt
- - name: Run test-dashboard.sh script (post upgrade)
- shell:
- cmd: tests/test-dashboard.sh
- executable: /bin/bash
- chdir: "{{ kolla_ansible_src_dir }}"
- environment:
- TLS_ENABLED: "{{ tls_enabled }}"
+ - import_role:
+ name: kolla-ansible-test-dashboard
when: dashboard_enabled
# NOTE(yoctozepto): We need the script module here to avoid
diff --git a/tests/test-dashboard.sh b/tests/test-dashboard.sh
deleted file mode 100755
index c3cb9a72c..000000000
--- a/tests/test-dashboard.sh
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/bash
-
-set -o xtrace
-set -o errexit
-
-export PYTHONUNBUFFERED=1
-
-
-function check_dashboard {
- # Query the dashboard, and check that the returned page looks like a login
- # page.
- DASHBOARD_URL=${OS_AUTH_URL%:*}
- output_path=$1
- args=(
- --include
- --location
- --fail
- )
- if [[ "$TLS_ENABLED" = "True" ]]; then
- args+=(--cacert $OS_CACERT)
- fi
- if ! curl "${args[@]}" $DASHBOARD_URL > $output_path; then
- return 1
- fi
- if ! grep Login $output_path >/dev/null; then
- return 1
- fi
-}
-
-function test_dashboard_logged {
- . /etc/kolla/admin-openrc.sh
-
- 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 30 ]]; then
- echo "FAILED: Dashboard did not become accessible. Response:"
- cat $output_path
- return 1
- fi
- sleep 10
- done
- echo "SUCCESS: Dashboard"
-}
-
-function test_dashboard {
- echo "Testing dashboard"
- log_file=/tmp/logs/ansible/test-dashboard
- if [[ -f $log_file ]]; then
- log_file=${log_file}-upgrade
- fi
- test_dashboard_logged > $log_file 2>&1
- result=$?
- if [[ $result != 0 ]]; then
- echo "Testing dashboard failed. See ansible/test-dashboard for details"
- else
- echo "Successfully tested dashboard. See ansible/test-dashboard for details"
- fi
- return $result
-}
-
-
-test_dashboard