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