Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add copy lib member test case for 1.5.0 #736

Merged
merged 4 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions changelogs/fragments/601-copy-loadlib-member.yml

This file was deleted.

3 changes: 3 additions & 0 deletions changelogs/fragments/641-copy-loadlib-member.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bugfixes:
- zos_copy - Copy failed from a loadlib member to another loadlib member. Fix now looks for error in stdout in the if statement to use -X option.
(https://github.com/ansible-collections/ibm_zos_core/pull/641)
88 changes: 88 additions & 0 deletions tests/functional/modules/test_zos_copy_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,58 @@
TEST_PDSE = "SYS1.NFSLIBE"
TEST_PDSE_MEMBER = "SYS1.NFSLIBE(GFSAMAIN)"

COBOL_SRC = """
IDENTIFICATION DIVISION.\n
PROGRAM-ID. HELLOWRD.\n
\n
PROCEDURE DIVISION.\n
DISPLAY "SIMPLE HELLO WORLD".\n
STOP RUN.\n
"""

LINK_JCL = """
//COMPLINK JOB MSGCLASS=H,MSGLEVEL=(1,1),NOTIFY=&SYSUID,REGION=0M
//STEP1 EXEC PGM=IGYCRCTL
//STEPLIB DD DSN=IGYV5R10.SIGYCOMP,DISP=SHR
// DD DSN=IGYV5R10.SIGYMAC,DISP=SHR
//SYSIN DD DISP=SHR,DSN={0}
//SYSPRINT DD SYSOUT=*
//SYSLIN DD UNIT=SYSDA,DISP=(MOD),
// SPACE=(CYL,(1,1)),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920),
// DSN=&&LOADSET
//SYSUT1 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT2 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT3 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT4 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT5 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT6 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT7 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT8 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT9 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT10 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT11 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT12 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT13 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT14 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSUT15 DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//SYSMDECK DD SPACE=(80,(10,10),,,ROUND),UNIT=SYSDA
//*
//LKED EXEC PGM=IEWL,REGION=0M
//SYSPRINT DD SYSOUT=*
//SYSLIB DD DSN=CEE.SCEELKED,DISP=SHR
// DD DSN=CEE.SCEELKEX,DISP=SHR
//SYSLMOD DD DSN={1},
// DISP=SHR
//SYSUT1 DD UNIT=SYSDA,DCB=BLKSIZE=1024,
// SPACE=(TRK,(3,3))
//SYSTERM DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSLIN DD DSN=&&LOADSET,DISP=(OLD,KEEP)
//SYSIN DD DUMMY
//*

"""

def populate_dir(dir_path):
for i in range(5):
Expand Down Expand Up @@ -153,6 +205,42 @@ def create_vsam_data_set(hosts, name, ds_type, add_data=False, key_length=None,
hosts.all.file(path=record_src, state="absent")


def link_loadlib_from_cobol(hosts, ds_name, cobol_pds):
"""
Given a PDSE, links a cobol program making allocated in a temp ds resulting in ds_name
as a loadlib.

Arguments:
ds_name (str) -- PDS/E to be linked with the cobol program.
cobol_src (str) -- Cobol source code to be used as the program.

Notes: PDS names are in the format of SOME.PDSNAME(MEMBER)
"""
# Copy the Link program
temp_jcl = "/tmp/link.jcl"
rc = 0
try:
cp_res = hosts.all.zos_copy(
content=LINK_JCL.format(cobol_pds, ds_name),
dest="/tmp/link.jcl",
force=True,
)
for res in cp_res.contacted.values():
print("copy link program result {0}".format(res))
# Link the temp ds with ds_name
job_result = hosts.all.zos_job_submit(
src="/tmp/link.jcl",
location="USS",
wait_time_s=60
)
for result in job_result.contacted.values():
print("link job submit result {0}".format(result))
rc = result.get("jobs")[0].get("ret_code").get("code")
finally:
hosts.all.file(path=temp_jcl, state="absent")
return rc


@pytest.mark.uss
@pytest.mark.parametrize("src", [
dict(src="/etc/profile", is_file=True, is_binary=False, is_remote=False),
Expand Down