Skip to content

Commit bbaa00e

Browse files
committed
Allow setting order and hooks for test role
NOTE: this patch will require setting order for all jobs running not only tempest - 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 bbaa00e

File tree

14 files changed

+98
-61
lines changed

14 files changed

+98
-61
lines changed

docs/source/usage/01_usage.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ are shared among multiple roles:
5252
- `cifmw_run_tests`: (Bool) Specifies whether tests should be executed.
5353
Defaults to false.
5454
- `cifmw_run_test_role`: (String) Specifies which ci-framework role will be used to run tests. Allowed options are `test_operator`, `tempest` and `shiftstack`. Defaults to `tempest`.
55-
- `cifmw_run_tempest`: (Bool) Specifies whether tempest tests should be run. Notice tempest tests can be executed with either `test_operator` or `tempest` roles. Defaults to true.
56-
- `cifmw_run_tobiko`: (Bool) Specifies whether tobiko tests should be run. Notice tobiko tests can only be executed with the `test_operator` role. Defaults to false.
5755
- `cifmw_edpm_deploy_nfs`: (Bool) Specifies whether an nfs server should be deployed.
5856
- `cifmw_nfs_target`: (String) The Ansible inventory group where the nfs server is deployed. Defaults to `computes`. Only has an effect if `cifmw_edpm_deploy_nfs` is set to `true`.
5957
- `cifmw_nfs_network`: (String) The network the deployed nfs server will be accessible from. Defaults to `storage`. Only has an effect if `cifmw_edpm_deploy_nfs` is set to `true`.

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/shiftstack/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ Role for triggering Openshift on Openstack QA automation (installation and tests
2222
The role is imported in the test playbook, i.e. when:
2323
```
2424
cifmw_run_tests: true
25-
cifmw_run_tempest: false
25+
cifmw_test_operator_stages: []
2626
cifmw_run_test_role: shiftstack
2727
cifmw_run_test_shiftstack_testconfig: 4.15_ovnkubernetes_ipi_va1.yaml
2828
cifmw_shiftstack_qa_gerrithub_change: refs/changes/29/1188429/50 #optional
2929
30-
$ ansible-playbook deploy-edpm.yml --extra-vars "cifmw_run_tests=true cifmw_run_tempest=false cifmw_run_test_role=shiftstack cifmw_openshift_kubeconfig={{ ansible_user_dir }}/.kube/config cifmw_run_test_shiftstack_testconfig=4.15_ovnkubernetes_ipi_va1.yaml cifmw_shiftstack_qa_gerrithub_change=refs/changes/29/1188429/50"
30+
$ ansible-playbook deploy-edpm.yml --extra-vars "cifmw_run_tests=true cifmw_run_test_role=shiftstack cifmw_test_operator_stages=[] cifmw_openshift_kubeconfig={{ ansible_user_dir }}/.kube/config cifmw_run_test_shiftstack_testconfig=4.15_ovnkubernetes_ipi_va1.yaml cifmw_shiftstack_qa_gerrithub_change=refs/changes/29/1188429/50"
3131
```

roles/test_operator/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/test-operator/).
44

