Skip to content

Commit 8099ffa

Browse files
author
ssambasu
committed
Fixing to run the tests in Windows platform
1 parent 91b9bac commit 8099ffa

File tree

2 files changed

+77
-28
lines changed

2 files changed

+77
-28
lines changed

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

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
import java.io.BufferedReader;
66
import java.io.File;
7+
import java.io.FileInputStream;
8+
import java.io.IOException;
9+
import java.io.InputStream;
710
import java.io.InputStreamReader;
811
import java.net.InetAddress;
912
import java.text.SimpleDateFormat;
@@ -14,6 +17,7 @@
1417
import java.util.HashMap;
1518
import java.util.List;
1619
import java.util.Map;
20+
import java.util.Properties;
1721
import java.util.Random;
1822
import java.util.concurrent.atomic.AtomicBoolean;
1923
import java.util.concurrent.atomic.AtomicInteger;
@@ -100,7 +104,6 @@ public static void setUpBeforeClass() throws Exception {
100104
String domain = null;
101105
if (matcher.find()) {
102106
domain = matcher.group(1);
103-
System.out.println(domain);
104107
}
105108
for (String host : hostNames) {
106109
hostLists.add(host);
@@ -121,12 +124,32 @@ public static void setUpBeforeClass() throws Exception {
121124
Map<String, String> props = new HashMap<>();
122125
String version = String.valueOf(evalClient.newServerEval().xquery("xquery version \"1.0-ml\"; xdmp:version()")
123126
.eval().next().getString().charAt(0));
124-
/*
125-
* if (OS.indexOf("win") >= 0) { dataDir =
126-
* "//netapp1-10g.colo.marklogic.com/lab1/space/dmsdk-failover/win/"+
127-
* version+"/temp-"; }else
128-
*/
129-
if (OS.indexOf("nux") >= 0) {
127+
if (OS.indexOf("win") >= 0) {
128+
Properties prop = new Properties();
129+
InputStream input = null;
130+
String location = null;
131+
String seperator = File.separator;
132+
try {
133+
input = new FileInputStream(System.getProperty("user.dir") + ".." + seperator + ".." + seperator + "qa"
134+
+ seperator + "failover-location.properties");
135+
prop.load(input);
136+
location = prop.getProperty("location");
137+
System.out.println(prop.getProperty("location"));
138+
} catch (IOException ex) {
139+
ex.printStackTrace();
140+
Assert.fail("Forest location file not found");
141+
} finally {
142+
if (input != null) {
143+
try {
144+
input.close();
145+
} catch (IOException e) {
146+
e.printStackTrace();
147+
Assert.fail("Forest location file not found");
148+
}
149+
}
150+
}
151+
dataDir = location + "/space/dmsdk-failover/win/" + version + "/temp-";
152+
} else if (OS.indexOf("nux") >= 0) {
130153
dataDir = "/project/qa-netapp/space/dmsdk-failover/linux/" + version + "/temp-";
131154
} else if (OS.indexOf("mac") >= 0) {
132155
dataDir = "/project/qa-netapp/space/dmsdk-failover/mac/" + version + "/temp-";
@@ -222,7 +245,7 @@ public void setUp() throws Exception {
222245
Assert.assertEquals(f.length, hostNames.length);
223246
Assert.assertEquals(f.length, 3L);
224247
addDocs();
225-
Assert.assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 15000);
248+
Assert.assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 20000);
226249
}
227250

228251
@After
@@ -281,7 +304,7 @@ public void testStopOneNode() throws Exception {
281304
System.out.println("Success " + success.intValue());
282305
System.out.println("Failure " + failure.intValue());
283306

284-
assertEquals("document count", 15000, success.intValue());
307+
assertEquals("document count", 20000, success.intValue());
285308
assertEquals("document count", 0, failure.intValue());
286309
}
287310

@@ -318,7 +341,7 @@ public void testRestart() throws Exception {
318341
System.out.println("Success " + success.intValue());
319342
System.out.println("Failure " + failure.intValue());
320343

321-
assertEquals("document count", 15000, success.intValue());
344+
assertEquals("document count", 20000, success.intValue());
322345
assertEquals("document count", 0, failure.intValue());
323346
}
324347

@@ -362,7 +385,7 @@ public void testRepeatedStopOneNode() throws Exception {
362385
System.out.println("Success " + success.intValue());
363386
System.out.println("Failure " + failure.intValue());
364387

365-
assertEquals("document count", 15000, success.intValue());
388+
assertEquals("document count", 20000, success.intValue());
366389
assertEquals("document count", 0, failure.intValue());
367390
}
368391

@@ -407,7 +430,7 @@ public void testMinNodes() throws Exception {
407430
Thread.currentThread().sleep(20000L);
408431
System.out.println("Success " + success.intValue());
409432
System.out.println("Failure " + failure.intValue());
410-
Assert.assertTrue(success.intValue() < 15000);
433+
Assert.assertTrue(success.intValue() < 20000);
411434
}
412435

413436
@Test
@@ -447,7 +470,7 @@ public void testStopTwoNodes() throws Exception {
447470
batcher.awaitCompletion();
448471
dmManager.stopJob(ticket);
449472
System.out.println("Success " + success.intValue());
450-
assertEquals("document count", 15000, success.intValue());
473+
assertEquals("document count", 20000, success.intValue());
451474
} catch (Exception e) {
452475
e.printStackTrace();
453476
}
@@ -517,8 +540,8 @@ public void xQueryMasstransformReplace() throws Exception {
517540
readBatcher.awaitCompletion();
518541
System.out.println("Modified docs: " + modified.intValue());
519542
Assert.assertTrue(passed.get());
520-
assertEquals("document count", 15000, modified.intValue());
521-
assertEquals("document count", 15000, success.intValue());
543+
assertEquals("document count", 20000, modified.intValue());
544+
assertEquals("document count", 20000, success.intValue());
522545
assertEquals("document count", 0, skipped.intValue());
523546

524547
}
@@ -590,8 +613,8 @@ public void xQueryMasstransformReplaceTwoNodes() throws Exception {
590613
readBatcher.awaitCompletion();
591614
System.out.println("Modified docs: " + modified.intValue());
592615
Assert.assertTrue(passed.get());
593-
assertEquals("document count", 15000, modified.intValue());
594-
assertEquals("document count", 15000, success.intValue());
616+
assertEquals("document count", 20000, modified.intValue());
617+
assertEquals("document count", 20000, success.intValue());
595618
assertEquals("document count", 0, skipped.intValue());
596619
}
597620

@@ -668,8 +691,8 @@ public void xQueryMasstransformReplaceRepeated() throws Exception {
668691
readBatcher.awaitCompletion();
669692
System.out.println("Modified docs: " + modified.intValue());
670693
Assert.assertTrue(passed.get());
671-
assertEquals("document count", 15000, modified.intValue());
672-
assertEquals("document count", 15000, success.intValue());
694+
assertEquals("document count", 20000, modified.intValue());
695+
assertEquals("document count", 20000, success.intValue());
673696
assertEquals("document count", 0, failure.intValue());
674697
}
675698

@@ -754,7 +777,7 @@ private void addDocs() {
754777

755778
dmManager.startJob(ihb2);
756779

757-
for (int j = 0; j < 15000; j++) {
780+
for (int j = 0; j < 20000; j++) {
758781
String uri = "/local/string-" + j;
759782
ihb2.add(uri, meta2, stringHandle);
760783
}

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

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.marklogic.client.datamovement.functionaltests;
22

33
import java.io.BufferedReader;
4+
import java.io.FileInputStream;
5+
import java.io.IOException;
6+
import java.io.InputStream;
47
import java.io.InputStreamReader;
58
import java.text.SimpleDateFormat;
69
import java.time.Duration;
@@ -10,6 +13,7 @@
1013
import java.util.HashMap;
1114
import java.util.List;
1215
import java.util.Map;
16+
import java.util.Properties;
1317
import java.util.Random;
1418
import java.util.concurrent.atomic.AtomicBoolean;
1519
import java.util.concurrent.atomic.AtomicInteger;
@@ -94,12 +98,30 @@ public static void setUpBeforeClass() throws Exception {
9498
Map<String, String> props = new HashMap<>();
9599
String version = String.valueOf(evalClient.newServerEval().xquery("xquery version \"1.0-ml\"; xdmp:version()")
96100
.eval().next().getString().charAt(0));
97-
/*
98-
* if (OS.indexOf("win") >= 0) { dataDir =
99-
* "//netapp1-10g.colo.marklogic.com/lab1/space/dmsdk-failover/win/" +
100-
* version + "/temp-"; } else
101-
*/
102-
if (OS.indexOf("nux") >= 0) {
101+
if (OS.indexOf("win") >= 0) {
102+
Properties prop = new Properties();
103+
InputStream input = null;
104+
String location = null;
105+
try {
106+
input = new FileInputStream("failover-location.properties");
107+
prop.load(input);
108+
location = prop.getProperty("location");
109+
System.out.println(prop.getProperty("location"));
110+
} catch (IOException ex) {
111+
ex.printStackTrace();
112+
Assert.fail("Forest location file not found");
113+
} finally {
114+
if (input != null) {
115+
try {
116+
input.close();
117+
} catch (IOException e) {
118+
e.printStackTrace();
119+
Assert.fail("Forest location file not found");
120+
}
121+
}
122+
}
123+
dataDir = location + "/space/dmsdk-failover/win/" + version + "/temp-";
124+
} else if (OS.indexOf("nux") >= 0) {
103125
dataDir = "/project/qa-netapp/space/dmsdk-failover/linux/" + version + "/temp-";
104126
} else if (OS.indexOf("mac") >= 0) {
105127
dataDir = "/project/qa-netapp/space/dmsdk-failover/mac/" + version + "/temp-";
@@ -227,7 +249,6 @@ public void testBlackListHost() throws Exception {
227249
HostAvailabilityListener.getInstance(ihb2).withMinHosts(2);
228250
NoResponseListener.getInstance(ihb2).withMinHosts(2);
229251
ihb2.onBatchSuccess(batch -> {
230-
System.out.println(batch.getClient().getHost());
231252
if (batch.getClient().getHost().equals(hostLists.get(2))
232253
|| batch.getClient().getHost().equals(hostLists.get(3))) {
233254
containsBLHost.set(true);
@@ -254,6 +275,7 @@ public void testBlackListHost() throws Exception {
254275

255276
@Test
256277
public void testStopOneNode() throws Exception {
278+
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
257279
Assert.assertTrue(evalClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 0);
258280
final AtomicInteger successCount = new AtomicInteger(0);
259281
final AtomicBoolean failState = new AtomicBoolean(false);
@@ -298,6 +320,7 @@ public void testStopOneNode() throws Exception {
298320

299321
@Test
300322
public void testRestart() throws Exception {
323+
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
301324
Assert.assertTrue(evalClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 0);
302325
final AtomicInteger successCount = new AtomicInteger(0);
303326
final AtomicBoolean failState = new AtomicBoolean(false);
@@ -345,6 +368,7 @@ public void testRestart() throws Exception {
345368

346369
@Test
347370
public void testRepeatedStopOneNode() throws Exception {
371+
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
348372
try {
349373
final AtomicInteger successCount = new AtomicInteger(0);
350374
final AtomicBoolean failState = new AtomicBoolean(false);
@@ -401,6 +425,7 @@ public void testRepeatedStopOneNode() throws Exception {
401425

402426
@Test
403427
public void testStopTwoNodes() throws Exception {
428+
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
404429
try {
405430
final AtomicInteger successCount = new AtomicInteger(0);
406431
final AtomicBoolean failState = new AtomicBoolean(false);
@@ -459,7 +484,7 @@ public void testStopTwoNodes() throws Exception {
459484

460485
@Test
461486
public void testMinHosts() throws Exception {
462-
System.out.println("Starting min test");
487+
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
463488
final AtomicInteger successCount = new AtomicInteger(0);
464489
final AtomicInteger failCount = new AtomicInteger(0);
465490
WriteBatcher ihb2 = null;
@@ -502,6 +527,7 @@ public void testMinHosts() throws Exception {
502527

503528
@Test
504529
public void testWhiteBlackListNPE() throws Exception {
530+
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
505531
try {
506532
FilteredForestConfiguration forestConfig = new FilteredForestConfiguration(dmManager.readForestConfig())
507533
.withBlackList(null);

0 commit comments

Comments
 (0)