Skip to content

Commit fda3ca9

Browse files
committed
Enhance test_operator role for flexible test workflows
This commit adds key improvements to the test_operator role: Support for defining test execution order. Ability to run the same testing controller multiple times. Pre-hooks and post-hooks for stage-specific customization. Per-stage variable overrides via files or test_vars. Refactored pre-set testing stages to enable more dynamic test management and extend hook behavior for complex scenarios. Jira: OSPRH-10106
1 parent 93de89d commit fda3ca9

File tree

17 files changed

+245
-151
lines changed

17 files changed

+245
-151
lines changed

docs/source/usage/01_usage.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ are shared among multiple roles:
5454
- `cifmw_run_tests`: (Bool) Specifies whether tests should be executed.
5555
Defaults to false.
5656
- `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`.
57-
- `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.
58-
- `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.
5957
- `cifmw_edpm_deploy_nfs`: (Bool) Specifies whether an nfs server should be deployed.
6058
- `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`.
6159
- `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/shiftstack/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ Role for triggering Openshift on Openstack QA automation (installation and tests
2525
The role is imported in the test playbook, i.e. when:
2626
```
2727
cifmw_run_tests: true
28-
cifmw_run_tempest: false
28+
cifmw_test_operator_stages: []
2929
cifmw_run_test_role: shiftstack
3030
cifmw_run_test_shiftstack_testconfig:
3131
- 4.17_ovnkubernetes_ipi.yaml
3232
- 4.17_ovnkubernetes_upi.yaml
3333
cifmw_shiftstack_qa_gerrithub_change: refs/changes/29/1188429/50 #optional
3434
35-
$ ansible-playbook deploy-edpm.yml -e 'cifmw_run_tests=true cifmw_run_tempest=false cifmw_run_test_role=shiftstack cifmw_openshift_kubeconfig={{ ansible_user_dir }}/.kube/config cifmw_shiftstack_qa_gerrithub_change=refs/changes/29/1188429/50' -e 'cifmw_run_test_shiftstack_testconfig=["4.17_ovnkubernetes_ipi.yaml","4.17_ovnkubernetes_upi.yaml"]'
35+
$ 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"
3636
```

roles/test_operator/README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
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`
109
* `cifmw_test_operator_timeout`: (Integer) Timeout in seconds for the execution of the tests. Default value: `3600`
1110
* `cifmw_test_operator_logs_image`: (String) Image that should be used to collect logs from the pods spawned by the test-operator. Default value: `quay.io/quay/busybox`
12-
* `cifmw_test_operator_concurrency`: (Integer) Tempest concurrency value. Default value: `8`
11+
* `cifmw_test_operator_concurrency`: (Integer) Tempest concurrency value. As of now this value can not be specified inside `test_vars`. Default value: `8`
1312
* `cifmw_test_operator_cleanup`: (Bool) Delete all resources created by the role at the end of the testing. Default value: `false`
1413
* `cifmw_test_operator_tempest_cleanup`: (Bool) Run tempest cleanup after test execution (tempest run) to delete any resources created by tempest that may have been left out.
1514
* `cifmw_test_operator_default_groups`: (List) List of groups in the include list to search for tests to be executed. Default value: `[ 'default' ]`
@@ -25,6 +24,20 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
2524
* `cifmw_test_operator_delete_logs_pod`: (Boolean) Delete tempest log pod created by the role at the end of the testing. Default value: `false`.
2625
* `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`
2726
* `cifmw_test_operator_selinux_level`: (String) Specify SELinux level that should be used for pods spawned with the test-operator. Note, that `cifmw_test_operator_privileged: true` must be set when this parameter has non-empty value. Default value: `s0:c478,c978`
27+
* `cifmw_test_operator_stages`: (List) List of dictionaries defining the stages that should be used in the test operator role. List items options are:
28+
* `name`: (String) The name of the stage. The name must be unique.
29+
* `type`: (String) The framework name you would like to call, currently the options are: tempest, ansibletest, horizontest, tobiko.
30+
* `test_vars_file`: (String) Path to the file used for testing, this file should contain the testing params for this stage. Only parameters specific for the controller can be used (Tempest, Ansibletest, Horizontest and Tobiko).
31+
* `test_vars`: (String) Testing parameters for this specific stage if a `test_vars` is used the specified parameters would override the ones in the `test_vars_file`. Only parameters specific for the controller can be used (Tempest, Ansibletest, Horizontest and Tobiko).
32+
> Important note! Only variables with the following structure can be used to override inside a stage: `cifmw_test_operator_[test-operator CR name]_[parameter name]` the only exception to that is `cifmw_test_operator_concurrency` which can not be override inside a stage.
33+
* `pre_test_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).
34+
* `post_test_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).
35+
Default value:
36+
```
37+
cifmw_test_operator_stages:
38+
- name: tempest
39+
type: tempest
40+
```
2841

