Skip to content

Commit c4de17d

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 c4de17d

File tree

15 files changed

+99
-69
lines changed

15 files changed

+99
-69
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`.

playbooks/08-run-tests.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
- name: "Run pre_tests hooks"
2-
vars:
3-
step: pre_tests
4-
ansible.builtin.import_playbook: ./hooks.yml
1+
# - name: "Run pre_tests hooks"
2+
# vars:
3+
# step: pre_tests
4+
# ansible.builtin.import_playbook: ./hooks.yml
55

66
- name: "Test playbook"
77
hosts: "{{ cifmw_target_host | default('localhost') }}"
@@ -19,7 +19,7 @@
1919
ansible.builtin.import_role:
2020
name: "{{ cifmw_run_test_role | default('tempest') }}"
2121

22-
- name: "Run post_tests hooks"
23-
vars:
24-
step: post_tests
25-
ansible.builtin.import_playbook: ./hooks.yml
22+
# - name: "Run post_tests hooks"
23+
# vars:
24+
# step: post_tests
25+
# ansible.builtin.import_playbook: ./hooks.yml

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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ 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
2625
cifmw_run_test_role: shiftstack
2726
cifmw_run_test_shiftstack_testconfig: 4.15_ovnkubernetes_ipi_va1.yaml
2827
cifmw_shiftstack_qa_gerrithub_change: refs/changes/29/1188429/50 #optional
2928
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"
29+
$ ansible-playbook deploy-edpm.yml --extra-vars "cifmw_run_tests=true 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"
3130
```

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.
27+
* `type`: (String) The framework name you would like to call, currently the optinos 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: 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

0 commit comments

Comments
 (0)