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 mf_getplatform.sas
18 @li mv_createjob.sas
19 @li mv_jobexecute.sas
20 @li mv_jobwaitfor.sas
21
22**/
23
24/* create the child job under the deployed appLoc (derived from
25 _program at runtime) so the test works whichever identity runs
26 it and whichever appLoc it is deployed to - the appLoc folder is
27 always writable by the test session, since the deploy itself
28 created it */
29%let testloc=%mf_getapploc(&_program)/tests/mv_jobwaitfor_test;
30
31filename testprog temp;
32data _null_;
33 file testprog;
34 put 'data;run;';
35run;
36%mv_createjob(path=&testloc,name=waitjob,code=testprog)
37
38/**
39 * Test Case 1 - wait with the plain job uri (no /state suffix)
40 */
41%mv_jobexecute(
42 path=&testloc,
43 name=waitjob,
44 outds=work.info
45)
46
47/* keep only the state link, then strip the /state suffix - this
48 submits the plain job uri to mv_jobwaitfor */
49data work.plainuri;
50 set work.info;
51 where method='GET' and rel='state';
52 uri=substr(uri,1,length(uri)-6);
53run;
54
55%mp_assertscope(SNAPSHOT)
56%mv_jobwaitfor(ALL,inds=work.plainuri,outds=work.jobstates1)
57%mp_assertscope(COMPARE)
58
59%mp_assert(
60 iftrue=(%sysfunc(attrn(%sysfunc(open(work.jobstates1)),NOBS))=1),
61 desc=mv_jobwaitfor completed the job from a plain uri
62)
63
64data _null_;
65 set work.jobstates1;
66 call symputx('goturi',uri);
67run;
68
69%mp_assert(
70 iftrue=(%symexist(goturi) and %length(&goturi)=55),
71 desc=outds uri is the plain 55-char job uri
72)
73
74/**
75 * Test Case 2 - wait with the state link (with /state suffix)
76 */
77%mv_jobexecute(
78 path=&testloc,
79 name=waitjob,
80 outds=work.info2
81)
82
83/* this time pass the state link as-is (with the /state suffix) */
84data work.statelink;
85 set work.info2;
86 where method='GET' and rel='state';
87run;
88
89%mp_assertscope(SNAPSHOT)
90%mv_jobwaitfor(ALL,inds=work.statelink,outds=work.jobstates2)
91%mp_assertscope(COMPARE)
92
93%mp_assert(
94 iftrue=(%sysfunc(attrn(%sysfunc(open(work.jobstates2)),NOBS))=1),
95 desc=mv_jobwaitfor completed the job from a state link
96)
97
98data _null_;
99 set work.jobstates2;
100 call symputx('goturi2',uri);
101run;
102
103%mp_assert(
104 iftrue=(%symexist(goturi2) and %length(&goturi2)=55),
105 desc=outds uri from state link is also the plain 55-char job uri
106)