Skip to content

Commit ad1eca3

Browse files
committed
[test-operator] Move to openstack-test-operator namespace
The test-operator got changed from cluster scoped operator to namespace scoped operator in this PR [1]. It is now recommended that the test-operator gets installed in a separate namespace other than the one where the test pods are spawned. This patch ensures that: - the test-operator gets installed in the openstack-test-operator namespace - the test-operator spawns test pods in the openstack namespace [1] openstack-k8s-operators/test-operator#264
1 parent 93de89d commit ad1eca3

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

roles/test_operator/defaults/main.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
# Section 1: generic parameters (applied to all supported test frameworks)
2222
cifmw_test_operator_fail_on_test_failure: true
2323
cifmw_test_operator_artifacts_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}/tests/test_operator"
24-
cifmw_test_operator_namespace: openstack
24+
cifmw_test_operator_namespace: openstack-test-operator
25+
cifmw_test_operator_target_namespace: openstack
2526
cifmw_test_operator_index: quay.io/openstack-k8s-operators/test-operator-index:latest
2627
cifmw_test_operator_timeout: 3600
2728
cifmw_test_operator_logs_image: quay.io/quay/busybox
@@ -102,7 +103,7 @@ cifmw_test_operator_tempest_config:
102103
kind: Tempest
103104
metadata:
104105
name: "{{ test_operator_job_name }}"
105-
namespace: "{{ cifmw_test_operator_namespace }}"
106+
namespace: "{{ cifmw_test_operator_target_namespace }}"
106107
spec:
107108
containerImage: "{{ cifmw_test_operator_tempest_image }}:{{ cifmw_test_operator_tempest_image_tag }}"
108109
storageClass: "{{ cifmw_test_operator_storage_class }}"
@@ -155,7 +156,7 @@ cifmw_test_operator_tobiko_config:
155156
kind: Tobiko
156157
metadata:
157158
name: tobiko-tests
158-
namespace: "{{ cifmw_test_operator_namespace }}"
159+
namespace: "{{ cifmw_test_operator_target_namespace }}"
159160
spec:
160161
kubeconfigSecretName: "{{ cifmw_test_operator_tobiko_kubeconfig_secret }}"
161162
storageClass: "{{ cifmw_test_operator_storage_class }}"
@@ -201,7 +202,7 @@ cifmw_test_operator_ansibletest_config:
201202
kind: AnsibleTest
202203
metadata:
203204
name: "{{ test_operator_job_name }}"
204-
namespace: "{{ cifmw_test_operator_namespace }}"
205+
namespace: "{{ cifmw_test_operator_target_namespace }}"
205206
spec:
206207
containerImage: "{{ cifmw_test_operator_ansibletest_image }}:{{ cifmw_test_operator_ansibletest_image_tag }}"
207208
extraConfigmapsMounts: "{{ cifmw_test_operator_ansibletest_extra_configmaps_mounts }}"
@@ -246,7 +247,7 @@ cifmw_test_operator_horizontest_config:
246247
kind: HorizonTest
247248
metadata:
248249
name: "{{ cifmw_test_operator_horizontest_name }}"
249-
namespace: "{{ cifmw_test_operator_namespace }}"
250+
namespace: "{{ cifmw_test_operator_target_namespace }}"
250251
spec:
251252
storageClass: "{{ cifmw_test_operator_storage_class }}"
252253
privileged: "{{ cifmw_test_operator_privileged }}"

roles/test_operator/tasks/main.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
run_ansibletest: "{{ cifmw_run_ansibletest | default('false') | bool }}"
3131
run_horizontest: "{{ cifmw_run_horizontest | default('false') | bool }}"
3232

33+
- name: Create namespace where the test-operator is going to be installed
34+
kubernetes.core.k8s:
35+
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
36+
api_key: "{{ cifmw_openshift_token | default(omit) }}"
37+
context: "{{ cifmw_openshift_context | default(omit) }}"
38+
state: present
39+
wait: true
40+
definition:
41+
apiVersion: v1
42+
kind: Namespace
43+
metadata:
44+
name: "{{ cifmw_test_operator_namespace }}"
45+
3346
- name: Ensure OperatorGroup for the test-operator is present
3447
kubernetes.core.k8s:
3548
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
@@ -45,7 +58,7 @@
4558
namespace: "{{ cifmw_test_operator_namespace }}"
4659
spec:
4760
targetNamespaces:
48-
- "{{ cifmw_test_operator_namespace }}"
61+
- "{{ cifmw_test_operator_target_namespace }}"
4962
when: not cifmw_test_operator_dry_run | bool
5063

5164
- name: Ensure CatalogSource for the test-operator is present
@@ -88,17 +101,17 @@
88101
nodeSelector: "{{ cifmw_test_operator_node_selector | default(omit) }}"
89102
when: not cifmw_test_operator_dry_run | bool
90103