2942
## Tempest specific parameters
3043
* `cifmw_test_operator_tempest_name`: (String) Value used in the `Tempest.Metadata.Name` field. The value specifies the name of some resources spawned by the test-operator role. Default value: `tempest-tests`
@@ -47,8 +60,16 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
4760
* `cifmw_test_operator_tempest_network_attachments`: (List) List of network attachment definitions to attach to the tempest pods spawned by test-operator. Default value: `[]`.
4861
* `cifmw_test_operator_tempest_extra_rpms`: (List) . A list of URLs that point to RPMs that should be installed before the execution of tempest. Note that this parameter has no effect when `cifmw_test_operator_tempest_external_plugin` is used. Default value: `[]`
4962
* `cifmw_test_operator_tempest_extra_configmaps_mounts`: (List) A list of configmaps that should be mounted into the tempest test pods. Default value: `[]`
50-
* `cifmw_test_operator_tempest_config`: (Object) Definition of Tempest CRD instance that is passed to the test-operator (see [the test-operator documentation](https://openstack-k8s-operators.github.io/test-operator/crds.html#tempest-custom-resource)). Default value:
5163
* `cifmw_test_operator_tempest_debug`: (Bool) Run Tempest in debug mode, it keeps the operator pod sleeping infinity (it must only set to `true`only for debugging purposes). Default value: `false`
64+
* `cifmw_tempest_tempestconf_config`: Deprecated, please use `cifmw_test_operator_tempest_tempestconf_config` instead
65+
* `cifmw_test_operator_tempest_tempestconf_config`: (Dict) This parameter can be used to customize the execution of the `discover-tempest-config` run. Please consult the test-operator documentation. For example, to pass a custom configuration for `tempest.conf`, use the `overrides` section:
66+
```
67+
cifmw_test_operator_tempest_tempestconf_config:
68+
overrides: |
69+
identity.v3_endpoint_type public
70+
Default value: {}
71+
```
72+
* `cifmw_test_operator_tempest_config`: (Object) Definition of Tempest CRD instance that is passed to the test-operator (see [the test-operator documentation](https://openstack-k8s-operators.github.io/test-operator/crds.html#tempest-custom-resource)). Default value:
5273
```
5374
apiVersion: test.openstack.org/v1beta1
5475
kind: Tempest
@@ -70,7 +91,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
7091
externalPlugin: "{{ cifmw_test_operator_tempest_external_plugin | default([]) }}"
7192
extraRPMs: "{{ cifmw_test_operator_tempest_extra_rpms | default([]) }}"
7293
extraImages: "{{ cifmw_test_operator_tempest_extra_images | default([]) }}"
73-
tempestconfRun: "{{ cifmw_tempest_tempestconf_config | default(omit) }}"
94+
tempestconfRun: "{{ cifmw_test_operator_tempest_tempestconf_config | default(omit) }}"
7495
debug: "{{ cifmw_test_operator_tempest_debug }}"
7596
```
7697

@@ -219,3 +240,23 @@ other than the default one (e.g., `tempest-tests`, `tobiko-tests`, ...):
219240
```
220241
cifmw_test_operator_tempest_name: "post-update-tempest-tests"
221242
```
243+
244+
### Use test operator stages
245+
Test operator stages are meant to allow setting the order of stages,running stages
246+
of the same controller multiple times and using different hooks,vars and names for stages.
247+
```
248+
cifmw_test_operator_stages:
249+
- name: basic-functionallity
250+
type: tempest
251+
test_vars:
252+
cifmw_test_operator_tempest_name: 'basic-functionality-tests'
253+
- name: ansibletest
254+
type: ansibletest
255+
- name: advanced-tests
256+
type: tempest
257+
test_vars:
258+
cifmw_test_operator_tempest_name: 'advanced-tests'
259+
- name: tobiko
260+
type: tobiko
261+
test_vars_file: /path/to/tobiko/override/test/file
262+
```

0 commit comments

Comments
 (0)