|
17 | 17 | import com.marklogic.client.impl.SSLUtil;
|
18 | 18 | import com.marklogic.client.io.DocumentMetadataHandle;
|
19 | 19 | import com.marklogic.client.io.DocumentMetadataHandle.Capability;
|
| 20 | +import com.marklogic.client.query.QueryManager; |
20 | 21 | import com.marklogic.mgmt.ManageClient;
|
21 | 22 | import com.marklogic.mgmt.ManageConfig;
|
22 | 23 | import com.marklogic.mgmt.resource.appservers.ServerManager;
|
@@ -313,21 +314,13 @@ public static void deleteDB(String dbName) {
|
313 | 314 | }
|
314 | 315 |
|
315 | 316 | public static void clearDB(int port) {
|
316 |
| - DatabaseClientBuilder builder = newDatabaseClientBuilder() |
317 |
| - .withDigestAuth(admin_user, admin_password) |
318 |
| - .withPort(port); |
319 |
| - |
320 |
| - try (DatabaseClient client = builder.build()) { |
321 |
| - // Trying an eval instead of a "DELETE v1/search", which leads to intermittent errors on Jenkins involving |
322 |
| - // a "clear" operation on a forest failing. |
323 |
| - String count = client.newServerEval() |
324 |
| - .xquery("let $uris := " + |
325 |
| - " for $uri in cts:uris((), (), cts:true-query()) " + |
326 |
| - " let $_ := xdmp:document-delete($uri) " + |
327 |
| - " return $uri " + |
328 |
| - "return fn:count($uris)") |
329 |
| - .evalAs(String.class); |
330 |
| - LoggerFactory.getLogger(ConnectedRESTQA.class).info("Cleared database, deleting {} URIs", count); |
| 317 | + try (DatabaseClient client = newDatabaseClientBuilder().withPort(port).build()) { |
| 318 | + QueryManager mgr = client.newQueryManager(); |
| 319 | + mgr.delete(mgr.newDeleteDefinition()); |
| 320 | + // Clearing the database occasionally causes a forest to not be available for a moment or two when the tests |
| 321 | + // are running on Jenkins. This leads to intermittent failures. Waiting is not guaranteed to avoid the |
| 322 | + // error but simply hopes to minimize the chance of an intermittent failure. |
| 323 | + waitFor(2000); |
331 | 324 | }
|
332 | 325 | }
|
333 | 326 |
|
|
0 commit comments