Skip to content

Commit d749fd6

Browse files
committed
Allow setting order and hooks for test role
- Allow passing hook list directly to hook role - Allow setting up stages and hooks for test operator role Jira: https://issues.redhat.com/browse/OSPRH-10106
1 parent 673c941 commit d749fd6

File tree

8 files changed

+97
-46
lines changed

8 files changed

+97
-46
lines changed

roles/run_hook/tasks/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
vars:
1919
_list_hooks: >-
2020
{{
21-
hostvars[inventory_hostname][step] |
21+
hostvars[inventory_hostname][step] is defined |
22+
ternary(hostvars[inventory_hostname][step], hook_list) |
2223
default([])
2324
}}
2425
_matcher: "^{{ step }}_(.*)$"

roles/test_operator/defaults/main.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@
1919
# All variables within this role should have a prefix of "cifmw_test_operator"
2020

2121
# Section 1: generic parameters (applied to all supported test frameworks)
22+
cifmw_test_operator_stages:
23+
- name: tempest
24+
type: tempest
25+
test_file: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/artifacts/ansible-vars"
26+
# pre_stage_hooks:
27+
# post_stage_hooks:
28+
- name: ansibletest
29+
type: ansibletest
30+
test_file: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/artifacts/ansible-vars"
31+
# pre_stage_hooks:
32+
# post_stage_hooks:
33+
- name: horizontest
34+
type: horizontest
35+
test_file: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/artifacts/ansible-vars"
36+
# pre_stage_hooks:
37+
# post_stage_hooks:
38+
- name: tobiko
39+
type: tobiko
40+
test_file: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/artifacts/ansible-vars"
41+
# pre_stage_hooks:
42+
# post_stage_hooks:
43+
2244
cifmw_test_operator_fail_on_test_failure: true
2345
cifmw_test_operator_artifacts_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/tests/test_operator"
2446
cifmw_test_operator_namespace: openstack

roles/test_operator/tasks/main.yml

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -132,52 +132,12 @@
132132
until: csv.resources[0].status.phase | default(omit) == "Succeeded"
133133
when: not cifmw_test_operator_dry_run | bool
134134

135-
- name: Run tempest job
135+
- name: Call test stages loop
136136
vars:
137-
run_test_fw: tempest
138-
test_operator_config: "{{ cifmw_test_operator_tempest_config }}"
139-
test_operator_job_name: "{{ cifmw_test_operator_tempest_name }}"
140-
test_operator_kind_name: "{{ cifmw_test_operator_tempest_kind_name }}"
141-
test_operator_crd_name: "{{ cifmw_test_operator_tempest_crd_name }}"
142-
test_operator_workflow: "{{ cifmw_test_operator_tempest_workflow }}"
143-
test_operator_config_playbook: tempest-tests.yml
144-
ansible.builtin.include_tasks: run-test-operator-job.yml
145-
when: run_tempest
146-
147-
- name: Run ansibletest job
148-
vars:
149-
run_test_fw: ansibletest
150-
test_operator_config: "{{ cifmw_test_operator_ansibletest_config }}"
151-
test_operator_job_name: "{{ cifmw_test_operator_ansibletest_name }}"
152-
test_operator_kind_name: "{{ cifmw_test_operator_ansibletest_kind_name }}"
153-
test_operator_crd_name: "{{ cifmw_test_operator_ansibletest_crd_name }}"
154-
test_operator_workflow: "{{ cifmw_test_operator_ansibletest_workflow }}"
155-
ansible.builtin.include_tasks: run-test-operator-job.yml
156-
when: run_ansibletest
157-
158-
- name: Run horizontest job
159-
vars:
160-
run_test_fw: horizontest
161-
test_operator_config: "{{ cifmw_test_operator_horizontest_config }}"
162-
test_operator_job_name: "{{ cifmw_test_operator_horizontest_name }}"
163-
test_operator_kind_name: "{{ cifmw_test_operator_horizontest_kind_name }}"
164-
test_operator_crd_name: "{{ cifmw_test_operator_horizontest_crd_name }}"
165-
test_operator_workflow: []
166-
ansible.builtin.include_tasks: run-test-operator-job.yml
167-
when: run_horizontest
168-
169-
# Since Tobiko may include disruptive tests (faults), it is better to execute it at the end
170-
- name: Run tobiko job
171-
vars:
172-
run_test_fw: tobiko
173-
test_operator_config: "{{ cifmw_test_operator_tobiko_config }}"
174-
test_operator_job_name: "{{ cifmw_test_operator_tobiko_name }}"
175-
test_operator_kind_name: "{{ cifmw_test_operator_tobiko_kind_name }}"
176-
test_operator_crd_name: "{{ cifmw_test_operator_tobiko_crd_name }}"
177-
test_operator_workflow: "{{ cifmw_test_operator_tobiko_workflow }}"
178-
test_operator_config_playbook: tobiko-tests.yml
179-
ansible.builtin.include_tasks: run-test-operator-job.yml
180-
when: run_tobiko
137+
stage_vars: "{{ item }}"
138+
ansible.builtin.include_tasks: stages.yml
139+
when: not cifmw_test_operator_dry_run | bool
140+
loop: "{{ cifmw_test_operator_stages }}"
181141

