Skip to content

Commit 6f231e9

Browse files
cescginaopenshift-merge-bot[bot]
authored andcommitted
Add job to run kuttl without install_yamls
This change attempts to make the approach that nova-operator uses to run kuttl more generic, so it can be used in other operators that follow a similar patter in their tests, like watcher-operator.
1 parent be20061 commit 6f231e9

File tree

4 files changed

+199
-0
lines changed

4 files changed

+199
-0
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
- name: Run ci_framework bootstrap playbook
3+
ansible.builtin.import_playbook: "../../../playbooks/01-bootstrap.yml"
4+
5+
- hosts: "{{ cifmw_target_host | default('localhost') }}"
6+
name: Install dev tools
7+
tasks:
8+
- name: Assert that operator_name is set
9+
ansible.builtin.assert:
10+
that:
11+
- operator_name is defined
12+
13+
- name: Download install_yamls deps
14+
ansible.builtin.include_role:
15+
name: 'install_yamls_makes'
16+
tasks_from: 'make_download_tools'
17+
18+
- name: Run ci_framework infra playbook
19+
ansible.builtin.import_playbook: "../../../playbooks/02-infra.yml"
20+
21+
- name: Build dataset hook
22+
hosts: "{{ cifmw_target_host | default('localhost') }}"
23+
gather_facts: false
24+
connection: local
25+
tasks:
26+
- name: Load parameters
27+
ansible.builtin.include_vars:
28+
dir: "{{ item }}"
29+
loop:
30+
- "{{ cifmw_basedir }}/artifacts/parameters"
31+
- "/etc/ci/env"
32+
loop_control:
33+
label: "{{ item }}"
34+
35+
- name: Ensure that the isolated net was configured for crc
36+
ansible.builtin.assert:
37+
that:
38+
- crc_ci_bootstrap_networks_out is defined
39+
- "'crc' in crc_ci_bootstrap_networks_out"
40+
- "'default' in crc_ci_bootstrap_networks_out['crc']"
41+
42+
- name: Set facts for further usage within the framework
43+
ansible.builtin.set_fact:
44+
cifmw_edpm_prepare_extra_vars:
45+
NNCP_INTERFACE: "{{ crc_ci_bootstrap_networks_out.crc.default.iface }}"
46+
NETWORK_MTU: "{{ crc_ci_bootstrap_networks_out.crc.default.mtu }}"
47+
48+
- hosts: "{{ cifmw_target_host | default('localhost') }}"
49+
name: Deploy Openstack Operators
50+
tasks:
51+
52+
- name: Use the locally built operators if any
53+
ansible.builtin.set_fact:
54+
_local_operators_indexes: >-
55+
{{
56+
_local_operators_indexes|default({}) |
57+
combine({ item.key.split('-')[0]|upper+'_IMG':
58+
cifmw_operator_build_output['operators'][item.key].image_catalog})
59+
}}
60+
loop: "{{ cifmw_operator_build_output['operators'] | dict2items }}"
61+
when:
62+
- cifmw_operator_build_output is defined
63+
- "'operators' in cifmw_operator_build_output"
64+
65+
- name: Set install_yamls Makefile environment variables
66+
vars:
67+
operators_build_output: "{{ (cifmw_operator_build_output | default({'operators':{}})).operators }}"
68+
_openstack_operator_images:
69+
OPENSTACK_IMG: "{{ cifmw_operator_build_output.operators['openstack-operator']['image_catalog'] | default(omit) }}"
70+
OPENSTACK_BUNDLE_IMG: "{{ cifmw_operator_build_output.operators['openstack-operator']['image_bundle'] | default(omit) }}"
71+
ansible.builtin.set_fact:
72+
cifmw_edpm_prepare_common_env: >-
73+
{{
74+
cifmw_install_yamls_environment |
75+
combine({'PATH': cifmw_path}) |
76+
combine(cifmw_edpm_prepare_extra_vars | default({}))
77+
}}
78+
cifmw_edpm_prepare_operators_build_output: "{{ operators_build_output }}"
79+
cifmw_edpm_prepare_make_openstack_env: "{{ _local_operators_indexes | combine(_openstack_operator_images) }}"
80+
81+
- name: Deploy openstack Operators
82+
environment:
83+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
84+
PATH: "{{ cifmw_path | default(ansible_env.PATH) }}"
85+
block:
86+
- name: detect if openstack operator is installed
87+
ansible.builtin.command:
88+
cmd: "oc get sub --ignore-not-found=true -n openstack-operators -o name openstack-operator"
89+
ignore_errors: true
90+
register: openstack_operator_subscription
91+
92+
- name: Install openstack operator
93+
when: openstack_operator_subscription.stdout == ""
94+
vars:
95+
make_openstack_env: "{{ cifmw_edpm_prepare_common_env |
96+
combine(cifmw_edpm_prepare_make_openstack_env) }}"
97+
make_openstack_dryrun: "{{ cifmw_edpm_prepare_dry_run }}"
98+
ansible.builtin.include_role:
99+
name: 'install_yamls_makes'
100+
tasks_from: 'make_openstack'
101+
102+
- name: Wait for OpenStack subscription creation
103+
when: openstack_operator_subscription.stdout == ""
104+
ansible.builtin.command:
105+
cmd: >-
106+
oc get sub openstack-operator
107+
--namespace=openstack-operators
108+
-o=jsonpath='{.status.installplan.name}'
109+
register: cifmw_edpm_prepare_wait_installplan_out
110+
until: cifmw_edpm_prepare_wait_installplan_out.rc == 0 and cifmw_edpm_prepare_wait_installplan_out.stdout != ""
111+
retries: 30
112+
delay: 10
113+
114+
- name: Wait for OpenStack operator to get installed
115+
when: openstack_operator_subscription.stdout == ""
116+
ansible.builtin.command:
117+
cmd: >-
118+
oc wait InstallPlan {{ cifmw_edpm_prepare_wait_installplan_out.stdout }}
119+
--namespace=openstack-operators
120+
--for=jsonpath='{.status.phase}'=Complete --timeout=20m
121+
122+
- name: install kuttl test_suite dependencies
123+
vars:
124+
project_name: "github.com/openstack-k8s-operators/{{ operator_name }}"
125+
operator_basedir: >-
126+
{{
127+
zuul.projects[project_name].src_dir
128+
}}
129+
ansible.builtin.command:
130+
cmd: make kuttl-test-prep
131+
chdir: "{{ ansible_user_dir }}/{{ operator_basedir }}"
132+
register: result
133+
until: result.rc == 0
134+
retries: 3
135+
delay: 10
136+
changed_when: true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
- name: "Run ci/playbooks/kuttl/deploy-deps.yml"
2+
hosts: controller
3+
gather_facts: true
4+
tasks:
5+
- name: Run kuttl deploy-deps playbook
6+
ansible.builtin.command:
7+
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework"
8+
cmd: >-
9+
ansible-playbook ci/playbooks/kuttl/deploy-deps.yaml
10+
-i "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml"
11+
-e @scenarios/centos-9/base.yml
12+
-e @scenarios/centos-9/ci.yml
13+
{%- if cifmw_extras is defined %}
14+
{%- for extra_vars in cifmw_extras %}
15+
-e "{{ extra_vars }}"
16+
{%- endfor %}
17+
{%- endif %}
18+
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/zuul-params.yml"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
- hosts: controller
2+
vars:
3+
project_name: "github.com/openstack-k8s-operators/{{ operator_name }}"
4+
operator_basedir: >-
5+
{{
6+
zuul.projects[project_name].src_dir
7+
}}
8+
kuttl_log_dir: "{{ local_log_dir | default(ansible_user_dir + '/zuul-output/logs/controller') }}"
9+
tasks:
10+
- name: run kuttl test suite from operator Makefile
11+
environment:
12+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
13+
PATH: "{{ cifmw_path | default(ansible_env.PATH) }}"
14+
ansible.builtin.command:
15+
cmd: make kuttl-test-run
16+
chdir: "{{ ansible_user_dir }}/{{ operator_basedir }}"
17+
changed_when: true
18+
register: kuttl_test_run
19+
20+
- name: Create log dir
21+
ansible.builtin.file:
22+
path: "{{ kuttl_log_dir }}"
23+
state: directory
24+
mode: "0755"
25+
recurse: yes
26+
27+
- name: save output to file
28+
ansible.builtin.copy:
29+
content: "{{ kuttl_test_run.stdout }}"
30+
dest: "{{ kuttl_log_dir }}/kuttl-test-run.out"
31+
when: kuttl_test_run.stdout is defined

zuul.d/kuttl_multinode.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,17 @@
7171
commands_after_kuttl_run:
7272
- oc get pv
7373
- oc get all
74+
75+
- job:
76+
name: cifmw-multinode-kuttl-operator-target
77+
parent: cifmw-base-multinode-kuttl
78+
description: |
79+
This job runs kuttl tests from the operator Make targets,
80+
without relying on install_yamls.
81+
dependencies: ["openstack-meta-content-provider"]
82+
pre-run:
83+
- ci/playbooks/kuttl/kuttl-from-operator-deps.yaml
84+
run:
85+
- ci/playbooks/kuttl/run-kuttl-from-operator-targets.yaml
86+
vars:
87+
cifmw_target_host: controller

0 commit comments

Comments
 (0)