Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mv_jobwaitfor.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mv_jobwaitfor macro
4 @details Submits a job and waits for it with the uri in both accepted
5 forms (plain job uri and state link), verifying the output dataset
6 always carries the plain job uri and that no macro variables leak
7 scope.
8
9 The child job is created under the JES job's own user folder
10 (rather than mcTestAppLoc) so the test is independent of the
11 identity the test session runs as.
12
13 <h4> SAS Macros </h4>
14 @li mp_assert.sas
15 @li mp_assertscope.sas
16 @li mf_getapploc.sas
17 @li mv_createjob.sas
18 @li mv_jobexecute.sas
19 @li mv_jobwaitfor.sas
20
21**/
22
23/* create the child job under the deployed appLoc (derived from
24 _program at runtime) so the test works whichever identity runs
25 it and whichever appLoc it is deployed to - the appLoc folder is
26 always writable by the test session, since the deploy itself
27 created it */
28%let testloc=%mf_getapploc(&_program)/tests/mv_jobwaitfor_test;
29
30filename testprog temp;
31data _null_;
32 file testprog;
33 put 'data;run;';
34run;
35%mv_createjob(path=&testloc,name=waitjob,code=testprog)
36
37/**
38 * Test Case 1 - wait with the plain job uri (no /state suffix)
39 */
40%mv_jobexecute(
41 path=&testloc,
42 name=waitjob,
43 outds=work.info
44)
45
46/* keep only the state link, then strip the /state suffix - this
47 submits the plain job uri to mv_jobwaitfor */
48data work.plainuri;
49 set work.info;
50 where method='GET' and rel='state';
51 uri=substr(uri,1,length(uri)-6);
52run;
53
54%mp_assertscope(SNAPSHOT)
55%mv_jobwaitfor(ALL,inds=work.plainuri,outds=work.jobstates1)
56%mp_assertscope(COMPARE)
57
58%mp_assert(
59 iftrue=(%sysfunc(attrn(%sysfunc(open(work.jobstates1)),NOBS))=1),
60 desc=mv_jobwaitfor completed the job from a plain uri
61)
62
63data _null_;
64 set work.jobstates1;
65 call symputx('goturi',uri);
66run;
67
68%mp_assert(
69 iftrue=(%symexist(goturi) and %length(&goturi)=55),
70 desc=outds uri is the plain 55-char job uri
71)
72
73/**
74 * Test Case 2 - wait with the state link (with /state suffix)
75 */
76%mv_jobexecute(
77 path=&testloc,
78 name=waitjob,
79 outds=work.info2
80)
81
82/* this time pass the state link as-is (with the /state suffix) */
83data work.statelink;
84 set work.info2;
85 where method='GET' and rel='state';
86run;
87
88%mp_assertscope(SNAPSHOT)
89%mv_jobwaitfor(ALL,inds=work.statelink,outds=work.jobstates2)
90%mp_assertscope(COMPARE)
91
92%mp_assert(
93 iftrue=(%sysfunc(attrn(%sysfunc(open(work.jobstates2)),NOBS))=1),
94 desc=mv_jobwaitfor completed the job from a state link
95)
96
97data _null_;
98 set work.jobstates2;
99 call symputx('goturi2',uri);
100run;
101
102%mp_assert(
103 iftrue=(%symexist(goturi2) and %length(&goturi2)=55),
104 desc=outds uri from state link is also the plain 55-char job uri
105)