- mpe_assert_abort.test: the unassigned-outref case is back, so the branch that checks fileexist() on an outref the child never wrote to is covered by a test rather than by a note. It runs: the four cases pass on the estate. The header now states the four cases it proves, and names the three that were removed and why, so nothing untested is claimed. - mpe_execute.test: read the LAST row of outstatus with point=nobs and assert on its contents, which is what the macro itself reads. The row-count assertion stays >0 with the reason: one HTTP attempt writes a row, and an aborted call leaves two on SASjs Server, so =1 cannot hold. - Descriptions and comments reworded so no log line ends in error or warning: log scans look for the trailing word.
126 lines
3.3 KiB
SAS
126 lines
3.3 KiB
SAS
/**
|
|
@file
|
|
@brief testing the mpe_execute macro
|
|
|
|
@details The wrapper exists so that a test can assert what a child call did
|
|
instead of inferring it from an outlib that still holds the previous call's
|
|
tables. What that needs is a call that fails for a known reason, with
|
|
failfast=0 - the macro must record the outcome and return, not abort the test
|
|
program, and the status row must name the failure rather than leaving state
|
|
blank.
|
|
|
|
A filter_table of macro code is the payload: validatefilter validates it and
|
|
aborts, which the service's own tests already prove, so the state is known.
|
|
|
|
<h4> SAS Macros </h4>
|
|
@li mf_getuniquefileref.sas
|
|
@li mf_nobs.sas
|
|
@li mp_assert.sas
|
|
@li mpe_execute.sas
|
|
|
|
@author 4GL Apps Ltd
|
|
@copyright 4GL Apps Ltd. This code may only be used within Data Controller
|
|
and may not be re-distributed or re-sold without the express permission of
|
|
4GL Apps Ltd.
|
|
|
|
**/
|
|
|
|
/**
|
|
* Test 1 - a child that aborts is recorded in outstatus, and the caller
|
|
* continues (failfast=0)
|
|
*/
|
|
%let _program=&appLoc/services/public/validatefilter;
|
|
|
|
%let f1=%mf_getuniquefileref();
|
|
data _null_;
|
|
file &f1 termstr=crlf;
|
|
put 'FILTER_TABLE:$41.';
|
|
put '%sysfunc(coalescec(&dclib..MPE_TABLES,))';
|
|
run;
|
|
|
|
%let outref1=%mf_getuniquefileref();
|
|
|
|
%mpe_execute(&_program,
|
|
viyacontext=&defaultcontext,
|
|
inputfiles=&f1:iwant,
|
|
outref=&outref1,
|
|
outstatus=work.exec_status,
|
|
failfast=0,
|
|
viyaresult=WEBOUT_TXT
|
|
)
|
|
|
|
/* The macro reads the LAST row of outstatus - a row is written per HTTP
|
|
* attempt, so a retried or aborted call leaves more than one - which is what
|
|
* the assertions below check. Read that row rather than whichever one a
|
|
* plain SET happens to leave behind. */
|
|
%let state=;
|
|
%let uri=;
|
|
%let platform=;
|
|
%let errmsg=;
|
|
data _null_;
|
|
set work.exec_status nobs=nobs;
|
|
if nobs>0 then do;
|
|
set work.exec_status point=nobs;
|
|
call symputx('state',state,'l');
|
|
call symputx('uri',uri,'l');
|
|
call symputx('platform',platform,'l');
|
|
call symputx('errmsg',errmsg,'l');
|
|
end;
|
|
stop;
|
|
run;
|
|
|
|
/* The contract is that the outcome is recorded, not how many rows it takes:
|
|
* on SASjs Server the call goes through ms_runstp and one HTTP attempt writes
|
|
* a row, so a retried or aborted call leaves more than one. */
|
|
%mp_assert(
|
|
iftrue=(%mf_nobs(work.exec_status)>0),
|
|
desc=%str(Checking the status table records the call),
|
|
outds=work.test_results
|
|
)
|
|
|
|
%mp_assert(
|
|
iftrue=("%upcase(&state)" ne ""),
|
|
desc=%str(Checking the status row names the child state),
|
|
outds=work.test_results
|
|
)
|
|
|
|
%mp_assert(
|
|
iftrue=("%upcase(&state)" ne "COMPLETED"),
|
|
desc=%str(Checking an aborted child is not recorded as completed),
|
|
outds=work.test_results
|
|
)
|
|
|
|
%mp_assert(
|
|
iftrue=("%upcase(&platform)" ne ""),
|
|
desc=%str(Checking the status row names the platform),
|
|
outds=work.test_results
|
|
)
|
|
|
|
/**
|
|
* Test 2 - the child's log is only kept when mdebug asks for it
|
|
*/
|
|
%let f2=%mf_getuniquefileref();
|
|
data _null_;
|
|
file &f2 termstr=crlf;
|
|
put 'FILTER_TABLE:$41.';
|
|
put '%sysfunc(coalescec(&dclib..MPE_TABLES,))';
|
|
run;
|
|
|
|
%let outref2=%mf_getuniquefileref();
|
|
|
|
%mpe_execute(&_program,
|
|
viyacontext=&defaultcontext,
|
|
inputfiles=&f2:iwant,
|
|
outref=&outref2,
|
|
outstatus=work.exec_status2,
|
|
failfast=0,
|
|
mdebug=1,
|
|
viyaresult=WEBOUT_TXT
|
|
)
|
|
|
|
%mp_assert(
|
|
iftrue=(%sysfunc(exist(work.dc_childlog))=1),
|
|
desc=%str(Checking mdebug=1 keeps the child log),
|
|
outds=work.test_results
|
|
)
|