55
## Parameters
6-
76
* `cifmw_test_operator_artifacts_basedir`: (String) Directory where we will have all test-operator related files. Default value: `{{ cifmw_basedir }}/tests/test_operator` which defaults to `~/ci-framework-data/tests/test_operator`
87
* `cifmw_test_operator_namespace`: (String) Namespace inside which all the resources are created. Default value: `openstack`
98
* `cifmw_test_operator_index`: (String) Full name of container image with index that contains the test-operator. Default value: `quay.io/openstack-k8s-operators/test-operator-index:latest`
@@ -23,6 +22,18 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
2322
* `cifmw_test_operator_storage_class`: (String) Value for `storageClass` in generated Tempest or Tobiko CRD file. Defaults to `"lvms-local-storage"` only if `cifmw_use_lvms` is True, otherwise it defaults to `"local-storage"`.
2423
* `cifmw_test_operator_delete_logs_pod`: (Boolean) Delete tempest log pod created by the role at the end of the testing. Default value: `false`.
2524
* `cifmw_test_operator_privileged`: (Boolean) Spawn the test pods with `allowPrivilegedEscalation: true` and default linux capabilities. This is required for certain test-operator functionalities to work properly (e.g.: `extraRPMs`, certain set of tobiko tests). Default value: `true`
25+
* `cifmw_test_operator_stages`: (List) List of dictionaries defining the stages that should be used in the test operator role. List items options are:
26+
* `name`: (String) The name of the stage. The name must be unique.
27+
* `type`: (String) The framework name you would like to call, currently the options are: tempest, ansibletest, horizontest, tobiko.
28+
* `test_file`: (String) Path to the file used for testing, this file should contain the testing params for this stage. Default value: `{{ ansible_user_dir }}/ci-framework-data/artifacts/ansible-vars.yml`
29+
* `pre_stage_hooks`: (List) List of pre hooks to run as described [hooks README](https://github.com/openstack-k8s-operators/ci-framework/tree/main/roles/run_hook#hooks-expected-format).
30+
* `pre_stage_hooks`: (List) List of post hooks to run as described [hooks README](https://github.com/openstack-k8s-operators/ci-framework/tree/main/roles/run_hook#hooks-expected-format).
31+
Default value:
32+
```
33+
cifmw_test_operator_stages:
34+
- name: tempest
35+
type: tempest
36+
```
2637

2738
## Tempest specific parameters
2839
* `cifmw_test_operator_tempest_registry`: (String) The registry where to pull tempest container. Default value: `quay.io`

roles/test_operator/defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
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
2225
cifmw_test_operator_fail_on_test_failure: true
2326
cifmw_test_operator_artifacts_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/tests/test_operator"
2427
cifmw_test_operator_namespace: openstack

roles/test_operator/tasks/main.yml

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@
2323
owner: "{{ ansible_user | default(lookup('env', 'USER')) }}"
2424
group: "{{ ansible_user | default(lookup('env', 'USER')) }}"
2525

26-
- name: Set run_tempest and run_tobiko bool values
27-
ansible.builtin.set_fact:
28-
run_tempest: "{{ cifmw_run_tempest | default('true') | bool }}"
29-
run_tobiko: "{{ cifmw_run_tobiko | default('false') | bool }}"
30-
run_ansibletest: "{{ cifmw_run_ansibletest | default('false') | bool }}"
31-
run_horizontest: "{{ cifmw_run_horizontest | default('false') | bool }}"
32-
3326
- name: Ensure OperatorGroup for the test-operator is present
3427
kubernetes.core.k8s:
3528
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
@@ -132,52 +125,12 @@
132125
until: csv.resources[0].status.phase | default(omit) == "Succeeded"
133126
when: not cifmw_test_operator_dry_run | bool
134127

135-
- name: Run tempest job
128+
- name: Call test stages loop
136129
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
130+
_stage_vars: "{{ item }}"
131+
ansible.builtin.include_tasks: stages.yml
132+
when: not cifmw_test_operator_dry_run | bool
133+
loop: "{{ cifmw_test_operator_stages }}"
181134

182135
- name: Delete all resources created by the role
183136
ansible.builtin.include_tasks: cleanup.yml
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: Run ansibletest job
3+
vars:
4+
run_test_fw: ansibletest
5+
test_operator_config: "{{ _stage_var_file.cifmw_test_operator_ansibletest_config | default(cifmw_test_operator_ansibletest_config) }}"
6+
test_operator_job_name: "{{ _stage_var_file.cifmw_test_operator_ansibletest_name | default(cifmw_test_operator_ansibletest_name) }}-{{ _stage_vars.name }}"
7+
test_operator_kind_name: "{{ _stage_var_file.cifmw_test_operator_ansibletest_kind_name | default(cifmw_test_operator_ansibletest_kind_name) }}"
8+
test_operator_crd_name: "{{ _stage_var_file.cifmw_test_operator_ansibletest_crd_name | default(cifmw_test_operator_ansibletest_crd_name) }}"
9+
test_operator_workflow: "{{ _stage_var_file.cifmw_test_operator_ansibletest_workflow | default(cifmw_test_operator_ansibletest_workflow) }}"
10+
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+
---
2+
- name: Run horizontest job
3+
vars:
4+
run_test_fw: horizontest
5+
test_operator_config: "{{ _stage_var_file.cifmw_test_operator_horizontest_config | default(cifmw_test_operator_horizontest_config) }}"
6+
test_operator_job_name: "{{ _stage_var_file.cifmw_test_operator_horizontest_name | default(cifmw_test_operator_horizontest_name) }}"
7+
test_operator_kind_name: "{{ _stage_var_file.cifmw_test_operator_horizontest_kind_name | default(cifmw_test_operator_horizontest_kind_name) }}"
8+
test_operator_crd_name: "{{ _stage_var_file.cifmw_test_operator_horizontest_crd_name | default(cifmw_test_operator_horizontest_crd_name) }}"
9+
test_operator_workflow: []
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+
---
2+
- name: Run tempest job
3+
vars:
4+
run_test_fw: tempest
5+
test_operator_config: "{{ _stage_var_file.cifmw_test_operator_tempest_config | default(cifmw_test_operator_tempest_config) }}"
6+
test_operator_job_name: "{{ _stage_var_file.cifmw_test_operator_tempest_name | default(cifmw_test_operator_tempest_name) }}-{{ _stage_vars.name }}"
7+
test_operator_kind_name: "{{ _stage_var_file.cifmw_test_operator_tempest_kind_name | default(cifmw_test_operator_tempest_kind_name) }}"
8+
test_operator_crd_name: "{{ _stage_var_file.cifmw_test_operator_tempest_crd_name | default(cifmw_test_operator_tempest_crd_name) }}"
9+
test_operator_workflow: "{{ _stage_var_file.cifmw_test_operator_tempest_workflow | default(cifmw_test_operator_tempest_workflow) }}"
10+
test_operator_config_playbook: tempest-tests.yml
11+
ansible.builtin.include_tasks: run-test-operator-job.yml
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
# Since Tobiko may include disruptive tests (faults), it is better to execute it at the end
3+
- name: Run tobiko job
4+
vars:
5+
run_test_fw: tobiko
6+
test_operator_config: "{{ _stage_var_file.cifmw_test_operator_tobiko_config | default(cifmw_test_operator_tobiko_config) }}"
7+
test_operator_job_name: "{{ _stage_var_file.cifmw_test_operator_tobiko_name | default(cifmw_test_operator_tobiko_name) }}-{{ _stage_vars.name }}"
8+
test_operator_kind_name: "{{ _stage_var_file.cifmw_test_operator_tobiko_kind_name | default(cifmw_test_operator_tobiko_kind_name) }}"
9+
test_operator_crd_name: "{{ _stage_var_file.cifmw_test_operator_tobiko_crd_name | default(cifmw_test_operator_tobiko_crd_name) }}"
10+
test_operator_workflow: "{{ _stage_var_file.cifmw_test_operator_tobiko_workflow | default(cifmw_test_operator_tobiko_workflow) }}"
11+
test_operator_config_playbook: tobiko-tests.yml
12+
ansible.builtin.include_tasks: run-test-operator-job.yml

0 commit comments

Comments
 (0)