You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/08/29 20:28:44 UTC
[1/3] brooklyn-server git commit: Prevent vanilla process commands
from being inherited by children
Repository: brooklyn-server
Updated Branches:
refs/heads/master b70841f72 -> b1cafd85f
Prevent vanilla process commands from being inherited by children
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/4cc823c2
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/4cc823c2
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/4cc823c2
Branch: refs/heads/master
Commit: 4cc823c2c311f86c8785ae863f017c9bd65d997f
Parents: 50d5bee
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Fri Jul 29 09:16:21 2016 +0100
Committer: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Committed: Sun Aug 28 22:23:21 2016 +0100
----------------------------------------------------------------------
.../core/entity/BrooklynConfigKeys.java | 36 +++++---
.../software/base/AbstractVanillaProcess.java | 29 ++++--
.../entity/software/base/SoftwareProcess.java | 6 ++
.../software/base/VanillaWindowsProcess.java | 93 ++++++++++++--------
4 files changed, 110 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4cc823c2/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java b/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
index 3530760..21db6f0 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
@@ -99,18 +99,30 @@ public class BrooklynConfigKeys {
public static final ConfigKey<Boolean> SKIP_ENTITY_INSTALLATION = newBooleanConfigKey("install.skip", "Skip the driver install commands entirely, for pre-installed software");
// The implementation in AbstractSoftwareSshDriver runs this command as an SSH command
- public static final ConfigKey<String> PRE_INSTALL_COMMAND = ConfigKeys.newStringConfigKey("pre.install.command",
- "Command to be run prior to the install method being called on the driver");
- public static final ConfigKey<String> POST_INSTALL_COMMAND = ConfigKeys.newStringConfigKey("post.install.command",
- "Command to be run after the install method being called on the driver");
- public static final ConfigKey<String> PRE_CUSTOMIZE_COMMAND = ConfigKeys.newStringConfigKey("pre.customize.command",
- "Command to be run prior to the customize method being called on the driver");
- public static final ConfigKey<String> POST_CUSTOMIZE_COMMAND = ConfigKeys.newStringConfigKey("post.customize.command",
- "Command to be run after the customize method being called on the driver");
- public static final ConfigKey<String> PRE_LAUNCH_COMMAND = ConfigKeys.newStringConfigKey("pre.launch.command",
- "Command to be run prior to the launch method being called on the driver");
- public static final ConfigKey<String> POST_LAUNCH_COMMAND = ConfigKeys.newStringConfigKey("post.launch.command",
- "Command to be run after the launch method being called on the driver");
+ public static final ConfigKey<String> PRE_INSTALL_COMMAND = ConfigKeys.builder(String.class, "pre.install.command")
+ .description("Command to be run prior to the install method being called on the driver")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+ public static final ConfigKey<String> POST_INSTALL_COMMAND = ConfigKeys.builder(String.class, "post.install.command")
+ .description("Command to be run after the install method being called on the driver")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+ public static final ConfigKey<String> PRE_CUSTOMIZE_COMMAND = ConfigKeys.builder(String.class, "pre.customize.command")
+ .description("Command to be run prior to the customize method being called on the driver")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+ public static final ConfigKey<String> POST_CUSTOMIZE_COMMAND = ConfigKeys.builder(String.class, "post.customize.command")
+ .description("Command to be run after the customize method being called on the driver")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+ public static final ConfigKey<String> PRE_LAUNCH_COMMAND = ConfigKeys.builder(String.class, "pre.launch.command")
+ .description("Command to be run prior to the launch method being called on the driver")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+ public static final ConfigKey<String> POST_LAUNCH_COMMAND = ConfigKeys.builder(String.class, "post.launch.command")
+ .description("Command to be run after the launch method being called on the driver")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
public static final MapConfigKey<Object> SHELL_ENVIRONMENT = new MapConfigKey.Builder<Object>(Object.class, "shell.env")
.description("Map of environment variables to pass to the runtime shell. Non-string values are serialized to json before passed to the shell.")
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4cc823c2/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractVanillaProcess.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractVanillaProcess.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractVanillaProcess.java
index 35bdd94..f5c1bf5 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractVanillaProcess.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractVanillaProcess.java
@@ -18,6 +18,7 @@
*/
package org.apache.brooklyn.entity.software.base;
+import org.apache.brooklyn.config.ConfigInheritance;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.config.ConfigKeys;
import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
@@ -26,10 +27,26 @@ public interface AbstractVanillaProcess extends SoftwareProcess {
AttributeSensorAndConfigKey<String, String> DOWNLOAD_URL = SoftwareProcess.DOWNLOAD_URL;
ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "0.0.0");
-
- ConfigKey<String> INSTALL_COMMAND = ConfigKeys.newStringConfigKey("install.command", "command to run during the install phase");
- ConfigKey<String> CUSTOMIZE_COMMAND = ConfigKeys.newStringConfigKey("customize.command", "command to run during the customization phase");
- ConfigKey<String> LAUNCH_COMMAND = ConfigKeys.newStringConfigKey("launch.command", "command to run to launch the process");
- ConfigKey<String> CHECK_RUNNING_COMMAND = ConfigKeys.newStringConfigKey("checkRunning.command", "command to determine whether the process is running");
- ConfigKey<String> STOP_COMMAND = ConfigKeys.newStringConfigKey("stop.command", "command to run to stop the process");
+
+ ConfigKey<String> INSTALL_COMMAND = ConfigKeys.builder(String.class, "install.command")
+ .description("command to run during the install phase")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+ ConfigKey<String> CUSTOMIZE_COMMAND = ConfigKeys.builder(String.class, "customize.command")
+ .description("command to run during the customization phase")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+ ConfigKey<String> LAUNCH_COMMAND = ConfigKeys.builder(String.class, "launch.command")
+ .description("command to run to launch the process")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+ ConfigKey<String> CHECK_RUNNING_COMMAND = ConfigKeys.builder(String.class, "checkRunning.command")
+ .description("command to determine whether the process is running")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+ ConfigKey<String> STOP_COMMAND = ConfigKeys.builder(String.class, "stop.command")
+ .description("command to run to stop the process")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4cc823c2/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
index 05bdd15..883dfb7 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
@@ -178,6 +178,7 @@ public interface SoftwareProcess extends Entity, Startable {
@SetFromFlag("preInstallFiles")
MapConfigKey<String> PRE_INSTALL_FILES = new MapConfigKey.Builder<String>(String.class, "files.preinstall")
.description("Mapping of files, to be copied before install, to destination name relative to installDir")
+ .parentInheritance(ConfigInheritance.NONE)
.typeInheritance(ConfigInheritance.DEEP_MERGE)
.build();
@@ -190,6 +191,7 @@ public interface SoftwareProcess extends Entity, Startable {
@SetFromFlag("preInstallTemplates")
MapConfigKey<String> PRE_INSTALL_TEMPLATES = new MapConfigKey.Builder<String>(String.class, "templates.preinstall")
.description("Mapping of templates, to be filled in and copied before pre-install, to destination name relative to installDir")
+ .parentInheritance(ConfigInheritance.NONE)
.typeInheritance(ConfigInheritance.DEEP_MERGE)
.build();
@@ -205,6 +207,7 @@ public interface SoftwareProcess extends Entity, Startable {
@SetFromFlag("installFiles")
MapConfigKey<String> INSTALL_FILES = new MapConfigKey.Builder<String>(String.class, "files.install")
.description("Mapping of files, to be copied before install, to destination name relative to installDir")
+ .parentInheritance(ConfigInheritance.NONE)
.typeInheritance(ConfigInheritance.DEEP_MERGE)
.build();
@@ -217,6 +220,7 @@ public interface SoftwareProcess extends Entity, Startable {
@SetFromFlag("installTemplates")
MapConfigKey<String> INSTALL_TEMPLATES = new MapConfigKey.Builder<String>(String.class, "templates.install")
.description("Mapping of templates, to be filled in and copied before install, to destination name relative to installDir")
+ .parentInheritance(ConfigInheritance.NONE)
.typeInheritance(ConfigInheritance.DEEP_MERGE)
.build();
@@ -232,6 +236,7 @@ public interface SoftwareProcess extends Entity, Startable {
@SetFromFlag("runtimeFiles")
MapConfigKey<String> RUNTIME_FILES = new MapConfigKey.Builder<String>(String.class, "files.runtime")
.description("Mapping of files, to be copied before customisation, to destination name relative to runDir")
+ .parentInheritance(ConfigInheritance.NONE)
.typeInheritance(ConfigInheritance.DEEP_MERGE)
.build();
@@ -244,6 +249,7 @@ public interface SoftwareProcess extends Entity, Startable {
@SetFromFlag("runtimeTemplates")
MapConfigKey<String> RUNTIME_TEMPLATES = new MapConfigKey.Builder<String>(String.class, "templates.runtime")
.description("Mapping of templates, to be filled in and copied before customisation, to destination name relative to runDir")
+ .parentInheritance(ConfigInheritance.NONE)
.typeInheritance(ConfigInheritance.DEEP_MERGE)
.build();
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4cc823c2/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcess.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcess.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcess.java
index 795d4dc..63ccfbe 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcess.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcess.java
@@ -21,19 +21,18 @@ package org.apache.brooklyn.entity.software.base;
import java.util.Collection;
import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableSet;
+
import org.apache.brooklyn.api.catalog.Catalog;
import org.apache.brooklyn.api.catalog.CatalogConfig;
import org.apache.brooklyn.api.entity.ImplementedBy;
import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.config.ConfigInheritance;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.util.core.internal.winrm.WinRmTool;
import org.apache.brooklyn.util.time.Duration;
-import com.google.common.collect.ImmutableSet;
-
@Catalog(name="Vanilla Windows Process", description="A basic Windows entity configured with scripts, e.g. for launch, check-running and stop")
@ImplementedBy(VanillaWindowsProcessImpl.class)
public interface VanillaWindowsProcess extends AbstractVanillaProcess {
@@ -41,59 +40,81 @@ public interface VanillaWindowsProcess extends AbstractVanillaProcess {
ConfigKey<Collection<Integer>> REQUIRED_OPEN_LOGIN_PORTS = ConfigKeys.newConfigKeyWithDefault(
SoftwareProcess.REQUIRED_OPEN_LOGIN_PORTS,
ImmutableSet.of(5986, 5985, 3389));
-
+
@CatalogConfig(label = "Install PowerShell command", priority=5.5)
- ConfigKey<String> INSTALL_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("install.powershell.command",
- "powershell command to run during the install phase");
-
+ ConfigKey<String> INSTALL_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "install.powershell.command")
+ .description("powershell command to run during the install phase")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+
@CatalogConfig(label = "Install Command", priority=5)
ConfigKey<String> INSTALL_COMMAND = VanillaSoftwareProcess.INSTALL_COMMAND;
@CatalogConfig(label = "Customize PowerShell command", priority=4.5)
- ConfigKey<String> CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("customize.powershell.command",
- "powershell command to run during the customization phase");
-
+ ConfigKey<String> CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "customize.powershell.command")
+ .description("powershell command to run during the customization phase")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+
@CatalogConfig(label = "Customize command", priority=4)
ConfigKey<String> CUSTOMIZE_COMMAND = VanillaSoftwareProcess.CUSTOMIZE_COMMAND;
-
+
@CatalogConfig(label = "Launch PowerShell command", priority=3.5)
- ConfigKey<String> LAUNCH_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("launch.powershell.command",
- "command to run to launch the process");
+ ConfigKey<String> LAUNCH_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "launch.powershell.command")
+ .description("command to run to launch the process")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
@CatalogConfig(label = "Launch Command", priority=3)
ConfigKey<String> LAUNCH_COMMAND = ConfigKeys.newConfigKeyWithDefault(VanillaSoftwareProcess.LAUNCH_COMMAND, null);
@CatalogConfig(label = "Check-running PowerShell Command", priority=2.5)
- ConfigKey<String> CHECK_RUNNING_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("checkRunning.powershell.command",
- "command to determine whether the process is running");
+ ConfigKey<String> CHECK_RUNNING_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "checkRunning.powershell.command")
+ .description("command to determine whether the process is running")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
@CatalogConfig(label = "Check-running Command", priority=2)
ConfigKey<String> CHECK_RUNNING_COMMAND = VanillaSoftwareProcess.CHECK_RUNNING_COMMAND;
@CatalogConfig(label = "Stop PowerShell Command", priority=1.5)
- ConfigKey<String> STOP_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("stop.powershell.command",
- "command to run to stop the process");
-
+ ConfigKey<String> STOP_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "stop.powershell.command")
+ .description("command to run to stop the process")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+
@CatalogConfig(label = "Stop Command", priority=1)
ConfigKey<String> STOP_COMMAND = VanillaSoftwareProcess.STOP_COMMAND;
- ConfigKey<String> PRE_INSTALL_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("pre.install.powershell.command",
- "powershell command to run during the pre-install phase");
-
- ConfigKey<String> POST_INSTALL_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("post.install.powershell.command",
- "powershell command to run during the post-install phase");
-
- ConfigKey<String> PRE_CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("pre.customize.powershell.command",
- "powershell command to run during the pre-customize phase");
-
- ConfigKey<String> POST_CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("post.customize.powershell.command",
- "powershell command to run during the post-customize phase");
-
- ConfigKey<String> PRE_LAUNCH_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("pre.launch.powershell.command",
- "powershell command to run during the pre-launch phase");
-
- ConfigKey<String> POST_LAUNCH_POWERSHELL_COMMAND = ConfigKeys.newStringConfigKey("post.launch.powershell.command",
- "powershell command to run during the post-launch phase");
+ ConfigKey<String> PRE_INSTALL_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "pre.install.powershell.command")
+ .description("powershell command to run during the pre-install phase")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+
+ ConfigKey<String> POST_INSTALL_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "post.install.powershell.command")
+ .description("powershell command to run during the post-install phase")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+
+ ConfigKey<String> PRE_CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "pre.customize.powershell.command")
+ .description("powershell command to run during the pre-customize phase")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+
+ ConfigKey<String> POST_CUSTOMIZE_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "post.customize.powershell.command")
+ .description("powershell command to run during the post-customize phase")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+
+ ConfigKey<String> PRE_LAUNCH_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "pre.launch.powershell.command")
+ .description("powershell command to run during the pre-launch phase")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
+
+ ConfigKey<String> POST_LAUNCH_POWERSHELL_COMMAND = ConfigKeys.builder(String.class, "post.launch.powershell.command")
+ .description("powershell command to run during the post-launch phase")
+ .parentInheritance(ConfigInheritance.NONE)
+ .build();
ConfigKey<Boolean> PRE_INSTALL_REBOOT_REQUIRED = ConfigKeys.newBooleanConfigKey("pre.install.reboot.required",
"indicates that a reboot should be performed after the pre-install command is run", false);
[3/3] brooklyn-server git commit: This closes #281
Posted by he...@apache.org.
This closes #281
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/b1cafd85
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/b1cafd85
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/b1cafd85
Branch: refs/heads/master
Commit: b1cafd85f0272b1f5624202993e84da93c83ad05
Parents: b70841f 6ff2aff
Author: Alex Heneveld <al...@Alexs-MacBook-Pro.local>
Authored: Mon Aug 29 21:28:12 2016 +0100
Committer: Alex Heneveld <al...@Alexs-MacBook-Pro.local>
Committed: Mon Aug 29 21:28:12 2016 +0100
----------------------------------------------------------------------
.../brooklyn/ConfigInheritanceYamlTest.java | 14 +--
.../core/entity/BrooklynConfigKeys.java | 36 +++++---
.../util/core/internal/ssh/ExecCmdAsserts.java | 27 +++++-
.../software/base/AbstractVanillaProcess.java | 29 ++++--
.../entity/software/base/SoftwareProcess.java | 6 ++
.../software/base/VanillaWindowsProcess.java | 93 ++++++++++++--------
.../base/VanillaSoftwareProcessTest.java | 67 ++++++++++----
7 files changed, 186 insertions(+), 86 deletions(-)
----------------------------------------------------------------------
[2/3] brooklyn-server git commit: Added tests for changed
SoftwareProcess config inheritance
Posted by he...@apache.org.
Added tests for changed SoftwareProcess config inheritance
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/6ff2aff5
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/6ff2aff5
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/6ff2aff5
Branch: refs/heads/master
Commit: 6ff2aff5f59f69919ac746e5908f66089d1839d6
Parents: 4cc823c
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Sun Aug 28 22:37:58 2016 +0100
Committer: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Committed: Sun Aug 28 22:37:58 2016 +0100
----------------------------------------------------------------------
.../brooklyn/ConfigInheritanceYamlTest.java | 14 +---
.../util/core/internal/ssh/ExecCmdAsserts.java | 27 +++++++-
.../base/VanillaSoftwareProcessTest.java | 67 +++++++++++++++-----
3 files changed, 76 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6ff2aff5/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigInheritanceYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigInheritanceYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigInheritanceYamlTest.java
index b44bf70..fd4472c 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigInheritanceYamlTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigInheritanceYamlTest.java
@@ -202,18 +202,6 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
" brooklyn.config:",
" shell.env:",
" ENV1: myEnv1",
- " templates.preinstall:",
- " "+emptyFile.toUri()+": myfile",
- " files.preinstall:",
- " "+emptyFile.toUri()+": myfile",
- " templates.install:",
- " "+emptyFile.toUri()+": myfile",
- " files.install:",
- " "+emptyFile.toUri()+": myfile",
- " templates.runtime:",
- " "+emptyFile.toUri()+": myfile",
- " files.runtime:",
- " "+emptyFile.toUri()+": myfile",
" provisioning.properties:",
" mykey: myval",
" templateOptions:",
@@ -227,7 +215,7 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
assertEmptySoftwareProcessConfig(
entity,
ImmutableMap.of("ENV1", "myEnv1"),
- ImmutableMap.of(emptyFile.toUri().toString(), "myfile"),
+ null,
ImmutableMap.of("mykey", "myval", "templateOptions", ImmutableMap.of("myOptionsKey", "myOptionsVal")));
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6ff2aff5/core/src/test/java/org/apache/brooklyn/util/core/internal/ssh/ExecCmdAsserts.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/util/core/internal/ssh/ExecCmdAsserts.java b/core/src/test/java/org/apache/brooklyn/util/core/internal/ssh/ExecCmdAsserts.java
index f5fcab5..8aab3b0 100644
--- a/core/src/test/java/org/apache/brooklyn/util/core/internal/ssh/ExecCmdAsserts.java
+++ b/core/src/test/java/org/apache/brooklyn/util/core/internal/ssh/ExecCmdAsserts.java
@@ -15,16 +15,17 @@
*/
package org.apache.brooklyn.util.core.internal.ssh;
+import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.util.List;
-import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool.ExecCmd;
-
import com.google.common.annotations.Beta;
import com.google.common.base.Predicate;
+import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool.ExecCmd;
+
@Beta
public class ExecCmdAsserts {
@@ -83,6 +84,28 @@ public class ExecCmdAsserts {
}
}
+ public static void assertExecHasNever(List<ExecCmd> actuals, String expectedCmd) {
+ assertExecHasExactly(actuals, expectedCmd, 0);
+ }
+
+ public static void assertExecHasOnlyOnce(List<ExecCmd> actuals, String expectedCmd) {
+ assertExecHasExactly(actuals, expectedCmd, 1);
+ }
+
+ public static void assertExecHasExactly(List<ExecCmd> actuals, String expectedCmd, int expectedCount) {
+ String errMsg = "actuals="+actuals+"; expected="+expectedCmd;
+ int count = 0;
+ for (ExecCmd actual : actuals) {
+ for (String subActual : actual.commands) {
+ if (subActual.matches(expectedCmd)) {
+ count++;
+ break;
+ }
+ }
+ }
+ assertEquals(count, expectedCount, errMsg);
+ }
+
public static ExecCmd findExecContaining(List<ExecCmd> actuals, String cmdRegex) {
for (ExecCmd actual : actuals) {
for (String subActual : actual.commands) {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/6ff2aff5/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessTest.java
index 45b7cc6..93934ed 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessTest.java
@@ -18,28 +18,37 @@
*/
package org.apache.brooklyn.entity.software.base;
+import static org.apache.brooklyn.util.core.internal.ssh.ExecCmdAsserts.assertExecContains;
+import static org.apache.brooklyn.util.core.internal.ssh.ExecCmdAsserts.assertExecHasNever;
+import static org.apache.brooklyn.util.core.internal.ssh.ExecCmdAsserts.assertExecHasOnlyOnce;
+import static org.apache.brooklyn.util.core.internal.ssh.ExecCmdAsserts.assertExecSatisfies;
+import static org.apache.brooklyn.util.core.internal.ssh.ExecCmdAsserts.assertExecsContain;
+import static org.apache.brooklyn.util.core.internal.ssh.ExecCmdAsserts.assertExecsNotContains;
+import static org.apache.brooklyn.util.core.internal.ssh.ExecCmdAsserts.assertExecsSatisfy;
+
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.api.location.Location;
import org.apache.brooklyn.api.location.LocationSpec;
import org.apache.brooklyn.api.location.MachineLocation;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
+import org.apache.brooklyn.entity.software.base.SoftwareProcess.ChildStartableMode;
import org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation;
import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.util.core.internal.ssh.ExecCmdAsserts;
import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool;
import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool.CustomResponse;
import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool.ExecCmdPredicates;
import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool.ExecParams;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
public class VanillaSoftwareProcessTest extends BrooklynAppUnitTestSupport {
@@ -80,7 +89,7 @@ public class VanillaSoftwareProcessTest extends BrooklynAppUnitTestSupport {
.configure(VanillaSoftwareProcess.STOP_COMMAND, "stopCommand"));
app.start(ImmutableList.of(loc));
- ExecCmdAsserts.assertExecsContain(RecordingSshTool.getExecCmds(), ImmutableList.of(
+ assertExecsContain(RecordingSshTool.getExecCmds(), ImmutableList.of(
"preInstallCommand", "installCommand", "postInstallCommand",
"preCustomizeCommand", "customizeCommand", "postCustomizeCommand",
"preLaunchCommand", "launchCommand", "postLaunchCommand",
@@ -88,7 +97,7 @@ public class VanillaSoftwareProcessTest extends BrooklynAppUnitTestSupport {
app.stop();
- ExecCmdAsserts.assertExecContains(RecordingSshTool.getLastExecCmd(), "stopCommand");
+ assertExecContains(RecordingSshTool.getLastExecCmd(), "stopCommand");
}
// See https://issues.apache.org/jira/browse/BROOKLYN-273
@@ -122,7 +131,7 @@ public class VanillaSoftwareProcessTest extends BrooklynAppUnitTestSupport {
VanillaSoftwareProcess.RestartSoftwareParameters.RESTART_MACHINE.getName(), VanillaSoftwareProcess.RestartSoftwareParameters.RestartMachineMode.FALSE))
.get();
- ExecCmdAsserts.assertExecsContain(RecordingSshTool.getExecCmds(), ImmutableList.of(
+ assertExecsContain(RecordingSshTool.getExecCmds(), ImmutableList.of(
"checkRunningCommand", "stopCommand",
"preLaunchCommand", "launchCommand", "postLaunchCommand",
"checkRunningCommand"));
@@ -146,12 +155,12 @@ public class VanillaSoftwareProcessTest extends BrooklynAppUnitTestSupport {
.configure(VanillaSoftwareProcess.STOP_COMMAND, "stopCommand"));
app.start(ImmutableList.of(loc));
- ExecCmdAsserts.assertExecsContain(RecordingSshTool.getExecCmds(), ImmutableList.of(
+ assertExecsContain(RecordingSshTool.getExecCmds(), ImmutableList.of(
"preCustomizeCommand", "customizeCommand", "postCustomizeCommand",
"preLaunchCommand", "launchCommand", "postLaunchCommand",
"checkRunningCommand"));
- ExecCmdAsserts.assertExecsNotContains(RecordingSshTool.getExecCmds(), ImmutableList.of(
+ assertExecsNotContains(RecordingSshTool.getExecCmds(), ImmutableList.of(
"preInstallCommand", "installCommand", "postInstallCommand"));
}
@@ -172,10 +181,10 @@ public class VanillaSoftwareProcessTest extends BrooklynAppUnitTestSupport {
.configure(VanillaSoftwareProcess.STOP_COMMAND, "stopCommand"));
app.start(ImmutableList.of(loc));
- ExecCmdAsserts.assertExecsContain(RecordingSshTool.getExecCmds(), ImmutableList.of(
+ assertExecsContain(RecordingSshTool.getExecCmds(), ImmutableList.of(
"checkRunningCommand"));
- ExecCmdAsserts.assertExecsNotContains(RecordingSshTool.getExecCmds(), ImmutableList.of(
+ assertExecsNotContains(RecordingSshTool.getExecCmds(), ImmutableList.of(
"launchCommand"));
}
@@ -214,7 +223,7 @@ public class VanillaSoftwareProcessTest extends BrooklynAppUnitTestSupport {
.configure(VanillaSoftwareProcess.STOP_COMMAND, "stopCommand"));
app.start(ImmutableList.of(loc));
- ExecCmdAsserts.assertExecsContain(RecordingSshTool.getExecCmds(), ImmutableList.of(
+ assertExecsContain(RecordingSshTool.getExecCmds(), ImmutableList.of(
"checkRunningCommand",
"preInstallCommand", "installCommand", "postInstallCommand",
"preCustomizeCommand", "customizeCommand", "postCustomizeCommand",
@@ -241,7 +250,7 @@ public class VanillaSoftwareProcessTest extends BrooklynAppUnitTestSupport {
Map<String, String> expectedEnv = ImmutableMap.of("KEY1", "VAL1");
- ExecCmdAsserts.assertExecsSatisfy(RecordingSshTool.getExecCmds(), ImmutableList.of(
+ assertExecsSatisfy(RecordingSshTool.getExecCmds(), ImmutableList.of(
Predicates.and(ExecCmdPredicates.containsCmd("preInstallCommand"), ExecCmdPredicates.containsEnv(expectedEnv)),
Predicates.and(ExecCmdPredicates.containsCmd("installCommand"), ExecCmdPredicates.containsEnv(expectedEnv)),
Predicates.and(ExecCmdPredicates.containsCmd("postInstallCommand"), ExecCmdPredicates.containsEnv(expectedEnv)),
@@ -255,8 +264,32 @@ public class VanillaSoftwareProcessTest extends BrooklynAppUnitTestSupport {
app.stop();
- ExecCmdAsserts.assertExecSatisfies(
+ assertExecSatisfies(
RecordingSshTool.getLastExecCmd(),
Predicates.and(ExecCmdPredicates.containsCmd("stopCommand"), ExecCmdPredicates.containsEnv(expectedEnv)));
}
+
+ @Test
+ public void testCmdNotInheritedByChildrenOfSoftwareProcess() throws Exception {
+ app.createAndManageChild(EntitySpec.create(VanillaSoftwareProcess.class)
+ .configure(VanillaSoftwareProcess.PRE_INSTALL_COMMAND, "preInstallCommand")
+ .configure(VanillaSoftwareProcess.LAUNCH_COMMAND, "parentLaunchCommand")
+ .configure(VanillaSoftwareProcess.CHILDREN_STARTABLE_MODE, ChildStartableMode.FOREGROUND)
+ .child(EntitySpec.create(VanillaSoftwareProcess.class)
+ .configure(VanillaSoftwareProcess.LAUNCH_COMMAND, "childLaunchCommand")));
+ app.start(ImmutableList.of(loc));
+
+ assertExecHasOnlyOnce(RecordingSshTool.getExecCmds(), "childLaunchCommand");
+ assertExecHasOnlyOnce(RecordingSshTool.getExecCmds(), "preInstallCommand");
+ }
+
+ @Test
+ public void testCmdNotInheritedFromParentOfSoftwareProcess() throws Exception {
+ app.config().set(VanillaSoftwareProcess.PRE_INSTALL_COMMAND, "preInstallCommand");
+ app.createAndManageChild(EntitySpec.create(VanillaSoftwareProcess.class)
+ .configure(VanillaSoftwareProcess.LAUNCH_COMMAND, "launchCommand"));
+ app.start(ImmutableList.of(loc));
+
+ assertExecHasNever(RecordingSshTool.getExecCmds(), "preInstallCommand");
+ }
}