Skip to content

Commit c955e4d

Browse files
committed
Functional tests should pass now
Realized that QueryBatcherJobReportTest fails intermittently due to a known Java Client bug that still needs fixing. Updated Jenkinsfile to run both 11 and 10 regression tests. Expecting all to pass, except the Optic test that is known to fail sometimes due to a server bug where URIs and properties fragments are sometimes returned.
1 parent 56291ce commit c955e4d

File tree

2 files changed

+54
-102
lines changed

2 files changed

+54
-102
lines changed

Jenkinsfile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,23 @@ pipeline{
117117
}
118118
}
119119

120-
// stage('regressions-11.0-Latest') {
121-
// when {
122-
// allOf {
123-
// branch 'develop'
124-
// expression {return params.regressions}
125-
// }
126-
// }
127-
// steps {
128-
// runtests('Latest','11.0')
129-
// junit '**/build/**/TEST*.xml'
130-
// }
131-
// post {
132-
// unsuccessful {
133-
// sendMail params.Email,'<h3>Some Tests Failed on Released 11.0 ML Nightly Server Single Node </h3><h4><a href=${JENKINS_URL}/blue/organizations/jenkins/java-client-api-regression/detail/$JOB_BASE_NAME/$BUILD_ID/tests><font color=red>Check the Test Report</font></a></h4><h4><a href=${RUN_DISPLAY_URL}>Check the Pipeline View</a></h4><h4> <a href=${BUILD_URL}/console> Check Console Output Here</a></h4><h4>Please create bugs for the failed regressions and fix them</h4>',false,'${STAGE_NAME} on develop against ML 11.0-nightly Failed'
134-
// }
135-
// }
136-
// }
120+
stage('regressions-11.0-Latest') {
121+
when {
122+
allOf {
123+
branch 'develop'
124+
expression {return params.regressions}
125+
}
126+
}
127+
steps {
128+
runtests('Latest','11.0')
129+
junit '**/build/**/TEST*.xml'
130+
}
131+
post {
132+
unsuccessful {
133+
sendMail params.Email,'<h3>Some Tests Failed on Released 11.0 ML Nightly Server Single Node </h3><h4><a href=${JENKINS_URL}/blue/organizations/jenkins/java-client-api-regression/detail/$JOB_BASE_NAME/$BUILD_ID/tests><font color=red>Check the Test Report</font></a></h4><h4><a href=${RUN_DISPLAY_URL}>Check the Pipeline View</a></h4><h4> <a href=${BUILD_URL}/console> Check Console Output Here</a></h4><h4>Please create bugs for the failed regressions and fix them</h4>',false,'${STAGE_NAME} on develop against ML 11.0-nightly Failed'
134+
}
135+
}
136+
}
137137

