Skip to content

Commit e1d1403

Browse files
committed
CI: Separate monitoring vs host test execution in SOT
There are currently two types of tests in StackHPC OpenStack Tests: service-level tests such as those for monitoring, and host-level tests such as those for Docker and SELinux. We should execute the service-level tests from a single remote host, while the host-level tests should be executed on each of the overcloud hosts. This means that we now get several results files, so it becomes important to provide a summary of failures.
1 parent 7c21b46 commit e1d1403

File tree

2 files changed

+83
-26
lines changed

2 files changed

+83
-26
lines changed

.github/workflows/stackhpc-all-in-one.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,6 @@ jobs:
383383
KAYOBE_AUTOMATION_SSH_PRIVATE_KEY: ${{ steps.ssh_key.outputs.ssh_key }}
384384

385385
- name: StackHPC OpenStack tests
386-
id: stackhpc-openstack-tests
387-
continue-on-error: true
388386
run: |
389387
mkdir -p sot-results
390388
docker run -t --rm \
@@ -420,16 +418,20 @@ jobs:
420418
sot-results/
421419
if: ${{ !cancelled() && (steps.tempest.outcome == 'success' || steps.stackhpc-openstack-tests.outcome == 'success' || steps.diagnostics.outcome == 'success') }}
422420

423-
- name: Fail if any Tempest tests failed
421+
- name: Fail if any tests failed
424422
run: |
425-
test $(wc -l < tempest-artifacts/failed-tests) -lt 1
426-
427-
- name: Fail if any StackHPC OpenStack tests failed
428-
run: |
429-
echo "Some StackHPC OpenStack tests failed."
430-
echo "See HTML results artifact (sot-results) for details."
431-
exit 1
432-
if: steps.stackhpc-openstack-tests.outcome == 'failure'
423+
rc=0
424+
if [[ $(wc -l < tempest-artifacts/failed-tests) -ne 0 ]]; then
425+
echo "Some Tempest tests failed."
426+
echo "See HTML results artifact (tempest-artifacts) for details."
427+
rc=1
428+
fi
429+
if [[ $(wc -l < sot-results/failed-tests) -ne 0 ]]; then
430+
echo "Some StackHPC OpenStack tests failed."
431+
echo "See HTML results artifact (sot-results) for details."
432+
rc=1
433+
fi
434+
exit $rc
433435
434436
- name: Destroy
435437
run: terraform destroy -auto-approve

etc/kayobe/ansible/stackhpc-openstack-tests.yml

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
2+
# This playbook executes tests from the StackHPC OpenStack Tests repository.
3+
# https://github.com/stackhpc/stackhpc-openstack-tests
4+
25
- name: Run StackHPC OpenStack tests
3-
hosts: tempest_runner
6+
hosts: tempest_runner:overcloud
47
tags:
58
- stackhpc-openstack-tests
69
vars:
@@ -10,6 +13,11 @@
1013
sot_timeout: 30
1114
results_path_local: "{{ lookup('env', 'HOME') }}/sot-results"
1215
tasks:
16+
- name: Assert that there is only one host in the tempest_runner group
17+
assert:
18+
that: groups.get('tempest_runner', []) | length == 1
19+
fail_msg: The tempest_runner group should contain exactly one host
20+
1321
- block:
1422
- name: Create a temporary directory for tests repo
1523
ansible.builtin.tempfile:
@@ -55,18 +63,18 @@
5563
file: "{{ kayobe_env_config_path }}/kolla/passwords.yml"
5664
name: kolla_passwords
5765

