Skip to content

Commit 2d2ec1c

Browse files
author
ssambasu
committed
Fixing ApplyTransform and WriteBatcher tests
1 parent 9b0d437 commit 2d2ec1c

File tree

2 files changed

+12
-115
lines changed

2 files changed

+12
-115
lines changed

test-complete/src/test/java/com/marklogic/client/datamovement/functionaltests/ApplyTransformTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,8 @@ public void failedTransformTest() throws Exception{
589589
assertEquals("Size should be 0", 0,skippedBatch.size());
590590

591591
}
592-
592+
593+
//ISSUE # 569
593594
@Test
594595
public void jsMasstransformReplaceDelete() throws Exception{
595596

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

Lines changed: 10 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -793,12 +793,15 @@ public void testClientObject() throws Exception {
793793
System.out.println(successDb.toString());
794794

795795
Assert.assertTrue(count(successPort.toString(),String.valueOf(port))==10);
796-
Assert.assertTrue(count(successHost.toString(),String.valueOf(host))!=10);
797-
Assert.assertTrue(count(successDb.toString(),String.valueOf(dbName))==10);
798-
796+
if (hostNames.length > 1){
797+
Assert.assertTrue(count(successHost.toString(),String.valueOf(host))!=10);
798+
}
799+
799800
Assert.assertTrue(count(failurePort.toString(),String.valueOf(port))==5);
800-
Assert.assertTrue(count(failureHost.toString(),String.valueOf(host))!=5);
801-
Assert.assertTrue(count(failureDb.toString(),String.valueOf(dbName))==5);
801+
if (hostNames.length > 1){
802+
Assert.assertTrue(count(failureHost.toString(),String.valueOf(host))!=5);
803+
}
804+
802805
}
803806

804807
private int count(String s, String in){
@@ -2014,8 +2017,7 @@ public void run() {
20142017
}
20152018

20162019
ihbMT.awaitCompletion();
2017-
ihbMT.awaitTermination(10L,TimeUnit.MILLISECONDS);
2018-
2020+
20192021
int count = dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue();
20202022
System.out.println(count);
20212023
Assert.assertTrue(count >=80);
@@ -2182,7 +2184,7 @@ public void testRetry() throws Exception{
21822184
changeProperty(properties,"/manage/v2/databases/"+dbName+"/properties");
21832185
ihbMT.awaitCompletion();
21842186
Assert.assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue()==200);
2185-
Assert.assertFalse(successCalled.get());
2187+
Assert.assertTrue(successCalled.get());
21862188
}
21872189

21882190
// ea3
@@ -2324,111 +2326,5 @@ public void run() {
23242326
}
23252327
}
23262328

2327-
}
2328-
2329-
@Test
2330-
public void testOfflineForestStopServerDuringInsert() throws Exception{
2331-
2332-
final String query1 = "fn:count(fn:doc())";
2333-
Thread t1 = new Thread(new OffLineForestStopServerRunnable());
2334-
AtomicBoolean failCheck = new AtomicBoolean(false);
2335-
AtomicInteger successCount = new AtomicInteger(0);
2336-
AtomicInteger failureCount = new AtomicInteger(0);
2337-
2338-
t1.setName("Status Check");
2339-
Map<String,String> properties = new HashMap<>();
2340-
2341-
2342-
2343-
WriteBatcher ihb2 = dmManager.newWriteBatcher();
2344-
ihb2.withBatchSize(50);
2345-
2346-
ihb2.onBatchSuccess(
2347-
batch -> {
2348-
successCount.getAndAdd(batch.getItems().length);
2349-
2350-
System.out.println("Success host: "+batch.getClient().getHost());
2351-
System.out.println("Success Batch size "+batch.getItems().length);
2352-
for(WriteEvent w:batch.getItems()){
2353-
System.out.println("Success "+w.getTargetUri());
2354-
}
2355-
}
2356-
)
2357-
.onBatchFailure(
2358-
(batch, throwable) -> {
2359-
failCheck.set(true);
2360-
failureCount.getAndAdd(batch.getItems().length);
2361-
throwable.printStackTrace();
2362-
System.out.println("Failure host: "+batch.getClient().getHost());
2363-
System.out.println("Failure Batch size "+batch.getItems().length);
2364-
for(WriteEvent w:batch.getItems()){
2365-
System.out.println("Failure "+w.getTargetUri());
2366-
}
2367-
});
2368-
2369-
2370-
dmManager.startJob(ihb2);
2371-
2372-
properties.put("forest-name",dbName+"-1");
2373-
properties.put("availability","offline");
2374-
2375-
2376-
2377-
for (int j =0 ;j < 10000; j++){
2378-
String uri ="/local/json-"+ j;
2379-
ihb2.add(uri, fileHandle);
2380-
if (j == 30){
2381-
changeProperty(properties,"/manage/v2/forests/"+dbName+"-1/properties");
2382-
t1.start();
2383-
}
2384-
2385-
if (j == 2500){
2386-
properties.put("forest-name",dbName+"-3");
2387-
changeProperty(properties,"/manage/v2/forests/"+dbName+"-3/properties");
2388-
2389-
}
2390-
}
2391-
2392-
ihb2.flushAndWait();
2393-
t1.join();
2394-
properties.clear();
2395-
properties.put("forest-name",dbName+"-1");
2396-
properties.put("availability","online");
2397-
changeProperty(properties,"/manage/v2/forests/"+dbName+"-1/properties");
2398-
2399-
properties.put("forest-name",dbName+"-3");
2400-
changeProperty(properties,"/manage/v2/forests/"+dbName+"-3/properties");
2401-
Assert.assertTrue(successCount.intValue() == 10000);
2402-
Assert.assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue()==10000);
2403-
2404-
}
2405-
2406-
class OffLineForestStopServerRunnable implements Runnable {
2407-
final String query1 = "fn:count(fn:doc())";
2408-
Map<String,String> properties = new HashMap<>();
2409-
2410-
@Override
2411-
public void run() {
2412-
String stopHost;
2413-
if(hostNames.length >= 1){
2414-
stopHost = hostNames[1];
2415-
}
2416-
else{
2417-
stopHost = hostNames[0];
2418-
2419-
}
2420-
int count = 0;
2421-
while (count < 5){
2422-
2423-
changeServer(stopHost,"restart");
2424-
try {
2425-
Thread.currentThread().sleep(6000L);
2426-
} catch (InterruptedException e) {
2427-
e.printStackTrace();
2428-
}
2429-
count++;
2430-
2431-
}
2432-
}
24332329
}
24342330
}

0 commit comments

Comments
 (0)