Skip to content
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
8 changes: 4 additions & 4 deletions code/segmentedtickerplant/pubsub.q
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@

// Check for end of day/period and call inner UPD function
.stpps.upd.def:{[t;x]
if[.stplg.nextendUTC<now:.z.p;.stplg.checkends now];
if[.stplg.nextendUTC<now:.proc.cp[];.stplg.checkends now];
// Type check allows update messages to contain multiple tables/data
$[0h<type t;.stplg.updmsg'[t;x;now+.eodtime.dailyadj];.stplg.updmsg[t;x;now+.eodtime.dailyadj]];
.stplg.seqnum+:1;
};

// Don't check for period/day end if process is chained STP
.stpps.upd.chained:{[t;x]
now:.z.p;
now:.proc.cp[];
$[0h<type t;.stplg.updmsg'[t;x;now+.eodtime.dailyadj];.stplg.updmsg[t;x;now+.eodtime.dailyadj]];
.stplg.seqnum+:1;
};

// Call inner ZTS function and check for end of day/period
.stpps.zts.def:{
.stplg.ts now:.z.p;
.stplg.ts now:.proc.cp[];
.stplg.checkends now
};

// Don't check for period/day end if process is chained STP
.stpps.zts.chained:{
.stplg.ts now:.z.p
.stplg.ts now:.proc.cp[]
};
4 changes: 2 additions & 2 deletions tests/stp/pubsub/process.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
host,port,proctype,procname,U,localtime,g,T,w,load,startwithall,extras,qcmd
localhost,{KDBBASEPORT}+100,discovery,discovery1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/discovery.q,1,,q
localhost,{KDBBASEPORT}+101,pubsub,ps1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBTESTS}/stp/pubsub/ps.q,1,,q
localhost,{KDBBASEPORT}+100,discovery,discovery1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/discovery.q,1,,q
localhost,{KDBBASEPORT}+101,pubsub,ps1,${TORQAPPHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBTESTS}/stp/pubsub/ps.q,1,,q
2 changes: 1 addition & 1 deletion tests/stp/pubsub/ps.q
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Load in table schemas, pubsub is loaded by torq.q
.proc.loadf[getenv[`TORQHOME],"/database.q"];
.proc.loadf[getenv[`TORQAPPHOME],"/database.q"];
14 changes: 7 additions & 7 deletions tests/stp/pubsub/pubsub.csv
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ run,0,0,q,neg[psHandle](`.stpps.pubclear;`trade),1,,"Call pubclear funtion"
true,0,0,q,0~count psHandle(`trade),1,,"Check that trade table has been cleared"
run,0,0,q,upd:upsert,1,,"Define upd for sub filter tests"
true,0,0,q,0~.tst.upd,1,,"Check that local UPD function has been called"
run,0,0,q,rdbHandle(`.u.sub;`trade;`AAPL`GOOG),1,,"Subscribe to filtered sym list"
run,0,0,q,rdbHandle"test:select from trade where i=(last;i)fby sym",1,,"Define set data to compare filter against"
run,0,0,q,rdbHandle".u.pub[`trade;test]",1,,"Force publish for the filtered list to check it is working as intended"
true,0,0,q,trade~rdbHandle"(select from test where sym in `AAPL`GOOG)",1,,"Check that published filtered sym list is same as select statement"
run,0,0,q,rdbHandle(`.u.sub;`trade;`AAPL`GOOG`MSFT),1,,"Re-subscribe with additional sym in the filtered sym list"
run,0,0,q,psHandle(`.u.sub;`trade;`AAPL`GOOG),1,,"Subscribe to filtered sym list"
run,0,0,q,psHandle"test:select from trade where i=(last;i)fby sym",1,,"Define set data to compare filter against"
run,0,0,q,psHandle".u.pub[`trade;test]",1,,"Force publish for the filtered list to check it is working as intended"
true,0,0,q,trade~psHandle"(select from test where sym in `AAPL`GOOG)",1,,"Check that published filtered sym list is same as select statement"
run,0,0,q,psHandle(`.u.sub;`trade;`AAPL`GOOG`MSFT),1,,"Re-subscribe with additional sym in the filtered sym list"
run,0,0,q,trade:0#trade,1,,"Empty local trade table to make sure nothing is in it before publishing filtered sym list"
run,0,0,q,rdbHandle".u.pub[`trade;test]",1,,"Force publish filter list again with updated sym list publishing to empty trade table"
true,0,0,q,trade~rdbHandle"(select from test where sym in `AAPL`GOOG`MSFT)",1,,"Check that updated published filtered sym list is same as select statement"
run,0,0,q,psHandle".u.pub[`trade;test]",1,,"Force publish filter list again with updated sym list publishing to empty trade table"
true,0,0,q,trade~psHandle"(select from test where sym in `AAPL`GOOG`MSFT)",1,,"Check that updated published filtered sym list is same as select statement"

1 change: 1 addition & 0 deletions tests/stp/pubsub/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ${TORQHOME}/torq.sh start discovery1 ps1 -csv ${testpath}/process.csv
-load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \
-testresults ${KDBTESTS}/stp/results/ \
-procfile ${testpath}/process.csv \
-debug \
-runtime $run \
$debug $stop $write $quiet

Expand Down
2 changes: 1 addition & 1 deletion tests/stp/pubsub/settings.q
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.servers.USERPASS:`admin:admin;

// Path to table schemas
schemapath:getenv[`TORQHOME],"/database.q";
schemapath:getenv[`TORQAPPHOME],"/database.q";

// Keyed sub table
ksubtab:1!enlist `tabname`filters`columns!(`trade;"sym in `GOOG`AMZN,price>80";"time,sym,price");
Expand Down