Skip to content

Commit 6dcd0b4

Browse files
committed
stop module integration tests
Signed-off-by: Andrew Twydell <[email protected]>
1 parent ce025fa commit 6dcd0b4

File tree

7 files changed

+387
-32
lines changed

7 files changed

+387
-32
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# (c) Copyright IBM Corp. 2024
2+
# Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0)
3+
---
4+
- name: Stop missing jobs
5+
hosts: 'all'
6+
gather_facts: false
7+
environment: "{{ environment_vars }}"
8+
9+
tasks:
10+
- name: Issue shutdown command on missing job ID
11+
ibm.ibm_zos_cics.stop_region:
12+
job_id: NONJOB
13+
register: stop_result
14+
ignore_errors: true
15+
16+
- name: Log output of stop
17+
ansible.builtin.debug:
18+
msg: "{{ stop_result }}"
19+
20+
- name: Assert CICS stop failed
21+
ansible.builtin.assert:
22+
that:
23+
- stop_result.failed == true
24+
- stop_result.msg == "No jobs found with id NONJOB"
25+
26+
- name: Issue shutdown command on missing job name
27+
ibm.ibm_zos_cics.stop_region:
28+
job_name: NONJOB
29+
register: stop_result
30+
ignore_errors: true
31+
32+
- name: Log output of stop
33+
ansible.builtin.debug:
34+
msg: "{{ stop_result }}"
35+
36+
- name: Assert CICS stop failed
37+
ansible.builtin.assert:
38+
that:
39+
- stop_result.failed == true
40+
- stop_result.msg == "Job with name NONJOB not found"
41+
42+
- name: Issue shutdown command on missing job name and ID
43+
ibm.ibm_zos_cics.stop_region:
44+
job_name: NONJOB
45+
job_id: NONJOB
46+
register: stop_result
47+
ignore_errors: true
48+
49+
- name: Log output of stop
50+
ansible.builtin.debug:
51+
msg: "{{ stop_result }}"
52+
53+
- name: Assert CICS stop failed
54+
ansible.builtin.assert:
55+
that:
56+
- stop_result.failed == true
57+
- stop_result.msg == "No jobs found with name NONJOB and ID NONJOB"

tests/integration/targets/cics_start_stop/playbooks/provisioning_and_deprovisioning.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
space_type: "M"
1818

1919
tasks:
20-
- name: Skip whole test if Ansible version too low
21-
when: ansible_version.minor > 11
20+
- name: Normal Start Stop
2221
block:
22+
- name: Initial normal
23+
block:
2324
- name: Create data sets
2425
ansible.builtin.import_tasks: ../repeatable_tasks/data_sets.yml
2526
vars:
@@ -33,6 +34,14 @@
3334
vars:
3435
mode: normal
3536

37+
always:
38+
- name: Delete job
39+
ansible.builtin.command:
40+
cmd: "jcan P {{ start_region_applid }} {{ start_result.job_id }}"
41+
ignore_errors: true
42+
43+
- name: Warm Immediate
44+
block:
3645
- name: Warm CICS data sets
3746
ansible.builtin.import_tasks: ../repeatable_tasks/data_sets.yml
3847
vars:
@@ -46,6 +55,14 @@
4655
vars:
4756
mode: immediate
4857

58+
always:
59+
- name: Delete job
60+
ansible.builtin.command:
61+
cmd: "jcan P {{ start_region_applid }} {{ start_result.job_id }}"
62+
ignore_errors: true
63+
64+
- name: Normal Cancel
65+
block:
4966
- name: Start CICS
5067
ansible.builtin.import_tasks: ../repeatable_tasks/start_cics.yml
5168

@@ -54,6 +71,12 @@
5471
vars:
5572
mode: cancel
5673

