Skip to content

Commit 1ff0498

Browse files
authored
Merge pull request #1986 from marklogic/MLE-33561
MLE-33561: Purge unrecoverable dead test code
2 parents 129a76d + 08e3a69 commit 1ff0498

7 files changed

Lines changed: 5 additions & 485 deletions

File tree

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

Lines changed: 0 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -729,123 +729,6 @@ public void testRawCtsQuery() throws IOException, InterruptedException {
729729
}
730730
}
731731

732-
/*
733-
* To test query by example with WriteBatcher and QueryBatcher with Query
734-
* Failure (incorrect query syntax).
735-
*
736-
* @throws IOException
737-
*
738-
* @throws InterruptedException
739-
*/
740-
// EA 3 Modify the test for batch failure results. Remove the fail.
741-
@Disabled
742-
public void testQueryBatcherQueryFailures() throws IOException, InterruptedException
743-
{
744-
System.out.println("Running testQueryBatcherQueryFailures");
745-
746-
try {
747-
String[] filenames = { "constraint1.xml", "constraint2.xml", "constraint3.xml", "constraint4.xml", "constraint5.xml" };
748-
WriteBatcher batcher = dmManager.newWriteBatcher();
749-
750-
batcher.withBatchSize(2);
751-
// Move to individual data sub folders.
752-
String dataFileDir = dataConfigDirPath + "/data/";
753-
754-
InputStreamHandle contentHandle1 = new InputStreamHandle();
755-
contentHandle1.set(new FileInputStream(dataFileDir + filenames[0]));
756-
InputStreamHandle contentHandle2 = new InputStreamHandle();
757-
contentHandle2.set(new FileInputStream(dataFileDir + filenames[1]));
758-
InputStreamHandle contentHandle3 = new InputStreamHandle();
759-
contentHandle3.set(new FileInputStream(dataFileDir + filenames[2]));
760-
InputStreamHandle contentHandle4 = new InputStreamHandle();
761-
contentHandle4.set(new FileInputStream(dataFileDir + filenames[3]));
762-
InputStreamHandle contentHandle5 = new InputStreamHandle();
763-
contentHandle5.set(new FileInputStream(dataFileDir + filenames[4]));
764-
765-
batcher.add("/fail-contraints1.xml", contentHandle1);
766-
batcher.add("/fail-contraints2.xml", contentHandle2);
767-
batcher.add("/fail-contraints3.xml", contentHandle3);
768-
batcher.add("/fail-contraints4.xml", contentHandle4);
769-
batcher.add("/fail-contraints5.xml", contentHandle5);
770-
771-
// Flush
772-
batcher.flushAndWait();
773-
StringBuilder batchResults = new StringBuilder();
774-
StringBuilder batchFailResults = new StringBuilder();
775-
// create query def
776-
String combinedQuery = "{\"search\":" +
777-
"{\"query\":{\"value-constraint-query\":{\"constraint-name\":\"id\", \"text\":\"0026\"}}," +
778-
"\"options\":{\"return-metrcs\":false, \"return-qtext\":false, \"debug\":true, \"transorm-results\":{\"apply\":\"raw\"}," +
779-
"\"constraint\":{\"name\":\"id\", \"value\":{\"element\":{\"ns\":\"\", \"name\":\"id\"}}}}}}";
780-
781-
System.out.println("QUERY IS : " + combinedQuery);
782-
// create a handle for the search criteria
783-
StringHandle rawHandle = new StringHandle(combinedQuery);
784-
785-
rawHandle.setFormat(Format.JSON);
786-
787-
QueryManager queryMgr = client.newQueryManager();
788-
789-
// create a search definition based on the handle
790-
RawCombinedQueryDefinition querydef = queryMgr.newRawCombinedQueryDefinition(rawHandle);
791-
792-
// Run a QueryBatcher.
793-
QueryBatcher queryBatcher1 = dmManager.newQueryBatcher(querydef);
794-
queryBatcher1.onUrisReady(batch -> {
795-
796-
for (String str : batch.getItems()) {
797-
batchResults.append(str).append('|');
798-
}
799-
800-
batchResults.append(batch.getJobResultsSoFar())
801-
.append('|')
802-
.append(batch.getForest().getForestName())
803-
.append('|')
804-
.append(batch.getJobBatchNumber())
805-
.append('|');
806-
807-
});
808-
queryBatcher1.onQueryFailure(throwable -> {
809-
System.out.println("Exceptions thrown from callback onQueryFailure");
810-
Forest forest = throwable.getForest();
811-
batchFailResults.append("Test has Exceptions")
812-
.append('|')
813-
.append(throwable.getForestResultsSoFar())
814-
.append('|')
815-
.append(forest.getForestName())
816-
.append('|')
817-
.append(forest.getHost())
818-
.append('|')
819-
.append(forest.getDatabaseName())
820-
.append('|')
821-
.append(forest.isUpdateable());
822-
});
823-
dmManager.startJob(queryBatcher1);
824-
boolean isStopped = queryBatcher1.awaitCompletion(3, TimeUnit.MINUTES);
825-
826-
if (isStopped) {
827-
if (!batchFailResults.toString().isEmpty() && batchFailResults.toString().contains("Exceptions")) {
828-
// Write out and assert on query failures.
829-
System.out.println("Exception Buffer contents on Query Exceptions received from callback onQueryFailure");
830-
System.out.println(batchFailResults);
831-
// Remove this failure once there are no NPEs and doa asserts on various
832-
// counters in failure scenario.
833-
fail("Test failed due to exceptions");
834-
}
835-
}
836-
} catch (Exception e) {
837-
e.printStackTrace();
838-
fail("testQueryBatcherQueryFailures method failed");
839-
}
840-
finally {
841-
try {
842-
clearDB();
843-
} catch (Exception e) {
844-
e.printStackTrace();
845-
}
846-
}
847-
}
848-
849732
/*
850733
* To test QueryBatcher's callback support by invoking the client object to do
851734
* a lookup Insert only one document to validate the functionality
@@ -1565,106 +1448,6 @@ public void testBatchClientLookupTimeout() throws InterruptedException{
15651448
}
15661449
}
15671450

1568-
/*
1569-
* To test QueryBatcher when WriteBatcher writes same document. Simulate a
1570-
* deadlock / resource contention.
1571-
*
1572-
* @throws IOException
1573-
*
1574-
* @throws InterruptedException
1575-
*/
1576-
1577-
/*
1578-
* public void testSimultaneousBothBatcherAccess() throws IOException,
1579-
* InterruptedException {
1580-
* System.out.println("Running testSimultaneousBothBatcherAccess");
1581-
* clearDB(restServerPort);
1582-
*
1583-
* String[] filenames = {"constraint1.json", "constraint2.json",
1584-
* "constraint3.json", "constraint4.json", "constraint5.json"}; WriteBatcher
1585-
* batcher = dmManager.newWriteBatcher();
1586-
*
1587-
* batcher.withBatchSize(2);
1588-
*
1589-
* InputStreamHandle contentHandle1 = new InputStreamHandle();
1590-
* contentHandle1.set(new FileInputStream(dataFileDir + filenames[0]));
1591-
* InputStreamHandle contentHandle2 = new InputStreamHandle();
1592-
* contentHandle2.set(new FileInputStream(dataFileDir + filenames[1]));
1593-
* InputStreamHandle contentHandle3 = new InputStreamHandle();
1594-
* contentHandle3.set(new FileInputStream(dataFileDir + filenames[2]));
1595-
* InputStreamHandle contentHandle4 = new InputStreamHandle();
1596-
* contentHandle4.set(new FileInputStream(dataFileDir + filenames[3]));
1597-
* InputStreamHandle contentHandle5 = new InputStreamHandle();
1598-
* contentHandle5.set(new FileInputStream(dataFileDir + filenames[4]));
1599-
*
1600-
* StringBuilder writebatchResults = new StringBuilder();
1601-
* batcher.add("/batcher-contraints1.json", contentHandle1);
1602-
* batcher.add("/batcher-contraints2.json", contentHandle2);
1603-
* batcher.add("/batcher-contraints3.json", contentHandle3);
1604-
* batcher.add("/batcher-contraints4.json", contentHandle4);
1605-
* batcher.add("/batcher-contraints5.json", contentHandle5);
1606-
*
1607-
* // Flush batcher.flushAndWait();
1608-
*
1609-
* StringBuffer querybatchResults = new StringBuffer(); StringBuilder
1610-
* querybatchFailResults = new StringBuilder();
1611-
*
1612-
* // get the query File file = new File(dataConfigDirPath + "qbe1.json");
1613-
* FileHandle fileHandle = new FileHandle(file);
1614-
*
1615-
* QueryManager queryMgr = client.newQueryManager();
1616-
* RawQueryByExampleDefinition qbyexDef =
1617-
* queryMgr.newRawQueryByExampleDefinition
1618-
* (fileHandle.withFormat(Format.JSON));
1619-
*
1620-
* // Run a QueryBatcher. QueryBatcher queryBatcher1 =
1621-
* dmManager.newQueryBatcher(qbyexDef); queryBatcher1.onUrisReady(batch-> {
1622-
*
1623-
* for (String str : batch.getItems()) { querybatchResults.append(str)
1624-
* .append('|'); }
1625-
*
1626-
* querybatchResults.append(batch.getForestResultsSoFar()) .append('|')
1627-
* .append(batch.getForest().getForestName()) .append('|')
1628-
* .append(batch.getJobBatchNumber()) .append('|');
1629-
*
1630-
* }); queryBatcher1.onQueryFailure(throwable-> {
1631-
* System.out.println("Exceptions thrown from callback onQueryFailure");
1632-
* throwable.printStackTrace();
1633-
* querybatchFailResults.append("Test has Exceptions");
1634-
* querybatchFailResults.append(throwable.getMessage()); } );
1635-
*
1636-
* // Trying to use a WriteBatcher on the same docId. WriteBatcher batcherTwo
1637-
* = dmManager.newWriteBatcher(); String jsonDoc = "{" + "\"employees\": [" +
1638-
* "{ \"firstName\":\"John\" , \"lastName\":\"Doe\" }," +
1639-
* "{ \"firstName\":\"Ann\" , \"lastName\":\"Smith\" }," +
1640-
* "{ \"firstName\":\"Bob\" , \"lastName\":\"Foo\" }]" + "}"; StringHandle
1641-
* handle = new StringHandle(); handle.set(jsonDoc);
1642-
*
1643-
* // Update contents to same doc uri. batcherTwo.withBatchSize(1);
1644-
* batcherTwo.add("/batcher-contraints11.json", handle);
1645-
* batcherTwo.flushAndWait();
1646-
*
1647-
* JobTicket jobTicketWriteTwo = dmManager.startJob(batcherTwo);
1648-
*
1649-
* JobTicket jobTicket = dmManager.startJob(queryBatcher1);
1650-
* queryBatcher1.awaitTermination(1, TimeUnit.MINUTES);
1651-
*
1652-
* if (queryBatcher1.isStopped()) {
1653-
*
1654-
* if( !querybatchFailResults.toString().isEmpty() &&
1655-
* querybatchFailResults.toString().contains("Exceptions")) {
1656-
* System.out.println("Query Batch Failed - Buffer Contents are:" +
1657-
* querybatchFailResults.toString()); fail("Test failed due to exceptions"); }
1658-
* if( querybatchResults != null && !querybatchResults.toString().isEmpty()) {
1659-
* // Verify the batch results now. String[] res =
1660-
* querybatchResults.toString().split("\\|");
1661-
*
1662-
* assertTrue(
1663-
* res[0].contains("/batcher-contraints1.json"));
1664-
* assertEquals("Bytes Moved","0", res[1]); assertEquals("Batch Number","0",
1665-
* res[3]); } } }
1666-
*/
1667-
16681451
@Test
16691452
public void testQueryBatcherJobDetails() throws Exception
16701453
{

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

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
2+
* Copyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
33
*/
44

55
package com.marklogic.client.datamovement.functionaltests;
@@ -2164,71 +2164,6 @@ public void run() {
21642164

21652165
}
21662166

2167-
// EA 3 - We need a better way of getting to know that DB is disabled and
2168-
// how
2169-
// to assert on counts.
2170-
@Disabled
2171-
public void testDisableDBDuringInsert() throws Exception {
2172-
System.out.println("In testDisableDBDuringInsert method");
2173-
2174-
Thread t1 = new Thread(new DisabledDBRunnable());
2175-
AtomicBoolean failCheck = new AtomicBoolean(false);
2176-
AtomicInteger successCount = new AtomicInteger(0);
2177-
AtomicInteger failureCount = new AtomicInteger(0);
2178-
2179-
t1.setName("Status Check");
2180-
Map<String, String> properties = new HashMap<>();
2181-
WriteBatcher ihb2 = dmManager.newWriteBatcher();
2182-
ihb2.withBatchSize(5);
2183-
2184-
ihb2.onBatchSuccess(batch -> {
2185-
successCount.getAndAdd(batch.getItems().length);
2186-
}).onBatchFailure((batch, throwable) -> {
2187-
failCheck.set(true);
2188-
failureCount.getAndAdd(batch.getItems().length);
2189-
throwable.printStackTrace();
2190-
});
2191-
dmManager.startJob(ihb2);
2192-
t1.start();
2193-
2194-
for (int j = 0; j < 1000; j++) {
2195-
String uri = "/local/json-" + j;
2196-
ihb2.add(uri, fileHandle);
2197-
}
2198-
2199-
ihb2.flushAndWait();
2200-
t1.join();
2201-
properties.put("enabled", "true");
2202-
changeProperty(properties, "/manage/v2/databases/" + dbName + "/properties");
2203-
assertTrue(failCheck.get());
2204-
assertTrue(successCount.intValue() >= 100);
2205-
assertTrue(successCount.intValue() < 1000);
2206-
assertTrue(failureCount.intValue() <= 900);
2207-
}
2208-
2209-
class DisabledDBRunnable implements Runnable {
2210-
final String query1 = "fn:count(fn:doc())";
2211-
Map<String, String> properties = new HashMap<>();
2212-
2213-
@Override
2214-
public void run() {
2215-
2216-
properties.put("enabled", "false");
2217-
boolean state = true;
2218-
while (state) {
2219-
int count = dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue();
2220-
System.out.println("Count is " + count);
2221-
if (count >= 100) {
2222-
changeProperty(properties, "/manage/v2/databases/" + dbName + "/properties");
2223-
2224-
state = false;
2225-
}
2226-
2227-
}
2228-
}
2229-
2230-
}
2231-
22322167
@Test
22332168
public void testNoHost() throws Exception {
22342169
Assumptions.assumeTrue(!isLBHost());

‎marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/fastfunctest/TestAppServerConstraints.java‎

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
2+
* Copyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
33
*/
44

55
package com.marklogic.client.fastfunctest;
@@ -152,63 +152,6 @@ public void testWithNoFacet() throws KeyManagementException, NoSuchAlgorithmExce
152152
assertXpathEvaluatesTo(expectedSearchReport, "string(//*[local-name()='report'])", resultDoc);
153153
}
154154

155-
// @Test
156-
public void testWithWordConstraintAndGoogleGrammar() throws KeyManagementException, NoSuchAlgorithmException, IOException, ParserConfigurationException, SAXException,
157-
XpathException
158-
{
159-
System.out.println("Running testWithWordConstraintAndGoogleGrammar");
160-
161-
String filename1 = "constraint1.xml";
162-
String filename2 = "constraint2.xml";
163-
String filename3 = "constraint3.xml";
164-
String filename4 = "constraint4.xml";
165-
String filename5 = "constraint5.xml";
166-
String queryOptionName = "collectionConstraintWithWordConstraintAndGoogleGrammarOpt.xml";
167-
168-
// create and initialize a handle on the metadata
169-
DocumentMetadataHandle metadataHandle1 = new DocumentMetadataHandle();
170-
DocumentMetadataHandle metadataHandle2 = new DocumentMetadataHandle();
171-
DocumentMetadataHandle metadataHandle3 = new DocumentMetadataHandle();
172-
DocumentMetadataHandle metadataHandle4 = new DocumentMetadataHandle();
173-
DocumentMetadataHandle metadataHandle5 = new DocumentMetadataHandle();
174-
175-
// set the metadata
176-
metadataHandle1.getCollections().addAll("http://test.com/set1");
177-
metadataHandle1.getCollections().addAll("http://test.com/set5");
178-
metadataHandle2.getCollections().addAll("http://test.com/set1");
179-
metadataHandle3.getCollections().addAll("http://test.com/set3");
180-
metadataHandle4.getCollections().addAll("http://test.com/set3/set3-1");
181-
metadataHandle5.getCollections().addAll("http://test.com/set1");
182-
metadataHandle5.getCollections().addAll("http://test.com/set5");
183-
184-
// write docs
185-
writeDocumentUsingInputStreamHandle(client, filename1, "/collection-constraint/", metadataHandle1, "XML");
186-
writeDocumentUsingInputStreamHandle(client, filename2, "/collection-constraint/", metadataHandle2, "XML");
187-
writeDocumentUsingInputStreamHandle(client, filename3, "/collection-constraint/", metadataHandle3, "XML");
188-
writeDocumentUsingInputStreamHandle(client, filename4, "/collection-constraint/", metadataHandle4, "XML");
189-
writeDocumentUsingInputStreamHandle(client, filename5, "/collection-constraint/", metadataHandle5, "XML");
190-
191-
setQueryOption(client, queryOptionName);
192-
QueryManager queryMgr = client.newQueryManager();
193-
194-
// create query def
195-
StringQueryDefinition querydef = queryMgr.newStringDefinition(queryOptionName);
196-
querydef.setCriteria("(coll:set1 AND coll:set5) AND -intitle:memex");
197-
198-
// create handle
199-
DOMHandle resultsHandle = new DOMHandle();
200-
queryMgr.search(querydef, resultsHandle);
201-
202-
// get the result
203-
Document resultDoc = resultsHandle.get();
204-
205-
assertXpathEvaluatesTo("1", "string(//*[local-name()='result'][last()]//@*[local-name()='index'])", resultDoc);
206-
assertXpathEvaluatesTo("Vannevar Bush", "string(//*[local-name()='result'][1]//*[local-name()='title'])", resultDoc);
207-
208-
String expectedSearchReport = "(cts:search(fn:collection(), cts:and-query((cts:collection-query(\"http://test.com/set1\"), cts:collection-query(\"http://test.com/set5\"), cts:not-query(cts:element-word-query(fn:QName(\"\", \"title\"), \"memex\", (\"lang=en\"), 1), 1)), ()), (\"score-logtfidf\"), 1))[1 to 10]";
209-
210-
assertXpathEvaluatesTo(expectedSearchReport, "string(//*[local-name()='report'])", resultDoc);
211-
}
212155
// End of TestAppServicesCollectionConstraint
213156

214157
// Begin TestAppServicesConstraintCombination

0 commit comments

Comments
 (0)