@@ -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 {
0 commit comments