Skip to content

Commit 5846bae

Browse files
authored
Merge pull request #1807 from marklogic/feature/test-fix
MLE-12345 Going back to clearing the database
2 parents 1d4d9c5 + c548a0a commit 5846bae

File tree

1 file changed

+8
-15
lines changed
  • marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/functionaltest

1 file changed

+8
-15
lines changed

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/functionaltest/ConnectedRESTQA.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.marklogic.client.impl.SSLUtil;
1818
import com.marklogic.client.io.DocumentMetadataHandle;
1919
import com.marklogic.client.io.DocumentMetadataHandle.Capability;
20+
import com.marklogic.client.query.QueryManager;
2021
import com.marklogic.mgmt.ManageClient;
2122
import com.marklogic.mgmt.ManageConfig;
2223
import com.marklogic.mgmt.resource.appservers.ServerManager;
@@ -313,21 +314,13 @@ public static void deleteDB(String dbName) {
313314
}
314315

315316
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);
331324
}
332325
}
333326

0 commit comments

Comments
 (0)