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

LinkedIn | Twitter | YouTube | Facebook

 

From: Eliot Kimber <eliot.kimber@servicenow.com>
Date: Saturday, February 19, 2022 at 10:23 AM
To: basex-talk@mailman.uni-konstanz.de <basex-talk@mailman.uni-konstanz.de>
Subject: Re: [basex-talk] Using %unit:after to verify database creation

Attached is a Zip with two directories:

 

 

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

LinkedIn | Twitter | YouTube | Facebook

 

From: Christian Grün <christian.gruen@gmail.com>
Date: Saturday, February 19, 2022 at 9:21 AM
To: Eliot Kimber <eliot.kimber@servicenow.com>
Cc: basex-talk@mailman.uni-konstanz.de <basex-talk@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@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