Skip to content

Commit

Permalink
Allow setting order and hooks for test role
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
eshulman2 committed Sep 24, 2024
1 parent 673c941 commit 9e7ab2d
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 46 deletions.
3 changes: 2 additions & 1 deletion roles/run_hook/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
vars:
_list_hooks: >-
{{
hostvars[inventory_hostname][step] |
hostvars[inventory_hostname][step] is defined |
ternary(hostvars[inventory_hostname][step], hook_list) |
default([])
}}
_matcher: "^{{ step }}_(.*)$"
Expand Down
22 changes: 22 additions & 0 deletions roles/test_operator/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@
# All variables within this role should have a prefix of "cifmw_test_operator"

# Section 1: generic parameters (applied to all supported test frameworks)
cifmw_test_operator_stages:
- name: tempest
type: tempest
test_file: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/artifacts/ansible-vars.yml"
# pre_stage_hooks:
# post_stage_hooks:
- name: ansibletest
type: ansibletest
test_file: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/artifacts/ansible-vars.yml"
# pre_stage_hooks:
# post_stage_hooks:
- name: horizontest
type: horizontest
test_file: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/artifacts/ansible-vars.yml"
# pre_stage_hooks:
# post_stage_hooks:
- name: tobiko
type: tobiko
test_file: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/artifacts/ansible-vars.yml"
# pre_stage_hooks:
# post_stage_hooks:

cifmw_test_operator_fail_on_test_failure: true
cifmw_test_operator_artifacts_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/tests/test_operator"
cifmw_test_operator_namespace: openstack
Expand Down
50 changes: 5 additions & 45 deletions roles/test_operator/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,52 +132,12 @@
until: csv.resources[0].status.phase | default(omit) == "Succeeded"
when: not cifmw_test_operator_dry_run | bool

- name: Run tempest job
- name: Call test stages loop
vars:
run_test_fw: tempest
test_operator_config: "{{ cifmw_test_operator_tempest_config }}"
test_operator_job_name: "{{ cifmw_test_operator_tempest_name }}"
test_operator_kind_name: "{{ cifmw_test_operator_tempest_kind_name }}"
test_operator_crd_name: "{{ cifmw_test_operator_tempest_crd_name }}"
test_operator_workflow: "{{ cifmw_test_operator_tempest_workflow }}"
test_operator_config_playbook: tempest-tests.yml
ansible.builtin.include_tasks: run-test-operator-job.yml
when: run_tempest

- name: Run ansibletest job
vars:
run_test_fw: ansibletest
test_operator_config: "{{ cifmw_test_operator_ansibletest_config }}"
test_operator_job_name: "{{ cifmw_test_operator_ansibletest_name }}"
test_operator_kind_name: "{{ cifmw_test_operator_ansibletest_kind_name }}"
test_operator_crd_name: "{{ cifmw_test_operator_ansibletest_crd_name }}"
test_operator_workflow: "{{ cifmw_test_operator_ansibletest_workflow }}"
ansible.builtin.include_tasks: run-test-operator-job.yml
when: run_ansibletest

- name: Run horizontest job
vars:
run_test_fw: horizontest
test_operator_config: "{{ cifmw_test_operator_horizontest_config }}"
test_operator_job_name: "{{ cifmw_test_operator_horizontest_name }}"
test_operator_kind_name: "{{ cifmw_test_operator_horizontest_kind_name }}"
test_operator_crd_name: "{{ cifmw_test_operator_horizontest_crd_name }}"
test_operator_workflow: []
ansible.builtin.include_tasks: run-test-operator-job.yml
when: run_horizontest

# Since Tobiko may include disruptive tests (faults), it is better to execute it at the end
- name: Run tobiko job
vars:
run_test_fw: tobiko
test_operator_config: "{{ cifmw_test_operator_tobiko_config }}"
test_operator_job_name: "{{ cifmw_test_operator_tobiko_name }}"
test_operator_kind_name: "{{ cifmw_test_operator_tobiko_kind_name }}"
test_operator_crd_name: "{{ cifmw_test_operator_tobiko_crd_name }}"
test_operator_workflow: "{{ cifmw_test_operator_tobiko_workflow }}"
test_operator_config_playbook: tobiko-tests.yml
ansible.builtin.include_tasks: run-test-operator-job.yml
when: run_tobiko
stage_vars: "{{ item }}"
ansible.builtin.include_tasks: stages.yml
when: not cifmw_test_operator_dry_run | bool
loop: "{{ cifmw_test_operator_stages }}"

