Skip to content

Commit 6bf1119

Browse files
authored
Merge pull request #1798 from marklogic/feature/test-plumbing-fix
MLE-12345 Reworking how test plumbing clears a database
2 parents 55c80fa + e9248c5 commit 6bf1119

File tree

7 files changed

+23
-14
lines changed

7 files changed

+23
-14
lines changed

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.marklogic.mgmt.resource.temporal.TemporalAxesManager;
3131
import com.marklogic.mgmt.resource.temporal.TemporalCollectionLSQTManager;
3232
import com.marklogic.mgmt.resource.temporal.TemporalCollectionManager;
33+
import org.slf4j.LoggerFactory;
3334

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

318319
public static void clearDB(int port) {
319320
try (DatabaseClient client = newDatabaseClientBuilder().withPort(port).build()) {
320-
QueryManager mgr = client.newQueryManager();
321-
mgr.delete(mgr.newDeleteDefinition());
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);
322331
}
323332
}
324333

325-
public static void tearDownJavaRESTServer(String dbName, String[] fNames, String restServerName) {
334+
public static void tearDownJavaRESTServer(String dbName, String restServerName) {
326335
associateRESTServerWithDB(restServerName, "Documents");
327336
deleteDB(dbName);
328337
}
@@ -849,11 +858,11 @@ public static void configureRESTServer(String dbName, String[] fNames, boolean b
849858
}
850859

851860
// Removes the database and forest from a REST server.
852-
public static void cleanupRESTServer(String dbName, String[] fNames) throws Exception {
861+
public static void cleanupRESTServer(String dbName) {
853862
if (IsSecurityEnabled())
854-
tearDownJavaRESTServer(dbName, fNames, restSslServerName);
863+
tearDownJavaRESTServer(dbName, restSslServerName);
855864
else
856-
tearDownJavaRESTServer(dbName, fNames, restServerName);
865+
tearDownJavaRESTServer(dbName, restServerName);
857866
}
858867

859868
// Returns true or false based security (ssl) is enabled or disabled.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static void setUpBeforeClass() throws Exception {
5555
@AfterAll
5656
public static void tearDownAfterClass() throws Exception {
5757
System.out.println("In tear down");
58-
cleanupRESTServer(dbName, fNames);
58+
cleanupRESTServer(dbName);
5959
}
6060

6161
@BeforeEach

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static void setUpBeforeClass() throws Exception {
109109
public static void tearDownAfterClass() throws Exception {
110110
System.out.println("In tear down");
111111

112-
cleanupRESTServer(dbName, fNames);
112+
cleanupRESTServer(dbName);
113113
deleteRESTUser("eval-bitemp-meta-user");
114114
deleteRESTUser("eval-readeruser");
115115
deleteUserRole("test-eval-bitemp");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static void tearDownAfterClass() throws Exception {
112112
System.out.println("In tear down");
113113

114114
// Delete database first. Otherwise axis and collection cannot be deleted
115-
cleanupRESTServer(dbName, fNames);
115+
cleanupRESTServer(dbName);
116116
deleteRESTUser("eval-user");
117117
deleteUserRole("test-eval");
118118
deleteDB(schemadbName);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static void tearDownAfterClass() throws Exception {
137137
System.out.println("In tear down");
138138
deleteUserRole("test-evalKer");
139139
deleteRESTUser("builder");
140-
tearDownJavaRESTServer(dbName, fNames, appServerName);
140+
tearDownJavaRESTServer(dbName, appServerName);
141141
}
142142

143143
@BeforeEach

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public static void tearDownAfterClass() throws Exception {
111111
System.out.println("In tear down");
112112
deleteUserRole("test-evalKer");
113113
deleteRESTUser("user2");
114-
tearDownJavaRESTServer(dbName, fNames, appServerName);
114+
tearDownJavaRESTServer(dbName, appServerName);
115115
}
116116

117117
@BeforeEach

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ public static void setUpBeforeClass() throws Exception {
5252
@AfterAll
5353
public static void tearDownAfterClass() throws Exception {
5454
System.out.println("In tear down");
55-
cleanupRESTServer(dbName, fNames);
55+
cleanupRESTServer(dbName);
5656
deleteRESTUser("eval-user");
5757
deleteUserRole("test-eval");
5858
}
5959

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

@@ -198,7 +198,7 @@ public void test3XqueryEvalTransactionsWithRunTimeDB() throws KeyManagementExcep
198198
t1.rollback();
199199
client2.release();
200200
}
201-
cleanupRESTServer(dbNameTmp, fNamesTmp);
201+
cleanupRESTServer(dbNameTmp);
202202
associateRESTServerWithDB(getRestServerName(), "Documents");
203203
}
204204
}

0 commit comments

Comments
 (0)