91-
- name: Wait until the test-operator csv is present
104+
- name: Wait until the test-operator CSV is present in the target namespace
92105
kubernetes.core.k8s_info:
93106
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
94107
api_key: "{{ cifmw_openshift_token | default(omit)}}"
95108
context: "{{ cifmw_openshift_context | default(omit) }}"
96-
namespace: "{{ cifmw_test_operator_namespace }}"
109+
namespace: "{{ cifmw_test_operator_target_namespace }}"
97110
kind: ClusterServiceVersion
98111
api_version: operators.coreos.com/v1alpha1
99112
register: csv_list
100113
delay: 10
101-
retries: 20
114+
retries: 100
102115
until: >-
103116
{{
104117
csv_list.resources |
@@ -107,7 +120,7 @@
107120
}}
108121
when: not cifmw_test_operator_dry_run | bool
109122

110-
- name: Get full name of the test-operator csv
123+
- name: Get full name of the test-operator CSV in the target namespace
111124
ansible.builtin.set_fact:
112125
test_operator_csv_name: >-
113126
{{
@@ -117,12 +130,12 @@
117130
}}
118131
when: not cifmw_test_operator_dry_run | bool
119132

120-
- name: Wait for the test-operator csv to Succeed
133+
- name: Wait for the test-operator CSV to Succeed in the target namespace
121134
kubernetes.core.k8s_info:
122135
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
123136
api_key: "{{ cifmw_openshift_token | default(omit)}}"
124137
context: "{{ cifmw_openshift_context | default(omit) }}"
125-
namespace: "{{ cifmw_test_operator_namespace }}"
138+
namespace: "{{ cifmw_test_operator_target_namespace }}"
126139
kind: ClusterServiceVersion
127140
api_version: operators.coreos.com/v1alpha1
128141
name: "{{ test_operator_csv_name }}"

roles/test_operator/tasks/run-test-operator-job.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
4343
api_key: "{{ cifmw_openshift_token | default(omit) }}"
4444
context: "{{ cifmw_openshift_context | default(omit) }}"
45-
namespace: "{{ cifmw_test_operator_namespace }}"
45+
namespace: "{{ cifmw_test_operator_target_namespace }}"
4646
kind: Job
4747
label_selectors:
4848
- "workflowStep={{ [(test_operator_workflow | length) - 1, 0] | max }}"
@@ -116,7 +116,7 @@
116116
kind: Pod
117117
metadata:
118118
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
119-
namespace: "{{ cifmw_test_operator_namespace }}"
119+
namespace: "{{ cifmw_test_operator_target_namespace }}"
120120
spec:
121121
containers:
122122
- name: test-operator-logs-container
@@ -132,7 +132,7 @@
132132
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
133133
api_key: "{{ cifmw_openshift_token | default(omit) }}"
134134
context: "{{ cifmw_openshift_context | default(omit) }}"
135-
namespace: "{{ cifmw_test_operator_namespace }}"
135+
namespace: "{{ cifmw_test_operator_target_namespace }}"
136136
kind: Pod
137137
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
138138
wait: true
@@ -148,7 +148,7 @@
148148
vars:
149149
pod_path: mnt/logs-{{ test_operator_job_name }}-step-{{ index }}
150150
ansible.builtin.shell: >
151-
oc cp -n {{ cifmw_test_operator_namespace }}
151+
oc cp -n {{ cifmw_test_operator_target_namespace }}
152152
openstack/test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}:{{ pod_path }}
153153
{{ cifmw_test_operator_artifacts_basedir }}
154154
loop: "{{ logsPVCs.resources }}"
@@ -160,7 +160,7 @@
160160
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
161161
api_key: "{{ cifmw_openshift_token | default(omit)}}"
162162
context: "{{ cifmw_openshift_context | default(omit) }}"
163-
namespace: "{{ cifmw_test_operator_namespace }}"
163+
namespace: "{{ cifmw_test_operator_target_namespace }}"
164164
kind: Pod
165165
register: pod_list
166166
when: not cifmw_test_operator_dry_run | bool
@@ -171,7 +171,7 @@
171171
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
172172
api_key: "{{ cifmw_openshift_token | default(omit) }}"
173173
context: "{{ cifmw_openshift_context | default(omit) }}"
174-
namespace: "{{ cifmw_test_operator_namespace }}"
174+
namespace: "{{ cifmw_test_operator_target_namespace }}"
175175
kind: Pod
176176
label_selectors:
177177
- "instanceName={{ test_operator_job_name }}"
@@ -226,7 +226,7 @@
226226
state: absent
227227
api_version: test.openstack.org/v1beta1
228228
name: "{{ test_operator_job_name }}"
229-
namespace: "{{ cifmw_test_operator_namespace }}"
229+
namespace: "{{ cifmw_test_operator_target_namespace }}"
230230
wait: true
231231
wait_timeout: 600
232232

@@ -239,7 +239,7 @@
239239
state: absent
240240
api_version: v1
241241
name: "{{ test_operator_crd_name }}"
242-
namespace: "{{ cifmw_test_operator_namespace }}"
242+
namespace: "{{ cifmw_test_operator_target_namespace }}"
243243
wait: true
244244
wait_timeout: 600
245245

@@ -252,7 +252,7 @@
252252
state: absent
253253
api_version: v1
254254
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
255-
namespace: "{{ cifmw_test_operator_namespace }}"
255+
namespace: "{{ cifmw_test_operator_target_namespace }}"
256256
wait: true
257257
wait_timeout: 600
258258
when:

0 commit comments

Comments
 (0)