Using %unit:after to verify database creation
Saturday, 19 February 2022 · 10 messages · last reply 20 Feb 2022
EK
Eliot Kimber19 Feb 2022 15:56 #
I’m working out my new-and-improved orchestration mechanism using the job-chaining approach and I’m not getting the unit test behavior I was expecting.
My current unit test is:
declare %unit:after("test:runMultipleJobs") function test:afterRunMultipleJobs() {
(
for $database in $test:dbs
return
unit:assert(db:exists($database), 'Expected database ' || $database || ' to exist')
)
};
declare %unit:test function test:runMultipleJobs() {
let $jobs as xs:string* := (
for $database in $test:dbs
return dbadmin:makeJob('dbadmin:createDatabase', $database)
)
let $jobIds as xs:string* := orch:runJobs($jobs)
return
(
unit:assert-equals(count($jobIds), 3, 'Expected 3 job IDs')
)
};When I run this test I expect it to either pass (because my job-runner caused all the databases to be created) or fail on “db2” (because I can see that the first database db1 is created by inspecting the Databases via the DBA console after running the test, but the others are not).
What I’m getting, however, is that the assert in the test:afterRunMultipleJobs() fails on db1, meaning it doesn’t see that that database has in fact been created.
This must be an issue with when the test runner can actually see that the database exists or a timing issue with when the job runs relative to the unit test code.
I did experiment with having both the base unit test and the after function sleep before doing the existence assertion but that seemed to have no effect, which suggests that the runner simply can’t see databases created by the tests it runs.
Is the inability to see the newly-created databases simply a limitation in the test runner or am I doing something wrong?
Thanks,
E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>
CG
Christian Grün19 Feb 2022 16:21 #
Could you provide us with a little self-contained example?
Thanks in advance,
Christian
Quoted text · Eliot Kimber · 92 lines
On Sat, Feb 19, 2022 at 3:56 PM Eliot Kimber <eliot.kimber at servicenow.com> wrote: > > I’m working out my new-and-improved orchestration mechanism using the job-chaining approach and I’m not getting the unit test behavior I was expecting. > > > > My current unit test is: > > > > declare %unit:after("test:runMultipleJobs") function test:afterRunMultipleJobs() { > > ( > > for $database in $test:dbs > > return > > unit:assert(db:exists($database), 'Expected database ' || $database || ' to exist') > > ) > > }; > > > > declare %unit:test function test:runMultipleJobs() { > > let $jobs as xs:string* := ( > > for $database in $test:dbs > > return dbadmin:makeJob('dbadmin:createDatabase', $database) > > ) > > let $jobIds as xs:string* := orch:runJobs($jobs) > > return > > ( > > unit:assert-equals(count($jobIds), 3, 'Expected 3 job IDs') > > ) > > }; > > > > When I run this test I expect it to either pass (because my job-runner caused all the databases to be created) or fail on “db2” (because I can see that the first database db1 is created by inspecting the Databases via the DBA console after running the test, but the others are not). > > > > What I’m getting, however, is that the assert in the test:afterRunMultipleJobs() fails on db1, meaning it doesn’t see that that database has in fact been created. > > > > This must be an issue with when the test runner can actually see that the database exists or a timing issue with when the job runs relative to the unit test code. > > > > I did experiment with having both the base unit test and the after function sleep before doing the existence assertion but that seemed to have no effect, which suggests that the runner simply can’t see databases created by the tests it runs. > > > > Is the inability to see the newly-created databases simply a limitation in the test runner or am I doing something wrong? > > > > Thanks, > > > > E. > > > > _____________________________________________ > > Eliot Kimber > > Sr Staff Content Engineer > > O: 512 554 9368 > > M: 512 554 9368 > > servicenow.com > > LinkedIn | Twitter | YouTube | Facebook
EK
Eliot Kimber19 Feb 2022 17:14 #
I can provide an example but I think I see what’s happening: The jobs are not run until the unit tests complete—I see all the messages from the jobs emitted after all the messages from any unit tests. The fact that the jobs do run and do what I expect supports that analysis.
I’ll put together a package that lets you run my tests.
Cheers,
E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>
Quoted text · Christian Grün · 101 lines
From: Christian Grün <christian.gruen at gmail.com> Date: Saturday, February 19, 2022 at 9:21 AM To: Eliot Kimber <eliot.kimber at servicenow.com> Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Using %unit:after to verify database creation [External Email] Could you provide us with a little self-contained example? Thanks in advance, Christian On Sat, Feb 19, 2022 at 3:56 PM Eliot Kimber <eliot.kimber at servicenow.com> wrote: > > I’m working out my new-and-improved orchestration mechanism using the job-chaining approach and I’m not getting the unit test behavior I was expecting. > > > > My current unit test is: > > > > declare %unit:after("test:runMultipleJobs") function test:afterRunMultipleJobs() { > > ( > > for $database in $test:dbs > > return > > unit:assert(db:exists($database), 'Expected database ' || $database || ' to exist') > > ) > > }; > > > > declare %unit:test function test:runMultipleJobs() { > > let $jobs as xs:string* := ( > > for $database in $test:dbs > > return dbadmin:makeJob('dbadmin:createDatabase', $database) > > ) > > let $jobIds as xs:string* := orch:runJobs($jobs) > > return > > ( > > unit:assert-equals(count($jobIds), 3, 'Expected 3 job IDs') > > ) > > }; > > > > When I run this test I expect it to either pass (because my job-runner caused all the databases to be created) or fail on “db2” (because I can see that the first database db1 is created by inspecting the Databases via the DBA console after running the test, but the others are not). > > > > What I’m getting, however, is that the assert in the test:afterRunMultipleJobs() fails on db1, meaning it doesn’t see that that database has in fact been created. > > > > This must be an issue with when the test runner can actually see that the database exists or a timing issue with when the job runs relative to the unit test code. > > > > I did experiment with having both the base unit test and the after function sleep before doing the existence assertion but that seemed to have no effect, which suggests that the runner simply can’t see databases created by the tests it runs. > > > > Is the inability to see the newly-created databases simply a limitation in the test runner or am I doing something wrong? > > > > Thanks, > > > > E. > > > > _____________________________________________ > > Eliot Kimber > > Sr Staff Content Engineer > > O: 512 554 9368 > > M: 512 554 9368 > > servicenow.com > > LinkedIn | Twitter | YouTube | Facebook
EK
Attached is a Zip with two directories:
* repo/ contains the deployed modules—just copy now/ into basex/repo
* test/ contains test-orchestration.xqy, which should run correctly using the TEST command
The tests I’m focused on are test:runJob1, test:runJob2, and test:runMultipleJobs(): all attempt to verify the result of the jobs and all fail to do so.
The test:runMultipleJobs() test should fail to find db2 because there’s a bug in the job chaining logic reflected in this version of the code, but it fails to find db1.
It’s definitely not the end of the world if it’s not possible or practical to unit test jobs—it’s easy enough to inspect the results, but it would be nice to be able to unit test them.
Cheers,
E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>
Quoted text · Christian Grün · 101 lines
From: Christian Grün <christian.gruen at gmail.com> Date: Saturday, February 19, 2022 at 9:21 AM To: Eliot Kimber <eliot.kimber at servicenow.com> Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Using %unit:after to verify database creation [External Email] Could you provide us with a little self-contained example? Thanks in advance, Christian On Sat, Feb 19, 2022 at 3:56 PM Eliot Kimber <eliot.kimber at servicenow.com> wrote: > > I’m working out my new-and-improved orchestration mechanism using the job-chaining approach and I’m not getting the unit test behavior I was expecting. > > > > My current unit test is: > > > > declare %unit:after("test:runMultipleJobs") function test:afterRunMultipleJobs() { > > ( > > for $database in $test:dbs > > return > > unit:assert(db:exists($database), 'Expected database ' || $database || ' to exist') > > ) > > }; > > > > declare %unit:test function test:runMultipleJobs() { > > let $jobs as xs:string* := ( > > for $database in $test:dbs > > return dbadmin:makeJob('dbadmin:createDatabase', $database) > > ) > > let $jobIds as xs:string* := orch:runJobs($jobs) > > return > > ( > > unit:assert-equals(count($jobIds), 3, 'Expected 3 job IDs') > > ) > > }; > > > > When I run this test I expect it to either pass (because my job-runner caused all the databases to be created) or fail on “db2” (because I can see that the first database db1 is created by inspecting the Databases via the DBA console after running the test, but the others are not). > > > > What I’m getting, however, is that the assert in the test:afterRunMultipleJobs() fails on db1, meaning it doesn’t see that that database has in fact been created. > > > > This must be an issue with when the test runner can actually see that the database exists or a timing issue with when the job runs relative to the unit test code. > > > > I did experiment with having both the base unit test and the after function sleep before doing the existence assertion but that seemed to have no effect, which suggests that the runner simply can’t see databases created by the tests it runs. > > > > Is the inability to see the newly-created databases simply a limitation in the test runner or am I doing something wrong? > > > > Thanks, > > > > E. > > > > _____________________________________________ > > Eliot Kimber > > Sr Staff Content Engineer > > O: 512 554 9368 > > M: 512 554 9368 > > servicenow.com > > LinkedIn | Twitter | YouTube | Facebook
EK
Eliot Kimber19 Feb 2022 17:48 #
FYI, I’ve fixed the bugs in my job construction logic. Constructing a non-trivial XQuery from XQuery can be a challenge. Thank goodness for string consructors in XQuery 3.
Cheers,
E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>
Quoted text · Eliot Kimber · 119 lines
From: Eliot Kimber <eliot.kimber at servicenow.com> Date: Saturday, February 19, 2022 at 10:23 AM To: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Using %unit:after to verify database creation Attached is a Zip with two directories: * repo/ contains the deployed modules—just copy now/ into basex/repo * test/ contains test-orchestration.xqy, which should run correctly using the TEST command The tests I’m focused on are test:runJob1, test:runJob2, and test:runMultipleJobs(): all attempt to verify the result of the jobs and all fail to do so. The test:runMultipleJobs() test should fail to find db2 because there’s a bug in the job chaining logic reflected in this version of the code, but it fails to find db1. It’s definitely not the end of the world if it’s not possible or practical to unit test jobs—it’s easy enough to inspect the results, but it would be nice to be able to unit test them. Cheers, E. Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 servicenow.com<https://www.servicenow.com> LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow> From: Christian Grün <christian.gruen at gmail.com> Date: Saturday, February 19, 2022 at 9:21 AM To: Eliot Kimber <eliot.kimber at servicenow.com> Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Using %unit:after to verify database creation [External Email] Could you provide us with a little self-contained example? Thanks in advance, Christian On Sat, Feb 19, 2022 at 3:56 PM Eliot Kimber <eliot.kimber at servicenow.com> wrote: > > I’m working out my new-and-improved orchestration mechanism using the job-chaining approach and I’m not getting the unit test behavior I was expecting. > > > > My current unit test is: > > > > declare %unit:after("test:runMultipleJobs") function test:afterRunMultipleJobs() { > > ( > > for $database in $test:dbs > > return > > unit:assert(db:exists($database), 'Expected database ' || $database || ' to exist') > > ) > > }; > > > > declare %unit:test function test:runMultipleJobs() { > > let $jobs as xs:string* := ( > > for $database in $test:dbs > > return dbadmin:makeJob('dbadmin:createDatabase', $database) > > ) > > let $jobIds as xs:string* := orch:runJobs($jobs) > > return > > ( > > unit:assert-equals(count($jobIds), 3, 'Expected 3 job IDs') > > ) > > }; > > > > When I run this test I expect it to either pass (because my job-runner caused all the databases to be created) or fail on “db2” (because I can see that the first database db1 is created by inspecting the Databases via the DBA console after running the test, but the others are not). > > > > What I’m getting, however, is that the assert in the test:afterRunMultipleJobs() fails on db1, meaning it doesn’t see that that database has in fact been created. > > > > This must be an issue with when the test runner can actually see that the database exists or a timing issue with when the job runs relative to the unit test code. > > > > I did experiment with having both the base unit test and the after function sleep before doing the existence assertion but that seemed to have no effect, which suggests that the runner simply can’t see databases created by the tests it runs. > > > > Is the inability to see the newly-created databases simply a limitation in the test runner or am I doing something wrong? > > > > Thanks, > > > > E. > > > > _____________________________________________ > > Eliot Kimber > > Sr Staff Content Engineer > > O: 512 554 9368 > > M: 512 554 9368 > > servicenow.com > > LinkedIn | Twitter | YouTube | Facebook
CG
I guess the function dutils:getDirectReferences is still missing in your example.
But I’m glad to hear you’ve already found the bug.
EK
Eliot Kimber19 Feb 2022 18:30 #
Let me remake the sample code—it should all be there—with my now-working job construction log.
The issue with the unit tests not seeing the results of the jobs remains.
I’ve attached take 2 of the code, which fixes my earlier bug with job creation and running, so that, for example, the test:runMultipleJobs test does create all three expected databases, meaning the chain of three jobs ran.
I tested this code package by deleting the now/ directory from basex/repo, verifying nothing works, copied the now/ directory from the zip to basex/repo, ran the test from the zip in the GUI:
test /Users/eliot.kimber/temp/basex-job-test-test/test/test-orchestration.xqm
which produces for me this result:
<testsuites time="PT0.429S">
<testsuite name="file:///Users/eliot.kimber/temp/basex-job-test-test/test/test-orchestration.xqm" time="PT0.429S" tests="8" failures="4" errors="0" skipped="0">
<testcase name="createJob" time="PT0.036S"/>
<testcase name="createBadJob" time="PT0.016S"/>
<testcase name="runJobs1" time="PT0.065S">
<failure line="97" column="16">
<info>Expected database test_01 to exist</info>
</failure>
</testcase>
<testcase name="runJobs2" time="PT0.061S">
<failure line="123" column="14">
<info>Expected database test_01 to not exist</info>
</failure>
</testcase>
<testcase name="runMultipleJobs" time="PT0.041S">
<failure line="143" column="16">
<info>Expected database db1 to exist</info>
</failure>
</testcase>
<testcase name="runSwapJobs" time="PT0.074S">
<failure line="185" column="16">
<info>Expected to find doc2 in database test_swapped_to</info>
</failure>
</testcase>
<testcase name="makeJobsFromModules" time="PT0.016S"/>
<testcase name="makeSwapJobs" time="PT0.016S"/>
</testsuite>
</testsuites>Cheers,
E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>
Quoted text · Christian Grün · 9 lines
From: Christian Grün <christian.gruen at gmail.com> Date: Saturday, February 19, 2022 at 11:02 AM To: Eliot Kimber <eliot.kimber at servicenow.com> Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Using %unit:after to verify database creation [External Email] I guess the function dutils:getDirectReferences is still missing in your example. But I’m glad to hear you’ve already found the bug.
CG
Christian Grün19 Feb 2022 18:38 #
I still get numerous parsing errors when opening your project files with BaseX, and I’m sorry I don’t have time to track all this down. If you believe that anything of your code that can still be dropped, feel free to give it a go. See e.g. [1] for some hints on some suggestions.
[1] https://stackoverflow.com/help/minimal-reproducible-example
Quoted text · Eliot Kimber · 118 lines
On Sat, Feb 19, 2022 at 6:30 PM Eliot Kimber <eliot.kimber at servicenow.com> wrote: > > Let me remake the sample code—it should all be there—with my now-working job construction log. > > > > The issue with the unit tests not seeing the results of the jobs remains. > > > > I’ve attached take 2 of the code, which fixes my earlier bug with job creation and running, so that, for example, the test:runMultipleJobs test does create all three expected databases, meaning the chain of three jobs ran. > > > > I tested this code package by deleting the now/ directory from basex/repo, verifying nothing works, copied the now/ directory from the zip to basex/repo, ran the test from the zip in the GUI: > > > > test /Users/eliot.kimber/temp/basex-job-test-test/test/test-orchestration.xqm > > > > which produces for me this result: > > <testsuites time="PT0.429S"> > > <testsuite name="file:///Users/eliot.kimber/temp/basex-job-test-test/test/test-orchestration.xqm" time="PT0.429S" tests="8" failures="4" errors="0" skipped="0"> > > <testcase name="createJob" time="PT0.036S"/> > > <testcase name="createBadJob" time="PT0.016S"/> > > <testcase name="runJobs1" time="PT0.065S"> > > <failure line="97" column="16"> > > <info>Expected database test_01 to exist</info> > > </failure> > > </testcase> > > <testcase name="runJobs2" time="PT0.061S"> > > <failure line="123" column="14"> > > <info>Expected database test_01 to not exist</info> > > </failure> > > </testcase> > > <testcase name="runMultipleJobs" time="PT0.041S"> > > <failure line="143" column="16"> > > <info>Expected database db1 to exist</info> > > </failure> > > </testcase> > > <testcase name="runSwapJobs" time="PT0.074S"> > > <failure line="185" column="16"> > > <info>Expected to find doc2 in database test_swapped_to</info> > > </failure> > > </testcase> > > <testcase name="makeJobsFromModules" time="PT0.016S"/> > > <testcase name="makeSwapJobs" time="PT0.016S"/> > > </testsuite> > > </testsuites> > > > > Cheers, > > > > E. > > _____________________________________________ > > Eliot Kimber > > Sr Staff Content Engineer > > O: 512 554 9368 > > M: 512 554 9368 > > servicenow.com > > LinkedIn | Twitter | YouTube | Facebook > > > > From: Christian Grün <christian.gruen at gmail.com> > Date: Saturday, February 19, 2022 at 11:02 AM > To: Eliot Kimber <eliot.kimber at servicenow.com> > Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> > Subject: Re: [basex-talk] Using %unit:after to verify database creation > > [External Email] > > > I guess the function dutils:getDirectReferences is still missing in > your example. > > But I’m glad to hear you’ve already found the bug.
EK
Eliot Kimber19 Feb 2022 18:50 #
No worries—I’ll try to make something smaller at some point. I’m sorry my initial attempt didn’t work. Did not mean to waste your time with that. The orchestration bit is possibly useful as a standalone thing so might be worth taking the effort to package it as its own little github project.
Cheers,
E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>
Quoted text · Christian Grün · 129 lines
From: Christian Grün <christian.gruen at gmail.com> Date: Saturday, February 19, 2022 at 11:39 AM To: Eliot Kimber <eliot.kimber at servicenow.com> Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Using %unit:after to verify database creation [External Email] I still get numerous parsing errors when opening your project files with BaseX, and I’m sorry I don’t have time to track all this down. If you believe that anything of your code that can still be dropped, feel free to give it a go. See e.g. [1] for some hints on some suggestions. [1] https://urldefense.com/v3/__https://stackoverflow.com/help/minimal-reproducible-example__;!!N4vogdjhuJM!Uw8n7H4gU-0LZJBR5OFYbnRkp3bE1Bc_y-dcqHfm884d73RvzLmBm5UFSPt1F1VT6rEwuA$<https://urldefense.com/v3/__https:/stackoverflow.com/help/minimal-reproducible-example__;!!N4vogdjhuJM!Uw8n7H4gU-0LZJBR5OFYbnRkp3bE1Bc_y-dcqHfm884d73RvzLmBm5UFSPt1F1VT6rEwuA$> On Sat, Feb 19, 2022 at 6:30 PM Eliot Kimber <eliot.kimber at servicenow.com> wrote: > > Let me remake the sample code—it should all be there—with my now-working job construction log. > > > > The issue with the unit tests not seeing the results of the jobs remains. > > > > I’ve attached take 2 of the code, which fixes my earlier bug with job creation and running, so that, for example, the test:runMultipleJobs test does create all three expected databases, meaning the chain of three jobs ran. > > > > I tested this code package by deleting the now/ directory from basex/repo, verifying nothing works, copied the now/ directory from the zip to basex/repo, ran the test from the zip in the GUI: > > > > test /Users/eliot.kimber/temp/basex-job-test-test/test/test-orchestration.xqm > > > > which produces for me this result: > > <testsuites time="PT0.429S"> > > <testsuite name="file:///Users/eliot.kimber/temp/basex-job-test-test/test/test-orchestration.xqm" time="PT0.429S" tests="8" failures="4" errors="0" skipped="0"> > > <testcase name="createJob" time="PT0.036S"/> > > <testcase name="createBadJob" time="PT0.016S"/> > > <testcase name="runJobs1" time="PT0.065S"> > > <failure line="97" column="16"> > > <info>Expected database test_01 to exist</info> > > </failure> > > </testcase> > > <testcase name="runJobs2" time="PT0.061S"> > > <failure line="123" column="14"> > > <info>Expected database test_01 to not exist</info> > > </failure> > > </testcase> > > <testcase name="runMultipleJobs" time="PT0.041S"> > > <failure line="143" column="16"> > > <info>Expected database db1 to exist</info> > > </failure> > > </testcase> > > <testcase name="runSwapJobs" time="PT0.074S"> > > <failure line="185" column="16"> > > <info>Expected to find doc2 in database test_swapped_to</info> > > </failure> > > </testcase> > > <testcase name="makeJobsFromModules" time="PT0.016S"/> > > <testcase name="makeSwapJobs" time="PT0.016S"/> > > </testsuite> > > </testsuites> > > > > Cheers, > > > > E. > > _____________________________________________ > > Eliot Kimber > > Sr Staff Content Engineer > > O: 512 554 9368 > > M: 512 554 9368 > > servicenow.com > > LinkedIn | Twitter | YouTube | Facebook > > > > From: Christian Grün <christian.gruen at gmail.com> > Date: Saturday, February 19, 2022 at 11:02 AM > To: Eliot Kimber <eliot.kimber at servicenow.com> > Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> > Subject: Re: [basex-talk] Using %unit:after to verify database creation > > [External Email] > > > I guess the function dutils:getDirectReferences is still missing in > your example. > > But I’m glad to hear you’ve already found the bug.
EK
Eliot Kimber20 Feb 2022 16:45 #
I’ve created this GitHub project: https://github.com/ekimbernow/basex-orchestration
With just the orchestration code and one module with functions that are orchestrated, along with the original unit test.
This should work in isolation—it did in my tests 😊
The orchestration processing definitely works but I have no idea if this approach to managing multiple transactions is sound—I’m sure there are details in the code that can be improved but I put this together very quickly…
Cheers,
E.
_____________________________________________
Eliot Kimber
Sr Staff Content Engineer
O: 512 554 9368
M: 512 554 9368
servicenow.com<https://www.servicenow.com>
LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>
Quoted text · Eliot Kimber · 143 lines
From: Eliot Kimber <eliot.kimber at servicenow.com> Date: Saturday, February 19, 2022 at 11:50 AM To: Christian Grün <christian.gruen at gmail.com> Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Using %unit:after to verify database creation No worries—I’ll try to make something smaller at some point. I’m sorry my initial attempt didn’t work. Did not mean to waste your time with that. The orchestration bit is possibly useful as a standalone thing so might be worth taking the effort to package it as its own little github project. Cheers, E. Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 servicenow.com<https://www.servicenow.com> LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow> From: Christian Grün <christian.gruen at gmail.com> Date: Saturday, February 19, 2022 at 11:39 AM To: Eliot Kimber <eliot.kimber at servicenow.com> Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Using %unit:after to verify database creation [External Email] I still get numerous parsing errors when opening your project files with BaseX, and I’m sorry I don’t have time to track all this down. If you believe that anything of your code that can still be dropped, feel free to give it a go. See e.g. [1] for some hints on some suggestions. [1] https://urldefense.com/v3/__https://stackoverflow.com/help/minimal-reproducible-example__;!!N4vogdjhuJM!Uw8n7H4gU-0LZJBR5OFYbnRkp3bE1Bc_y-dcqHfm884d73RvzLmBm5UFSPt1F1VT6rEwuA$<https://urldefense.com/v3/__https:/stackoverflow.com/help/minimal-reproducible-example__;!!N4vogdjhuJM!Uw8n7H4gU-0LZJBR5OFYbnRkp3bE1Bc_y-dcqHfm884d73RvzLmBm5UFSPt1F1VT6rEwuA$> On Sat, Feb 19, 2022 at 6:30 PM Eliot Kimber <eliot.kimber at servicenow.com> wrote: > > Let me remake the sample code—it should all be there—with my now-working job construction log. > > > > The issue with the unit tests not seeing the results of the jobs remains. > > > > I’ve attached take 2 of the code, which fixes my earlier bug with job creation and running, so that, for example, the test:runMultipleJobs test does create all three expected databases, meaning the chain of three jobs ran. > > > > I tested this code package by deleting the now/ directory from basex/repo, verifying nothing works, copied the now/ directory from the zip to basex/repo, ran the test from the zip in the GUI: > > > > test /Users/eliot.kimber/temp/basex-job-test-test/test/test-orchestration.xqm > > > > which produces for me this result: > > <testsuites time="PT0.429S"> > > <testsuite name="file:///Users/eliot.kimber/temp/basex-job-test-test/test/test-orchestration.xqm" time="PT0.429S" tests="8" failures="4" errors="0" skipped="0"> > > <testcase name="createJob" time="PT0.036S"/> > > <testcase name="createBadJob" time="PT0.016S"/> > > <testcase name="runJobs1" time="PT0.065S"> > > <failure line="97" column="16"> > > <info>Expected database test_01 to exist</info> > > </failure> > > </testcase> > > <testcase name="runJobs2" time="PT0.061S"> > > <failure line="123" column="14"> > > <info>Expected database test_01 to not exist</info> > > </failure> > > </testcase> > > <testcase name="runMultipleJobs" time="PT0.041S"> > > <failure line="143" column="16"> > > <info>Expected database db1 to exist</info> > > </failure> > > </testcase> > > <testcase name="runSwapJobs" time="PT0.074S"> > > <failure line="185" column="16"> > > <info>Expected to find doc2 in database test_swapped_to</info> > > </failure> > > </testcase> > > <testcase name="makeJobsFromModules" time="PT0.016S"/> > > <testcase name="makeSwapJobs" time="PT0.016S"/> > > </testsuite> > > </testsuites> > > > > Cheers, > > > > E. > > _____________________________________________ > > Eliot Kimber > > Sr Staff Content Engineer > > O: 512 554 9368 > > M: 512 554 9368 > > servicenow.com > > LinkedIn | Twitter | YouTube | Facebook > > > > From: Christian Grün <christian.gruen at gmail.com> > Date: Saturday, February 19, 2022 at 11:02 AM > To: Eliot Kimber <eliot.kimber at servicenow.com> > Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> > Subject: Re: [basex-talk] Using %unit:after to verify database creation > > [External Email] > > > I guess the function dutils:getDirectReferences is still missing in > your example. > > But I’m glad to hear you’ve already found the bug.
Written for BaseX 9.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery