From ff5cbf0538ad29eea63c8d27fcd0fd895ccebbba Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Wed, 8 Oct 2025 17:12:35 +0200 Subject: CI: Rework test-dashboard.sh to Ansible role Change-Id: Iaeb6786625c8c0c71c7b4e0ab9450c67bc13ed1c Signed-off-by: Michal Nasiadka --- roles/kolla-ansible-test-dashboard/tasks/main.yml | 21 +++++++ tests/run.yml | 22 ++------ tests/test-dashboard.sh | 68 ----------------------- 3 files changed, 25 insertions(+), 86 deletions(-) create mode 100644 roles/kolla-ansible-test-dashboard/tasks/main.yml delete mode 100755 tests/test-dashboard.sh 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 -- cgit v1.2.3