Skip to content

Commit 1b557d1

Browse files
committed
[test-operator] Move away from Jobs to Pods
With this PR [1] the test operator dropped the usage of OCP Jobs for spawning of the test pods. This change updates the test-operator role so that it works with the new version of the test-operator that spawns test pods directly through the OCP Pods object. [1] openstack-k8s-operators/test-operator#266
1 parent 93de89d commit 1b557d1

File tree

4 files changed

+39
-27
lines changed

4 files changed

+39
-27
lines changed

roles/test_operator/defaults/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ cifmw_test_operator_tempest_config:
101101
apiVersion: test.openstack.org/v1beta1
102102
kind: Tempest
103103
metadata:
104-
name: "{{ test_operator_job_name }}"
104+
name: "{{ test_operator_instance_name }}"
105105
namespace: "{{ cifmw_test_operator_namespace }}"
106106
spec:
107107
containerImage: "{{ cifmw_test_operator_tempest_image }}:{{ cifmw_test_operator_tempest_image_tag }}"
@@ -200,7 +200,7 @@ cifmw_test_operator_ansibletest_config:
200200
apiVersion: test.openstack.org/v1beta1
201201
kind: AnsibleTest
202202
metadata:
203-
name: "{{ test_operator_job_name }}"
203+
name: "{{ test_operator_instance_name }}"
204204
namespace: "{{ cifmw_test_operator_namespace }}"
205205
spec:
206206
containerImage: "{{ cifmw_test_operator_ansibletest_image }}:{{ cifmw_test_operator_ansibletest_image_tag }}"

roles/test_operator/tasks/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
vars:
137137
run_test_fw: tempest
138138
test_operator_config: "{{ cifmw_test_operator_tempest_config }}"
139-
test_operator_job_name: "{{ cifmw_test_operator_tempest_name }}"
139+
test_operator_instance_name: "{{ cifmw_test_operator_tempest_name }}"
140140
test_operator_kind_name: "{{ cifmw_test_operator_tempest_kind_name }}"
141141
test_operator_crd_name: "{{ cifmw_test_operator_tempest_crd_name }}"
142142
test_operator_workflow: "{{ cifmw_test_operator_tempest_workflow }}"
@@ -148,7 +148,7 @@
148148
vars:
149149
run_test_fw: ansibletest
150150
test_operator_config: "{{ cifmw_test_operator_ansibletest_config }}"
151-
test_operator_job_name: "{{ cifmw_test_operator_ansibletest_name }}"
151+
test_operator_instance_name: "{{ cifmw_test_operator_ansibletest_name }}"
152152
test_operator_kind_name: "{{ cifmw_test_operator_ansibletest_kind_name }}"
153153
test_operator_crd_name: "{{ cifmw_test_operator_ansibletest_crd_name }}"
154154
test_operator_workflow: "{{ cifmw_test_operator_ansibletest_workflow }}"
@@ -159,7 +159,7 @@
159159
vars:
160160
run_test_fw: horizontest
161161
test_operator_config: "{{ cifmw_test_operator_horizontest_config }}"
162-
test_operator_job_name: "{{ cifmw_test_operator_horizontest_name }}"
162+
test_operator_instance_name: "{{ cifmw_test_operator_horizontest_name }}"
163163
test_operator_kind_name: "{{ cifmw_test_operator_horizontest_kind_name }}"
164164
test_operator_crd_name: "{{ cifmw_test_operator_horizontest_crd_name }}"
165165
test_operator_workflow: []
@@ -171,7 +171,7 @@
171171
vars:
172172
run_test_fw: tobiko
173173
test_operator_config: "{{ cifmw_test_operator_tobiko_config }}"
174-
test_operator_job_name: "{{ cifmw_test_operator_tobiko_name }}"
174+
test_operator_instance_name: "{{ cifmw_test_operator_tobiko_name }}"
175175
test_operator_kind_name: "{{ cifmw_test_operator_tobiko_kind_name }}"
176176
test_operator_crd_name: "{{ cifmw_test_operator_tobiko_crd_name }}"
177177
test_operator_workflow: "{{ cifmw_test_operator_tobiko_workflow }}"

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

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,47 @@
3737
definition: "{{ test_operator_cr }}"
3838
when: not cifmw_test_operator_dry_run | bool
3939

40-
- name: Wait for the last job to be Completed - {{ run_test_fw }}
40+
- name: Wait for the last Pod to be Completed - {{ run_test_fw }}
4141
kubernetes.core.k8s_info:
4242
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"
4343
api_key: "{{ cifmw_openshift_token | default(omit) }}"
4444
context: "{{ cifmw_openshift_context | default(omit) }}"
4545
namespace: "{{ cifmw_test_operator_namespace }}"
46-
kind: Job
46+
kind: Pod
4747
label_selectors:
4848
- "workflowStep={{ [(test_operator_workflow | length) - 1, 0] | max }}"
49-
- "instanceName={{ test_operator_job_name }}"
50-
retries: "{{ (cifmw_test_operator_timeout / 10) | round | int }}"
51-
delay: 10
49+
- "instanceName={{ test_operator_instance_name }}"
50+
# retries: "{{ (cifmw_test_operator_timeout / 10) | round | int }}"
51+
# delay: 10
5252
until: >
53-
testjob.resources[0].status.succeeded | default(0) | int >= 1 or
54-
testjob.resources[0].status.failed | default(0) | int >= 1
53+
testpod.resources[0].status.phase == "Succeeded" or
54+
testpod.resources[0].phase == "Failed"
5555
ignore_errors: true
56-
register: testjob
56+
register: testpod
5757
when: not cifmw_test_operator_dry_run | bool
5858

