-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
be20061
commit 6f231e9
Showing
4 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
--- | ||
- name: Run ci_framework bootstrap playbook | ||
ansible.builtin.import_playbook: "../../../playbooks/01-bootstrap.yml" | ||
|
||
- hosts: "{{ cifmw_target_host | default('localhost') }}" | ||
name: Install dev tools | ||
tasks: | ||
- name: Assert that operator_name is set | ||
ansible.builtin.assert: | ||
that: | ||
- operator_name is defined | ||
|
||
- name: Download install_yamls deps | ||
ansible.builtin.include_role: | ||
name: 'install_yamls_makes' | ||
tasks_from: 'make_download_tools' | ||
|
||
- name: Run ci_framework infra playbook | ||
ansible.builtin.import_playbook: "../../../playbooks/02-infra.yml" | ||
|
||
- name: Build dataset hook | ||
hosts: "{{ cifmw_target_host | default('localhost') }}" | ||
gather_facts: false | ||
connection: local | ||
tasks: | ||
- name: Load parameters | ||
ansible.builtin.include_vars: | ||
dir: "{{ item }}" | ||
loop: | ||
- "{{ cifmw_basedir }}/artifacts/parameters" | ||
- "/etc/ci/env" | ||
loop_control: | ||
label: "{{ item }}" | ||
|
||
- name: Ensure that the isolated net was configured for crc | ||
ansible.builtin.assert: | ||
that: | ||
- crc_ci_bootstrap_networks_out is defined | ||
- "'crc' in crc_ci_bootstrap_networks_out" | ||
- "'default' in crc_ci_bootstrap_networks_out['crc']" | ||
|
||
- name: Set facts for further usage within the framework | ||
ansible.builtin.set_fact: | ||
cifmw_edpm_prepare_extra_vars: | ||
NNCP_INTERFACE: "{{ crc_ci_bootstrap_networks_out.crc.default.iface }}" | ||
NETWORK_MTU: "{{ crc_ci_bootstrap_networks_out.crc.default.mtu }}" | ||
|
||
- hosts: "{{ cifmw_target_host | default('localhost') }}" | ||
name: Deploy Openstack Operators | ||
tasks: | ||
|
||
- name: Use the locally built operators if any | ||
ansible.builtin.set_fact: | ||
_local_operators_indexes: >- | ||
{{ | ||
_local_operators_indexes|default({}) | | ||
combine({ item.key.split('-')[0]|upper+'_IMG': | ||
cifmw_operator_build_output['operators'][item.key].image_catalog}) | ||
}} | ||
loop: "{{ cifmw_operator_build_output['operators'] | dict2items }}" | ||
when: | ||
- cifmw_operator_build_output is defined | ||
- "'operators' in cifmw_operator_build_output" | ||
|
||
- name: Set install_yamls Makefile environment variables | ||
vars: | ||
operators_build_output: "{{ (cifmw_operator_build_output | default({'operators':{}})).operators }}" | ||
_openstack_operator_images: | ||
OPENSTACK_IMG: "{{ cifmw_operator_build_output.operators['openstack-operator']['image_catalog'] | default(omit) }}" | ||
OPENSTACK_BUNDLE_IMG: "{{ cifmw_operator_build_output.operators['openstack-operator']['image_bundle'] | default(omit) }}" | ||
ansible.builtin.set_fact: | ||
cifmw_edpm_prepare_common_env: >- | ||
{{ | ||
cifmw_install_yamls_environment | | ||
combine({'PATH': cifmw_path}) | | ||
combine(cifmw_edpm_prepare_extra_vars | default({})) | ||
}} | ||
cifmw_edpm_prepare_operators_build_output: "{{ operators_build_output }}" | ||
cifmw_edpm_prepare_make_openstack_env: "{{ _local_operators_indexes | combine(_openstack_operator_images) }}" | ||
|
||
- name: Deploy openstack Operators | ||
environment: | ||
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" | ||
PATH: "{{ cifmw_path | default(ansible_env.PATH) }}" | ||
block: | ||
- name: detect if openstack operator is installed | ||
ansible.builtin.command: | ||
cmd: "oc get sub --ignore-not-found=true -n openstack-operators -o name openstack-operator" | ||
ignore_errors: true | ||
register: openstack_operator_subscription | ||
|
||
- name: Install openstack operator | ||
when: openstack_operator_subscription.stdout == "" | ||
vars: | ||
make_openstack_env: "{{ cifmw_edpm_prepare_common_env | | ||
combine(cifmw_edpm_prepare_make_openstack_env) }}" | ||
make_openstack_dryrun: "{{ cifmw_edpm_prepare_dry_run }}" | ||
ansible.builtin.include_role: | ||
name: 'install_yamls_makes' | ||
tasks_from: 'make_openstack' | ||
|
||
- name: Wait for OpenStack subscription creation | ||
when: openstack_operator_subscription.stdout == "" | ||
ansible.builtin.command: | ||
cmd: >- | ||
oc get sub openstack-operator | ||
--namespace=openstack-operators | ||
-o=jsonpath='{.status.installplan.name}' | ||
register: cifmw_edpm_prepare_wait_installplan_out | ||
until: cifmw_edpm_prepare_wait_installplan_out.rc == 0 and cifmw_edpm_prepare_wait_installplan_out.stdout != "" | ||
retries: 30 | ||
delay: 10 | ||
|
||
- name: Wait for OpenStack operator to get installed | ||
when: openstack_operator_subscription.stdout == "" | ||
ansible.builtin.command: | ||
cmd: >- | ||
oc wait InstallPlan {{ cifmw_edpm_prepare_wait_installplan_out.stdout }} | ||
--namespace=openstack-operators | ||
--for=jsonpath='{.status.phase}'=Complete --timeout=20m | ||
- name: install kuttl test_suite dependencies | ||
vars: | ||
project_name: "github.com/openstack-k8s-operators/{{ operator_name }}" | ||
operator_basedir: >- | ||
{{ | ||
zuul.projects[project_name].src_dir | ||
}} | ||
ansible.builtin.command: | ||
cmd: make kuttl-test-prep | ||
chdir: "{{ ansible_user_dir }}/{{ operator_basedir }}" | ||
register: result | ||
until: result.rc == 0 | ||
retries: 3 | ||
delay: 10 | ||
changed_when: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
- name: "Run ci/playbooks/kuttl/deploy-deps.yml" | ||
hosts: controller | ||
gather_facts: true | ||
tasks: | ||
- name: Run kuttl deploy-deps playbook | ||
ansible.builtin.command: | ||
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework" | ||
cmd: >- | ||
ansible-playbook ci/playbooks/kuttl/deploy-deps.yaml | ||
-i "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml" | ||
-e @scenarios/centos-9/base.yml | ||
-e @scenarios/centos-9/ci.yml | ||
{%- if cifmw_extras is defined %} | ||
{%- for extra_vars in cifmw_extras %} | ||
-e "{{ extra_vars }}" | ||
{%- endfor %} | ||
{%- endif %} | ||
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/zuul-params.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
- hosts: controller | ||
vars: | ||
project_name: "github.com/openstack-k8s-operators/{{ operator_name }}" | ||
operator_basedir: >- | ||
{{ | ||
zuul.projects[project_name].src_dir | ||
}} | ||
kuttl_log_dir: "{{ local_log_dir | default(ansible_user_dir + '/zuul-output/logs/controller') }}" | ||
tasks: | ||
- name: run kuttl test suite from operator Makefile | ||
environment: | ||
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" | ||
PATH: "{{ cifmw_path | default(ansible_env.PATH) }}" | ||
ansible.builtin.command: | ||
cmd: make kuttl-test-run | ||
chdir: "{{ ansible_user_dir }}/{{ operator_basedir }}" | ||
changed_when: true | ||
register: kuttl_test_run | ||
|
||
- name: Create log dir | ||
ansible.builtin.file: | ||
path: "{{ kuttl_log_dir }}" | ||
state: directory | ||
mode: "0755" | ||
recurse: yes | ||
|
||
- name: save output to file | ||
ansible.builtin.copy: | ||
content: "{{ kuttl_test_run.stdout }}" | ||
dest: "{{ kuttl_log_dir }}/kuttl-test-run.out" | ||
when: kuttl_test_run.stdout is defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters