From 6891baf4174381775c68eaa4fff556f304bb4b18 Mon Sep 17 00:00:00 2001 From: pkerrAqua Date: Mon, 15 Nov 2021 16:19:55 +0000 Subject: [PATCH 1/7] Update pub function to properly filter subscriptions --- code/common/pubsub.q | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/code/common/pubsub.q b/code/common/pubsub.q index a89c4a094..0cb0f6426 100644 --- a/code/common/pubsub.q +++ b/code/common/pubsub.q @@ -73,13 +73,14 @@ selfiltered:{[x;y] // Publish table data pub:{[t;x] - if[not count x;:()]; - if[count h:subrequestall[t];-25!(h;(`upd;t;x))]; - if[t in subrequestfiltered`tbl; - {[t;x] data:eval(?;t;x`filts;0b;x`columns);neg[x`handle](`upd;t;data)}[t;] - each select handle,filts,columns from subrequestfiltered where tbl=t - ]; - }; + if[not count x;:()]; + if[count h:subrequestall[t];-25!(h;(`upd;t;x))]; + if[t in .stpps.subrequestfiltered`tbl; + {[t;x;sels] data:eval(?;x;sels`filts;0b;sels`columns); + //show count data; + if[count data;neg[sels`handle](`upd;t;data)]}[t;x;] + each select handle,filts,columns from .stpps.subrequestfiltered where tbl=t]; + }; // publish and clear tables pubclear:{ From 02fae9cb225b605d32ade6e707acb7f152b83b6a Mon Sep 17 00:00:00 2001 From: pkerrAqua Date: Mon, 15 Nov 2021 16:29:30 +0000 Subject: [PATCH 2/7] Add unit tests for filter subscription tests --- tests/stp/pubsub/pubsub.csv | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/stp/pubsub/pubsub.csv b/tests/stp/pubsub/pubsub.csv index b4902cbf9..18b9d2a2d 100644 --- a/tests/stp/pubsub/pubsub.csv +++ b/tests/stp/pubsub/pubsub.csv @@ -37,4 +37,10 @@ run,0,0,q,psHandle(upsert;`trade;testtrade),1,,"Update trade table on pubsub" true,0,0,q,1~count psHandle(`trade),1,,"Check there is one row in trade table" 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" -true,0,0,q,1~.tst.upd,1,,"Check that local UPD function has been called" \ No newline at end of file +true,0,0,q,1~.tst.upd,1,,"Check that local UPD function has been called" +run,0,0,q,upd:{show x:show count y},1,,"Define upd for sub filter tests" +run,0,0,q,rdbHandle(`.u.sub;`trade;`AAPL`GOOG),1,,"Subscribe to filtered sym list" +run,0,0,q,rdbHandle".stpps.subrequestfiltered",1,,"Check filtered subscription has passed" +run,0,0,q,rdbHandle".u.pub[`trade;-10 sublist trade]",1,,"Force publish for the filtered list" +run,0,0,q,rdbHandle"upd:insert",1,,"Return upd back to default definition" +true,0,0,q,rdbHandle"(upd)~(insert)",1,,"Check upd has been reset to default" From e02625f4f2b2fe66f672a3b3451eaab32de94559 Mon Sep 17 00:00:00 2001 From: pkerrAqua Date: Mon, 15 Nov 2021 17:15:06 +0000 Subject: [PATCH 3/7] Add definition for TestCases --- tests/stp/TestCases.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/stp/TestCases.csv b/tests/stp/TestCases.csv index a26adacdd..85216c03d 100644 --- a/tests/stp/TestCases.csv +++ b/tests/stp/TestCases.csv @@ -7,6 +7,7 @@ RDB (or any Subscriber),Subscriptions,All Subscriptions,1.1.1,"Data is published ,,Update logs,1.1.6,"Data is published, it is saved in the log file",Update saved in log file,,MP,Done,subscription/subs.csv, ,,Error logs,1.1.7,"Bad update published, gets saved in error log",Bad update saved to log file,,MP,Done,subscription/subs.csv, ,,Filtered Subscription file missing ,1.1.8,Filtered sub file doesn't exist,Process fails to start,,MP,Done,subfile/subfilemissing.csv,is this one covered? +,,Publish only by filtered subsciptions,1.1.9,Subscriber subscribes with .u.sub[`table;`list`of`symbols],Consumer subscribes to specific list of sym data onlywith only the specific data being published,,PK,In Progress,pubsub/pubsub.csv,^M RDB ,Recovery - single daily log file (tabperiod=`none),"RDB Restart, all subscriptions",2.1.1,"RDB subscribes for all data, is bounced",Data is the same in the RDB pre and post bounce,,AW,Done,recovery/recoverysinglelog.csv, ,,"RDB restart, sym subscriptions (using .rdb.subscribesyms variable)",2.1.2,"RDB subscribes to a subset of syms, is bounced",Data is the same in the RDB pre and post bounce,,AW,Done,recovery/recoverysinglelog.csv, ,,"RDB restart, complex filter using filtered subs functionality ",2.1.3,RDB subscribes to a subset of data using filtered functionality ,Data is the same in the RDB pre and post bounce,"These are similar to 2.1.1 but for this type of TP log file the TP may have multple log files, all of which should be replayed. So the set up should be: From a5ba11b9369c8667aea0c47345970cf50d6875f7 Mon Sep 17 00:00:00 2001 From: pkerrAqua Date: Wed, 17 Nov 2021 10:55:27 +0000 Subject: [PATCH 4/7] Remove comment, revert indentation --- code/common/pubsub.q | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/common/pubsub.q b/code/common/pubsub.q index 0cb0f6426..047b4bbe2 100644 --- a/code/common/pubsub.q +++ b/code/common/pubsub.q @@ -73,14 +73,14 @@ selfiltered:{[x;y] // Publish table data pub:{[t;x] - if[not count x;:()]; - if[count h:subrequestall[t];-25!(h;(`upd;t;x))]; - if[t in .stpps.subrequestfiltered`tbl; - {[t;x;sels] data:eval(?;x;sels`filts;0b;sels`columns); - //show count data; + if[not count x;:()]; + if[count h:subrequestall[t];-25!(h;(`upd;t;x))]; + if[t in .stpps.subrequestfiltered`tbl; + {[t;x;sels] data:eval(?;x;sels`filts;0b;sels`columns); if[count data;neg[sels`handle](`upd;t;data)]}[t;x;] - each select handle,filts,columns from .stpps.subrequestfiltered where tbl=t]; - }; + each select handle,filts,columns from .stpps.subrequestfiltered where tbl=t + ]; + }; // publish and clear tables pubclear:{ From 47df505bd148062efa3ae0644c3ce886a263a25c Mon Sep 17 00:00:00 2001 From: pkerrAqua Date: Wed, 24 Nov 2021 19:04:43 +0000 Subject: [PATCH 5/7] Update unit tests for pubsub filter issue --- tests/stp/pubsub/pubsub.csv | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/stp/pubsub/pubsub.csv b/tests/stp/pubsub/pubsub.csv index 18b9d2a2d..085a522a1 100644 --- a/tests/stp/pubsub/pubsub.csv +++ b/tests/stp/pubsub/pubsub.csv @@ -38,9 +38,14 @@ true,0,0,q,1~count psHandle(`trade),1,,"Check there is one row in trade table" 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" true,0,0,q,1~.tst.upd,1,,"Check that local UPD function has been called" -run,0,0,q,upd:{show x:show count y},1,,"Define upd for sub filter tests" +run,0,0,q,upd:upsert,1,,"Define upd for sub filter tests" run,0,0,q,rdbHandle(`.u.sub;`trade;`AAPL`GOOG),1,,"Subscribe to filtered sym list" -run,0,0,q,rdbHandle".stpps.subrequestfiltered",1,,"Check filtered subscription has passed" -run,0,0,q,rdbHandle".u.pub[`trade;-10 sublist trade]",1,,"Force publish for the filtered list" -run,0,0,q,rdbHandle"upd:insert",1,,"Return upd back to default definition" -true,0,0,q,rdbHandle"(upd)~(insert)",1,,"Check upd has been reset to default" +run,0,0,q,rdbHandle"test:select by sym from trade",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" +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 to publish to empty trade table" +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,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" From 2728843108fc40340144a364a7f0593107cada64 Mon Sep 17 00:00:00 2001 From: pkerrAqua Date: Fri, 3 Dec 2021 16:08:05 +0000 Subject: [PATCH 6/7] Update unit tests to use new set table definition --- tests/stp/pubsub/pubsub.csv | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/stp/pubsub/pubsub.csv b/tests/stp/pubsub/pubsub.csv index 085a522a1..7edf841be 100644 --- a/tests/stp/pubsub/pubsub.csv +++ b/tests/stp/pubsub/pubsub.csv @@ -37,15 +37,14 @@ run,0,0,q,psHandle(upsert;`trade;testtrade),1,,"Update trade table on pubsub" true,0,0,q,1~count psHandle(`trade),1,,"Check there is one row in trade table" 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" -true,0,0,q,1~.tst.upd,1,,"Check that local UPD function has been called" 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 by sym from trade",1,,"Define set data to compare filter against" +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" -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 to publish to empty trade table" 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,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" + From 4d6e7cff22fb1019090af7206a5f4193c88a4f10 Mon Sep 17 00:00:00 2001 From: pkerrAqua Date: Fri, 3 Dec 2021 16:22:14 +0000 Subject: [PATCH 7/7] Update Test Case definition --- tests/stp/TestCases.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/stp/TestCases.csv b/tests/stp/TestCases.csv index 85216c03d..3b462ff7f 100644 --- a/tests/stp/TestCases.csv +++ b/tests/stp/TestCases.csv @@ -7,7 +7,7 @@ RDB (or any Subscriber),Subscriptions,All Subscriptions,1.1.1,"Data is published ,,Update logs,1.1.6,"Data is published, it is saved in the log file",Update saved in log file,,MP,Done,subscription/subs.csv, ,,Error logs,1.1.7,"Bad update published, gets saved in error log",Bad update saved to log file,,MP,Done,subscription/subs.csv, ,,Filtered Subscription file missing ,1.1.8,Filtered sub file doesn't exist,Process fails to start,,MP,Done,subfile/subfilemissing.csv,is this one covered? -,,Publish only by filtered subsciptions,1.1.9,Subscriber subscribes with .u.sub[`table;`list`of`symbols],Consumer subscribes to specific list of sym data onlywith only the specific data being published,,PK,In Progress,pubsub/pubsub.csv,^M +,,Publish only by filtered subsciptions,1.1.9,Subscriber subscribes with .u.sub[`table;`list`of`symbols],Consumer subscribes to specific list of sym data with only the specific data being published,,PK,In Progress,pubsub/pubsub.csv, RDB ,Recovery - single daily log file (tabperiod=`none),"RDB Restart, all subscriptions",2.1.1,"RDB subscribes for all data, is bounced",Data is the same in the RDB pre and post bounce,,AW,Done,recovery/recoverysinglelog.csv, ,,"RDB restart, sym subscriptions (using .rdb.subscribesyms variable)",2.1.2,"RDB subscribes to a subset of syms, is bounced",Data is the same in the RDB pre and post bounce,,AW,Done,recovery/recoverysinglelog.csv, ,,"RDB restart, complex filter using filtered subs functionality ",2.1.3,RDB subscribes to a subset of data using filtered functionality ,Data is the same in the RDB pre and post bounce,"These are similar to 2.1.1 but for this type of TP log file the TP may have multple log files, all of which should be replayed. So the set up should be: