Skip to content

Commit d69236e

Browse files
committed
Fixing slow functional tests
They were using 8014 instead of 8011. Also fixed some assertions in DeleteListenerTest to do assertEquals instead of assertTrue as I was using that test to debug the failures.
1 parent 3a1b6ec commit d69236e

File tree

2 files changed

+17
-27
lines changed

2 files changed

+17
-27
lines changed

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/datamovement/functionaltests/DeleteListenerTest.java

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public class DeleteListenerTest extends BasicJavaClientREST {
4040
private static final String TEST_DIR_PREFIX = "/WriteHostBatcher-testdata/";
4141

4242
private static DatabaseClient dbClient;
43-
private static String host = null;
4443
private static String user = "admin";
4544
private static int port = 8000;
4645
private static String password = "admin";
@@ -64,7 +63,6 @@ public static void setUpBeforeClass() throws Exception {
6463
server = getRestAppServerName();
6564
port = getRestAppServerPort();
6665

67-
host = getRestAppServerHostName();
6866
hostNames = getHosts();
6967
createDB(dbName);
7068
Thread.currentThread().sleep(500L);
@@ -124,24 +122,14 @@ public void setUp() throws Exception {
124122
Thread.currentThread().sleep(1000L);
125123
WriteBatcher ihb2 = dmManager.newWriteBatcher();
126124
ihb2.withBatchSize(27).withThreadCount(10);
127-
ihb2.onBatchSuccess(
128-
batch -> {
129-
130-
}
131-
)
132-
.onBatchFailure(
133-
(batch, throwable) -> {
134-
throwable.printStackTrace();
135-
});
136-
137125
dmManager.startJob(ihb2);
138126
for (int j = 0; j < 2000; j++) {
139127
String uri = "/local/json-" + j;
140128
ihb2.add(uri, meta, jacksonHandle);
141129
}
142130

143131
ihb2.flushAndWait();
144-
assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 2000);
132+
assertEquals(2000, dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue());
145133
}
146134

147135
@AfterEach
@@ -154,7 +142,7 @@ public void massDeleteSingleThread() throws Exception {
154142
HashSet<String> urisList = new HashSet<>();
155143

156144
assertTrue(urisList.isEmpty());
157-
assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 2000);
145+
assertEquals(2000, dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue());
158146

159147
QueryBatcher queryBatcher = dmManager.newQueryBatcher(new StructuredQueryBuilder().collection("DeleteListener"))
160148
.withBatchSize(11, 1)
@@ -175,7 +163,7 @@ public void massDeleteSingleThread() throws Exception {
175163
dmManager.stopJob(ticket);
176164

177165
Thread.currentThread().sleep(2000L);
178-
assertTrue(urisList.size() == 2000);
166+
assertEquals(2000, urisList.size());
179167

180168
AtomicInteger successDocs = new AtomicInteger();
181169
HashSet<String> uris2 = new HashSet<>();
@@ -198,7 +186,7 @@ public void massDeleteSingleThread() throws Exception {
198186

199187
if (failures2.length() > 0)
200188
fail(failures2.toString());
201-
assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 0);
189+
assertEquals(0, dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue());
202190
}
203191

204192
@Test
@@ -226,7 +214,7 @@ public void massDeleteMultipleThreads() throws Exception {
226214
queryBatcher.awaitCompletion();
227215
dmManager.stopJob(ticket);
228216

229-
assertTrue(urisList.size() == 2000);
217+
assertEquals(2000, urisList.size());
230218

231219
AtomicInteger successDocs = new AtomicInteger();
232220
HashSet<String> uris2 = new HashSet<>();
@@ -249,7 +237,7 @@ public void massDeleteMultipleThreads() throws Exception {
249237

250238
if (failures2.length() > 0)
251239
fail(failures2.toString());
252-
assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 0);
240+
assertEquals(0, dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue());
253241
}
254242

255243
@Test
@@ -309,7 +297,7 @@ public void deleteNonExistentDoc() throws Exception {
309297

310298
if (failures2.length() > 0)
311299
fail(failures2.toString());
312-
assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 2000);
300+
assertEquals(2000, dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue());
313301
}
314302

315303
// ISSUE 94
@@ -396,7 +384,7 @@ public void run() {
396384
}
397385

398386
@Test
399-
public void deleteEmptyIterator() throws Exception {
387+
public void deleteEmptyIterator() {
400388

401389
HashSet<String> urisList = new HashSet<>();
402390

@@ -419,27 +407,27 @@ public void deleteEmptyIterator() throws Exception {
419407

420408
if (failures2.length() > 0)
421409
fail(failures2.toString());
422-
assertTrue(successDocs.intValue() == 0);
423-
assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 2000);
410+
assertEquals(0, successDocs.intValue());
411+
assertEquals(2000, dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue());
424412
}
425413

426414
@Test
427415
public void deleteOnDiskUris() throws Exception {
428416
String pathname = "uriCache.txt";
429-
assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 2000);
417+
assertEquals(2000, dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue());
430418

431419
ArrayList<String> foundUris = getUris();
432420
ArrayList<String> diskUris = writeUrisToDisk();
433421

434-
assertTrue(foundUris.size() == diskUris.size());
422+
assertEquals(foundUris.size(), diskUris.size());
435423

436424
File file = new File(pathname);
437425
assertTrue(file.exists());
438426

439427
ArrayList<String> deletedUris = deleteDocuments(pathname);
440428

441-
assertTrue(foundUris.size() == deletedUris.size());
442-
assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 0);
429+
assertEquals(foundUris.size(), deletedUris.size());
430+
assertEquals(0, dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue());
443431
file.delete();
444432
}
445433

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,9 @@ else if (getSslEnabled().trim().equalsIgnoreCase("false") || getSslEnabled() ==
20242024
public static DatabaseClientBuilder newDatabaseClientBuilder() {
20252025
Map<String, Object> props = new HashMap<>();
20262026
testProperties.entrySet().forEach(entry -> props.put((String) entry.getKey(), entry.getValue()));
2027-
return new DatabaseClientBuilder(props);
2027+
DatabaseClientBuilder builder = new DatabaseClientBuilder(props);
2028+
// Have to override the port so that the "slow" functional tests can still hit 8011
2029+
return builder.withPort(getRestServerPort());
20282030
}
20292031

20302032
public static DatabaseClient newClientAsUser(String username, String password) {

0 commit comments

Comments
 (0)