182142
- name: Delete all resources created by the role
183143
ansible.builtin.include_tasks: cleanup.yml
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- name: Run ansibletest job
2+
vars:
3+
run_test_fw: ansibletest
4+
test_operator_config: "{{ cifmw_test_operator_ansibletest_config }}"
5+
test_operator_job_name: "{{ cifmw_test_operator_ansibletest_name }}"
6+
test_operator_kind_name: "{{ cifmw_test_operator_ansibletest_kind_name }}"
7+
test_operator_crd_name: "{{ cifmw_test_operator_ansibletest_crd_name }}"
8+
test_operator_workflow: "{{ cifmw_test_operator_ansibletest_workflow }}"
9+
ansible.builtin.include_tasks: run-test-operator-job.yml
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- name: Run horizontest job
2+
vars:
3+
run_test_fw: horizontest
4+
test_operator_config: "{{ cifmw_test_operator_horizontest_config }}"
5+
test_operator_job_name: "{{ cifmw_test_operator_horizontest_name }}"
6+
test_operator_kind_name: "{{ cifmw_test_operator_horizontest_kind_name }}"
7+
test_operator_crd_name: "{{ cifmw_test_operator_horizontest_crd_name }}"
8+
test_operator_workflow: []
9+
ansible.builtin.include_tasks: run-test-operator-job.yml
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- name: Run tempest job
2+
vars:
3+
run_test_fw: tempest
4+
test_operator_config: "{{ cifmw_test_operator_tempest_config }}"
5+
test_operator_job_name: "{{ cifmw_test_operator_tempest_name }}"
6+
test_operator_kind_name: "{{ cifmw_test_operator_tempest_kind_name }}"
7+
test_operator_crd_name: "{{ cifmw_test_operator_tempest_crd_name }}"
8+
test_operator_workflow: "{{ cifmw_test_operator_tempest_workflow }}"
9+
test_operator_config_playbook: tempest-tests.yml
10+
ansible.builtin.include_tasks: run-test-operator-job.yml
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Since Tobiko may include disruptive tests (faults), it is better to execute it at the end
2+
- name: Run tobiko job
3+
vars:
4+
run_test_fw: tobiko
5+
test_operator_config: "{{ cifmw_test_operator_tobiko_config }}"
6+
test_operator_job_name: "{{ cifmw_test_operator_tobiko_name }}"
7+
test_operator_kind_name: "{{ cifmw_test_operator_tobiko_kind_name }}"
8+
test_operator_crd_name: "{{ cifmw_test_operator_tobiko_crd_name }}"
9+
test_operator_workflow: "{{ cifmw_test_operator_tobiko_workflow }}"
10+
test_operator_config_playbook: tobiko-tests.yml
11+
ansible.builtin.include_tasks: run-test-operator-job.yml
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
- debug:
3+
msg: "Run stage {{ stage_vars.name }}"
4+
5+
- name: "Call pre stage hooks for test operator stage {{ stage_vars.name }}"
6+
vars:
7+
step: none
8+
hook_list: "{{ stage_vars.pre_stage_hooks }}"
9+
ansible.builtin.import_role:
10+
name: run_hook
11+
when:
12+
- not cifmw_test_operator_dry_run | bool
13+
- stage_vars.pre_stage_hooks is defined
14+
15+
- name: Include stage var file
16+
ansible.builtin.include_vars:
17+
file: "{{ stage_vars.test_file }}"
18+
19+
- name: "Call {{ stage_vars.type }} runner"
20+
ansible.builtin.include_tasks: "runners/{{ stage_vars.type }}_runner.yml"
21+
22+
- name: "Call post stage hooks for test operator stage {{ stage_vars.name }}"
23+
vars:
24+
step: stage_vars.post_stage_hooks
25+
ansible.builtin.import_role:
26+
name: run_hook
27+
when:
28+
- not cifmw_test_operator_dry_run | bool
29+
- stage_vars.post_stage_hooks is defined

0 commit comments

Comments
 (0)