Skip to content

Commit

Permalink
Change the method of installing test-operator
Browse files Browse the repository at this point in the history
This patch introduces a new way of installing test-operator.
Before, we wanted test-operator role to install the test-operator,
but now test-operator will be installed the same way as other
operators - using openstack-operator.

Additionally, there is a need to ensure we can change which
version of test-operator is used. This will be necessary for
having a way to prevent big issues by changing the versions
temporarily.
  • Loading branch information
kstrenkova committed Feb 12, 2025
1 parent 351e999 commit a900a67
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 60 deletions.
1 change: 1 addition & 0 deletions roles/env_op_images/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
cifmw_env_op_images_dir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}"
cifmw_env_op_images_file: operator_images.yaml
cifmw_env_op_images_dryrun: false
cifmw_env_op_test_operator_image: ""
15 changes: 15 additions & 0 deletions roles/env_op_images/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@
loop_control:
label: "{{ item.name }}"

- name: Patch CSV to change test-operator image if needed
when:
- cifmw_env_op_test_operator_image != ""
ansible.builtin.set_fact:
cifmw_openstack_service_images_content: >-
{{
cifmw_openstack_service_images_content |
default({}) |
combine(
{
"RELATED_IMAGE_TEST_OPERATOR_MANAGER_IMAGE_URL": {{ cifmw_env_op_test_operator_image }}
}
)
}}
- name: Get all the pods in openstack-operator namespace
vars:
csv_items: "{{ (_csvs_out.stdout | from_yaml)['items'] }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/test_operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Execute tests via the [test-operator](https://openstack-k8s-operators.github.io/

## Parameters
* `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`
* `cifmw_test_operator_namespace`: (String) Namespace inside which all the resources are created. Default value: `openstack`
* `cifmw_test_operator_namespace`: (String) Namespace inside which all the resources are created. Default value: `openstack-opearators`
* `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`
Expand Down
2 changes: 1 addition & 1 deletion roles/test_operator/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cifmw_test_operator_stages:
type: tempest
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
cifmw_test_operator_namespace: openstack-operators
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
Expand Down
58 changes: 0 additions & 58 deletions roles/test_operator/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,64 +23,6 @@
owner: "{{ ansible_user | default(lookup('env', 'USER')) }}"
group: "{{ ansible_user | default(lookup('env', 'USER')) }}"

- name: Ensure OperatorGroup for the test-operator is present
kubernetes.core.k8s:
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
api_key: "{{ cifmw_openshift_token | default(omit) }}"
context: "{{ cifmw_openshift_context | default(omit) }}"
state: present
wait: true
definition:
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: test-operator-operatorgroup
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
targetNamespaces:
- "{{ cifmw_test_operator_namespace }}"
when: not cifmw_test_operator_dry_run | bool

- name: Ensure CatalogSource for the test-operator is present
kubernetes.core.k8s:
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
api_key: "{{ cifmw_openshift_token | default(omit) }}"
context: "{{ cifmw_openshift_context | default(omit) }}"
state: present
wait: true
definition:
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: test-operator-catalog
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
sourceType: grpc
image: "{{ cifmw_test_operator_index }}"
when: not cifmw_test_operator_dry_run | bool

- name: Ensure Subscription for the test-operator is present
kubernetes.core.k8s:
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
api_key: "{{ cifmw_openshift_token | default(omit)}}"
context: "{{ cifmw_openshift_context | default(omit)}}"
state: present
wait: true
definition:
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: test-operator
namespace: "{{ cifmw_test_operator_namespace }}"
spec:
name: test-operator
source: test-operator-catalog
sourceNamespace: "{{ cifmw_test_operator_namespace }}"
config:
tolerations: "{{ cifmw_test_operator_tolerations | default(omit) }}"
nodeSelector: "{{ cifmw_test_operator_node_selector | default(omit) }}"
when: not cifmw_test_operator_dry_run | bool

- name: Wait until the test-operator csv is present
kubernetes.core.k8s_info:
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
Expand Down

0 comments on commit a900a67

Please sign in to comment.