From 53ebddc6d987ab25f9b4bbabb1afa6f77c2329f4 Mon Sep 17 00:00:00 2001 From: Marcos Jaen Date: Wed, 4 Nov 2026 23:47:11 -0500 Subject: [PATCH 1/7] Fix two bugs which break TorQ on every engine, kdb+ included - code/common/dbwriteutils.q: the default .save.postreplay was a projection of the error string (the trap passes the error to its handler), so every end-of-day which called .save.postreplay[dir;date] stopped with 'rank (introduced by #762) - code/common/html.q: wssub called sub, which builds a table schema, and the monitor's start subscribes lmchart, a function: 'type, so the monitor's start never completed - tests/bugfixes: k4unit tests for both --- code/common/dbwriteutils.q | 2 +- code/common/html.q | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/common/dbwriteutils.q b/code/common/dbwriteutils.q index 97a997fb5..f3bdc6a72 100644 --- a/code/common/dbwriteutils.q +++ b/code/common/dbwriteutils.q @@ -79,7 +79,7 @@ manipulate:{[t;x] /- post eod/replay, this is called after the date has been persisted to disk and sorted and /- takes a directory (typically hdb directory) and partition value as parameters -postreplay:@[value;`postreplay;{[d;p] }]; +postreplay:@[value;`postreplay;{[e] {[d;p] }}]; / - functions for running and descriptively logging garbage collection \d .gc diff --git a/code/common/html.q b/code/common/html.q index c927c8272..cbe6a1262 100644 --- a/code/common/html.q +++ b/code/common/html.q @@ -39,7 +39,7 @@ add:{$[(count w x)>i:w[x;;0]?.z.w;.[`.u.w;(x;i;1);union;y];w[x],:enlist(.z.w;y)] sub:{if[x~`;:sub[;y]each t];if[not x in t;'x];del[x].z.w;add[x;y]} // add wssub method - have to subscribe to everything, don't return anything -wssub:{sub[x;`];} +wssub:{if[x~`;.z.s each t;:(::)];if[not x in t;'x];del[x].z.w;w[x],:enlist(.z.w;`);} end:{(neg union/[w[;;0]])@\:(`.u.end;x)} From 21b255aadeca769060d8161af2a82ffd92756059 Mon Sep 17 00:00:00 2001 From: Marcos Jaen Date: Wed, 11 Nov 2026 01:42:02 +0000 Subject: [PATCH 2/7] tests/stp/wdb: check the WDB's end-of-day hook .save.postreplay partbyenum.csv triggers a WDB end of day and then checks the HDB. Before the dbwriteutils.q fix in this PR, the default .save.postreplay stopped that end of day with 'rank, so the trigger and both HDB checks failed. The new row calls the WDB's hook with (dir;date), as wdb.q does at end of day, so a regression fails with its cause named. On KDB-X, master vs this PR: the trigger, the two HDB checks and the new row fail on master and pass here; every other test is unchanged. --- tests/stp/wdb/partbyenum.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/stp/wdb/partbyenum.csv b/tests/stp/wdb/partbyenum.csv index 2fae50992..c7278d2bc 100644 --- a/tests/stp/wdb/partbyenum.csv +++ b/tests/stp/wdb/partbyenum.csv @@ -26,6 +26,7 @@ run,0,0,q,wdbHandle(`.u.end;`.wdb.currentpartition),1,,"Trigger EOD on WDB" run,0,0,q,.proc.sys "sleep 3",1,,"Wait for merge to HDB to happen" true,0,0,q,(2*count[first testtrade])~hdbHandle "count select from trade",1,,"Check trade in hdb" true,0,0,q,(2*count[first testquote])~hdbHandle "count select from quote",1,,"Check quote in hdb" +true,0,0,q,(::)~wdbHandle(`.save.postreplay;`:/tmp;2026.01.01),1,,"Check the WDB's end-of-day hook .save.postreplay takes (dir;date)" after,0,0,q,kill9proc each ("stpnone";"wdbenum";"hdb1"),1,,"Stop all procs" after,0,0,q,.os.deldir logdir,1,,"Delete test segmented tickerplant logs" after,0,0,q,.os.deldir 1_string temphdbdir,1,,"Delete temp HDB" From c36c01187820d6303543eaa92fbc8f94b569a8df Mon Sep 17 00:00:00 2001 From: Marcos Jaen Date: Wed, 11 Nov 2026 01:52:13 +0000 Subject: [PATCH 3/7] tests/monitor: the monitor's start and .html.wssub A new suite which starts a monitor and calls start, as its web page does on every connection. start subscribes heartbeat, logmsg and lmchart with .html.wssub; lmchart is a function, and the original wssub stopped with 'type on it, so start never returned its data. The checks: start runs; calling it twice leaves one subscription each; each subscription is the handle and ` (all syms), as the original wssub registers for a table; wssub ` subscribes every value; an unknown name is still rejected. Master fails the start and wssub ` checks with 'type; with the html.q fix in this PR all pass on KDB-X, and with #769 also on L and PeachQ. --- tests/monitor/monitor.csv | 9 +++++++++ tests/monitor/process.csv | 3 +++ tests/monitor/run.sh | 23 +++++++++++++++++++++++ tests/monitor/settings.q | 7 +++++++ 4 files changed, 42 insertions(+) create mode 100644 tests/monitor/monitor.csv create mode 100644 tests/monitor/process.csv create mode 100755 tests/monitor/run.sh create mode 100644 tests/monitor/settings.q diff --git a/tests/monitor/monitor.csv b/tests/monitor/monitor.csv new file mode 100644 index 000000000..2210f0283 --- /dev/null +++ b/tests/monitor/monitor.csv @@ -0,0 +1,9 @@ +action,ms,bytes,lang,code,repeat,minver,comment +before,0,0,q,.servers.startup[],1,,"Start TorQ connection management" +before,0,0,q,monHandle:gethandle[`monitor1],1,,"Open monitor handle" +true,0,0,q,@[{monHandle"start[]";1b};::;0b],1,,"start runs: .html.wssub subscribes lmchart, a function (it used to stop with 'type)" +run,0,0,q,"monHandle""start[]""",1,,"Call start again, as a refresh of the page does" +true,0,0,q,(1 1 1)~count each monHandle(`.html.w;monsubs),1,,"Calling start twice leaves one subscription each" +true,0,0,q,"all {(-6h=type x 0) and ` ~ x 1} each raze monHandle(`.html.w;monsubs)",1,,"Each subscription is the handle and ` (all syms), as the original wssub registers for a table" +true,0,0,q,"@[{monHandle(`.html.wssub;`);1b};::;0b]",1,,"wssub ` subscribes every value the monitor publishes (it used to stop with 'type)" +true,0,0,q,"0b~@[{monHandle(`.html.wssub;`nosuch);1b};::;0b]",1,,"wssub of a name the monitor does not publish is rejected, as before" diff --git a/tests/monitor/process.csv b/tests/monitor/process.csv new file mode 100644 index 000000000..3ebdaa08a --- /dev/null +++ b/tests/monitor/process.csv @@ -0,0 +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,monitor,monitor1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/monitor.q,1,,q diff --git a/tests/monitor/run.sh b/tests/monitor/run.sh new file mode 100755 index 000000000..c0d0260a4 --- /dev/null +++ b/tests/monitor/run.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Handle command-line arguments +source $KDBTESTS/flagparse.sh + +# Path to test directory +testpath=${KDBTESTS}/monitor + +# Start procs +${TORQHOME}/torq.sh start discovery1 monitor1 -csv ${testpath}/process.csv + +# Start test proc +/usr/bin/rlwrap q ${TORQHOME}/torq.q \ + -proctype test -procname test1 \ + -test ${testpath} \ + -load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \ + -testresults ${KDBTESTS}/monitor/results/ \ + -runtime $run \ + -procfile ${testpath}/process.csv \ + $debug $stop $write $quiet + +# Shut down procs +${TORQHOME}/torq.sh stop discovery1 monitor1 -csv ${testpath}/process.csv diff --git a/tests/monitor/settings.q b/tests/monitor/settings.q new file mode 100644 index 000000000..82a716199 --- /dev/null +++ b/tests/monitor/settings.q @@ -0,0 +1,7 @@ +// IPC connection parameters +.servers.CONNECTIONS:`monitor; +.servers.USERPASS:`admin:admin; + +// the monitor's web page calls start on every connection, which subscribes these with .html.wssub +// (heartbeat and logmsg are tables, lmchart is a function) +monsubs:`heartbeat`logmsg`lmchart; From 929d17d2e91bc43b73e958aa006299e404d4123a Mon Sep 17 00:00:00 2001 From: Marcos Jaen Date: Thu, 12 Nov 2026 20:23:41 +0000 Subject: [PATCH 4/7] Fix three tickerplant bugs and the stale tests which were hiding them Running the tickerplant suites on several engines turned up failures that are not engine differences at all: they fail on kdb+ on master. Three are bugs in the segmented tickerplant, and the rest are tests that fell behind the code. All of it is in tests/stp or the code those tests exercise. Tickerplant bugs - End of day and end of period called .stpps.pubclear[.stplg.t]. That list is every table in the process, including logmsg, but pubclear resets each table from the publish schemas, which since #638 have no entry for logmsg. A dictionary of tables returns an empty copy of its first table for a key it doesn't have, so at every roll logmsg was quietly replaced by an empty table with another table's columns. The three calls now pass .stpps.t, as the batch code already does. - The exit handler closed .stpps.t, the published tables, although a log is opened for every table. On a clean shutdown the logmsg log stayed open and its row in the meta table kept a null end time. It now closes .stplg.logtabs, the same list end of day uses. - A chained tickerplant that is not creating logs replaces the loghandles view with a dictionary of no-ops (#368). If it was then switched to create its own logs, the logs were opened but nothing was written to them, because loghandles was still that dictionary. The view is now restored when a chained tickerplant opens logs. Tests that were wrong - stp/pubsub: seven rows from #391 call rdbHandle, which the suite never defines. They now use the suite's own publisher, with one row that gives it trades to filter. - stp/eod and three chained suites still called .stplg.stpeod, which #523 folded into .stplg.endofday. - stp/eod, stp/periodend, stp/chainedperiodend sized the meta table by the publish list, which is one short since #638. - stp/tz upserted six values into the time zone table, which has had four columns since the tzinfo file was regenerated in #603. - stp/custommode expects quote_iex, trade_iex and heartbeat. The Starter Pack dropped the _iex tables, so the suite now has its own schema file. It also moved the logs with setenv on KDBTPLOG, which the tickerplant has read once at start-up since #638; it now sets .stplg.kdbtplog. Its bad update is a one-item list and its file count is compared by value, so the same rows also hold on Korze and L. - Seven run.sh passed -results where runtests.q reads -testresults, so those suites never wrote a results file; two also left out $write. - helperfunctions.q: gethandle opened a new handle on every call and never closed the old one. A process has a limit on open connections, and stp/wdb reopened handles often enough to reach it. On KDB-X 5.0, master against this branch: stp/pubsub 34/41 to 42/42, eod 10/15 to 15/15, exit 4/5 to 5/5, periodend 6/8 to 8/8, tz 26/31 to 31/31, custommode 39/47 to 47/47, chainedstp 37/40 to 40/40, and stp/wdb 73/96 to 96/96. --- code/segmentedtickerplant/stplog.q | 17 ++++++++++++----- tests/helperfunctions.q | 4 +++- tests/stp/chainedeod/eodroutine.csv | 2 +- tests/stp/chainedeod/run.sh | 4 ++-- tests/stp/chainedeodlognone/run.sh | 2 +- tests/stp/chainedeodlognone/sctplognone.csv | 2 +- tests/stp/chainedlogmodes/eodroutine.csv | 4 ++-- tests/stp/chainedlogmodes/run.sh | 2 +- tests/stp/chainedperiodend/endp.csv | 10 +++++----- tests/stp/chainedperiodend/run.sh | 4 ++-- tests/stp/chainedrecovery/run.sh | 2 +- tests/stp/chainedstp/run.sh | 2 +- tests/stp/custommode/database.q | 6 ++++++ tests/stp/custommode/logs.csv | 10 +++++----- tests/stp/custommode/metaroll.csv | 4 ++-- tests/stp/custommode/process.csv | 2 +- tests/stp/eod/eodroutine.csv | 4 ++-- tests/stp/periodend/endp.csv | 8 ++++---- tests/stp/pubsub/pubsub.csv | 15 ++++++++------- tests/stp/tz/settings.q | 3 ++- tests/stp/upds/run.sh | 2 +- 21 files changed, 63 insertions(+), 46 deletions(-) create mode 100644 tests/stp/custommode/database.q diff --git a/code/segmentedtickerplant/stplog.q b/code/segmentedtickerplant/stplog.q index b587c7311..0ab3dd60d 100644 --- a/code/segmentedtickerplant/stplog.q +++ b/code/segmentedtickerplant/stplog.q @@ -5,6 +5,9 @@ currlog:([tbl:`symbol$()]logname:`symbol$();handle:`int$()) // View of log file handles for faster lookups loghandles::exec tbl!handle from currlog +// Re-establish the view above. A chained tickerplant which is not creating logs replaces it with a dictionary of +// no-ops (see init); without this, switching that process to create its own logs opened them but wrote nothing +restoreloghandles:{value "loghandles::exec tbl!handle from currlog"}; \d .stplg @@ -184,7 +187,8 @@ endofdaydata:@[value;`.stplg.endofdaydata;{ {`proctype`procname`tables!(.proc.pr // passes on eop messages to subscribers and rolls logs endofperiod:{[currentpd;nextpd;data] .lg.o[`endofperiod;"flushing remaining data to subscribers and clearing tables"]; - .stpps.pubclear[.stplg.t]; + // the published tables only: pubclear resets a table from the publish schemas, which have no entry for logmsg + .stpps.pubclear[.stpps.t]; .lg.o[`endofperiod;"executing end of period for ",.Q.s1 `currentperiod`nextperiod!(currentpd;nextpd)]; .stpps.endp[currentpd;nextpd;data]; // sends endofperiod message to subscribers currperiod::nextpd; // increments current period @@ -195,7 +199,8 @@ endofperiod:{[currentpd;nextpd;data] // eop log roll is stopped if eod is also going to be triggered (roll is not stopped in SCTP) stpeoperiod:{[currentpd;nextpd;data;rolllogs] .lg.o[`endofperiod;"flushing remaining data to subscribers and clearing tables"]; - .stpps.pubclear[.stplg.t]; + // the published tables only: pubclear resets a table from the publish schemas, which have no entry for logmsg + .stpps.pubclear[.stpps.t]; .lg.o[`stpeoperiod;"passing on endofperiod message to subscribers"]; .stpps.endp[currentpd;nextpd;data]; // sends endofperiod message to subscribers currperiod::nextperiod; // increments current period @@ -215,7 +220,8 @@ periodrollover:{[data] // common eod for STP and SCTP to send out eod messages and roll logs endofday:{[date;data] .lg.o[`endofday;"flushing remaining data to subscribers and clearing tables"]; - .stpps.pubclear[.stplg.t]; + // the published tables only: pubclear resets a table from the publish schemas, which have no entry for logmsg + .stpps.pubclear[.stpps.t]; .lg.o[`endofday;"executing end of day for ",.Q.s1 .eodtime.d]; .stpps.end[date;data]; // sends endofday message to subscribers dayrollover[data]; @@ -259,6 +265,7 @@ init:{[dbname] seqnum::0; if[(value `..createlogs) or .sctp.loggingmode=`create; + if[.sctp.chainedtp;`.[`restoreloghandles][]]; createdld[dbname;.eodtime.d]; openlog[multilog;dldir;;.z.p+.eodtime.dailyadj]each logtabs; // If appropriate, roll error log @@ -294,6 +301,6 @@ init:{[dbname] // exit before logs are touched if process is an sctp NOT in create mode if[.sctp.chainedtp and not .sctp.loggingmode=`create; :()]; .lg.o[`stpexit;"Closing off log files"]; - .stpm.updmeta[.stplg.multilog][`close;.stpps.t;.z.p]; - .stplg.closelog each .stpps.t; + .stpm.updmeta[.stplg.multilog][`close;.stplg.logtabs;.z.p]; + .stplg.closelog each .stplg.logtabs; }] diff --git a/tests/helperfunctions.q b/tests/helperfunctions.q index b8ad95f21..22ea93402 100644 --- a/tests/helperfunctions.q +++ b/tests/helperfunctions.q @@ -16,6 +16,8 @@ isalive:{[proc] any "q" in' @[system;"pgrep -lf ",proc," -u $USER";" "]}; // Have slightly more fluid handle opening mechanic - update: force it to open a new handle each time gethandle:{[name] - .z.pc exec first w from .servers.SERVERS where procname=name; + .z.pc h:exec first w from .servers.SERVERS where procname=name; + // close the old handle as well: .z.pc only marks it closed, and a process can run out of connections + if[not null h;@[hclose;h;()]]; exec first w from .servers.getservers[`procname;name;()!();1b;1b] }; diff --git a/tests/stp/chainedeod/eodroutine.csv b/tests/stp/chainedeod/eodroutine.csv index 488042c8a..b480a1da1 100644 --- a/tests/stp/chainedeod/eodroutine.csv +++ b/tests/stp/chainedeod/eodroutine.csv @@ -17,7 +17,7 @@ true,0,0,q,1=counttplogs[`stptest1],1,,"Should be 1 log directory for STP" true,0,0,q,1=counttplogs[`sctptest1],1,,"Should be 1 log directory for SCTP" run,0,0,q,now:.z.p,1,,"Get current time" run,0,0,q,data:stpHandle".stplg.endofdaydata[]",1,,"get data" -run,0,0,q,"stpHandle(`.stplg.stpeod;.eodtime.d;data,(enlist `p)!enlist now)",1,,"Run EoD function on STP" +run,0,0,q,"stpHandle(`.stplg.endofday;.eodtime.d;data,(enlist `p)!enlist now)",1,,"Run EoD function on STP" true,0,0,q,all 0 = sctpHandle"count each `. .stpps.t",1,,"Check tables have been flushed" run,0,0,q,meta2:get .Q.dd[sctpDir1;`stpmeta],1,,"Get meta table from disk" run,0,0,q,stpEod2:stpHandle".eodtime.d",1,,"Get new date on STP" diff --git a/tests/stp/chainedeod/run.sh b/tests/stp/chainedeod/run.sh index 1b1001617..49f39d190 100755 --- a/tests/stp/chainedeod/run.sh +++ b/tests/stp/chainedeod/run.sh @@ -14,10 +14,10 @@ ${TORQHOME}/torq.sh start discovery1 stptest1 sctptest1 rdb1 -csv ${testpath}/pr -proctype test -procname test1 \ -test ${testpath} \ -load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \ - -results ${KDBTESTS}/stp/results/ \ + -testresults ${KDBTESTS}/stp/results/ \ -procfile ${testpath}/process.csv \ -runtime $run \ - $debug $stop $quiet + $debug $stop $write $quiet # Shut down procs ${TORQHOME}/torq.sh stop discovery1 stptest1 sctptest1 rdb1 -csv ${testpath}/process.csv diff --git a/tests/stp/chainedeodlognone/run.sh b/tests/stp/chainedeodlognone/run.sh index aec217e51..ff1c86d1b 100755 --- a/tests/stp/chainedeodlognone/run.sh +++ b/tests/stp/chainedeodlognone/run.sh @@ -14,7 +14,7 @@ ${TORQHOME}/torq.sh start discovery1 stptest1 sctptest1 rdb1 -csv ${testpath}/pr -proctype test -procname test1 \ -test ${testpath} \ -load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \ - -results ${KDBTESTS}/stp/results/ \ + -testresults ${KDBTESTS}/stp/results/ \ -procfile ${testpath}/process.csv \ -runtime $run \ $debug $stop $quiet diff --git a/tests/stp/chainedeodlognone/sctplognone.csv b/tests/stp/chainedeodlognone/sctplognone.csv index 5681b9102..981f8e5b8 100644 --- a/tests/stp/chainedeodlognone/sctplognone.csv +++ b/tests/stp/chainedeodlognone/sctplognone.csv @@ -16,7 +16,7 @@ true,0,0,q,all rdbHandle"{count value x} each `trade`quote",1,,"Both trade & quo run,0,0,q,data:stpHandle".stplg.endofdaydata[]",1,,"get data" true,0,0,q,1=counttplogs[`stptest1],1,,"Should be 1 log directory for STP" true,0,0,q,0=counttplogs[`sctptest1],1,,"Should be 0 log directories for SCTP" -run,0,0,q,"stpHandle(`.stplg.stpeod;.eodtime.d;data,(enlist `p)!enlist .z.p)",1,,"Run EoD function on STP" +run,0,0,q,"stpHandle(`.stplg.endofday;.eodtime.d;data,(enlist `p)!enlist .z.p)",1,,"Run EoD function on STP" true,0,0,q,all 0 = sctpHandle"count each `. .stpps.t",1,,"Check tables have been flushed" run,0,0,q,stpEod2:stpHandle".eodtime.d",1,,"Get new date on STP" run,0,0,q,sctpEod2:sctpHandle".eodtime.d",1,,"Get new date on SCTP" diff --git a/tests/stp/chainedlogmodes/eodroutine.csv b/tests/stp/chainedlogmodes/eodroutine.csv index 5fd177e11..291b88620 100644 --- a/tests/stp/chainedlogmodes/eodroutine.csv +++ b/tests/stp/chainedlogmodes/eodroutine.csv @@ -22,7 +22,7 @@ true,0,0,q,all 0=(enlist rdbHandle) @\: (`.tst.endp),1,,"Check the endofperiod f run,0,0,q,sctpHandle".z.exit[0i]",1,,"check that sctp can exit cleanly in parent mode" run,0,0,q,now:.z.p,1,,"Get current time" run,0,0,q,data:stpHandle".stplg.endofdaydata[]",1,,"get data" -run,0,0,q,"stpHandle(`.stplg.stpeod;.eodtime.d;data,(enlist `p)!enlist now)",1,,"Run EoD function on STP" +run,0,0,q,"stpHandle(`.stplg.endofday;.eodtime.d;data,(enlist `p)!enlist now)",1,,"Run EoD function on STP" true,0,0,q,all 0 = sctpHandle"count each `. .stpps.t",1,,"Check tables have been flushed" run,0,0,q,eod2:stpHandle".eodtime.d",1,,"Get new date" true,0,0,q,rdbHandle".tst.eod",1,,"Check EoD was triggered on the sub" @@ -43,7 +43,7 @@ true,0,0,q,all 0 = sctpHandle"count each `. .stpps.t",1,,"Check tables have been true,0,0,q,all 1=(enlist rdbHandle) @\: (`.tst.endp),1,,"Check the endofperiod function has been triggered once on all subs" run,0,0,q,now:.z.p,1,,"Get current time" run,0,0,q,data:stpHandle".stplg.endofdaydata[]",1,,"get data" -run,0,0,q,"stpHandle(`.stplg.stpeod;.eodtime.d;data,(enlist `p)!enlist now)",1,,"Run EoD function on STP" +run,0,0,q,"stpHandle(`.stplg.endofday;.eodtime.d;data,(enlist `p)!enlist now)",1,,"Run EoD function on STP" true,0,0,q,all 0 = sctpHandle"count each `. .stpps.t",1,,"Check tables have been flushed" run,0,0,q,eod2:stpHandle".eodtime.d",1,,"Get new date" true,0,0,q,rdbHandle".tst.eod",1,,"Check EoD was triggered on the sub" diff --git a/tests/stp/chainedlogmodes/run.sh b/tests/stp/chainedlogmodes/run.sh index 5676ca299..c9ccc367e 100755 --- a/tests/stp/chainedlogmodes/run.sh +++ b/tests/stp/chainedlogmodes/run.sh @@ -14,7 +14,7 @@ ${TORQHOME}/torq.sh start discovery1 stp1 sctp1 rdb1 -csv ${testpath}/process.cs -proctype test -procname test1 \ -test ${testpath} \ -load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \ - -results ${KDBTESTS}/stp/results/ \ + -testresults ${KDBTESTS}/stp/results/ \ -procfile ${testpath}/process.csv \ -runtime $run \ $debug $stop $quiet diff --git a/tests/stp/chainedperiodend/endp.csv b/tests/stp/chainedperiodend/endp.csv index 4f8fc2ca2..76f6b4283 100644 --- a/tests/stp/chainedperiodend/endp.csv +++ b/tests/stp/chainedperiodend/endp.csv @@ -7,20 +7,20 @@ before,0,0,q,sctpHandle".sctp.loggingmode:`create",1,,"Let SCTP create logs" before,0,0,q,sctpHandle(`.stplg.init;testlogdb),1,,"Switch test stplog directory" before,0,0,q,rdbHandles:`all`sym`tab!gethandle each `rdball`rdbsymfilt`rdbonetab,1,,"Get RDB handles" before,0,0,q,(value rdbHandles) @\: (set;`endofperiod;endp),1,,"Set dummy endofperiod function on each sub" -before,0,0,q,tcount:count tabs:sctpHandle".stpps.t",1,,"Get number of tables" +before,0,0,q,tcount:count tabs:sctpHandle".stplg.logtabs",1,,"Get number of tables" before,0,0,q,logperiod:sctpHandle".stplg.multilogperiod",1,,"Get logging period" before,0,0,q,metacount:sctpHandle"count .stpm.metatable",1,,"Get initial table count" -before,0,0,q,mstarts:sctpHandle"neg[count .stpps.t]#exec start from .stpm.metatable",1,,"Get most recent start times" +before,0,0,q,mstarts:sctpHandle"neg[count .stplg.logtabs]#exec start from .stpm.metatable",1,,"Get most recent start times" before,0,0,q,mseq:sctpHandle"exec last seq from .stpm.metatable",1,,"Get most recent sequence number" before,0,0,q,period:`curr`next!sctpHandle".stplg[`currperiod`nextperiod]",1,,"Get current and next roll periods" before,0,0,q,system "sleep 11",1,,"Wait for a full period" -true,0,0,q,all 0 = sctpHandle"count each `. .stpps.t",1,,"Check tables have been flushed" -run,0,0,q,mends:(sctpHandle"neg[2*count .stpps.t]#exec end from .stpm.metatable") except 0Np,1,,"Get previous period end times" +true,0,0,q,all 0 = sctpHandle"count each `. .stplg.logtabs",1,,"Check tables have been flushed" +run,0,0,q,mends:(sctpHandle"neg[2*count .stplg.logtabs]#exec end from .stpm.metatable") except 0Np,1,,"Get previous period end times" run,0,0,q,currlog:sctpHandle"currlog",1,,"Get currlog table" true,0,0,q,all 0=(value rdbHandles) @\: (`.tst.endp),1,,"Check the endofperiod function has been triggered once on all subs" true,0,0,q,(metacount+tcount)~sctpHandle"count .stpm.metatable",1,,"Check that the STP metatable count has increased correctly" true,0,0,q,all 1e6>abs "i"$logperiod-mends-mstarts,1,,"Check that the new metatable periods are within 1 microsec of the stated period" true,0,0,q,(mseq+1h)~sctpHandle"exec last seq from .stpm.metatable",1,,"Check that the sequence number has incremented by 1" -true,0,0,q,tabs~raze sctpHandle"exec neg[count .stpps.t]#tbls from .stpm.metatable",1,,"Check that the correct tables are incremented" +true,0,0,q,tabs~raze sctpHandle"exec neg[count .stplg.logtabs]#tbls from .stpm.metatable",1,,"Check that the correct tables are incremented" true,0,0,q,("T"$-6#string currlog[`trade;`logname])~"t"$period`next,1,,"Check trade log name rolled" after,0,0,q,"system ""rm -rf "",1_string sctpHandle(`.stplg.dldir)",1,,"Delete logs folder" \ No newline at end of file diff --git a/tests/stp/chainedperiodend/run.sh b/tests/stp/chainedperiodend/run.sh index 0a2c08825..0d553355f 100755 --- a/tests/stp/chainedperiodend/run.sh +++ b/tests/stp/chainedperiodend/run.sh @@ -14,10 +14,10 @@ ${TORQHOME}/torq.sh start discovery1 stp1 sctp1 rdball rdbsymfilt rdbonetab -cs -proctype test -procname test1 \ -test ${testpath} \ -load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \ - -results ${KDBTESTS}/stp/results/ \ + -testresults ${KDBTESTS}/stp/results/ \ -procfile ${testpath}/process.csv \ -runtime $run \ - $debug $stop $quiet + $debug $stop $write $quiet # Shut down procs ${TORQHOME}/torq.sh stop discovery1 stp1 sctp1 rdball rdbsymfilt rdbonetab -csv ${testpath}/process.csv diff --git a/tests/stp/chainedrecovery/run.sh b/tests/stp/chainedrecovery/run.sh index e2f6cde00..99cb887fb 100755 --- a/tests/stp/chainedrecovery/run.sh +++ b/tests/stp/chainedrecovery/run.sh @@ -14,7 +14,7 @@ ${TORQHOME}/torq.sh start discovery1 -csv ${testpath}/process.csv -proctype test -procname test1 \ -test ${testpath} \ -load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \ - -results ${KDBTESTS}/stp/results/ \ + -testresults ${KDBTESTS}/stp/results/ \ -runtime $run \ -procfile ${testpath}/process.csv \ $debug $stop $quiet diff --git a/tests/stp/chainedstp/run.sh b/tests/stp/chainedstp/run.sh index 42ce8f968..f87341660 100755 --- a/tests/stp/chainedstp/run.sh +++ b/tests/stp/chainedstp/run.sh @@ -14,7 +14,7 @@ ${TORQHOME}/torq.sh start discovery1 stp1 sctp1 -csv ${KDBTESTS}/stp/chainedstp/ -proctype test -procname test1 \ -test ${testpath} \ -load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \ - -results ${KDBTESTS}/stp/results/ \ + -testresults ${KDBTESTS}/stp/results/ \ -runtime $run \ -procfile ${testpath}/process.csv \ $debug $stop $write $quiet diff --git a/tests/stp/custommode/database.q b/tests/stp/custommode/database.q new file mode 100644 index 000000000..2072c52a2 --- /dev/null +++ b/tests/stp/custommode/database.q @@ -0,0 +1,6 @@ +// Schema for this suite: it needs these five tables whatever the application's own schema file defines +quote:([]time:`timestamp$(); sym:`g#`symbol$(); bid:`float$(); ask:`float$(); bsize:`long$(); asize:`long$(); mode:`char$(); ex:`char$(); src:`symbol$()) +trade:([]time:`timestamp$(); sym:`g#`symbol$(); price:`float$(); size:`int$(); stop:`boolean$(); cond:`char$(); ex:`char$();side:`symbol$()) +quote_iex:([]time:`timestamp$(); sym:`g#`symbol$(); bid:`float$(); ask:`float$(); bsize:`long$(); asize:`long$(); mode:`char$(); ex:`char$(); srctime:`timestamp$()) +trade_iex:([]time:`timestamp$(); sym:`g#`symbol$(); price:`float$(); size:`int$(); stop:`boolean$(); cond:`char$(); ex:`char$(); srctime:`timestamp$()) +heartbeat:([]time:`timestamp$(); sym:`symbol$(); procname:`symbol$(); counter:`long$(); pid:`int$(); host:`$(); port:`int$()) diff --git a/tests/stp/custommode/logs.csv b/tests/stp/custommode/logs.csv index cff562d23..8ba5d75a5 100644 --- a/tests/stp/custommode/logs.csv +++ b/tests/stp/custommode/logs.csv @@ -4,7 +4,7 @@ before,0,0,q,.servers.startup[],1,,"Set up connection management" before,0,0,q,system "sleep 2",1,,"Wait for connections" before,0,0,q,stpHandle:gethandle[`stp1],1,,"Get STP handle" before,0,0,q,rdbHandle:gethandle[`rdb1],1,,"Get RDB handle" -before,0,0,q,stpHandle(setenv;`KDBTPLOG;tstlogs),1,,"Change STP logging directory" +before,0,0,q,stpHandle({.stplg.kdbtplog:`$x};tstlogs),1,,"Change STP logging directory" before,0,0,q,stpHandle".stplg.custommode:1_(!).(string `SS;csv) 0: .stplg.customcsv",1,,"Load STP custom settings" before,0,0,q,stpHandle"delete from `currlog",1,,"Clear log table" before,0,0,q,stpHandle(system;"t 0"),1,,"Turn off timer" @@ -13,7 +13,7 @@ before,0,0,q,stpHandle".stplg.init[string .proc.procname]",1,,"Re-initialise STP before,0,0,q,c1:rdbHandle @/: ("count trade";"count quote"),1,,"Get initial RDB counts" before,0,0,q,l1:count each (trade;quote),1,,"Get initial local counts" true,0,0,q,"all (key hsym `$tstlogs) like ""*"",string .z.d",1,,"Check logging directory exists" -true,0,0,q,"6i~(sum/) (key hsym `$tstlogs,""/"",db) like\:/: liketabs",1,,"Check log files exist for all tables" +true,0,0,q,"6=(sum/) (key hsym `$tstlogs,""/"",db) like\:/: liketabs",1,,"Check log files exist for all tables" true,0,0,q,all `trade`trade_iex`quote`quote_iex`heartbeat`segmentederrorlogfile in stpHandle"exec tbl from currlog",1,,"Check all tables in logging table" true,0,0,q,not `logmsg in stpHandle"exec tbl from currlog",1,,"Check logmsg not in logging table" true,0,0,q,all not null stpHandle"exec logname from currlog",1,,"Check all lognames filled" @@ -25,12 +25,12 @@ true,0,0,q,(~/) `hh$(("T"$-6#stpHandle"string currlog[`trade;`logname]");"t"$stp true,0,0,q,stpHandle".stplg.currperiod<.z.p+.eodtime.dailyadj",1,,"Check logging period times" true,0,0,q,stpHandle".stplg.nextperiod>.z.p+.eodtime.dailyadj",1,,"Check logging period times" true,0,0,q,stpHandle".stplg.nextperiod~.stplg.currperiod+.stplg.multilogperiod",1,,"Check logging period times" -run,0,0,q,"stpHandle @/: `.u.upd ,/: ((`trade;testtrade);(`quote;testquote);(`heartbeat;`error))",1,,"Send trade,quote and bad updates to STP" +run,0,0,q,"stpHandle @/: `.u.upd ,/: ((`trade;testtrade);(`quote;testquote);(`heartbeat;enlist`error))",1,,"Send trade,quote and bad updates to STP" run,0,0,q,system "sleep 1",1,,"Wait for updates to publish" run,0,0,q,![-11;] each stpHandle"exec logname from currlog where tbl in `trade`quote`segmentederrorlogfile",1,,"Get log contents" true,0,0,q,(c1+10)~rdbHandle @/: ("count trade";"count quote"),1,,"Check tables updated in the RDB" true,0,0,q,(l1+10)~count each (trade;quote),1,,"Check tables updated correctly in logs" -true,0,0,q,`error~.tst.err,1,,"Check error logs updated" -after,0,0,q,stpHandle(setenv;`KDBTPLOG;deflogs),1,,"Change STP logging directory to default" +true,0,0,q,`error~first .tst.err,1,,"Check error logs updated" +after,0,0,q,stpHandle({.stplg.kdbtplog:`$x};deflogs),1,,"Change STP logging directory to default" after,0,0,q,stpHandle(system;"t 1000"),1,,"Turn on timer" after,0,0,q,"system""rm -r "",tstlogs",1,,"Clear log directory" \ No newline at end of file diff --git a/tests/stp/custommode/metaroll.csv b/tests/stp/custommode/metaroll.csv index 9712d9ad9..0471b7e75 100644 --- a/tests/stp/custommode/metaroll.csv +++ b/tests/stp/custommode/metaroll.csv @@ -1,6 +1,6 @@ action,ms,bytes,lang,code,repeat,minver,comment before,0,0,q,.servers.startup[],1,,"Set up connection management" -before,0,0,q,stpHandle(setenv;`KDBTPLOG;tstlogs),1,,"Change STP logging directory" +before,0,0,q,stpHandle({.stplg.kdbtplog:`$x};tstlogs),1,,"Change STP logging directory" before,0,0,q,stpHandle"delete from `.stpm.metatable",1,,"Delete meta table" before,0,0,q,stpHandle"setup[`defaultbatch]",1,,"Re-init STP" before,0,0,q,stpHandle".stplg.init[string .proc.procname]",1,,"Re-init STP" @@ -37,5 +37,5 @@ true,0,0,q,period[`next]~stpHandle".stplg.currperiod",1,,"Check period rolled co true,0,0,q,all ("T"$-6#'string exec logname from clog where tbl in `trade`heartbeat)="t"$period[`next],1,,"Check trade/heartbeat log names rolled" true,0,0,q,qlog~clog[`quote;`logname],1,,"Check quote log not rolled" true,0,0,q,not (~/) exec logname from clog where tbl in `trade`quote,1,,"Check trade and quote writing to different logs" -after,0,0,q,stpHandle(setenv;`KDBTPLOG;deflogs),1,,"Change STP logging directory to default" +after,0,0,q,stpHandle({.stplg.kdbtplog:`$x};deflogs),1,,"Change STP logging directory to default" after,0,0,q,"system""rm -r "",tstlogs",1,,"Clear log directory" \ No newline at end of file diff --git a/tests/stp/custommode/process.csv b/tests/stp/custommode/process.csv index f7d8ec663..0c5383285 100644 --- a/tests/stp/custommode/process.csv +++ b/tests/stp/custommode/process.csv @@ -1,4 +1,4 @@ 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,segmentedtickerplant,stp1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,-schemafile ${TORQHOME}/database.q -.stplg.multilog custom -.stplg.customcsv ${KDBTESTS}/stpcustom.csv,q +localhost,{KDBBASEPORT}+101,segmentedtickerplant,stp1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,0,,,${KDBCODE}/processes/segmentedtickerplant.q,1,-schemafile ${KDBTESTS}/stp/custommode/database.q -.stplg.multilog custom -.stplg.customcsv ${KDBTESTS}/stpcustom.csv,q localhost,{KDBBASEPORT}+102,rdb,rdb1,${TORQHOME}/appconfig/passwords/accesslist.txt,1,1,180,,${KDBCODE}/processes/rdb.q,1,-.rdb.replaylog 0b,q diff --git a/tests/stp/eod/eodroutine.csv b/tests/stp/eod/eodroutine.csv index fc2708984..4cc7c2616 100644 --- a/tests/stp/eod/eodroutine.csv +++ b/tests/stp/eod/eodroutine.csv @@ -6,14 +6,14 @@ before,0,0,q,stpHandle:gethandle[`stp1],1,,"Get STP handle" before,0,0,q,rdbHandle:gethandle[`rdb1],1,,"Get RDB handle" before,0,0,q,rdbHandle"endofday:{[x;y] .tst.eod:1b}",1,,"Overwrite RDB endofday function" before,0,0,q,meta1:stpHandle".stpm.metatable",1,,"Get initial meta table" -before,0,0,q,tcount:count stpHandle".stpps.t",1,,"Get table count" +before,0,0,q,tcount:count stpHandle".stplg.logtabs",1,,"Get table count" before,0,0,q,adj:stpHandle".eodtime.dailyadj",1,,"Get time adjustment" before,0,0,q,eod1:stpHandle".eodtime.d",1,,"Get initial date" before,0,0,q,dir1:stpHandle".stplg.dldir",1,,"Get initial log directory" before,0,0,q,db:stpHandle"string .proc.procname",1,,"Get dbname" run,0,0,q,now:.z.p,1,,"Get current time" run,0,0,q,eoddata: stpHandle".stplg.endofdaydata[]",1,,"Get eod data to send" -run,0,0,q,"stpHandle(`.stplg.stpeod;.eodtime.d;eoddata,(enlist `p)!enlist now)",1,,"Run EoD function on STP" +run,0,0,q,"stpHandle(`.stplg.endofday;.eodtime.d;eoddata,(enlist `p)!enlist now)",1,,"Run EoD function on STP" run,0,0,q,meta2:get .Q.dd[dir1;`stpmeta],1,,"Get meta table from disk" run,0,0,q,eod2:stpHandle".eodtime.d",1,,"Get new date" run,0,0,q,dir2:stpHandle".stplg.dldir",1,,"Get new log directory" diff --git a/tests/stp/periodend/endp.csv b/tests/stp/periodend/endp.csv index 03cbdc72c..8a4a71690 100644 --- a/tests/stp/periodend/endp.csv +++ b/tests/stp/periodend/endp.csv @@ -4,18 +4,18 @@ before,0,0,q,.servers.startup[],1,,"Get connection management set up" before,0,0,q,stpHandle:gethandle[`stp1],1,,"Get STP handle" before,0,0,q,rdbHandles:`all`sym`tab!gethandle each `rdball`rdbsymfilt`rdbonetab,1,,"Get RDB handles" before,0,0,q,(value rdbHandles) @\: (set;`endofperiod;endp),1,,"Set dummy endofperiod function on each sub" -before,0,0,q,tcount:count tabs:stpHandle".stpps.t",1,,"Get number of tables" +before,0,0,q,tcount:count tabs:stpHandle".stplg.logtabs",1,,"Get number of tables" before,0,0,q,logperiod:stpHandle".stplg.multilogperiod",1,,"Get logging period" before,0,0,q,metacount:stpHandle"count .stpm.metatable",1,,"Get initial table count" -before,0,0,q,mstarts:stpHandle"neg[count .stpps.t]#exec start from .stpm.metatable",1,,"Get most recent start times" +before,0,0,q,mstarts:stpHandle"neg[count .stplg.logtabs]#exec start from .stpm.metatable",1,,"Get most recent start times" before,0,0,q,mseq:stpHandle"exec last seq from .stpm.metatable",1,,"Get most recent sequence number" before,0,0,q,period:`curr`next!stpHandle".stplg[`currperiod`nextperiod]",1,,"Get current and next roll periods" before,0,0,q,system "sleep 11",1,,"Wait for a full period" -run,0,0,q,mends:(stpHandle"neg[2*count .stpps.t]#exec end from .stpm.metatable") except 0Np,1,,"Get previous period end times" +run,0,0,q,mends:(stpHandle"neg[2*count .stplg.logtabs]#exec end from .stpm.metatable") except 0Np,1,,"Get previous period end times" run,0,0,q,currlog:stpHandle"currlog",1,,"Get currlog table" true,0,0,q,all 0=(value rdbHandles) @\: (`.tst.endp),1,,"Check the endofperiod function has been triggered once on all subs" true,0,0,q,(metacount+tcount)~stpHandle"count .stpm.metatable",1,,"Check that the STP metatable count has increased correctly" true,0,0,q,all 1e6>abs "i"$logperiod-mends-mstarts,1,,"Check that the new metatable periods are within 1 microsec of the stated period" true,0,0,q,(mseq+1h)~stpHandle"exec last seq from .stpm.metatable",1,,"Check that the sequence number has incremented by 1" -true,0,0,q,tabs~raze stpHandle"exec neg[count .stpps.t]#tbls from .stpm.metatable",1,,"Check that the correct tables are incremented" +true,0,0,q,tabs~raze stpHandle"exec neg[count .stplg.logtabs]#tbls from .stpm.metatable",1,,"Check that the correct tables are incremented" true,0,0,q,("T"$-6#string currlog[`trade;`logname])~"t"$period`next,1,,"Check trade log name rolled" \ No newline at end of file diff --git a/tests/stp/pubsub/pubsub.csv b/tests/stp/pubsub/pubsub.csv index 7edf841be..bb13d0a47 100644 --- a/tests/stp/pubsub/pubsub.csv +++ b/tests/stp/pubsub/pubsub.csv @@ -39,12 +39,13 @@ 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(insert;`trade;(4#.z.p;`AAPL`GOOG`MSFT`IBM;80 90 100 110f;4#50i;4#1b;4#""H"";4#""I"";4#`ask))",1,,"Give the pubsub process trades for four syms" +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" diff --git a/tests/stp/tz/settings.q b/tests/stp/tz/settings.q index d6c964e41..69b725e33 100644 --- a/tests/stp/tz/settings.q +++ b/tests/stp/tz/settings.q @@ -17,7 +17,8 @@ eodinit:{ if[x in `custom`customoffsetplus`customoffsetminus; dt:"p"$0;doff:"n"$0; adj:("p"$1+.z.d) - .z.p + 00:00:02 + off:(`custom`customoffsetplus`customoffsetminus!(0D00;0D02;-0D02))[x]; - `.tz.t upsert (x;dt;adj;doff;adj;dt); + // timezoneID, gmtDateTime, adjustment, localDateTime (the table lost gmtOffset and dstOffset in #603) + `.tz.t upsert (x;dt;adj;dt); .stplg.nextendUTC:"p"$0 ]; diff --git a/tests/stp/upds/run.sh b/tests/stp/upds/run.sh index 9f35e6194..41cf94097 100755 --- a/tests/stp/upds/run.sh +++ b/tests/stp/upds/run.sh @@ -14,7 +14,7 @@ ${TORQHOME}/torq.sh start discovery1 stp1 -csv ${KDBTESTS}/stp/upds/process.csv -proctype test -procname test1 \ -test ${testpath} \ -load ${KDBTESTS}/helperfunctions.q ${testpath}/settings.q \ - -results ${KDBTESTS}/stp/results/ \ + -testresults ${KDBTESTS}/stp/results/ \ -runtime $run \ -procfile ${testpath}/process.csv \ $debug $stop $write $quiet From 3e7cde1ff840baec6e9c6243a7024cca342f77ad Mon Sep 17 00:00:00 2001 From: Marcos Jaen Date: Fri, 13 Nov 2026 00:20:24 +0000 Subject: [PATCH 5/7] tests/stp/batching: wait for the publish before the second-batch check defbatch.csv resumes publication with .z.ts[] on the tickerplant and checks the RDB's row count on the very next line. The tickerplant publishes asynchronously, so the check raced the update: straight after the call the RDB still had 10 rows, and a second later 11. membatch.csv has the same sequence with a one-second wait in between ("Give data a chance to publish"); defbatch.csv was missing that row. On KDB-X the check failed about one run in three. With the wait, tests/stp/batching passed six runs out of six. --- tests/stp/batching/defbatch.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/stp/batching/defbatch.csv b/tests/stp/batching/defbatch.csv index 44e24d91f..348963417 100644 --- a/tests/stp/batching/defbatch.csv +++ b/tests/stp/batching/defbatch.csv @@ -20,5 +20,6 @@ run,0,0,q,![-11;] each logs,1,,"Replay logs locally" true,0,0,q,(l1+11)~l2:count trade,1,,"Check logs contain both batches" true,0,0,q,(c1+10)~c2:rdbHandle"count trade",1,,"Check first batch was successfully replayed from log" run,0,0,q,stpHandle".z.ts[]",1,,"Resume publication" +run,0,0,q,system "sleep 1",1,,"Give data a chance to publish" true,0,0,q,(c2+1)~rdbHandle"count trade",1,,"Check second batch gets published" after,0,0,q,delete from `trade,1,,"Clear local trade table" \ No newline at end of file From 818991b605ff4d78d6f474cdd5ec7870810174e9 Mon Sep 17 00:00:00 2001 From: Marcos Jaen Date: Sun, 15 Nov 2026 18:21:41 -0500 Subject: [PATCH 6/7] Keep the name and type of a process started without the handlers When discovery connects to a process it asks for .servers.getdetails, and a process started without TorQ's handlers (every tickerlogreplay process, by default) does not have it. The fallback then sent back a null procname and proctype, and discovery replaced the process.csv entry with one named after the script (torq.q) and with no type, so nothing could find the process by type afterwards. That only happens when discovery reaches the process after it is already listening, so it depends on start-up timing. The fallback now sends .proc.procname and .proc.proctype, which every TorQ process sets whether or not it loads the handlers. Now with these changes we have KDB-X 632/632, L 632/632, PeachQ 552/632 and Korze 608/632. stp/tickerlog is 56/68 on PeachQ (before 34/68), and Korze goes from 34/68 to 47/68. --- code/handlers/trackservers.q | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/handlers/trackservers.q b/code/handlers/trackservers.q index fda2115d3..6f0c05b99 100644 --- a/code/handlers/trackservers.q +++ b/code/handlers/trackservers.q @@ -138,7 +138,7 @@ getdetails:{(.z.f;.z.h;system"p";@[value;`.proc.procname;`];@[value;`.proc.proct / add session behind a handle addhw:{[hpuP;W] // Get the information around a process - info:`f`h`port`procname`proctype`attributes!(@[W;({$[`getdetails in key`.servers;.servers.getdetails[];(.z.f;.z.h;system"p";`;`;$[`getattributes in key`.proc;.proc.getattributes[];()!()])]};`);(`;`;0Ni;`;`;()!())]); + info:`f`h`port`procname`proctype`attributes!(@[W;({$[`getdetails in key`.servers;.servers.getdetails[];(.z.f;.z.h;system"p";@[value;`.proc.procname;`];@[value;`.proc.proctype;`];$[`getattributes in key`.proc;.proc.getattributes[];()!()])]};`);(`;`;0Ni;`;`;()!())]); if[0Ni~info`port;'"remote call failed on handle ",string W]; if[null name:info`procname;name:`$last("/"vs string info`f)except enlist""]; if[0=count name;name:`default]; From e04de5be9e7fe03e12327eaefeec9664151cdecb Mon Sep 17 00:00:00 2001 From: Marcos Jaen Date: Sun, 15 Nov 2026 20:00:31 -0500 Subject: [PATCH 7/7] Fix six tests that could not pass or did not write results merge/tplogreplay loaded treplaysettings.q, but the file is tpreplaysettings.q, so its replays never ran partandmerge and the temp-directory checks failed. With the right file the checks still failed: they look at .replay.tempdir in the test process, which kept the default instead of the directory the replay uses. The test's settings now set it to that directory. stp/idbdefault and stp/idbpartbyenum queried quote_iex through the gateway to check that an unpublished table has no rows. The Starter Pack schema no longer has quote_iex, so the gateway returned an error string instead. They now query packets, which is in the schema and which the tests never publish to. stp/chainedeodlognone, chainedlogmodes and chainedrecovery left $write out of their test command, so run.sh -w never wrote their results. --- tests/merge/tplogreplay/settings.q | 4 +++- tests/stp/chainedeodlognone/run.sh | 2 +- tests/stp/chainedlogmodes/run.sh | 2 +- tests/stp/chainedrecovery/run.sh | 2 +- tests/stp/idbdefault/idbdefault.csv | 2 +- tests/stp/idbpartbyenum/idbenum.csv | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/merge/tplogreplay/settings.q b/tests/merge/tplogreplay/settings.q index 64b063d52..0cc67ea51 100644 --- a/tests/merge/tplogreplay/settings.q +++ b/tests/merge/tplogreplay/settings.q @@ -9,7 +9,7 @@ hdbdir:getenv[`KDBTESTS],"/merge/tplogreplay/testhdb" schemafile:getenv[`KDBTESTS],"/merge/tplogreplay/database.q" tplogdir:getenv[`KDBTESTS],"/merge/tplogreplay/testlogs" processfile:getenv[`KDBCODE],"/processes/tickerlogreplay.q" -testconfig:getenv[`KDBTESTS],"/merge/tplogreplay/treplaysettings.q" +testconfig:getenv[`KDBTESTS],"/merge/tplogreplay/tpreplaysettings.q" // system commands to run tickerlogreplay script with different merge methods colreplay:{system"q torq.q -debug -load ",processfile," ",testconfig," -.replay.tplogdir ",tplogdir," -.replay.hdbdir ",hdbdir," -.replay.schemafile ", schemafile," -.replay.mergemethod col -proctype tickerlogreplay -procname tplogreplay1"}; @@ -20,6 +20,8 @@ hybridreplay:{system"q torq.q -debug -load ",processfile," ",testconfig," -.repl .replay.autoreplay:0b .replay.tplogdir: `$tplogdir .replay.hdbdir: `$hdbdir +// the checks look at .replay.tempdir here, so point it at the temp directory tpreplaysettings.q gives the replay +.replay.tempdir:hsym `$tempdir .replay.schemafile: `$schemafile //dropping the tables that are not replayed by log files needed to get use function for names of stp logs .replay.tablestoreplay:3_tables[] diff --git a/tests/stp/chainedeodlognone/run.sh b/tests/stp/chainedeodlognone/run.sh index ff1c86d1b..d9780c621 100755 --- a/tests/stp/chainedeodlognone/run.sh +++ b/tests/stp/chainedeodlognone/run.sh @@ -17,7 +17,7 @@ ${TORQHOME}/torq.sh start discovery1 stptest1 sctptest1 rdb1 -csv ${testpath}/pr -testresults ${KDBTESTS}/stp/results/ \ -procfile ${testpath}/process.csv \ -runtime $run \ - $debug $stop $quiet + $debug $stop $write $quiet # Shut down procs ${TORQHOME}/torq.sh stop discovery1 stptest1 sctptest1 rdb1 -csv ${testpath}/process.csv diff --git a/tests/stp/chainedlogmodes/run.sh b/tests/stp/chainedlogmodes/run.sh index c9ccc367e..746318cff 100755 --- a/tests/stp/chainedlogmodes/run.sh +++ b/tests/stp/chainedlogmodes/run.sh @@ -17,7 +17,7 @@ ${TORQHOME}/torq.sh start discovery1 stp1 sctp1 rdb1 -csv ${testpath}/process.cs -testresults ${KDBTESTS}/stp/results/ \ -procfile ${testpath}/process.csv \ -runtime $run \ - $debug $stop $quiet + $debug $stop $write $quiet # Shut down procs ${TORQHOME}/torq.sh stop discovery1 stp1 sctp1 rdb1 -csv ${testpath}/process.csv diff --git a/tests/stp/chainedrecovery/run.sh b/tests/stp/chainedrecovery/run.sh index 99cb887fb..70421021e 100755 --- a/tests/stp/chainedrecovery/run.sh +++ b/tests/stp/chainedrecovery/run.sh @@ -17,7 +17,7 @@ ${TORQHOME}/torq.sh start discovery1 -csv ${testpath}/process.csv -testresults ${KDBTESTS}/stp/results/ \ -runtime $run \ -procfile ${testpath}/process.csv \ - $debug $stop $quiet + $debug $stop $write $quiet # Shut down procs ${TORQHOME}/torq.sh stop discovery1 stp1 stptabperiod rdball rdbsymfilt rdbcomplexfilt -csv ${testpath}/process.csv diff --git a/tests/stp/idbdefault/idbdefault.csv b/tests/stp/idbdefault/idbdefault.csv index 6c32642be..12d5ffcb8 100644 --- a/tests/stp/idbdefault/idbdefault.csv +++ b/tests/stp/idbdefault/idbdefault.csv @@ -16,7 +16,7 @@ true,0,0,q,neg[gwHandle](`.gw.asyncexec;"select from trade where date=.z.D";`idb run,0,0,q,"stpHandle @/: `.u.upd ,/: ((`trade;testtrade);(`quote;testquote))",1,,"Send trade and quote updates to STP" run,0,0,q,.proc.sys "sleep 3",1,,"Wait for updates to get published" true,0,0,q,"neg[gwHandle](`.gw.asyncexec;""select from trade where date=.z.D, sym=`GOOG"";`idb);5~count gwHandle[]",1,,"Check trade update was correctly published" -true,0,0,q,"neg[gwHandle](`.gw.asyncexec;""select from quote_iex where date=.z.D"";`idb);0~count gwHandle[]",1,,"Check if table that not have been published has 0 rows" +true,0,0,q,"neg[gwHandle](`.gw.asyncexec;""select from packets where date=.z.D"";`idb);0~count gwHandle[]",1,,"Check if table that not have been published has 0 rows" run,0,0,q,wdbHandle(`.u.end;`.wdb.currentpartition),1,,"Trigger EOD on WDB" run,0,0,q,.proc.sys "sleep 3",1,,"Wait for merge to HDB to happen" true,0,0,q,neg[gwHandle](`.gw.asyncexec;"select from trade where sym in `GOOG";`hdb);5~count gwHandle[],1,,"Check if HDB has the merged data" diff --git a/tests/stp/idbpartbyenum/idbenum.csv b/tests/stp/idbpartbyenum/idbenum.csv index 41e563725..7e12457f2 100644 --- a/tests/stp/idbpartbyenum/idbenum.csv +++ b/tests/stp/idbpartbyenum/idbenum.csv @@ -16,7 +16,7 @@ true,0,0,q,neg[gwHandle](`.gw.asyncexec;"select from trade";`idb);0~count gwHand run,0,0,q,"stpHandle @/: `.u.upd ,/: ((`trade;testtrade);(`quote;testquote))",1,,"Send trade and quote updates to STP" run,0,0,q,.proc.sys "sleep 3",1,,"Wait for updates to get published" true,0,0,q,neg[gwHandle](`.gw.asyncexec;"select from trade where int=maptoint[`GOOG]";`idb);5~count gwHandle[],1,,"Check trade update was correctly published and maptoint works" -true,0,0,q,neg[gwHandle](`.gw.asyncexec;"select from quote_iex";`idb);0~count gwHandle[],1,,"Check if table that not have been published has 0 rows" +true,0,0,q,neg[gwHandle](`.gw.asyncexec;"select from packets";`idb);0~count gwHandle[],1,,"Check if table that not have been published has 0 rows" run,0,0,q,wdbHandle(`.u.end;`.wdb.currentpartition),1,,"Trigger EOD on WDB" run,0,0,q,.proc.sys "sleep 3",1,,"Wait for merge to HDB to happen" true,0,0,q,neg[gwHandle](`.gw.asyncexec;"select from trade where sym=`GOOG";`hdb);5~count gwHandle[],1,,"Check if HDB has the merged data"