Skip to content

Commit 3d38011

Browse files
[Bugfix][1239][zos job submit]max_rc_more_than_0_doesn_not_put_change_as_true (#1345)
* First iteration of solution * Change dataset * Ensure all cases for false * Remove print * Change behavior for bugfix * Add fragment * Fix latest lower case * Fix uppercase * Remove typo * Remove typo * Fix redundance * Fix test and upper cases * Fix test case * Fix fragment * Return to lower case * Return to lower case --------- Co-authored-by: Fernando Flores <[email protected]>
1 parent 7abaa36 commit 3d38011

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bugfixes:
2+
- zos_job_submit - when the argument max_rc was different than 0 the changed response returned
3+
as false. Fix now return a changed response as true when the rc is not 0 and max_rc is above
4+
or equal to the value of the job.
5+
(https://github.com/ansible-collections/ibm_zos_core/pull/1345).

plugins/modules/zos_job_submit.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,9 @@ def assert_valid_return_code(max_rc, job_rc, ret_code, result):
11081108
# should NOT be 'changed=true' even though the user did override the return code,
11091109
# a non-zero return code means the job did not change anything, so set it as
11101110
# result["chagned"]=False,
1111-
if job_rc != 0:
1111+
if max_rc and job_rc > max_rc:
1112+
return False
1113+
elif job_rc != 0 and max_rc is None:
11121114
return False
11131115

11141116
return True

tests/functional/modules/test_zos_fetch_func.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,12 @@ def test_fetch_sequential_data_set_replace_on_local_machine(ansible_zos_module):
539539
ds_name = TEST_PS
540540
hosts.all.zos_data_set(name=TEST_PS, state="present")
541541
hosts.all.shell(cmd="decho \"{0}\" \"{1}\"".format(TEST_DATA, TEST_PS))
542-
dest_path = "/tmp/" + ds_name
542+
dest_path = "/tmp/" + TEST_PS
543543
with open(dest_path, "w") as infile:
544544
infile.write(DUMMY_DATA)
545545

546546
local_checksum = checksum(dest_path, hash_func=sha256)
547-
params = dict(src=ds_name, dest="/tmp/", flat=True)
547+
params = dict(src=TEST_PS, dest="/tmp/", flat=True)
548548
try:
549549
results = hosts.all.zos_fetch(**params)
550550
for result in results.contacted.values():
@@ -562,6 +562,7 @@ def test_fetch_partitioned_data_set_replace_on_local_machine(ansible_zos_module)
562562
pds_name = get_tmp_ds_name()
563563
dest_path = "/tmp/" + pds_name
564564
full_path = dest_path + "/MYDATA"
565+
pds_name_mem = pds_name + "(MYDATA)"
565566
hosts.all.zos_data_set(
566567
name=pds_name,
567568
type="pds",

tests/functional/modules/test_zos_job_submit_func.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,11 +713,11 @@ def test_job_submit_max_rc(ansible_zos_module, args):
713713
assert re.search(r'the submitted job is greater than the value set for option', repr(result.get("msg")))
714714

715715
elif args["max_rc"] == 12:
716-
# Will not fail but changed will be false for the non-zero RC, there
717-
# are other possibilities like an ABEND or JCL ERROR will fail this even
716+
# Will not fail and as the max_rc is set to 12 and the rc is 8 is a change true
717+
# there are other possibilities like an ABEND or JCL ERROR will fail this even
718718
# with a MAX RC
719719
assert result.get("msg") is None
720-
assert result.get('changed') is False
720+
assert result.get('changed') is True
721721
assert result.get("jobs")[0].get("ret_code").get("code") < 12
722722
finally:
723723
hosts.all.file(path=tmp_file.name, state="absent")

0 commit comments

Comments
 (0)