|
1 | 1 | ---
|
2 | 2 | - name: Run StackHPC Cloud tests
|
3 |
| - hosts: tempest_runner |
| 3 | + hosts: tempest_runner:overcloud |
4 | 4 | tags:
|
5 | 5 | - stackhpc-cloud-tests
|
6 | 6 | vars:
|
7 | 7 | sct_venv: "{{ virtualenv_path }}/sct-venv"
|
8 | 8 | sct_repo: https://github.com/stackhpc/stackhpc-cloud-tests
|
| 9 | + # Define the version of SCT used for testing, the github workflow overrides this with |
| 10 | + # stackhpc_cloud_tests_version so this is only used if running "locally". |
9 | 11 | sct_version: main
|
10 | 12 | sct_timeout: 30
|
11 | 13 | results_path_local: "{{ lookup('env', 'HOME') }}/sct-results"
|
12 | 14 | tasks:
|
13 | 15 | - name: Stackhpc Cloud tests
|
14 | 16 | block:
|
| 17 | + - name: Assert that there is only one host in the tempest_runner group |
| 18 | + ansible.builtin.assert: |
| 19 | + that: groups.get('tempest_runner', []) | length == 1 |
| 20 | + fail_msg: The tempest_runner group should contain exactly one host |
| 21 | + |
15 | 22 | - name: Create a temporary directory for tests repo
|
16 | 23 | ansible.builtin.tempfile:
|
17 | 24 | state: directory
|
|
45 | 52 | - name: Ensure required individual Python packages are installed
|
46 | 53 | ansible.builtin.pip:
|
47 | 54 | name:
|
48 |
| - - "{{ repo_tmpdir.path }}" |
49 | 55 | - pytest-html
|
50 | 56 | - pytest-timeout
|
51 | 57 | virtualenv: "{{ sct_venv }}"
|
|
60 | 66 | file: "{{ kayobe_env_config_path }}/kolla/passwords.yml"
|
61 | 67 | name: kolla_passwords
|
62 | 68 |
|
63 |
| - - name: Run StackHPC Cloud tests |
| 69 | + # Monitoring tests should run once, executed on the host in the |
| 70 | + # tempest_runner group. |
| 71 | + - name: Check for StackHPC Cloud monitoring tests |
| 72 | + ansible.builtin.stat: |
| 73 | + path: "{{ repo_tmpdir.path }}/stackhpc_cloud_tests/monitoring" |
| 74 | + register: stackhpc_cloud_monitoring_tests |
| 75 | + |
| 76 | + - name: Run StackHPC Cloud monitoring tests |
64 | 77 | ansible.builtin.command:
|
65 | 78 | cmd: >
|
66 | 79 | {{ sct_venv }}/bin/py.test
|
67 |
| - --html={{ results_tmpdir.path }}/stackhpc-cloud-tests.html |
| 80 | + --html={{ results_tmpdir.path }}/monitoring.html |
68 | 81 | --self-contained-html
|
69 |
| - --pyargs stackhpc_cloud_tests |
70 | 82 | --timeout {{ sct_timeout }}
|
71 | 83 | -rfEx
|
72 | 84 | -vv
|
| 85 | + "{{ repo_tmpdir.path }}/stackhpc_cloud_tests/monitoring" |
73 | 86 | environment:
|
| 87 | + GRAFANA_URL: "{{ sct_grafana_url }}" |
| 88 | + GRAFANA_USERNAME: "{{ sct_grafana_username }}" |
| 89 | + GRAFANA_PASSWORD: "{{ sct_grafana_password }}" |
74 | 90 | OPENSEARCH_HOSTS: "{{ sct_opensearch_hosts }}"
|
75 | 91 | OPENSEARCH_PORT: "{{ sct_opensearch_port }}"
|
76 | 92 | OPENSEARCH_TLS: "{{ sct_opensearch_tls }}"
|
| 93 | + OPENSEARCH_DASHBOARDS_URL: "{{ sct_opensearch_dashboards_url }}" |
| 94 | + OPENSEARCH_DASHBOARDS_USERNAME: "{{ sct_opensearch_dashboards_username }}" |
| 95 | + OPENSEARCH_DASHBOARDS_PASSWORD: "{{ sct_opensearch_dashboards_password }}" |
77 | 96 | PROMETHEUS_URL: "{{ sct_prometheus_url }}"
|
78 | 97 | PROMETHEUS_USERNAME: "{{ sct_prometheus_username }}"
|
79 | 98 | PROMETHEUS_PASSWORD: "{{ sct_prometheus_password }}"
|
80 | 99 | vars:
|
81 | 100 | kolla_external_scheme: "{{ 'https' if kolla_enable_tls_external | bool else 'http' }}"
|
82 | 101 | kolla_internal_scheme: "{{ 'https' if kolla_enable_tls_internal | bool else 'http' }}"
|
| 102 | + sct_grafana_url: "{{ kolla_external_scheme }}://{{ kolla_external_fqdn }}:3000" |
| 103 | + sct_grafana_username: "grafana_local_admin" |
| 104 | + sct_grafana_password: "{{ kolla_passwords.grafana_admin_password }}" |
83 | 105 | sct_opensearch_hosts: "{{ kolla_internal_fqdn }}"
|
84 | 106 | sct_opensearch_port: 9200
|
85 |
| - sct_opensearch_tls: false |
| 107 | + sct_opensearch_tls: "{{ kolla_enable_tls_internal | bool }}" |
| 108 | + sct_opensearch_dashboards_url: "{{ kolla_external_scheme }}://{{ kolla_external_fqdn }}:5601" |
| 109 | + sct_opensearch_dashboards_username: "opensearch" |
| 110 | + sct_opensearch_dashboards_password: "{{ kolla_passwords.opensearch_dashboards_password }}" |
86 | 111 | sct_prometheus_url: "{{ kolla_internal_scheme }}://{{ kolla_internal_fqdn }}:9091"
|
87 | 112 | sct_prometheus_username: admin
|
88 | 113 | sct_prometheus_password: "{{ kolla_passwords.prometheus_password }}"
|
| 114 | + failed_when: monitoring_results.rc not in [0, 1] |
| 115 | + register: monitoring_results |
| 116 | + when: "'tempest_runner' in group_names and stackhpc_cloud_monitoring_tests.stat.exists" |
| 117 | + |
| 118 | + # Host tests should run on every host in the overcloud group. |
| 119 | + # TODO: Use TestInfra's native Ansible or SSH connection plugins for |
| 120 | + # remote test execution? That would place all results in a single file |
| 121 | + # and allow us to execute all tests from a single host. |
| 122 | + # https://testinfra.readthedocs.io/en/latest/backends.html#connection-backends |
| 123 | + - name: Check for StackHPC Cloud host tests |
| 124 | + ansible.builtin.stat: |
| 125 | + path: "{{ repo_tmpdir.path }}/stackhpc_cloud_tests/host" |
| 126 | + register: stackhpc_cloud_host_tests |
| 127 | + |
| 128 | + - name: Run StackHPC Cloud host tests |
| 129 | + ansible.builtin.command: |
| 130 | + cmd: > |
| 131 | + {{ sct_venv }}/bin/py.test |
| 132 | + --html={{ results_tmpdir.path }}/host-{{ inventory_hostname }}.html |
| 133 | + --self-contained-html |
| 134 | + --timeout {{ sct_timeout }} |
| 135 | + -vv |
| 136 | + "{{ repo_tmpdir.path }}/stackhpc_cloud_tests/host" |
| 137 | + environment: |
| 138 | + DOCKER_VERSION_MIN: "{{ sct_docker_version_min }}" |
| 139 | + DOCKER_VERSION_MAX: "{{ sct_docker_version_max }}" |
| 140 | + SELINUX_STATE: "{{ sct_selinux_state }}" |
| 141 | + vars: |
| 142 | + # Inclusive min |
| 143 | + sct_docker_version_min: "24.0.0" |
| 144 | + # Exclusive max |
| 145 | + sct_docker_version_max: "28.0.0" |
| 146 | + sct_selinux_state: "{{ selinux_state }}" |
| 147 | + failed_when: host_results.rc not in [0, 1] |
| 148 | + register: host_results |
| 149 | + # Some host checks may need to run as root |
| 150 | + become: true |
| 151 | + when: "'overcloud' in group_names and stackhpc_cloud_host_tests.stat.exists" |
| 152 | + |
| 153 | + # Host test results will be owned by root - we need to read and delete them |
| 154 | + - name: Change permissions on SCT host test results |
| 155 | + ansible.builtin.command: |
| 156 | + cmd: chmod 666 {{ results_tmpdir.path }}/host-{{ inventory_hostname }}.html |
| 157 | + become: true |
| 158 | + when: "'overcloud' in group_names and stackhpc_cloud_host_tests.stat.exists" |
| 159 | + |
89 | 160 | always:
|
90 |
| - - name: Fetch results |
91 |
| - ansible.builtin.fetch: |
92 |
| - src: "{{ results_tmpdir.path }}/stackhpc-cloud-tests.html" |
| 161 | + - name: Synchronize results |
| 162 | + ansible.posix.synchronize: |
| 163 | + src: "{{ results_tmpdir.path }}/" |
93 | 164 | dest: "{{ results_path_local }}/"
|
94 |
| - flat: true |
| 165 | + mode: pull |
| 166 | + archive: no |
| 167 | + recursive: true |
| 168 | + # For jump host |
| 169 | + use_ssh_args: true |
| 170 | + |
| 171 | + - name: Write a file containing failed test runs |
| 172 | + ansible.builtin.copy: |
| 173 | + content: |- |
| 174 | + {% for host in ansible_play_hosts_all %} |
| 175 | + {% if host not in ansible_play_hosts %} |
| 176 | + {{ host }}: Host failure |
| 177 | + {% endif %} |
| 178 | + {% if hostvars[host].monitoring_results.rc | default(0) != 0 %} |
| 179 | + monitoring.html |
| 180 | + {% endif %} |
| 181 | + {% if hostvars[host].host_results.rc | default(0) != 0 %} |
| 182 | + host-{{ host }}.html |
| 183 | + {% endif %} |
| 184 | + {% endfor %} |
| 185 | + dest: "{{ results_path_local }}/failed-tests" |
| 186 | + delegate_to: localhost |
| 187 | + run_once: true |
95 | 188 |
|
96 | 189 | - name: Clean up temporary directory
|
97 | 190 | ansible.builtin.file:
|
|
100 | 193 | loop:
|
101 | 194 | - "{{ repo_tmpdir.path }}"
|
102 | 195 | - "{{ results_tmpdir.path }}"
|
| 196 | + # Some files used by host tests may now be owned by root |
| 197 | + become: true |
0 commit comments