Skip to content

Commit 4318252

Browse files
georgeajitgeorgeajit
authored andcommitted
No Task - Fixed failover tests and clean up of forests
1 parent f39960f commit 4318252

File tree

10 files changed

+53
-34
lines changed

10 files changed

+53
-34
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ public static void setUpBeforeClass() throws Exception {
124124
count++;
125125
Thread.currentThread().sleep(500L);
126126
}
127+
// Create App Server if needed.
128+
createRESTServerWithDB(server, port);
127129
assocRESTServer(server, dbName, port);
128130

129131
dbClient = getDatabaseClient(user, password, Authentication.DIGEST);
@@ -233,9 +235,8 @@ public static void setUpBeforeClass() throws Exception {
233235

234236
@AfterClass
235237
public static void tearDownAfterClass() throws Exception {
236-
clearDB(port);
237238
associateRESTServerWithDB(server, "Documents");
238-
for (int i = 0; i < clusterInfo.size(); i++) {
239+
for (int i = 0; i < hostNames.length; i++) {
239240
detachForest(dbName, dbName + "-" + (i + 1));
240241
deleteForest(dbName + "-" + (i + 1));
241242
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public static void setUpBeforeClass() throws Exception {
9393
count++;
9494
Thread.currentThread().sleep(500L);
9595
}
96+
// Create App Server if needed.
97+
createRESTServerWithDB(server, port);
9698

9799
assocRESTServer(server, dbName, port);
98100

@@ -124,7 +126,7 @@ public static void setUpBeforeClass() throws Exception {
124126
@AfterClass
125127
public static void tearDownAfterClass() throws Exception {
126128
associateRESTServerWithDB(server, "Documents");
127-
for (int i = 0; i < clusterInfo.size(); i++) {
129+
for (int i = 0; i < hostNames.length; i++) {
128130
System.out.println(dbName + "-" + (i + 1));
129131
detachForest(dbName, dbName + "-" + (i + 1));
130132
deleteForest(dbName + "-" + (i + 1));

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public static void setUpBeforeClass() throws Exception {
7878
count++;
7979
Thread.currentThread().sleep(500L);
8080
}
81-
81+
// Create App Server if needed.
82+
createRESTServerWithDB(server, port);
8283
assocRESTServer(server, dbName, port);
8384

8485
dbClient = getDatabaseClient(user, password, Authentication.DIGEST);
@@ -92,7 +93,7 @@ public static void setUpBeforeClass() throws Exception {
9293
@AfterClass
9394
public static void tearDownAfterClass() throws Exception {
9495
associateRESTServerWithDB(server, "Documents");
95-
for (int i = 0; i < clusterInfo.size(); i++) {
96+
for (int i = 0; i < hostNames.length; i++) {
9697
System.out.println(dbName + "-" + (i + 1));
9798
detachForest(dbName, dbName + "-" + (i + 1));
9899
deleteForest(dbName + "-" + (i + 1));

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public static void setUpBeforeClass() throws Exception {
113113
count++;
114114
Thread.currentThread().sleep(500L);
115115
}
116+
// Create App Server if needed.
117+
createRESTServerWithDB(server, port);
116118
assocRESTServer(server, dbName, port);
117119

118120
dbClient = getDatabaseClient(user, password, Authentication.DIGEST);
@@ -171,7 +173,7 @@ public static void setUpBeforeClass() throws Exception {
171173
@AfterClass
172174
public static void tearDownAfterClass() throws Exception {
173175
associateRESTServerWithDB(server, "Documents");
174-
for (int i = 0; i < clusterInfo.size(); i++) {
176+
for (int i = 0; i < hostNames.length; i++) {
175177
System.out.println(dbName + "-" + (i + 1));
176178
detachForest(dbName, dbName + "-" + (i + 1));
177179
deleteForest(dbName + "-" + (i + 1));

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ public class QBFailover extends BasicJavaClientREST {
9595
@BeforeClass
9696
public static void setUpBeforeClass() throws Exception {
9797
loadGradleProperties();
98-
server = getRestAppServerName();
99-
port = getRestAppServerPort();
100-
10198
host = getRestAppServerHostName();
99+
100+
server = getRestAppServerName();
101+
port = getRestAppServerPort();
102+
102103
hostNames = getHosts();
103104
// Add all possible hostnames and pick a random one to create a client
104105
List<String> hostLists = new ArrayList<String>();
@@ -118,11 +119,9 @@ public static void setUpBeforeClass() throws Exception {
118119
}
119120
}
120121
hostLists.add("localhost");
121-
createDB(dbName);
122-
Thread.currentThread().sleep(500L);
123122
int index = new Random().nextInt(hostLists.size());
124-
dbClient = getDatabaseClientOnDatabase(hostLists.get(index), port, dbName, user, password, Authentication.DIGEST);
125-
evalClient = DatabaseClientFactory.newClient(host, port, dbName, user, password, Authentication.DIGEST);
123+
dbClient = DatabaseClientFactory.newClient(hostLists.get(index), port, user, password, Authentication.DIGEST);
124+
evalClient = DatabaseClientFactory.newClient(host, port, user, password, Authentication.DIGEST);
126125
System.out.println("Connected to: " + dbClient.getHost());
127126
dmManager = dbClient.newDataMovementManager();
128127
tempMgr = evalClient.newDataMovementManager();
@@ -156,15 +155,15 @@ public static void setUpBeforeClass() throws Exception {
156155
}
157156
dataDir = location + "/space/dmsdk-failover/win/" + version + "/temp-";
158157
} else if (OS.indexOf("nux") >= 0) {
159-
// Avoid creating Forest at same location when multiple Linux platforms are used
160-
String uniqueForestStr = localhost +"-" + version;
161-
dataDir = "/project/qa-netapp/space/dmsdk-failover/linux/" + uniqueForestStr + "/temp-";
158+
dataDir = "/project/qa-netapp/space/dmsdk-failover/linux/" + version + "/temp-";
162159
} else if (OS.indexOf("mac") >= 0) {
163160
dataDir = "/project/qa-netapp/space/dmsdk-failover/mac/" + version + "/temp-";
164161
} else {
165162
Assert.fail("Unsupported platform");
166163
}
167-
164+
165+
createDB(dbName);
166+
Thread.currentThread().sleep(500L);
168167
for (int i = 0; i < hostNames.length; i++) {
169168
if (i != 0) {
170169
createForest(dbName + "-" + (i + 1), hostNames[i], dataDir + (i + 1), hostNames[0]);
@@ -182,6 +181,8 @@ public static void setUpBeforeClass() throws Exception {
182181
props.put("journaling", "strict");
183182
changeProperty(props, "/manage/v2/databases/" + dbName + "/properties");
184183
Thread.currentThread().sleep(500L);
184+
// Create App Server if needed.
185+
createRESTServerWithDB(server, port);
185186
associateRESTServerWithDB(server, dbName);
186187

187188
// StringHandle

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public static void setUpBeforeClass() throws Exception {
104104
count++;
105105
Thread.currentThread().sleep(500L);
106106
}
107+
// Create App Server if needed.
108+
createRESTServerWithDB(server, port);
107109

108110
assocRESTServer(server, dbName, port);
109111

@@ -170,9 +172,8 @@ public static void setUpBeforeClass() throws Exception {
170172

171173
@AfterClass
172174
public static void tearDownAfterClass() throws Exception {
173-
clearDB(port);
174175
associateRESTServerWithDB(server, "Documents");
175-
for (int i = 0; i < clusterInfo.size(); i++) {
176+
for (int i = 0; i < hostNames.length; i++) {
176177
detachForest(dbName, dbName + "-" + (i + 1));
177178
deleteForest(dbName + "-" + (i + 1));
178179
}

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ public class WBFailover extends BasicJavaClientREST {
7676
@BeforeClass
7777
public static void setUpBeforeClass() throws Exception {
7878
loadGradleProperties();
79+
host = getRestAppServerHostName();
80+
7981
server = getRestAppServerName();
8082
port = getRestAppServerPort();
8183

82-
host = getRestAppServerHostName();
8384
hostNames = getHosts();
8485
// Add all possible hostnames and pick a random one to create a client
8586
hostLists = new ArrayList<String>();
@@ -94,17 +95,16 @@ public static void setUpBeforeClass() throws Exception {
9495
}
9596
}
9697
hostLists.add("localhost");
97-
createDB(dbName);
98-
Thread.currentThread().sleep(500L);
99-
// Assuming the tests are run on 3 node cluster
100-
Assert.assertEquals(hostLists.size(), 7);
98+
// Assuming the tests are run on 3 node cluster. If order that test is not marked as a failure add a check.
99+
if (hostLists.size() > 1) {
100+
Assert.assertEquals(hostLists.size(), 7);
101+
}
101102
int index = new Random().nextInt(hostLists.size());
102-
dbClient = getDatabaseClientOnDatabase(hostLists.get(index), port, dbName, user, password, Authentication.DIGEST);
103-
evalClient = getDatabaseClientOnDatabase(host, port, dbName, user, password, Authentication.DIGEST);
103+
dbClient = DatabaseClientFactory.newClient(hostLists.get(index), port, user, password, Authentication.DIGEST);
104+
evalClient = DatabaseClientFactory.newClient(host, port, user, password, Authentication.DIGEST);
104105
dmManager = dbClient.newDataMovementManager();
105106

106107
Map<String, String> props = new HashMap<>();
107-
String localhost = InetAddress.getLocalHost().getHostName().toLowerCase();
108108
String version = String.valueOf(evalClient.newServerEval().xquery("xquery version \"1.0-ml\"; xdmp:version()")
109109
.eval().next().getString().charAt(0));
110110
if (OS.indexOf("win") >= 0) {
@@ -133,15 +133,14 @@ public static void setUpBeforeClass() throws Exception {
133133
}
134134
dataDir = location + "/space/dmsdk-failover/win/" + version + "/temp-";
135135
} else if (OS.indexOf("nux") >= 0) {
136-
// Avoid creating Forest at same location when multiple Linux platforms are used
137-
String uniqueForestStr = localhost +"-" + version;
138-
dataDir = "/project/qa-netapp/space/dmsdk-failover/linux/" + uniqueForestStr + "/temp-";
136+
dataDir = "/project/qa-netapp/space/dmsdk-failover/linux/" + version + "/temp-";
139137
} else if (OS.indexOf("mac") >= 0) {
140138
dataDir = "/project/qa-netapp/space/dmsdk-failover/mac/" + version + "/temp-";
141139
} else {
142140
Assert.fail("Unsupported platform");
143141
}
144-
142+
createDB(dbName);
143+
Thread.currentThread().sleep(500L);
145144
for (int i = 0; i < hostNames.length; i++) {
146145
if (i != 0) {
147146
createForest(dbName + "-" + (i + 1), hostNames[i], dataDir + (i + 1), hostNames[0]);
@@ -160,6 +159,8 @@ public static void setUpBeforeClass() throws Exception {
160159
changeProperty(props, "/manage/v2/databases/" + dbName + "/properties");
161160

162161
Thread.currentThread().sleep(2000L);
162+
// Create App Server if needed.
163+
createRESTServerWithDB(server, port);
163164

164165
associateRESTServerWithDB(server, dbName);
165166

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public static void setUpBeforeClass() throws Exception {
9191
count++;
9292
Thread.currentThread().sleep(500L);
9393
}
94+
// Create App Server if needed.
95+
createRESTServerWithDB(server, port);
9496

9597
associateRESTServerWithDB(server, dbName);
9698

@@ -137,7 +139,7 @@ public static void setUpBeforeClass() throws Exception {
137139
@AfterClass
138140
public static void tearDownAfterClass() throws Exception {
139141
associateRESTServerWithDB(server, "Documents");
140-
for (int i = 0; i < clusterInfo.size(); i++) {
142+
for (int i = 0; i < hostNames.length; i++) {
141143
System.out.println(dbName + "-" + (i + 1));
142144
detachForest(dbName, dbName + "-" + (i + 1));
143145
deleteForest(dbName + "-" + (i + 1));

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public static void setUpBeforeClass() throws Exception {
165165
count++;
166166
Thread.currentThread().sleep(500L);
167167
}
168+
// Create App Server if needed.
169+
createRESTServerWithDB(server, port);
168170
assocRESTServer(server, dbName, port);
169171

170172
dbClient = getDatabaseClient(user, password, Authentication.DIGEST);
@@ -210,7 +212,7 @@ public static void setUpBeforeClass() throws Exception {
210212
@AfterClass
211213
public static void tearDownAfterClass() throws Exception {
212214
associateRESTServerWithDB(server, "Documents");
213-
for (int i = 0; i < clusterInfo.size(); i++) {
215+
for (int i = 0; i < hostNames.length; i++) {
214216
System.out.println(dbName + "-" + (i + 1));
215217
detachForest(dbName, dbName + "-" + (i + 1));
216218
deleteForest(dbName + "-" + (i + 1));

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/functionaltest/ConnectedRESTQA.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,14 @@ public static void createForestonHost(String fName, String dbName, String hName)
249249

250250
public static void postRequest(Map<String, String> payload, Map<String, String> params, String endpoint) {
251251
DefaultHttpClient client = null;
252+
JSONObject JSONpayload = null;
252253
try {
253-
JSONObject JSONpayload = new JSONObject(payload);
254+
if (payload == null) {
255+
JSONpayload = new JSONObject();
256+
}
257+
else {
258+
JSONpayload = new JSONObject(payload);
259+
}
254260
client = new DefaultHttpClient();
255261
client.getCredentialsProvider().setCredentials(new AuthScope(host_name, getAdminPort()),
256262
new UsernamePasswordCredentials("admin", "admin"));

0 commit comments

Comments
 (0)