138138
stage('regressions-10.0-9') {
139139
when {

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

Lines changed: 37 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -15,58 +15,39 @@
1515
*/
1616
package com.marklogic.client.datamovement.functionaltests;
1717

18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertTrue;
20-
21-
import java.io.File;
22-
import java.io.IOException;
23-
import java.util.ArrayList;
24-
import java.util.Arrays;
25-
import java.util.Calendar;
26-
import java.util.Collection;
27-
import java.util.Collections;
28-
import java.util.HashMap;
29-
import java.util.HashSet;
30-
import java.util.Iterator;
31-
import java.util.LinkedHashSet;
32-
import java.util.List;
33-
import java.util.Map;
34-
import java.util.Set;
35-
import java.util.UUID;
36-
import java.util.concurrent.TimeUnit;
37-
import java.util.concurrent.atomic.AtomicBoolean;
38-
import java.util.concurrent.atomic.AtomicInteger;
39-
import java.util.concurrent.atomic.AtomicLong;
40-
41-
import com.marklogic.client.fastfunctest.AbstractFunctionalTest;
42-
import org.apache.commons.io.FileUtils;
43-
import org.junit.*;
44-
4518
import com.fasterxml.jackson.databind.JsonNode;
4619
import com.marklogic.client.DatabaseClient;
4720
import com.marklogic.client.admin.ExtensionMetadata;
4821
import com.marklogic.client.admin.TransformExtensionsManager;
49-
import com.marklogic.client.datamovement.ApplyTransformListener;
22+
import com.marklogic.client.datamovement.*;
5023
import com.marklogic.client.datamovement.ApplyTransformListener.ApplyResult;
51-
import com.marklogic.client.datamovement.DataMovementManager;
52-
import com.marklogic.client.datamovement.DeleteListener;
53-
import com.marklogic.client.datamovement.JobTicket;
54-
import com.marklogic.client.datamovement.QueryBatch;
55-
import com.marklogic.client.datamovement.QueryBatcher;
56-
import com.marklogic.client.datamovement.WriteBatcher;
5724
import com.marklogic.client.document.DocumentPage;
5825
import com.marklogic.client.document.DocumentRecord;
5926
import com.marklogic.client.document.ServerTransform;
27+
import com.marklogic.client.fastfunctest.AbstractFunctionalTest;
6028
import com.marklogic.client.functionaltest.BasicJavaClientREST;
61-
import com.marklogic.client.io.DOMHandle;
62-
import com.marklogic.client.io.DocumentMetadataHandle;
63-
import com.marklogic.client.io.FileHandle;
64-
import com.marklogic.client.io.Format;
65-
import com.marklogic.client.io.JacksonHandle;
66-
import com.marklogic.client.io.StringHandle;
29+
import com.marklogic.client.io.*;
6730
import com.marklogic.client.query.QueryManager;
6831
import com.marklogic.client.query.StringQueryDefinition;
6932
import com.marklogic.client.query.StructuredQueryBuilder;
33+
import org.apache.commons.io.FileUtils;
34+
import org.junit.Assert;
35+
import org.junit.BeforeClass;
36+
import org.junit.Ignore;
37+
import org.junit.Test;
38+
import org.slf4j.Logger;
39+
import org.slf4j.LoggerFactory;
40+
41+
import java.io.File;
42+
import java.io.IOException;
43+
import java.util.*;
44+
import java.util.concurrent.TimeUnit;
45+
import java.util.concurrent.atomic.AtomicBoolean;
46+
import java.util.concurrent.atomic.AtomicInteger;
47+
import java.util.concurrent.atomic.AtomicLong;
48+
49+
import static org.junit.Assert.assertEquals;
50+
import static org.junit.Assert.assertTrue;
7051

7152
public class QueryBatcherJobReportTest extends AbstractFunctionalTest {
7253

@@ -245,15 +226,19 @@ public void testNullQdef() throws IOException, InterruptedException {
245226
}
246227

247228
@Test
248-
@Ignore("Ignoring this test for now, as it fails intermittently, and when it does, the test hangs indefinitely, causing " +
249-
"the test suite to never finish. Needs further investigation to make it more robust.")
229+
@Ignore("Ignoring this test for now, as it's failing intermittently due to the bug captured at " +
230+
"https://github.com/marklogic/java-client-api/issues/1327; did some cleanup on this before ignoring it, as " +
231+
"when it passed, the onQueryFailure handler was never being invoked. So that stuff was removed. It appears " +
232+
"that the intent of the test is to verify that the retry mechanism for QueryBatcher kicks in when a failure " +
233+
"occurs due to the database being temporarily disabled. But due to the 1327 bug, the test can hang " +
234+
"indefinitely when the queryMgr.uris call fails.")
250235
public void queryFailures() throws Exception {
251236
// Insert documents to query
252237
String jsonDoc = "{" + "\"employees\": [" + "{ \"firstName\":\"John\" , \"lastName\":\"Doe\" },"
253238
+ "{ \"firstName\":\"Ann\" , \"lastName\":\"Smith\" },"
254239
+ "{ \"firstName\":\"Bob\" , \"lastName\":\"Foo\" }]" + "}";
255240
WriteBatcher writeBatcher = dmManager.newWriteBatcher();
256-
writeBatcher.withBatchSize(6000);
241+
writeBatcher.withBatchSize(100).withThreadCount(8);
257242
StringHandle handle = new StringHandle();
258243
handle.set(jsonDoc);
259244
for (int i = 0; i < 6000; i++) {
@@ -262,32 +247,14 @@ public void queryFailures() throws Exception {
262247
}
263248
writeBatcher.flushAndWait();
264249

265-
// Construct a query to return all of the docs inserted above
250+
// Construct a query to return the docs inserted above
266251
QueryManager queryMgr = dbClient.newQueryManager();
267252
StringQueryDefinition querydef = queryMgr.newStringDefinition();
268253
querydef.setCriteria("John AND Bob");
269254

270-
// Construct a QueryBatcher that will keep track of
271255
AtomicInteger successfulBatchCount = new AtomicInteger(0);
272-
AtomicInteger queryFailureCount = new AtomicInteger(0);
273-
QueryBatcher batcher = dmManager.newQueryBatcher(querydef).withBatchSize(10).withThreadCount(3);
256+
QueryBatcher batcher = dmManager.newQueryBatcher(querydef).withBatchSize(100).withThreadCount(3);
274257
batcher.onUrisReady(batch -> successfulBatchCount.incrementAndGet());
275-
batcher.onQueryFailure(throwable -> {
276-
System.out.println("QueryBatcher failure: " + throwable.getMessage());
277-
queryFailureCount.incrementAndGet();
278-
System.out.println("DB disabled for Forest " + throwable.getForest().getForestName());
279-
// TODO Figure out why 7s was chosen here
280-
try {
281-
Thread.currentThread().sleep(7000L);
282-
} catch (Exception e) {
283-
e.printStackTrace();
284-
}
285-
throwable.getBatcher().retry(throwable);
286-
// TODO Why does this need to throw an exception???
287-
// We need an NullPointerException. Hence these statements.
288-
String s = null;
289-
s.length();
290-
});
291258

292259
queryTicket = dmManager.startJob(batcher);
293260

@@ -302,46 +269,31 @@ public void queryFailures() throws Exception {
302269
// Verify that the QueryBatcher was able to recover after the database was re-enabled
303270
Assert.assertEquals(6000, dmManager.getJobReport(queryTicket).getSuccessEventsCount());
304271
Assert.assertEquals(successfulBatchCount.intValue(), dmManager.getJobReport(queryTicket).getSuccessBatchesCount());
305-
if(!isLBHost()) {
306-
System.out.println("Method queryFailure hostNames.length " + hostNames.length);
307-
System.out.println("Method queryFailure getFailureEventsCount() " + dmManager.getJobReport(queryTicket).getFailureEventsCount());
308-
309-
Assert.assertEquals(queryFailureCount.get(), dmManager.getJobReport(queryTicket).getFailureEventsCount());
310-
Assert.assertEquals(queryFailureCount.get(), dmManager.getJobReport(queryTicket).getFailureBatchesCount());
311-
}
312272
}
313273

314274
class DisabledDBRunnable implements Runnable {
315275
Map<String, String> properties = new HashMap<>();
276+
private final Logger logger = LoggerFactory.getLogger(getClass());
316277

317278
@Override
318279
public void run() {
319280
properties.put("enabled", "false");
320-
boolean state = true;
321-
while (state) {
322-
System.out.println(dmManager.getJobReport(queryTicket).getSuccessEventsCount());
323-
// Wait for at least one successful event before disabling
324-
if (dmManager.getJobReport(queryTicket).getSuccessEventsCount() >= 0) {
325-
System.out.println("Disabling the java-functest database");
326-
changeProperty(properties, "/manage/v2/databases/java-functest/properties");
327-
System.out.println("DB disabled");
328-
state = false;
329-
}
330-
331-
}
281+
logger.info("Disabling the java-functest database; successful events so far: "
282+
+ dmManager.getJobReport(queryTicket).getSuccessEventsCount());
283+
changeProperty(properties, "/manage/v2/databases/java-functest/properties");
332284

333285
// TODO Figure out why 5s was chosen here
334-
System.out.println("Sleeping before re-enabling the java-functest database");
286+
logger.info("Sleeping before re-enabling the java-functest database; successful events since database " +
287+
"was disabled: " + dmManager.getJobReport(queryTicket).getSuccessEventsCount());
335288
try {
336289
Thread.currentThread().sleep(5000L);
337290
} catch (InterruptedException e) {
338291
e.printStackTrace();
339292
}
340293

341-
System.out.println("Re-enabling the java-functest database");
342294
properties.put("enabled", "true");
343295
changeProperty(properties, "/manage/v2/databases/java-functest/properties");
344-
System.out.println("Re-enabled the java-functest database");
296+
logger.info("Re-enabled the java-functest database");
345297
}
346298
}
347299

0 commit comments

Comments
 (0)