Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.marklogic.mgmt.resource.temporal.TemporalAxesManager;
import com.marklogic.mgmt.resource.temporal.TemporalCollectionLSQTManager;
import com.marklogic.mgmt.resource.temporal.TemporalCollectionManager;
import org.slf4j.LoggerFactory;

import javax.net.ssl.*;
import java.io.IOException;
Expand Down Expand Up @@ -317,12 +318,20 @@ public static void deleteDB(String dbName) {

public static void clearDB(int port) {
try (DatabaseClient client = newDatabaseClientBuilder().withPort(port).build()) {
QueryManager mgr = client.newQueryManager();
mgr.delete(mgr.newDeleteDefinition());
// Trying an eval instead of a "DELETE v1/search", which leads to intermittent errors on Jenkins involving
// a "clear" operation on a forest failing.
String count = client.newServerEval()
.xquery("let $uris := " +
" for $uri in cts:uris((), (), cts:true-query()) " +
" let $_ := xdmp:document-delete($uri) " +
" return $uri " +
"return fn:count($uris)")
.evalAs(String.class);
LoggerFactory.getLogger(ConnectedRESTQA.class).info("Cleared database, deleting {} URIs", count);
}
}

public static void tearDownJavaRESTServer(String dbName, String[] fNames, String restServerName) {
public static void tearDownJavaRESTServer(String dbName, String restServerName) {
associateRESTServerWithDB(restServerName, "Documents");
deleteDB(dbName);
}
Expand Down Expand Up @@ -849,11 +858,11 @@ public static void configureRESTServer(String dbName, String[] fNames, boolean b
}

// Removes the database and forest from a REST server.
public static void cleanupRESTServer(String dbName, String[] fNames) throws Exception {
public static void cleanupRESTServer(String dbName) {
if (IsSecurityEnabled())
tearDownJavaRESTServer(dbName, fNames, restSslServerName);
tearDownJavaRESTServer(dbName, restSslServerName);
else
tearDownJavaRESTServer(dbName, fNames, restServerName);
tearDownJavaRESTServer(dbName, restServerName);
}

// Returns true or false based security (ssl) is enabled or disabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void setUpBeforeClass() throws Exception {
@AfterAll
public static void tearDownAfterClass() throws Exception {
System.out.println("In tear down");
cleanupRESTServer(dbName, fNames);
cleanupRESTServer(dbName);
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static void setUpBeforeClass() throws Exception {
public static void tearDownAfterClass() throws Exception {
System.out.println("In tear down");

cleanupRESTServer(dbName, fNames);
cleanupRESTServer(dbName);
deleteRESTUser("eval-bitemp-meta-user");
deleteRESTUser("eval-readeruser");
deleteUserRole("test-eval-bitemp");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static void tearDownAfterClass() throws Exception {
System.out.println("In tear down");

// Delete database first. Otherwise axis and collection cannot be deleted
cleanupRESTServer(dbName, fNames);
cleanupRESTServer(dbName);
deleteRESTUser("eval-user");
deleteUserRole("test-eval");
deleteDB(schemadbName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static void tearDownAfterClass() throws Exception {
System.out.println("In tear down");
deleteUserRole("test-evalKer");
deleteRESTUser("builder");
tearDownJavaRESTServer(dbName, fNames, appServerName);
tearDownJavaRESTServer(dbName, appServerName);
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static void tearDownAfterClass() throws Exception {
System.out.println("In tear down");
deleteUserRole("test-evalKer");
deleteRESTUser("user2");
tearDownJavaRESTServer(dbName, fNames, appServerName);
tearDownJavaRESTServer(dbName, appServerName);
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public static void setUpBeforeClass() throws Exception {
@AfterAll
public static void tearDownAfterClass() throws Exception {
System.out.println("In tear down");
cleanupRESTServer(dbName, fNames);
cleanupRESTServer(dbName);
deleteRESTUser("eval-user");
deleteUserRole("test-eval");
}

@BeforeEach
public void setUp() throws KeyManagementException, NoSuchAlgorithmException, Exception {
public void setUp() {
client = getDatabaseClient("eval-user", "x", getConnType());
}

Expand Down Expand Up @@ -198,7 +198,7 @@ public void test3XqueryEvalTransactionsWithRunTimeDB() throws KeyManagementExcep
t1.rollback();
client2.release();
}
cleanupRESTServer(dbNameTmp, fNamesTmp);
cleanupRESTServer(dbNameTmp);
associateRESTServerWithDB(getRestServerName(), "Documents");
}
}
Expand Down