Skip to content

Commit 116c907

Browse files
srinathgitaebadirad
authored andcommitted
Initialize 'hubAdminUserName', 'hubAdminRoleName' and fix build.gradle (#1692)
* Don't get 'bootStrapHost' if not required * Initializing 'hubAdminUserName' and 'hubAdminRoleName' * Fixing tests failing in DHS env
1 parent 690f083 commit 116c907

File tree

5 files changed

+37
-5
lines changed

5 files changed

+37
-5
lines changed

marklogic-data-hub/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,11 @@ task testBootstrap(type: Test) {
316316

317317
task setupSSL{
318318
doFirst{
319-
com.marklogic.mgmt.ManageClient manageClient = new ManageClient(new com.marklogic.mgmt.ManageConfig(mlHost, 8002, mlSecurityUsername, mlSecurityPassword))
320-
com.marklogic.mgmt.resource.hosts.HostManager hostManager = new HostManager(manageClient)
321-
def bootStrapHost = hostManager.getHostNames().get(0)
319+
def bootStrapHost = null
322320
if(sslRun || certAuth){
321+
com.marklogic.mgmt.ManageClient manageClient = new ManageClient(new com.marklogic.mgmt.ManageConfig(mlHost, 8002, mlSecurityUsername, mlSecurityPassword))
322+
com.marklogic.mgmt.resource.hosts.HostManager hostManager = new HostManager(manageClient)
323+
bootStrapHost = hostManager.getHostNames().get(0)
323324
if(! bootStrapHost.toLowerCase().contains("marklogic.com")){
324325
throw new GradleException("The test with current options will run only in marklogic.com domain")
325326
}

marklogic-data-hub/src/main/java/com/marklogic/hub/impl/HubConfigImpl.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,20 @@ public void loadConfigurationFromProperties(Properties properties, boolean loadG
12831283
else {
12841284
projectProperties.setProperty("mlHubUserName", hubUserName);
12851285
}
1286+
1287+
if (hubAdminRoleName == null) {
1288+
hubAdminRoleName = getEnvPropString(projectProperties, "mlHubAdminRole", environment.getProperty("mlHubAdminRole"));
1289+
}
1290+
else {
1291+
projectProperties.setProperty("mlHubAdminRole", hubAdminRoleName);
1292+
}
1293+
1294+
if (hubAdminUserName == null) {
1295+
hubAdminUserName = getEnvPropString(projectProperties, "mlHubAdminUserName", environment.getProperty("mlHubAdminUserName"));
1296+
}
1297+
else {
1298+
projectProperties.setProperty("mlHubAdminUserName", hubAdminUserName);
1299+
}
12861300

12871301
if (modulePermissions == null) {
12881302
modulePermissions = getEnvPropString(projectProperties, "mlModulePermissions", environment.getProperty("mlModulePermissions"));

marklogic-data-hub/src/test/java/com/marklogic/hub/flow/FlowManagerTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.marklogic.hub.flow;
1717

18+
import com.marklogic.bootstrap.Installer;
1819
import com.marklogic.client.io.DOMHandle;
1920
import com.marklogic.client.io.DocumentMetadataHandle;
2021
import com.marklogic.hub.FlowManager;
@@ -26,6 +27,7 @@
2627
import com.marklogic.hub.scaffold.Scaffolding;
2728
import org.apache.commons.io.FileUtils;
2829
import org.json.JSONException;
30+
import org.junit.jupiter.api.BeforeAll;
2931
import org.junit.jupiter.api.BeforeEach;
3032
import org.junit.jupiter.api.Test;
3133
import org.junit.jupiter.api.extension.ExtendWith;
@@ -56,6 +58,11 @@ public class FlowManagerTest extends HubTestBase {
5658

5759
@Autowired
5860
private Scaffolding scaffolding;
61+
62+
@BeforeAll
63+
public static void runOnce() {
64+
new Installer().deleteProjectDir();
65+
}
5966

6067
@BeforeEach
6168
public void setup() throws IOException {
@@ -309,6 +316,7 @@ public void testRunFlowWithBackwards() throws SAXException, IOException, ParserC
309316
installModules();
310317
assertEquals(0, getStagingDocCount());
311318
assertEquals(2, getFinalDocCount());
319+
getHubFlowRunnerConfig();
312320
Flow flow1 = fm.getFlow("test", "my-test-flow1");
313321
FlowRunner flowRunner = fm.newFlowRunner()
314322
.withFlow(flow1)
@@ -318,6 +326,7 @@ public void testRunFlowWithBackwards() throws SAXException, IOException, ParserC
318326
.withDestinationDatabase(HubConfig.DEFAULT_STAGING_NAME);
319327
flowRunner.run();
320328
flowRunner.awaitCompletion();
329+
getHubAdminConfig();
321330
assertEquals(2, getStagingDocCount());
322331
assertEquals(2, getFinalDocCount());
323332
assertXMLEqual(getXmlFromResource("flow-manager-test/harmonized/harmonized1.xml"), stagingDocMgr.read("/employee1.xml").next().getContent(new DOMHandle()).get() );
@@ -343,13 +352,15 @@ public void testRunFlowWithHeader() throws SAXException, IOException, ParserConf
343352

344353
assertEquals(2, getStagingDocCount());
345354
assertEquals(0, getFinalDocCount());
355+
getHubFlowRunnerConfig();
346356
Flow flow1 = fm.getFlow("test", "my-test-flow-with-header");
347357
FlowRunner flowRunner = fm.newFlowRunner()
348358
.withFlow(flow1)
349359
.withBatchSize(10)
350360
.withThreadCount(1);
351361
flowRunner.run();
352362
flowRunner.awaitCompletion();
363+
getHubAdminConfig();
353364
assertEquals(2, getStagingDocCount());
354365
assertEquals(2, getFinalDocCount());
355366
assertXMLEqual(getXmlFromResource("flow-manager-test/harmonized-with-header/harmonized1.xml"), finalDocMgr.read("/employee1.xml").next().getContent(new DOMHandle()).get() );
@@ -373,13 +384,15 @@ public void testRunFlowWithAll() throws SAXException, IOException, ParserConfigu
373384

374385
assertEquals(2, getStagingDocCount());
375386
assertEquals(0, getFinalDocCount());
387+
getHubFlowRunnerConfig();
376388
Flow flow1 = fm.getFlow("test", "my-test-flow-with-all");
377389
FlowRunner flowRunner = fm.newFlowRunner()
378390
.withFlow(flow1)
379391
.withBatchSize(10)
380392
.withThreadCount(1);
381393
flowRunner.run();
382394
flowRunner.awaitCompletion();
395+
getHubAdminConfig();
383396
assertEquals(2, getStagingDocCount());
384397
assertEquals(2, getFinalDocCount());
385398
assertXMLEqual(getXmlFromResource("flow-manager-test/harmonized-with-all/harmonized1.xml"), finalDocMgr.read("/employee1.xml").next().getContent(new DOMHandle()).get() );

marklogic-data-hub/src/test/java/com/marklogic/hub/job/JobManagerTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public void setupStuff() throws InterruptedException, IOException {
9292
HashMap<String, Object> options = new HashMap<>();
9393
options.put("name", "Bob Smith");
9494
options.put("age", 55);
95+
getHubFlowRunnerConfig();
9596
FlowRunner flowRunner = fm.newFlowRunner()
9697
.withFlow(harmonizeFlow)
9798
.withBatchSize(10)
@@ -113,7 +114,7 @@ public void setupStuff() throws InterruptedException, IOException {
113114
.onItemComplete(flowItemCompleteListener);
114115
flowRunner.run();
115116
flowRunner.awaitCompletion();
116-
jobManager = JobManager.create(getHubAdminConfig().newJobDbClient());
117+
jobManager = JobManager.create(getHubFlowRunnerConfig().newJobDbClient());
117118
}
118119

119120
@AfterEach
@@ -124,6 +125,7 @@ public void cleanup() {
124125
e.printStackTrace();
125126
}
126127
disableTracing();
128+
getHubAdminConfig();
127129
}
128130
private static void recordJobId(String jobId) {
129131
jobIds.add(jobId);

marklogic-data-hub/src/test/java/com/marklogic/hub/job/TracingTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ public void setup() throws IOException, URISyntaxException {
6767
new File(PROJECT_PATH + "/plugins")
6868
);
6969
installUserModules(adminHubConfig, true);
70+
//Disable tracing that may have been enabled in previous tests
71+
Tracing.create(flowRunnerClient).disable();
7072
}
7173

7274
@AfterEach
7375
public void afterEach() {
74-
disableTracing();
76+
Tracing.create(flowRunnerClient).disable();
7577
clearDatabases(HubConfig.DEFAULT_JOB_NAME, HubConfig.DEFAULT_FINAL_NAME);
7678
}
7779

0 commit comments

Comments
 (0)