59+
# - name: message
60+
# debug:
61+
# msg: "{{ testpod.status }}"
62+
63+
# - name: fail
64+
# fail:
65+
# msg: "tortuga"
66+
67+
# - name: debug
68+
# debug:
69+
# var: testpod
70+
5971
- name: Check whether timed out - {{ run_test_fw }}
6072
ansible.builtin.set_fact:
61-
testjob_timed_out: >-
62-
{{ testjob.attempts == (cifmw_test_operator_timeout / 10) | round | int }}
73+
testpod_timed_out: >-
74+
{{ testpod.attempts == (cifmw_test_operator_timeout / 10) | round | int }}
6375
when: not cifmw_test_operator_dry_run | bool
6476

6577
- name: Collect logs
6678
when:
6779
- not cifmw_test_operator_dry_run | bool
68-
- not testjob_timed_out
80+
- not testpod_timed_out
6981
block:
7082
- name: Reset volumes and volume_mounts to an empty list
7183
ansible.builtin.set_fact:
@@ -79,7 +91,7 @@
7991
context: "{{ cifmw_openshift_context | default(omit)}}"
8092
kind: PersistentVolumeClaim
8193
label_selectors:
82-
- "instanceName={{ test_operator_job_name }}"
94+
- "instanceName={{ test_operator_instance_name }}"
8395
register: logsPVCs
8496

8597
- name: Set up volume mounts and volumes for all PVCs
@@ -88,7 +100,7 @@
88100
{{
89101
(volume_mounts | default([])) + [{
90102
'name': "logs-volume-" ~ index,
91-
'mountPath': "/mnt/logs-{{ test_operator_job_name }}-step-" ~ index
103+
'mountPath': "/mnt/logs-{{ test_operator_instance_name }}-step-" ~ index
92104
}]
93105
}}
94106
volumes: >
@@ -115,7 +127,7 @@
115127
apiVersion: v1
116128
kind: Pod
117129
metadata:
118-
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
130+
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_instance_name }}"
119131
namespace: "{{ cifmw_test_operator_namespace }}"
120132
spec:
121133
containers:
@@ -134,7 +146,7 @@
134146
context: "{{ cifmw_openshift_context | default(omit) }}"
135147
namespace: "{{ cifmw_test_operator_namespace }}"
136148
kind: Pod
137-
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
149+
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_instance_name }}"
138150
wait: true
139151
register: logs_pod
140152
until: logs_pod.resources[0].status.phase == "Running"
@@ -146,10 +158,10 @@
146158
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
147159
PATH: "{{ cifmw_path }}"
148160
vars:
149-
pod_path: mnt/logs-{{ test_operator_job_name }}-step-{{ index }}
161+
pod_path: mnt/logs-{{ test_operator_instance_name }}-step-{{ index }}
150162
ansible.builtin.shell: >
151163
oc cp -n {{ cifmw_test_operator_namespace }}
152-
openstack/test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}:{{ pod_path }}
164+
openstack/test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_instance_name }}:{{ pod_path }}
153165
{{ cifmw_test_operator_artifacts_basedir }}
154166
loop: "{{ logsPVCs.resources }}"
155167
loop_control:
@@ -174,7 +186,7 @@
174186
namespace: "{{ cifmw_test_operator_namespace }}"
175187
kind: Pod
176188
label_selectors:
177-
- "instanceName={{ test_operator_job_name }}"
189+
- "instanceName={{ test_operator_instance_name }}"
178190
when: not cifmw_test_operator_dry_run | bool
179191

180192
- name: Get status from test pods
@@ -225,7 +237,7 @@
225237
kind: "{{ test_operator_kind_name }}"
226238
state: absent
227239
api_version: test.openstack.org/v1beta1
228-
name: "{{ test_operator_job_name }}"
240+
name: "{{ test_operator_instance_name }}"
229241
namespace: "{{ cifmw_test_operator_namespace }}"
230242
wait: true
231243
wait_timeout: 600
@@ -251,7 +263,7 @@
251263
kind: Pod
252264
state: absent
253265
api_version: v1
254-
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
266+
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_instance_name }}"
255267
namespace: "{{ cifmw_test_operator_namespace }}"
256268
wait: true
257269
wait_timeout: 600

roles/test_operator/tasks/tempest-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
tempest_list_allowed:
3030
yaml_file: "{{ cifmw_test_operator_artifacts_basedir }}/list_allowed.yml"
3131
groups: "{{ cifmw_test_operator_default_groups }}"
32-
job: "{{ cifmw_test_operator_job_name | default(omit) }}"
32+
job: "{{ cifmw_test_operator_instance_name | default(omit) }}"
3333
register:
3434
list_allowed
3535

0 commit comments

Comments
 (0)