74+
always:
75+
- name: Delete job
76+
ansible.builtin.command:
77+
cmd: "jcan P {{ start_region_applid }} {{ start_result.job_id }}"
78+
ignore_errors: true
79+
5780
always:
5881
- name: Delete data sets
5982
ansible.builtin.import_tasks: ../repeatable_tasks/data_sets.yml
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
# (c) Copyright IBM Corp. 2024
2+
# Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0)
3+
---
4+
- name: Deprovision with job name
5+
hosts: 'all'
6+
gather_facts: false
7+
environment: "{{ environment_vars }}"
8+
9+
module_defaults:
10+
group/ibm.ibm_zos_cics.region:
11+
cics_data_sets:
12+
template: "{{ cics_install_path }}.<< lib_name >>"
13+
region_data_sets:
14+
template: "{{ region_data_set_path }}.<< data_set_name >>"
15+
space_primary: 2
16+
space_secondary: 1
17+
space_type: "M"
18+
19+
tasks:
20+
- name: Stop no args and job name
21+
block:
22+
- name: Create data sets
23+
ansible.builtin.import_tasks: ../repeatable_tasks/data_sets.yml
24+
vars:
25+
data_set_state: initial
26+
27+
- name: Start CICS (1)
28+
ansible.builtin.import_tasks: ../repeatable_tasks/start_cics.yml
29+
30+
- name: Stop with no args
31+
ibm.ibm_zos_cics.stop_region:
32+
register: stop_result
33+
timeout: 300
34+
ignore_errors: true
35+
36+
- name: Assert stop with no args failed
37+
ansible.builtin.assert:
38+
that:
39+
- stop_result.failed is true
40+
- stop_result.changed is false
41+
- "{{ stop_result.executions | length }} == 0"
42+
- stop_result.msg == "one of the following is required: job_id, job_name"
43+
44+
- name: Stop CICS using job name
45+
ansible.builtin.import_tasks: ../repeatable_tasks/stop_region.yml
46+
vars:
47+
mode: normal
48+
jobid: false
49+
jobname: true
50+
51+
- name: Stop job name and job id
52+
block:
53+
- name: Start CICS (2)
54+
ansible.builtin.import_tasks: ../repeatable_tasks/start_cics.yml
55+
56+
- name: Stop CICS with both name and ID
57+
ansible.builtin.import_tasks: ../repeatable_tasks/stop_region.yml
58+
vars:
59+
mode: normal
60+
jobname: true
61+
job_id: true
62+
63+
- name: Stop job timeout
64+
block:
65+
- name: Start CICS (3)
66+
ansible.builtin.import_tasks: ../repeatable_tasks/start_cics.yml
67+
68+
- name: Issue shutdown command (with job_id and job_name)
69+
ibm.ibm_zos_cics.stop_region:
70+
job_name: "{{ start_region_applid }}"
71+
job_id: "{{ start_result.job_id }}"
72+
mode: normal
73+
timeout: 120
74+
register: stop_result
75+
76+
- name: Log output of stop
77+
ansible.builtin.debug:
78+
msg: "{{ stop_result }}"
79+
80+
- name: Assert CICS stop did not fail
81+
ansible.builtin.assert:
82+
that:
83+
- stop_result.failed == false
84+
- stop_result.msg == ""
85+
- stop_result.executions[-1].return.failed == False
86+
- stop_result.executions[-1].return.output[0].content | length == 2
87+
- "'ON OUTPUT QUEUE' in '{{ stop_result.executions[-1].return.output[0].content | join(' ') }}'"
88+
fail_msg: "CICS Region did not stop successfully"
89+
90+
always:
91+
- name: Delete job
92+
ansible.builtin.command:
93+
cmd: "jcan P {{ start_region_applid }} {{ start_result.job_id }}"
94+
ignore_errors: true
95+
96+
- name: Stop job no timeout
97+
block:
98+
- name: Start CICS (4)
99+
ansible.builtin.import_tasks: ../repeatable_tasks/start_cics.yml
100+
101+
- name: Issue shutdown command (with job_id and job_name)
102+
ibm.ibm_zos_cics.stop_region:
103+
job_name: "{{ start_region_applid }}"
104+
job_id: "{{ start_result.job_id }}"
105+
mode: normal
106+
timeout: -1
107+
register: stop_result
108+
timeout: 300
109+
110+
- name: Log output of stop
111+
ansible.builtin.debug:
112+
msg: "{{ stop_result }}"
113+
114+
- name: Assert CICS stop did not fail
115+
ansible.builtin.assert:
116+
that:
117+
- stop_result.failed != True
118+
- stop_result.msg == ""
119+
- stop_result.executions[-1].return.failed == False
120+
- stop_result.executions[-1].return.output[0].content | length == 2
121+
- "'ON OUTPUT QUEUE' in '{{ stop_result.executions[-1].return.output[0].content | join(' ') }}'"
122+
fail_msg: "CICS Region did not stop successfully"
123+
124+
- name: Stop job mismatched name and ID
125+
block:
126+
- name: Start CICS (5)
127+
ansible.builtin.import_tasks: ../repeatable_tasks/start_cics.yml
128+
129+
- name: Issue shutdown command (wrong id)
130+
ibm.ibm_zos_cics.stop_region:
131+
job_name: "{{ start_region_applid }}"
132+
job_id: "NONJOB"
133+
register: stop_result
134+
timeout: 300
135+
ignore_errors: true
136+
137+
- name: Log output of stop
138+
ansible.builtin.debug:
139+
msg: "{{ stop_result }}"
140+
141+
- name: Assert CICS stop did not fail
142+
ansible.builtin.assert:
143+
that:
144+
- stop_result.failed == true
145+
- stop_result.msg == "No jobs found with name TWYD01 and ID NONJOB"
146+
147+
- name: Issue shutdown command (wrong name)
148+
ibm.ibm_zos_cics.stop_region:
149+
job_name: "NONJOB"
150+
job_id: "{{ start_result.job_id }}"
151+
register: stop_result
152+
timeout: 300
153+
ignore_errors: true
154+
155+
- name: Log output of stop
156+
ansible.builtin.debug:
157+
msg: "{{ stop_result }}"
158+
159+
- name: Assert CICS stop did not fail
160+
ansible.builtin.assert:
161+
that:
162+
- stop_result.failed == true
163+
- stop_result.msg == "No jobs found with name NONJOB and ID {{ start_result.job_id }}"
164+
always:
165+
- name: Delete job
166+
ansible.builtin.command:
167+
cmd: "jcan C {{ start_region_applid }} {{ start_result.job_id }}"
168+
ignore_errors: true
169+
170+
- name: Stop job already stopped
171+
block:
172+
- name: Issue shutdown command with name
173+
ibm.ibm_zos_cics.stop_region:
174+
job_name: "{{ start_region_applid }}"
175+
register: stop_result
176+
- name: Assert CICS stop did not fail
177+
ansible.builtin.assert:
178+
that:
179+
- stop_result.failed == false
180+
- stop_result.changed == false
181+
- stop_result.msg == ""
182+
- name: Issue shutdown command with ID
183+
ibm.ibm_zos_cics.stop_region:
184+
job_id: "{{ start_result.job_id }}"
185+
register: stop_result
186+
- name: Assert CICS stop did not fail
187+
ansible.builtin.assert:
188+
that:
189+
- stop_result.failed == false
190+
- stop_result.changed == false
191+
- stop_result.msg == ""
192+
- name: Issue shutdown command with ID and name
193+
ibm.ibm_zos_cics.stop_region:
194+
job_id: "{{ start_result.job_id }}"
195+
job_name: "{{ start_region_applid }}"
196+
register: stop_result
197+
- name: Assert CICS stop did not fail
198+
ansible.builtin.assert:
199+
that:
200+
- stop_result.failed == false
201+
- stop_result.changed == false
202+
- stop_result.msg == ""
203+
204+
- name: Issue shutdown command with mismatched name and id (wrong name)
205+
ibm.ibm_zos_cics.stop_region:
206+
job_id: "{{ start_result.job_id }}"
207+
job_name: "NONJOB"
208+
register: stop_result
209+
ignore_errors: true
210+
- name: Assert CICS stop did not fail
211+
ansible.builtin.assert:
212+
that:
213+
- stop_result.failed == true
214+
- stop_result.changed == false
215+
- stop_result.msg == "No jobs found with name NONJOB and ID {{ start_result.job_id }}"
216+
- name: Issue shutdown command with mismatched name and id (wrong id)
217+
ibm.ibm_zos_cics.stop_region:
218+
job_id: "NONJOB"
219+
job_name: "{{ start_region_applid }}"
220+
register: stop_result
221+
ignore_errors: true
222+
- name: Assert CICS stop did not fail
223+
ansible.builtin.assert:
224+
that:
225+
- stop_result.failed == true
226+
- stop_result.changed == false
227+
- stop_result.msg == "No jobs found with name {{ start_region_applid }} and ID NONJOB"
228+
229+
always:
230+
- name: Delete job
231+
ansible.builtin.command:
232+
cmd: "jcan P {{ start_region_applid }} {{ start_result.job_id }}"
233+
ignore_errors: true
234+
- name: Delete data sets
235+
ansible.builtin.import_tasks: ../repeatable_tasks/data_sets.yml
236+
vars:
237+
data_set_state: absent

0 commit comments

Comments
 (0)