Skip to content

Commit

Permalink
even better override vars (this is going to be squashed)
Browse files Browse the repository at this point in the history
  • Loading branch information
eshulman2 committed Oct 15, 2024
1 parent 4519ed7 commit b6645f3
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 99 deletions.
23 changes: 21 additions & 2 deletions roles/test_operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
* `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`
* `cifmw_test_operator_timeout`: (Integer) Timeout in seconds for the execution of the tests. Default value: `3600`
* `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`
* `cifmw_test_operator_concurrency`: (Integer) Tempest concurrency value. Default value: `8`
* `cifmw_test_operator_tempest_concurrency`: (Integer) Tempest concurrency value. Default value: `8`
* `cifmw_test_operator_cleanup`: (Bool) Delete all resources created by the role at the end of the testing. Default value: `false`
* `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.
* `cifmw_test_operator_default_groups`: (List) List of groups in the include list to search for tests to be executed. Default value: `[ 'default' ]`
Expand All @@ -28,6 +28,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/
* `type`: (String) The framework name you would like to call, currently the options are: tempest, ansibletest, horizontest, tobiko.
* `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).
* `test_vars`: (String) Testing params for this specific stage if a `test_vars_file` 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).
>🔴 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]`
* `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).
* `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).
Default value:
Expand Down Expand Up @@ -76,7 +77,7 @@ cifmw_test_operator_stages:
{{ cifmw_test_operator_tempest_include_list | default('') }}
excludeList: |
{{ cifmw_test_operator_tempest_exclude_list | default('') }}
concurrency: "{{ cifmw_test_operator_concurrency }}"
concurrency: "{{ cifmw_test_operator_tempest_concurrency }}"
externalPlugin: "{{ cifmw_test_operator_tempest_external_plugin | default([]) }}"
extraRPMs: "{{ cifmw_test_operator_tempest_extra_rpms | default([]) }}"
extraImages: "{{ cifmw_test_operator_tempest_extra_images | default([]) }}"
Expand Down Expand Up @@ -227,3 +228,21 @@ other than the default one (e.g., `tempest-tests`, `tobiko-tests`, ...):
```
cifmw_test_operator_tempest_name: "post-update-tempest-tests"
```

### Use test operator stages
```
cifmw_test_operator_stages:
- name: best-tempest
type: tempest
test_vars:
cifmw_test_operator_tempest_name: 'best-tests'
- name: ansibletest
type: ansibletest
- name: not-the-best-tempest
type: tempest
test_vars:
cifmw_test_operator_tempest_name: 'not-so-best-tests'
- name: tobiko
type: tobiko
test_vars_file: /path/to/tobiko/override/test/file
```
128 changes: 64 additions & 64 deletions roles/test_operator/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cifmw_test_operator_namespace: openstack
cifmw_test_operator_index: quay.io/openstack-k8s-operators/test-operator-index:latest
cifmw_test_operator_timeout: 3600
cifmw_test_operator_logs_image: quay.io/quay/busybox
cifmw_test_operator_concurrency: 8
cifmw_test_operator_tempest_concurrency: 8
cifmw_test_operator_cleanup: false
cifmw_test_operator_dry_run: false
cifmw_test_operator_default_groups:
Expand Down Expand Up @@ -103,29 +103,29 @@ cifmw_test_operator_tempest_config:
name: "{{ test_operator_job_name }}"
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
containerImage: "{{ _test_operator_tempest_image }}:{{ _test_operator_tempest_image_tag }}"
storageClass: "{{ _test_operator_storage_class }}"
privileged: "{{ _test_operator_privileged }}"
parallel: "{{ _test_operator_tempest_parallel | default(omit) }}"
SSHKeySecretName: "{{ _test_operator_tempest_ssh_key_secret_name | default(omit) }}"
configOverwrite: "{{ _test_operator_tempest_config_overwrite | default(omit) }}"
networkAttachments: "{{ _test_operator_tempest_network_attachments }}"
containerImage: "{{ stage_vars_dict.cifmw_test_operator_tempest_image }}:{{ stage_vars_dict.cifmw_test_operator_tempest_image_tag }}"
storageClass: "{{ cifmw_test_operator_storage_class }}"
privileged: "{{ cifmw_test_operator_privileged }}"
parallel: "{{ stage_vars_dict.cifmw_test_operator_tempest_parallel | default(omit) }}"
SSHKeySecretName: "{{ stage_vars_dict.cifmw_test_operator_tempest_ssh_key_secret_name | default(omit) }}"
configOverwrite: "{{ stage_vars_dict.cifmw_test_operator_tempest_config_overwrite | default(omit) }}"
networkAttachments: "{{ stage_vars_dict.cifmw_test_operator_tempest_network_attachments }}"
tolerations: "{{ cifmw_test_operator_tolerations | default(omit) }}"
nodeSelector: "{{ cifmw_test_operator_node_selector | default(omit) }}"
extraConfigmapsMounts: "{{ _test_operator_tempest_extra_configmaps_mounts | default(omit) }}"
extraConfigmapsMounts: "{{ stage_vars_dict.cifmw_test_operator_tempest_extra_configmaps_mounts | default(omit) }}"
tempestRun:
includeList: |
{{ _test_operator_tempest_include_list | default('') }}
{{ stage_vars_dict.cifmw_test_operator_tempest_include_list | default('') }}
excludeList: |
{{ _test_operator_tempest_exclude_list | default('') }}
concurrency: "{{ cifmw_test_operator_concurrency }}"
externalPlugin: "{{ _test_operator_tempest_external_plugin | default([]) }}"
extraRPMs: "{{ _test_operator_tempest_extra_rpms | default([]) }}"
extraImages: "{{ _test_operator_tempest_extra_images | default([]) }}"
tempestconfRun: "{{ cifmw_tempest_tempestconf_config_defaults | combine(_test_operator_tempest_tempestconf_config | default({})) }}"
cleanup: "{{ _test_operator_tempest_cleanup }}"
workflow: "{{ _test_operator_tempest_workflow }}"
debug: "{{ _test_operator_tempest_debug }}"
{{ stage_vars_dict.cifmw_test_operator_tempest_exclude_list | default('') }}
concurrency: "{{ stage_vars_dict.cifmw_test_operator_tempest_concurrency }}"
externalPlugin: "{{ stage_vars_dict.cifmw_test_operator_tempest_external_plugin | default([]) }}"
extraRPMs: "{{ stage_vars_dict.cifmw_test_operator_tempest_extra_rpms | default([]) }}"
extraImages: "{{ stage_vars_dict.cifmw_test_operator_tempest_extra_images | default([]) }}"
tempestconfRun: "{{ cifmw_tempest_tempestconf_config_defaults | combine(stage_vars_dict.cifmw_test_operator_tempest_tempestconf_config | default({})) }}"
cleanup: "{{ stage_vars_dict.cifmw_test_operator_tempest_cleanup }}"
workflow: "{{ stage_vars_dict.cifmw_test_operator_tempest_workflow }}"
debug: "{{ stage_vars_dict.cifmw_test_operator_tempest_debug }}"

# Section 3: tobiko parameters - used when run_test_fw is 'tobiko'
cifmw_test_operator_tobiko_name: "tobiko-tests"
Expand All @@ -152,22 +152,22 @@ cifmw_test_operator_tobiko_config:
name: "{{ test_operator_job_name }}"
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
kubeconfigSecretName: "{{ _test_operator_tobiko_kubeconfig_secret }}"
storageClass: "{{ _test_operator_storage_class }}"
privileged: "{{ _test_operator_privileged }}"
containerImage: "{{ _test_operator_tobiko_image }}:{{ _test_operator_tobiko_image_tag }}"
testenv: "{{ _test_operator_tobiko_testenv }}"
version: "{{ _test_operator_tobiko_version }}"
pytestAddopts: "{{ _test_operator_tobiko_pytest_addopts if _test_operator_tobiko_pytest_addopts is not none else omit }}"
kubeconfigSecretName: "{{ stage_vars_dict.cifmw_test_operator_tobiko_kubeconfig_secret }}"
storageClass: "{{ cifmw_test_operator_storage_class }}"
privileged: "{{ cifmw_test_operator_privileged }}"
containerImage: "{{ stage_vars_dict.cifmw_test_operator_tobiko_image }}:{{ stage_vars_dict.cifmw_test_operator_tobiko_image_tag }}"
testenv: "{{ stage_vars_dict.cifmw_test_operator_tobiko_testenv }}"
version: "{{ stage_vars_dict.cifmw_test_operator_tobiko_version }}"
pytestAddopts: "{{ stage_vars_dict.cifmw_test_operator_tobiko_pytest_addopts if stage_vars_dict.cifmw_test_operator_tobiko_pytest_addopts is not none else omit }}"
tolerations: "{{ cifmw_test_operator_tolerations | default(omit) }}"
nodeSelector: "{{ _test_operator_node_selector | default(omit) }}"
networkAttachments: "{{ _test_operator_tobiko_network_attachments }}"
# preventCreate: preventCreate is generated by the test_operator role based on the value of _test_operator_tobiko_prevent_create
# numProcesses: numProcesses is generated by the test_operator role based on the value of _test_operator_tobiko_num_processes
nodeSelector: "{{ cifmw_test_operator_node_selector | default(omit) }}"
networkAttachments: "{{ stage_vars_dict.cifmw_test_operator_tobiko_network_attachments }}"
# preventCreate: preventCreate is generated by the test_operator role based on the value of stage_vars_dict.cifmw_test_operator_tobiko_prevent_create
# numProcesses: numProcesses is generated by the test_operator role based on the value of stage_vars_dict.cifmw_test_operator_tobiko_num_processes
# privateKey: privateKey is automatically by the test_operator role
# publicKey: publicKey is automatically generated by the test_operator role
# config: config is generated combining _test_operator_tobiko_default_conf and _test_operator_tobiko_override_conf
workflow: "{{ _test_operator_tobiko_workflow }}"
# config: config is generated combining stage_vars_dict.cifmw_test_operator_tobiko_default_conf and stage_vars_dict.cifmw_test_operator_tobiko_override_conf
workflow: "{{ stage_vars_dict.cifmw_test_operator_tobiko_workflow }}"

# Section 4: ansibletest parameters - used when run_test_fw is 'ansibletest'
cifmw_test_operator_ansibletest_name: "ansibletest"
Expand Down Expand Up @@ -196,22 +196,22 @@ cifmw_test_operator_ansibletest_config:
name: "{{ test_operator_job_name }}"
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
containerImage: "{{ _test_operator_ansibletest_image }}:{{ _test_operator_ansibletest_image_tag }}"
extraConfigmapsMounts: "{{ _test_operator_ansibletest_extra_configmaps_mounts }}"
storageClass: "{{ _test_operator_storage_class }}"
privileged: "{{ _test_operator_privileged }}"
computeSSHKeySecretName: "{{ _test_operator_ansibletest_compute_ssh_key_secret_name }}"
workloadSSHKeySecretName: "{{ _test_operator_ansibletest_workload_ssh_key_secret_name }}"
ansibleGitRepo: "{{ _test_operator_ansibletest_ansible_git_repo }}"
ansiblePlaybookPath: "{{ _test_operator_ansibletest_ansible_playbook_path }}"
ansibleCollections: "{{ _test_operator_ansibletest_ansible_collection }}"
ansibleVarFiles: "{{ _test_operator_ansibletest_ansible_var_files }}"
ansibleExtraVars: "{{ _test_operator_ansibletest_ansible_extra_vars }}"
ansibleInventory: "{{ _test_operator_ansibletest_ansible_inventory }}"
openStackConfigMap: "{{ _test_operator_ansibletest_openstack_config_map }}"
openStackConfigSecret: "{{ _test_operator_ansibletest_openstack_config_secret }}"
workflow: "{{ _test_operator_ansibletest_workflow }}"
debug: "{{ _test_operator_ansibletest_debug }}"
containerImage: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_image }}:{{ stage_vars_dict.cifmw_test_operator_ansibletest_image_tag }}"
extraConfigmapsMounts: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_extra_configmaps_mounts }}"
storageClass: "{{ cifmw_test_operator_storage_class }}"
privileged: "{{ cifmw_test_operator_privileged }}"
computeSSHKeySecretName: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_compute_ssh_key_secret_name }}"
workloadSSHKeySecretName: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_workload_ssh_key_secret_name }}"
ansibleGitRepo: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_ansible_git_repo }}"
ansiblePlaybookPath: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_ansible_playbook_path }}"
ansibleCollections: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_ansible_collection }}"
ansibleVarFiles: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_ansible_var_files }}"
ansibleExtraVars: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_ansible_extra_vars }}"
ansibleInventory: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_ansible_inventory }}"
openStackConfigMap: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_openstack_config_map }}"
openStackConfigSecret: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_openstack_config_secret }}"
workflow: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_workflow }}"
debug: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_debug }}"

# Section 5: horizontest parameters - used when run_test_fw is 'horizontest'
cifmw_test_operator_horizontest_name: "horizontest-tests"
Expand Down Expand Up @@ -240,19 +240,19 @@ cifmw_test_operator_horizontest_config:
name: "{{ test_operator_job_name }}"
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
storageClass: "{{ _test_operator_storage_class }}"
privileged: "{{ _test_operator_privileged }}"
containerImage: "{{ _test_operator_horizontest_image }}:{{ _test_operator_horizontest_image_tag }}"
adminUsername: "{{ _test_operator_horizontest_admin_username }}"
adminPassword: "{{ _test_operator_horizontest_admin_password }}"
dashboardUrl: "{{ _test_operator_horizontest_dashboard_url }}"
authUrl: "{{ _test_operator_horizontest_auth_url }}"
repoUrl: "{{ _test_operator_horizontest_repo_url }}"
horizonRepoBranch: "{{ _test_operator_horizontest_horizon_repo_branch }}"
imageUrl: "{{ _test_operator_horizontest_image_url }}"
projectName: "{{ _test_operator_horizontest_project_name }}"
user: "{{ _test_operator_horizontest_user }}"
password: "{{ _test_operator_horizontest_password }}"
flavorName: "{{ _test_operator_horizontest_flavor_name }}"
logsDirectoryName: "{{ _test_operator_horizontest_logs_directory_name }}"
horizonTestDir: "{{ _test_operator_horizontest_horizon_test_dir }}"
storageClass: "{{ cifmw_test_operator_storage_class }}"
privileged: "{{ cifmw_test_operator_privileged }}"
containerImage: "{{ stage_vars_dict.cifmw_test_operator_horizontest_image }}:{{ stage_vars_dict.cifmw_test_operator_horizontest_image_tag }}"
adminUsername: "{{ stage_vars_dict.cifmw_test_operator_horizontest_admin_username }}"
adminPassword: "{{ stage_vars_dict.cifmw_test_operator_horizontest_admin_password }}"
dashboardUrl: "{{ stage_vars_dict.cifmw_test_operator_horizontest_dashboard_url }}"
authUrl: "{{ stage_vars_dict.cifmw_test_operator_horizontest_auth_url }}"
repoUrl: "{{ stage_vars_dict.cifmw_test_operator_horizontest_repo_url }}"
horizonRepoBranch: "{{ stage_vars_dict.cifmw_test_operator_horizontest_horizon_repo_branch }}"
imageUrl: "{{ stage_vars_dict.cifmw_test_operator_horizontest_image_url }}"
projectName: "{{ stage_vars_dict.cifmw_test_operator_horizontest_project_name }}"
user: "{{ stage_vars_dict.cifmw_test_operator_horizontest_user }}"
password: "{{ stage_vars_dict.cifmw_test_operator_horizontest_password }}"
flavorName: "{{ stage_vars_dict.cifmw_test_operator_horizontest_flavor_name }}"
logsDirectoryName: "{{ stage_vars_dict.cifmw_test_operator_horizontest_logs_directory_name }}"
horizonTestDir: "{{ stage_vars_dict.cifmw_test_operator_horizontest_horizon_test_dir }}"
10 changes: 5 additions & 5 deletions roles/test_operator/tasks/runners/ansibletest_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
- name: Run ansibletest job
vars:
run_test_fw: ansibletest
test_operator_config: "{{ _stage_test_vars.cifmw_test_operator_ansibletest_config | default(cifmw_test_operator_ansibletest_config) }}"
test_operator_job_name: "{{ _test_operator_ansibletest_name }}-{{ _stage_vars.name }}"
test_operator_kind_name: "{{ _test_operator_ansibletest_kind_name }}"
test_operator_crd_name: "{{ _test_operator_ansibletest_crd_name }}"
test_operator_workflow: "{{ _test_operator_ansibletest_workflow }}"
test_operator_config: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_config }}"
test_operator_job_name: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_name }}-{{ _stage_vars.name }}"
test_operator_kind_name: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_kind_name }}"
test_operator_crd_name: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_crd_name }}"
test_operator_workflow: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_workflow }}"
ansible.builtin.include_tasks: run-test-operator-job.yml
8 changes: 4 additions & 4 deletions roles/test_operator/tasks/runners/horizontest_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
- name: Run horizontest job
vars:
run_test_fw: horizontest
test_operator_config: "{{ _stage_test_vars.cifmw_test_operator_horizontest_config | default(cifmw_test_operator_horizontest_config) }}"
test_operator_job_name: "{{ _test_operator_horizontest_name }}-{{ _stage_vars.name }}"
test_operator_kind_name: "{{ _test_operator_horizontest_kind_name }}"
test_operator_crd_name: "{{ _test_operator_horizontest_crd_name }}"
test_operator_config: "{{ stage_vars_dict.cifmw_test_operator_horizontest_config }}"
test_operator_job_name: "{{ stage_vars_dict.cifmw_test_operator_horizontest_name }}-{{ _stage_vars.name }}"
test_operator_kind_name: "{{ stage_vars_dict.cifmw_test_operator_horizontest_kind_name }}"
test_operator_crd_name: "{{ stage_vars_dict.cifmw_test_operator_horizontest_crd_name }}"
test_operator_workflow: []
ansible.builtin.include_tasks: run-test-operator-job.yml
10 changes: 5 additions & 5 deletions roles/test_operator/tasks/runners/tempest_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
- name: Run tempest job
vars:
run_test_fw: tempest
test_operator_config: "{{ _stage_test_vars.cifmw_test_operator_tempest_config | default(cifmw_test_operator_tempest_config) }}"
test_operator_job_name: "{{ _test_operator_tempest_name }}-{{ _stage_vars.name }}"
test_operator_kind_name: "{{ _test_operator_tempest_kind_name }}"
test_operator_crd_name: "{{ _test_operator_tempest_crd_name }}"
test_operator_workflow: "{{ _test_operator_tempest_workflow }}"
test_operator_config: "{{ stage_vars_dict.cifmw_test_operator_tempest_config }}"
test_operator_job_name: "{{ stage_vars_dict.cifmw_test_operator_tempest_name }}-{{ _stage_vars.name }}"
test_operator_kind_name: "{{ stage_vars_dict.cifmw_test_operator_tempest_kind_name }}"
test_operator_crd_name: "{{ stage_vars_dict.cifmw_test_operator_tempest_crd_name }}"
test_operator_workflow: "{{ stage_vars_dict.cifmw_test_operator_tempest_workflow }}"
test_operator_config_playbook: tempest-tests.yml
ansible.builtin.include_tasks: run-test-operator-job.yml
Loading

0 comments on commit b6645f3

Please sign in to comment.