58-
- name: Run StackHPC OpenStack tests
66+
# Monitoring tests should run once, executed on the host in the
67+
# tempest_runner group.
68+
- name: Run StackHPC OpenStack monitoring tests
5969
ansible.builtin.command:
6070
cmd: >
6171
{{ sot_venv }}/bin/py.test
62-
--html={{ results_tmpdir.path }}/stackhpc-openstack-tests.html
72+
--html={{ results_tmpdir.path }}/monitoring.html
6373
--self-contained-html
64-
--pyargs stackhpc_openstack_tests
74+
--pyargs stackhpc_openstack_tests.monitoring
6575
--timeout {{ sot_timeout }}
6676
-vv
6777
environment:
68-
DOCKER_VERSION_MIN: "{{ sot_docker_version_min }}"
69-
DOCKER_VERSION_MAX: "{{ sot_docker_version_max }}"
7078
GRAFANA_URL: "{{ sot_grafana_url }}"
7179
GRAFANA_USERNAME: "{{ sot_grafana_username }}"
7280
GRAFANA_PASSWORD: "{{ sot_grafana_password }}"
@@ -79,14 +87,9 @@
7987
PROMETHEUS_URL: "{{ sot_prometheus_url }}"
8088
PROMETHEUS_USERNAME: "{{ sot_prometheus_username }}"
8189
PROMETHEUS_PASSWORD: "{{ sot_prometheus_password }}"
82-
SELINUX_STATE: "{{ sot_selinux_state }}"
8390
vars:
8491
kolla_external_scheme: "{{ 'https' if kolla_enable_tls_external | bool else 'http' }}"
8592
kolla_internal_scheme: "{{ 'https' if kolla_enable_tls_internal | bool else 'http' }}"
86-
# Inclusive min
87-
sot_docker_version_min: "24.0.0"
88-
# Exclusive max
89-
sot_docker_version_max: "27.0.0"
9093
sot_grafana_url: "{{ kolla_external_scheme }}://{{ kolla_external_fqdn }}:3000"
9194
sot_grafana_username: "grafana_local_admin"
9295
sot_grafana_password: "{{ kolla_passwords.grafana_admin_password }}"
@@ -99,13 +102,65 @@
99102
sot_prometheus_url: "{{ kolla_internal_scheme }}://{{ kolla_internal_fqdn }}:9091"
100103
sot_prometheus_username: "admin"
101104
sot_prometheus_password: "{{ kolla_passwords.prometheus_password }}"
105+
failed_when: monitoring_results.rc not in [0, 1]
106+
register: monitoring_results
107+
when: "'tempest_runner' in group_names"
108+
109+
# Host tests should run on every host in the overcloud group.
110+
# TODO: Use TestInfra's native Ansible or SSH connection plugins for
111+
# remote test execution? That would place all results in a single file
112+
# and allow us to execute all tests from a single host.
113+
# https://testinfra.readthedocs.io/en/latest/backends.html#connection-backends
114+
- name: Run StackHPC OpenStack host tests
115+
ansible.builtin.command:
116+
cmd: >
117+
{{ sot_venv }}/bin/py.test
118+
--html={{ results_tmpdir.path }}/host-{{ inventory_hostname }}.html
119+
--self-contained-html
120+
--pyargs stackhpc_openstack_tests.host
121+
--timeout {{ sot_timeout }}
122+
-vv
123+
environment:
124+
DOCKER_VERSION_MIN: "{{ sot_docker_version_min }}"
125+
DOCKER_VERSION_MAX: "{{ sot_docker_version_max }}"
126+
SELINUX_STATE: "{{ sot_selinux_state }}"
127+
vars:
128+
# Inclusive min
129+
sot_docker_version_min: "24.0.0"
130+
# Exclusive max
131+
sot_docker_version_max: "27.0.0"
102132
sot_selinux_state: "{{ selinux_state }}"
133+
failed_when: host_results.rc not in [0, 1]
134+
register: host_results
135+
when: "'overcloud' in group_names"
103136
always:
104-
- name: Fetch results
105-
ansible.builtin.fetch:
106-
src: "{{ results_tmpdir.path }}/stackhpc-openstack-tests.html"
137+
- name: Synchronize results
138+
ansible.posix.synchronize:
139+
src: "{{ results_tmpdir.path }}/"
107140
dest: "{{ results_path_local }}/"
108-
flat: true
141+
mode: pull
142+
archive: no
143+
recursive: true
144+
# For jump host
145+
use_ssh_args: true
146+
147+
- name: Write a file containing failed test runs
148+
ansible.builtin.copy:
149+
content: |-
150+
{% for host in ansible_play_hosts_all %}
151+
{% if host not in ansible_play_hosts %}
152+
{{ host }}: Host failure
153+
{% endif %}
154+
{% if hostvars[host].monitoring_results.rc | default(0) != 0 %}
155+
monitoring.html
156+
{% endif %}
157+
{% if hostvars[host].host_results.rc | default(0) != 0 %}
158+
host-{{ host }}.html
159+
{% endif %}
160+
{% endfor %}
161+
dest: "{{ results_path_local }}/failed-tests"
162+
delegate_to: localhost
163+
run_once: true
109164

110165
- name: Clean up temporary directory
111166
ansible.builtin.file:

0 commit comments

Comments
 (0)