Skip to content

Commit aa161d6

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 ff9f827 commit aa161d6

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,35 @@
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 }}"
49+
- "instanceName={{ test_operator_instance_name }}"
5050
retries: "{{ (cifmw_test_operator_timeout / 10) | round | int }}"
5151
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

5959
- name: Check whether timed out - {{ run_test_fw }}
6060
ansible.builtin.set_fact:
61-
testjob_timed_out: >-
62-
{{ testjob.attempts == (cifmw_test_operator_timeout / 10) | round | int }}
61+
testpod_timed_out: >-
62+
{{ testpod.attempts == (cifmw_test_operator_timeout / 10) | round | int }}
6363
when: not cifmw_test_operator_dry_run | bool
6464

6565
- name: Collect logs
6666
when:
6767
- not cifmw_test_operator_dry_run | bool
68-
- not testjob_timed_out
68+
- not testpod_timed_out
6969
block:
7070
- name: Reset volumes and volume_mounts to an empty list
7171
ansible.builtin.set_fact:
@@ -79,7 +79,7 @@
7979
context: "{{ cifmw_openshift_context | default(omit)}}"
8080
kind: PersistentVolumeClaim
8181
label_selectors:
82-
- "instanceName={{ test_operator_job_name }}"
82+
- "instanceName={{ test_operator_instance_name }}"
8383
register: logsPVCs
8484

8585
- name: Set up volume mounts and volumes for all PVCs
@@ -88,7 +88,7 @@
8888
{{
8989
(volume_mounts | default([])) + [{
9090
'name': "logs-volume-" ~ index,
91-
'mountPath': "/mnt/logs-{{ test_operator_job_name }}-step-" ~ index
91+
'mountPath': "/mnt/logs-{{ test_operator_instance_name }}-step-" ~ index
9292
}]
9393
}}
9494
volumes: >
@@ -115,7 +115,7 @@
115115
apiVersion: v1
116116
kind: Pod
117117
metadata:
118-
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
118+
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_instance_name }}"
119119
namespace: "{{ cifmw_test_operator_namespace }}"
120120
spec:
121121
containers:
@@ -134,7 +134,7 @@
134134
context: "{{ cifmw_openshift_context | default(omit) }}"
135135
namespace: "{{ cifmw_test_operator_namespace }}"
136136
kind: Pod
137-
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
137+
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_instance_name }}"
138138
wait: true
139139
register: logs_pod
140140
until: logs_pod.resources[0].status.phase == "Running"
@@ -146,10 +146,10 @@
146146
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
147147
PATH: "{{ cifmw_path }}"
148148
vars:
149-
pod_path: mnt/logs-{{ test_operator_job_name }}-step-{{ index }}
149+
pod_path: mnt/logs-{{ test_operator_instance_name }}-step-{{ index }}
150150
ansible.builtin.shell: >
151151
oc cp -n {{ cifmw_test_operator_namespace }}
152-
openstack/test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}:{{ pod_path }}
152+
openstack/test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_instance_name }}:{{ pod_path }}
153153
{{ cifmw_test_operator_artifacts_basedir }}
154154
loop: "{{ logsPVCs.resources }}"
155155
loop_control:
@@ -174,7 +174,7 @@
174174
namespace: "{{ cifmw_test_operator_namespace }}"
175175
kind: Pod
176176
label_selectors:
177-
- "instanceName={{ test_operator_job_name }}"
177+
- "instanceName={{ test_operator_instance_name }}"
178178
when: not cifmw_test_operator_dry_run | bool
179179

180180
- name: Get status from test pods
@@ -225,7 +225,7 @@
225225
kind: "{{ test_operator_kind_name }}"
226226
state: absent
227227
api_version: test.openstack.org/v1beta1
228-
name: "{{ test_operator_job_name }}"
228+
name: "{{ test_operator_instance_name }}"
229229
namespace: "{{ cifmw_test_operator_namespace }}"
230230
wait: true
231231
wait_timeout: 600
@@ -251,7 +251,7 @@
251251
kind: Pod
252252
state: absent
253253
api_version: v1
254-
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_job_name }}"
254+
name: "test-operator-logs-pod-{{ run_test_fw }}-{{ test_operator_instance_name }}"
255255
namespace: "{{ cifmw_test_operator_namespace }}"
256256
wait: true
257257
wait_timeout: 600

roles/test_operator/tasks/runners/ansibletest_runner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
vars:
44
run_test_fw: ansibletest
55
test_operator_config: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_config }}"
6-
test_operator_job_name: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_name }}-{{ _stage_vars.name }}"
6+
test_operator_instance_name: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_name }}-{{ _stage_vars.name }}"
77
test_operator_kind_name: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_kind_name }}"
88
test_operator_crd_name: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_crd_name }}"
99
test_operator_workflow: "{{ stage_vars_dict.cifmw_test_operator_ansibletest_workflow }}"

roles/test_operator/tasks/runners/horizontest_runner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
vars:
44
run_test_fw: horizontest
55
test_operator_config: "{{ stage_vars_dict.cifmw_test_operator_horizontest_config }}"
6-
test_operator_job_name: "{{ stage_vars_dict.cifmw_test_operator_horizontest_name }}-{{ _stage_vars.name }}"
6+
test_operator_instance_name: "{{ stage_vars_dict.cifmw_test_operator_horizontest_name }}-{{ _stage_vars.name }}"
77
test_operator_kind_name: "{{ stage_vars_dict.cifmw_test_operator_horizontest_kind_name }}"
88
test_operator_crd_name: "{{ stage_vars_dict.cifmw_test_operator_horizontest_crd_name }}"
99
test_operator_workflow: []

roles/test_operator/tasks/runners/tempest_runner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
vars:
44
run_test_fw: tempest
55
test_operator_config: "{{ stage_vars_dict.cifmw_test_operator_tempest_config }}"
6-
test_operator_job_name: "{{ stage_vars_dict.cifmw_test_operator_tempest_name }}-{{ _stage_vars.name }}"
6+
test_operator_instance_name: "{{ stage_vars_dict.cifmw_test_operator_tempest_name }}-{{ _stage_vars.name }}"
77
test_operator_kind_name: "{{ stage_vars_dict.cifmw_test_operator_tempest_kind_name }}"
88
test_operator_crd_name: "{{ stage_vars_dict.cifmw_test_operator_tempest_crd_name }}"
99
test_operator_workflow: "{{ stage_vars_dict.cifmw_test_operator_tempest_workflow }}"

roles/test_operator/tasks/runners/tobiko_runner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
vars:
55
run_test_fw: tobiko
66
test_operator_config: "{{ stage_vars_dict.cifmw_test_operator_tobiko_config }}"
7-
test_operator_job_name: "{{ stage_vars_dict.cifmw_test_operator_tobiko_name }}-{{ _stage_vars.name }}"
7+
test_operator_instance_name: "{{ stage_vars_dict.cifmw_test_operator_tobiko_name }}-{{ _stage_vars.name }}"
88
test_operator_kind_name: "{{ stage_vars_dict.cifmw_test_operator_tobiko_kind_name }}"
99
test_operator_crd_name: "{{ stage_vars_dict.cifmw_test_operator_tobiko_crd_name }}"
1010
test_operator_workflow: "{{ stage_vars_dict.cifmw_test_operator_tobiko_workflow }}"

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)