Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit ef30dc8

Browse files
author
Rob Rudin
committed
#164 Fixing test for custom forests, was ignored
1 parent 70780d7 commit ef30dc8

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

src/main/java/com/marklogic/appdeployer/command/databases/DeployContentDatabasesCommand.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void execute(CommandContext context) {
4141
if (count != null) {
4242
this.setForestsPerHost(count);
4343
}
44-
44+
4545
super.execute(context);
4646

4747
AppConfig appConfig = context.getAppConfig();
@@ -51,7 +51,13 @@ public void execute(CommandContext context) {
5151
DatabaseManager dbMgr = new DatabaseManager(context.getManageClient());
5252
String json = tokenReplacer.replaceTokens(payload, appConfig, true);
5353
SaveReceipt receipt = dbMgr.save(json);
54-
buildDeployForestsCommand(payload, receipt, context).execute(context);
54+
if (shouldCreateForests(context, payload)) {
55+
buildDeployForestsCommand(payload, receipt, context).execute(context);
56+
} else {
57+
if (logger.isInfoEnabled()) {
58+
logger.info("Found custom forests for database, so not creating default forests");
59+
}
60+
}
5561
}
5662
}
5763
}

src/test/java/com/marklogic/appdeployer/command/forests/DeployCustomForestsTest.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
import com.marklogic.appdeployer.command.databases.DeployContentDatabasesCommand;
66
import com.marklogic.mgmt.forests.ForestManager;
77
import org.junit.After;
8-
import org.junit.Ignore;
98
import org.junit.Test;
109

1110
import java.io.File;
1211

1312
/**
1413
* Verifies that directories under ./forests/ are processed correctly.
1514
*/
16-
@Ignore("Failing on travis because it's not using the right hostname for forests, not sure how to fix yet")
1715
public class DeployCustomForestsTest extends AbstractAppDeployerTest {
1816

1917
@After
@@ -23,17 +21,13 @@ public void tearDown() {
2321

2422
@Test
2523
public void test() {
26-
// To avoid hardcoding host names that might cause the test to fail, we use a custom token and assume that
27-
// the host of the Management API will work
28-
appConfig.getCustomTokens().put("%%CUSTOM_HOST%%", super.manageConfig.getHost());
29-
3024
appConfig.setConfigDir(new ConfigDir(new File("src/test/resources/sample-app/custom-forests")));
3125

3226
initializeAppDeployer(new DeployContentDatabasesCommand(1), new DeployCustomForestsCommand());
3327
deploySampleApp();
3428

3529
ForestManager mgr = new ForestManager(manageClient);
36-
assertTrue("One 'simple' forest should have been created by default", mgr.exists("sample-app-content-1"));
30+
assertFalse("A default forest should not have been created since custom forests exist", mgr.exists("sample-app-content-1"));
3731
assertTrue(mgr.exists("sample-app-content-custom-1"));
3832
assertTrue(mgr.exists("sample-app-content-custom-2"));
3933
assertTrue(mgr.exists("sample-app-content-custom-3"));

src/test/resources/sample-app/custom-forests/forests/sample-app-content/custom-forests.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
{
33
"forest-name": "sample-app-content-custom-1",
44
"enabled": true,
5-
"host": "%%CUSTOM_HOST%%",
65
"database": "%%DATABASE%%"
76
},
87
{
98
"forest-name": "sample-app-content-custom-2",
109
"enabled": true,
11-
"host": "%%CUSTOM_HOST%%",
1210
"database": "%%DATABASE%%"
1311
}
1412
]
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"forest-name": "sample-app-content-custom-3",
33
"enabled": true,
4-
"host": "%%CUSTOM_HOST%%",
54
"database": "%%DATABASE%%"
65
}

0 commit comments

Comments
 (0)