From 9b9b3ed0c8a51ff9a51399111536255d07a1211a Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Fri, 18 Oct 2024 13:12:15 +0200 Subject: [PATCH 01/15] LDEV-4096 update to testbox 5.3.0 https://luceeserver.atlassian.net/browse/LDEV-4096 --- ant/build-core.xml | 19 ++++++++++++++----- ant/build-extensions.xml | 5 ++++- test/datasource/MongoDB.cfc | 5 +++++ test/tags/Query.cfc | 28 ++++++++++++++++------------ test/tickets/LDEV3116.cfc | 1 - 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/ant/build-core.xml b/ant/build-core.xml index 47d9c682e5..af1d330d38 100644 --- a/ant/build-core.xml +++ b/ant/build-core.xml @@ -11,11 +11,13 @@ - + - + + @@ -248,7 +250,7 @@ - + @@ -565,7 +567,7 @@ - + @@ -588,8 +590,15 @@ - + + + + + + + --> From 524b4e46790ee3a00b750b019eccc87577a324b0 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Sat, 7 Dec 2024 13:33:46 +0100 Subject: [PATCH 08/15] LDEV-5187 test case for Query Listener UDFs don't have the current application scope --- test/_testRunner.cfc | 2 +- test/tags/Query.cfc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/_testRunner.cfc b/test/_testRunner.cfc index e797ba5862..1808173795 100644 --- a/test/_testRunner.cfc +++ b/test/_testRunner.cfc @@ -92,7 +92,7 @@ component { onBundleStart = function( cfc, testResults ){ var meta = getComponentMetadata( cfc ); systemOutput( "" , true ); - application name="testBundle-#meta.name#"; + // application name="testBundle-#meta.name#"; // TODO see https://luceeserver.atlassian.net/browse/LDEV-5187 //systemOutput(structKeyList(getApplicationSettings().mappings), true ); SystemOut.setOut( out ); //SystemOut.setErr(err); diff --git a/test/tags/Query.cfc b/test/tags/Query.cfc index 938471d304..471b9fd548 100644 --- a/test/tags/Query.cfc +++ b/test/tags/Query.cfc @@ -223,7 +223,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { testAsyn(new query.QueryListener2(tbl),tbl,1); } - + // Query Listener UDFs don't have the current application scope https://luceeserver.atlassian.net/browse/LDEV-5187 public void function testAsynUDF() { var udf=function (caller,args,result,meta) { arguments.args.sql="insert into QueryTestAsync(id,i,dec) values('6',1,1.0)"; // change SQL From 4dd1134a1a18e5542b90daf2eab0318e637a1c85 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Sat, 7 Dec 2024 17:28:16 +0100 Subject: [PATCH 09/15] LDEV-5187 test case using request scope --- test/tags/Query.cfc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/tags/Query.cfc b/test/tags/Query.cfc index 471b9fd548..c96c6aec72 100644 --- a/test/tags/Query.cfc +++ b/test/tags/Query.cfc @@ -223,8 +223,22 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { testAsyn(new query.QueryListener2(tbl),tbl,1); } - // Query Listener UDFs don't have the current application scope https://luceeserver.atlassian.net/browse/LDEV-5187 public void function testAsynUDF() { + var udf=function (caller,args,result,meta) { + arguments.args.sql="insert into QueryTestAsync(id,i,dec) values('6',1,1.0)"; // change SQL + request.query_testAsynUDF=true; + return arguments; + }; + var tbl="QueryTestAsync"; + request.query_testAsynUDF=false; + testAsyn(udf,tbl,0); + sleep(500); + expect(request.query_testAsynUDF).toBeTrue(); + structDelete(request, "query_testAsynUDF"); + } + + // Query Listener UDFs don't have the current application scope https://luceeserver.atlassian.net/browse/LDEV-5187 + public void function testAsynUDFApplicationScope() skip="true" { var udf=function (caller,args,result,meta) { arguments.args.sql="insert into QueryTestAsync(id,i,dec) values('6',1,1.0)"; // change SQL application.query_testAsynUDF=true; From 434ad17987365c5a239f493ba7febc62322279f0 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Tue, 10 Dec 2024 12:53:03 +0100 Subject: [PATCH 10/15] LDEV-5187 use server scope for query async test --- test/_testRunner.cfc | 2 +- test/tags/Query.cfc | 38 +++++++++++++++----------------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/test/_testRunner.cfc b/test/_testRunner.cfc index 1808173795..e797ba5862 100644 --- a/test/_testRunner.cfc +++ b/test/_testRunner.cfc @@ -92,7 +92,7 @@ component { onBundleStart = function( cfc, testResults ){ var meta = getComponentMetadata( cfc ); systemOutput( "" , true ); - // application name="testBundle-#meta.name#"; // TODO see https://luceeserver.atlassian.net/browse/LDEV-5187 + application name="testBundle-#meta.name#"; //systemOutput(structKeyList(getApplicationSettings().mappings), true ); SystemOut.setOut( out ); //SystemOut.setErr(err); diff --git a/test/tags/Query.cfc b/test/tags/Query.cfc index c96c6aec72..ba637ec4ed 100644 --- a/test/tags/Query.cfc +++ b/test/tags/Query.cfc @@ -20,6 +20,10 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { //processingdirective pageencoding="UTF-8"; variables.suffix="Query"; + function afterAll(){ + structDelete( server, "query_testAsynUDF"); + } + public function beforeTests(){ defineDatasource(); @@ -223,36 +227,24 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { testAsyn(new query.QueryListener2(tbl),tbl,1); } - public void function testAsynUDF() { - var udf=function (caller,args,result,meta) { - arguments.args.sql="insert into QueryTestAsync(id,i,dec) values('6',1,1.0)"; // change SQL - request.query_testAsynUDF=true; - return arguments; - }; - var tbl="QueryTestAsync"; - request.query_testAsynUDF=false; - testAsyn(udf,tbl,0); - sleep(500); - expect(request.query_testAsynUDF).toBeTrue(); - structDelete(request, "query_testAsynUDF"); - } - - // Query Listener UDFs don't have the current application scope https://luceeserver.atlassian.net/browse/LDEV-5187 - public void function testAsynUDFApplicationScope() skip="true" { + /* + Async Query Listener UDFs get the current application scope + but get the default name="" application scope instead + https://luceeserver.atlassian.net/browse/LDEV-5187 + */ + public void function testAsynUDF { + server.query_testAsynUDF=false; var udf=function (caller,args,result,meta) { arguments.args.sql="insert into QueryTestAsync(id,i,dec) values('6',1,1.0)"; // change SQL - application.query_testAsynUDF=true; - systemOutput(application.query_testAsynUDF & " listener [#getApplicationSettings().name#]", true); - systemOutput(arguments, true); + server.query_testAsynUDF=true; return arguments; }; var tbl="QueryTestAsync"; - application.query_testAsynUDF=false; - systemOutput(application.query_testAsynUDF & " pre test, [#getApplicationSettings().name#]" , true); + server.query_testAsynUDF=false; testAsyn(udf,tbl,0); sleep(500); - systemOutput(application.query_testAsynUDF & " post test, [#getApplicationSettings().name#]" , true); - expect(application.query_testAsynUDF).toBeTrue(); + expect(server.query_testAsynUDF).toBeTrue(); + structDelete( server, "query_testAsynUDF"); } public void function testAsynStructUDF() { From 1119906f072cfea655ddeeeec1e383ec214d8984 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Tue, 10 Dec 2024 15:33:57 +0100 Subject: [PATCH 11/15] fix syntax error --- test/tags/Query.cfc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tags/Query.cfc b/test/tags/Query.cfc index ba637ec4ed..071181c21a 100644 --- a/test/tags/Query.cfc +++ b/test/tags/Query.cfc @@ -232,7 +232,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { but get the default name="" application scope instead https://luceeserver.atlassian.net/browse/LDEV-5187 */ - public void function testAsynUDF { + public void function testAsynUDF() { server.query_testAsynUDF=false; var udf=function (caller,args,result,meta) { arguments.args.sql="insert into QueryTestAsync(id,i,dec) values('6',1,1.0)"; // change SQL From 86f3ea8c06d555112978827d335f5731bc35d42e Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Tue, 10 Dec 2024 16:10:30 +0100 Subject: [PATCH 12/15] fix test, force MongoDBID to be a struct --- test/datasource/MongoDB.cfc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/datasource/MongoDB.cfc b/test/datasource/MongoDB.cfc index 14285d6dd1..307a7359db 100644 --- a/test/datasource/MongoDB.cfc +++ b/test/datasource/MongoDB.cfc @@ -114,13 +114,14 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="mongodb" { assertEquals(isNull(byid),true) } - public void function testMongoDBID() skip="isNotSupported" { - var id = MongoDBID(); - // TODO something changed with testbox - var objectId = deserializeJson(serializeJson(id)).objectId; // HACK - $assert.key(objectId,"date"); - $assert.key(objectId,"timestamp"); - //$assert.key(objectId,"id"); + public void function testMongoDBID_orig() skip="isNotSupported" { + if(isNotSupported()) return; + var _id = MongoDBID(); + var id = {}; // workaround https://ortussolutions.atlassian.net/browse/TESTBOX-370 + structAppend(id, _id); + $assert.key(id,"date"); + $assert.key(id,"timestamp"); + $assert.key(id,"id"); var dateSeed = now().add("d",-1) id = MongoDBID(dateSeed); From 8f9f04ee1915e69f00d02c47803798a2d4ffde22 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Tue, 10 Dec 2024 16:28:43 +0100 Subject: [PATCH 13/15] fix test, increase sleep --- test/tags/Query.cfc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/tags/Query.cfc b/test/tags/Query.cfc index 071181c21a..bd275db8a8 100644 --- a/test/tags/Query.cfc +++ b/test/tags/Query.cfc @@ -242,7 +242,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { var tbl="QueryTestAsync"; server.query_testAsynUDF=false; testAsyn(udf,tbl,0); - sleep(500); + sleep(600); expect(server.query_testAsynUDF).toBeTrue(); structDelete( server, "query_testAsynUDF"); } @@ -280,7 +280,6 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { } sleep(500); - systemOutput("post sleep", true); query name="local.qry" { echo("select * from "&tbl); } From a4e4c6468eee2ed362394debd0d4f5709f844e09 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Tue, 10 Dec 2024 16:51:07 +0100 Subject: [PATCH 14/15] fix test --- test/tags/Query.cfc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tags/Query.cfc b/test/tags/Query.cfc index bd275db8a8..bc4eba30b3 100644 --- a/test/tags/Query.cfc +++ b/test/tags/Query.cfc @@ -240,9 +240,9 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { return arguments; }; var tbl="QueryTestAsync"; - server.query_testAsynUDF=false; + expect(server.query_testAsynUDF).toBeFalse(); testAsyn(udf,tbl,0); - sleep(600); + sleep(200); expect(server.query_testAsynUDF).toBeTrue(); structDelete( server, "query_testAsynUDF"); } From 70cb35e501afc641ccb8af858c0f750ea4398e97 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Tue, 10 Dec 2024 17:08:25 +0100 Subject: [PATCH 15/15] increase timeout so async test can complete --- test/tags/Query.cfc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tags/Query.cfc b/test/tags/Query.cfc index bc4eba30b3..b298f55c31 100644 --- a/test/tags/Query.cfc +++ b/test/tags/Query.cfc @@ -242,7 +242,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { var tbl="QueryTestAsync"; expect(server.query_testAsynUDF).toBeFalse(); testAsyn(udf,tbl,0); - sleep(200); + sleep(800); // allow the async test to complete expect(server.query_testAsynUDF).toBeTrue(); structDelete( server, "query_testAsynUDF"); }