Skip to content

Commit 3e32513

Browse files
ryanjdewMarkLogic Builder
authored andcommitted
DHFPROD-8258: Ensure indexes are ready for match tests
1 parent d897c58 commit 3e32513

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

marklogic-data-hub/src/test/ml-modules/root/test/data-hub-test-helper.xqy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,13 @@ declare function wait-for-indexes($count as xs:unsignedLong) {
382382
}, ())
383383
return
384384
if ($is-indexing) then
385-
let $_sleep := xdmp:sleep(5 * $count)
386-
return wait-for-indexes($count + 1)
385+
try {
386+
let $_sleep := xdmp:sleep(5 * $count)
387+
return wait-for-indexes($count + 1)
388+
} catch ($e) {
389+
if ($e/error:code = "XDMP-EXTIME") then ()
390+
else xdmp:rethrow()
391+
}
387392
else
388393
()
389394
};

marklogic-data-hub/src/test/ml-modules/root/test/suites/data-hub/5/data-services/mastering/previewMatchingActivity/setup.xqy

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ import module namespace test = "http://marklogic.com/test" at "/test/test-helper
1010
hub-test:load-entities($test:__CALLER_FILE__)
1111

1212
;
13-
(: Sleep added to give time for trigger that builds the entity-based TDEs. :)
14-
xdmp:sleep(250);
1513

1614
xquery version "1.0-ml";
1715
import module namespace hub-test = "http://marklogic.com/data-hub/test" at "/test/data-hub-test-helper.xqy";
1816
import module namespace test = "http://marklogic.com/test" at "/test/test-helper.xqy";
19-
hub-test:load-artifacts($test:__CALLER_FILE__);
17+
hub-test:load-artifacts($test:__CALLER_FILE__)
18+
19+
;
20+
21+
xquery version "1.0-ml";
22+
import module namespace hub-test = "http://marklogic.com/data-hub/test" at "/test/data-hub-test-helper.xqy";
23+
hub-test:wait-for-indexes();

marklogic-data-hub/src/test/ml-modules/root/test/suites/data-hub/5/data-services/mastering/previewMatchingActivity2/setup.xqy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ return
3131
(xdmp:default-permissions(), xdmp:permission('data-hub-common', 'read'), xdmp:permission('data-hub-common', 'update')),
3232
$const:CONTENT-COLL
3333
)
34+
35+
36+
;
37+
38+
xquery version "1.0-ml";
39+
import module namespace hub-test = "http://marklogic.com/data-hub/test" at "/test/data-hub-test-helper.xqy";
40+
hub-test:wait-for-indexes();

marklogic-data-hub/src/test/ml-modules/root/test/suites/data-hub/5/smart-mastering/entity-matching/structured-property/suite-setup.xqy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ xquery version "1.0-ml";
88
import module namespace hub-test = "http://marklogic.com/data-hub/test" at "/test/data-hub-test-helper.xqy";
99
import module namespace test = "http://marklogic.com/test" at "/test/test-helper.xqy";
1010
hub-test:load-artifacts($test:__CALLER_FILE__)
11+
12+
;
13+
14+
xquery version "1.0-ml";
15+
import module namespace hub-test = "http://marklogic.com/data-hub/test" at "/test/data-hub-test-helper.xqy";
16+
hub-test:wait-for-indexes()

marklogic-data-hub/src/test/ml-modules/root/test/suites/data-hub/5/smart-mastering/lib/masteringTestLib.sjs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,30 +98,31 @@ function assertMatchExists(matchSummary, urisOfMatchingDocuments) {
9898
urisOfMatchingDocuments = [urisOfMatchingDocuments];
9999
}
100100

101-
const uriToProcess = matchSummary.URIsToProcess[0];
101+
const expectedPrefix = "/com.marklogic.smart-mastering/merged/";
102+
const uriToProcess = matchSummary.URIsToProcess.filter((uri) => uri.startsWith(expectedPrefix))[0];
102103
const actionDetails = matchSummary.actionDetails[uriToProcess];
103104

104105
// Add the input doc
105106
const expectedUriCount = urisOfMatchingDocuments.length + 1;
106107

107-
const prettyActionDetailsUris = xdmp.toJsonString(actionDetails.uris);
108-
const expectedPrefix = "/com.marklogic.smart-mastering/merged/";
108+
const actualUris = actionDetails ? actionDetails.uris : [];
109+
const prettyActionDetailsUris = xdmp.toJsonString(actualUris);
109110

110111
let assertions = [
111112
test.assertTrue(uriToProcess.startsWith(expectedPrefix),
112113
`Since a merge is expected, the URI to process should start with ${expectedPrefix}; actual URI: ${uriToProcess}`
113114
),
114-
test.assertEqual(expectedUriCount, actionDetails.uris.length,
115+
test.assertEqual(expectedUriCount, actualUris.length,
115116
`Expected ${expectedUriCount} matching URIs; actual URIs: ${prettyActionDetailsUris}`
116117
),
117-
test.assertTrue(actionDetails.uris.includes(TEST_DOC_URI),
118+
test.assertTrue(actualUris.includes(TEST_DOC_URI),
118119
`Expected the test doc ${TEST_DOC_URI} to be in actionDetails.uris; actual URIs: ${prettyActionDetailsUris}`
119120
)
120121
];
121122

122123
urisOfMatchingDocuments.forEach(uri => {
123124
assertions.push(
124-
test.assertTrue(actionDetails.uris.includes(uri),
125+
test.assertTrue(actualUris.includes(uri),
125126
`Expected actionDetails.uris to include ${uri}; actual URIs: ${prettyActionDetailsUris}`
126127
)
127128
);

0 commit comments

Comments
 (0)