- name: Delete all resources created by the role
ansible.builtin.include_tasks: cleanup.yml
Expand Down
9 changes: 9 additions & 0 deletions roles/test_operator/tasks/runners/ansibletest_runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- name: Run ansibletest job
vars:
run_test_fw: ansibletest
test_operator_config: "{{ cifmw_test_operator_ansibletest_config }}"
test_operator_job_name: "{{ cifmw_test_operator_ansibletest_name }}"
test_operator_kind_name: "{{ cifmw_test_operator_ansibletest_kind_name }}"
test_operator_crd_name: "{{ cifmw_test_operator_ansibletest_crd_name }}"
test_operator_workflow: "{{ cifmw_test_operator_ansibletest_workflow }}"
ansible.builtin.include_tasks: run-test-operator-job.yml
9 changes: 9 additions & 0 deletions roles/test_operator/tasks/runners/horizontest_runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- name: Run horizontest job
vars:
run_test_fw: horizontest
test_operator_config: "{{ cifmw_test_operator_horizontest_config }}"
test_operator_job_name: "{{ cifmw_test_operator_horizontest_name }}"
test_operator_kind_name: "{{ cifmw_test_operator_horizontest_kind_name }}"
test_operator_crd_name: "{{ cifmw_test_operator_horizontest_crd_name }}"
test_operator_workflow: []
ansible.builtin.include_tasks: run-test-operator-job.yml
10 changes: 10 additions & 0 deletions roles/test_operator/tasks/runners/tempest_runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: Run tempest job
vars:
run_test_fw: tempest
test_operator_config: "{{ cifmw_test_operator_tempest_config }}"
test_operator_job_name: "{{ cifmw_test_operator_tempest_name }}"
test_operator_kind_name: "{{ cifmw_test_operator_tempest_kind_name }}"
test_operator_crd_name: "{{ cifmw_test_operator_tempest_crd_name }}"
test_operator_workflow: "{{ cifmw_test_operator_tempest_workflow }}"
test_operator_config_playbook: tempest-tests.yml
ansible.builtin.include_tasks: run-test-operator-job.yml
11 changes: 11 additions & 0 deletions roles/test_operator/tasks/runners/tobiko_runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Since Tobiko may include disruptive tests (faults), it is better to execute it at the end
- name: Run tobiko job
vars:
run_test_fw: tobiko
test_operator_config: "{{ cifmw_test_operator_tobiko_config }}"
test_operator_job_name: "{{ cifmw_test_operator_tobiko_name }}"
test_operator_kind_name: "{{ cifmw_test_operator_tobiko_kind_name }}"
test_operator_crd_name: "{{ cifmw_test_operator_tobiko_crd_name }}"
test_operator_workflow: "{{ cifmw_test_operator_tobiko_workflow }}"
test_operator_config_playbook: tobiko-tests.yml
ansible.builtin.include_tasks: run-test-operator-job.yml
29 changes: 29 additions & 0 deletions roles/test_operator/tasks/stages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

- debug:
msg: "Run stage {{ stage_vars.name }}"

- name: "Call pre stage hooks for test operator stage {{ stage_vars.name }}"
vars:
step: none
hook_list: "{{ stage_vars.pre_stage_hooks }}"
ansible.builtin.import_role:
name: run_hook
when:
- not cifmw_test_operator_dry_run | bool
- stage_vars.pre_stage_hooks is defined

- name: Include stage var file
ansible.builtin.include_vars:
file: "{{ stage_vars.test_file }}"

- name: "Call {{ stage_vars.type }} runner"
ansible.builtin.include_tasks: "runners/{{ stage_vars.type }}_runner.yml"

- name: "Call post stage hooks for test operator stage {{ stage_vars.name }}"
vars:
step: stage_vars.post_stage_hooks
ansible.builtin.import_role:
name: run_hook
when:
- not cifmw_test_operator_dry_run | bool
- stage_vars.post_stage_hooks is defined

0 comments on commit 9e7ab2d

Please sign in to comment.