You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2014/12/22 15:07:40 UTC
[1/7] incubator-brooklyn git commit: Support logging VM credentials
Repository: incubator-brooklyn
Updated Branches:
refs/heads/master fda04de83 -> 1d32eb284
Support logging VM credentials
- In JcloudsLocation, if config says so then log the password/privateKey
- Useful for when debugging failing to ssh (e.g. in vcloud-director!),
but config should never be used in production!
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/970826d9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/970826d9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/970826d9
Branch: refs/heads/master
Commit: 970826d97fcab4f88f27aef8e3980611c63b9343
Parents: 3cb52e5
Author: Aled Sage <al...@gmail.com>
Authored: Tue Dec 16 21:04:00 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Dec 16 21:04:00 2014 +0000
----------------------------------------------------------------------
.../location/cloud/CloudLocationConfig.java | 5 +++
.../location/jclouds/JcloudsLocation.java | 38 +++++++++++++++-----
2 files changed, 34 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/970826d9/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java b/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java
index a7bd5ac..4d868ae 100644
--- a/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java
+++ b/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java
@@ -63,6 +63,11 @@ public interface CloudLocationConfig {
"Whether and how long to wait for a newly provisioned VM to be accessible via ssh; " +
"if 'false', won't check; if 'true' uses default duration; otherwise accepts a time string e.g. '5m' (the default) or a number of milliseconds", "5m");
+ public static final ConfigKey<Boolean> LOG_CREDENTIALS = ConfigKeys.newBooleanConfigKey(
+ "logCredentials",
+ "Whether to log credentials of a new VM - strongly recommended never be used in production, as it is a big security hole!",
+ false);
+
public static final ConfigKey<Object> CALLER_CONTEXT = LocationConfigKeys.CALLER_CONTEXT;
public static final ConfigKey<Boolean> DESTROY_ON_FAILURE = ConfigKeys.newBooleanConfigKey("destroyOnFailure", "Whether to destroy the VM if provisioningLocation.obtain() fails", true);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/970826d9/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
index 7c74ed5..a5f32a0 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
@@ -765,11 +765,16 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im
customizedTimestamp = Duration.of(provisioningStopwatch);
LOG.info("Finished VM "+setup.getDescription()+" creation:"
- + " "+sshMachineLocation.getUser()+"@"+sshMachineLocation.getAddress() + " ready after "+Duration.of(provisioningStopwatch).toStringRounded()
- + " ("+template+" template built in "+Duration.of(templateTimestamp).toStringRounded()+";"
- + " "+node+" provisioned in "+Duration.of(provisionTimestamp).subtract(templateTimestamp).toStringRounded()+";"
- + " "+sshMachineLocation+" ssh usable in "+Duration.of(usableTimestamp).subtract(provisionTimestamp).toStringRounded()+";"
- + " and os customized in "+Duration.of(customizedTimestamp).subtract(usableTimestamp).toStringRounded()+" - "+Joiner.on(", ").join(customisationForLogging)+")");
+ + " "+sshMachineLocation.getUser()+"@"+sshMachineLocation.getAddress()+":"+sshMachineLocation.getPort()
+ + (Boolean.TRUE.equals(setup.get(LOG_CREDENTIALS))
+ ? "password=" + (initialCredentials.getOptionalPassword().isPresent() ? initialCredentials.getOptionalPassword() : "<absent>")
+ + " && key=" + (initialCredentials.getOptionalPrivateKey().isPresent() ? initialCredentials.getOptionalPrivateKey() : "<absent>")
+ : "")
+ + " ready after "+Duration.of(provisioningStopwatch).toStringRounded()
+ + " ("+template+" template built in "+Duration.of(templateTimestamp).toStringRounded()+";"
+ + " "+node+" provisioned in "+Duration.of(provisionTimestamp).subtract(templateTimestamp).toStringRounded()+";"
+ + " "+sshMachineLocation+" ssh usable in "+Duration.of(usableTimestamp).subtract(provisionTimestamp).toStringRounded()+";"
+ + " and os customized in "+Duration.of(customizedTimestamp).subtract(usableTimestamp).toStringRounded()+" - "+Joiner.on(", ").join(customisationForLogging)+")");
return sshMachineLocation;
} catch (Exception e) {
@@ -1759,10 +1764,25 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im
delayMs = Time.parseTimeString(WAIT_FOR_SSHABLE.getDefaultValue());
String user = expectedCredentials.getUser();
- LOG.debug("VM {}: reported online, now waiting {} for it to be sshable on {}@{}:{}{}", new Object[] {
- setup.getDescription(), Time.makeTimeStringRounded(delayMs),
- user, vmIp, vmPort,
- Objects.equal(user, getUser(setup)) ? "" : " (setup user is different: "+getUser(setup)+")"});
+ if (LOG.isDebugEnabled()) {
+ Optional<String> password;
+ Optional<String> key;
+ if (Boolean.TRUE.equals(setup.get(LOG_CREDENTIALS))) {
+ password = expectedCredentials.getOptionalPassword();
+ key = expectedCredentials.getOptionalPrivateKey();
+ } else {
+ password = expectedCredentials.getOptionalPassword().isPresent() ? Optional.of("******") : Optional.<String>absent();
+ key = expectedCredentials.getOptionalPrivateKey().isPresent() ? Optional.of("******") : Optional.<String>absent();
+ }
+ LOG.debug("VM {}: reported online, now waiting {} for it to be sshable on {}@{}:{}{}; using credentials password={}; key={}",
+ new Object[] {
+ setup.getDescription(), Time.makeTimeStringRounded(delayMs),
+ user, vmIp, vmPort,
+ Objects.equal(user, getUser(setup)) ? "" : " (setup user is different: "+getUser(setup)+")",
+ (password.isPresent() ? password.get() : "<absent>"),
+ (key.isPresent() ? key.get() : "<absent>"),
+ });
+ }
Callable<Boolean> checker;
if (hostAndPortOverride.isPresent()) {
[7/7] incubator-brooklyn git commit: This closes #402
Posted by al...@apache.org.
This closes #402
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/1d32eb28
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/1d32eb28
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/1d32eb28
Branch: refs/heads/master
Commit: 1d32eb28464a9d2971b6b7106f636eb095ffd8ad
Parents: fda04de 4cd3d96
Author: Aled Sage <al...@gmail.com>
Authored: Mon Dec 22 14:07:10 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Dec 22 14:07:10 2014 +0000
----------------------------------------------------------------------
.../location/cloud/CloudLocationConfig.java | 5 ++
.../location/jclouds/JcloudsLocation.java | 38 ++++++--
...ctSoftwareProcessRestartIntegrationTest.java | 93 ++++++++++++++++++++
.../database/postgresql/PostgreSqlNodeImpl.java | 30 +------
.../mysql/MySqlRestartIntegrationTest.java | 60 ++-----------
.../PostgreSqlRebindIntegrationTest.java | 58 ++++++++++++
.../PostgreSqlRestartIntegrationTest.java | 50 +++++++++++
.../mongodb/MongoDBRestartIntegrationTest.java | 42 +++++++++
.../TomcatServerRestartIntegrationTest.java | 58 ++----------
.../camp/brooklyn/YamlLauncherAbstract.java | 12 ++-
10 files changed, 304 insertions(+), 142 deletions(-)
----------------------------------------------------------------------
[4/7] incubator-brooklyn git commit: Add tests for Postgres
restart/rebind
Posted by al...@apache.org.
Add tests for Postgres restart/rebind
- And changes Postgres connectSensors() to use
connectServiceUpIsRunning(), given that was all
the feed was doing anyway.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/ccea3ecd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/ccea3ecd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/ccea3ecd
Branch: refs/heads/master
Commit: ccea3ecd889707c5bb4dab24b1ee9fd277d42ef4
Parents: 99a2d2a
Author: Aled Sage <al...@gmail.com>
Authored: Tue Dec 16 21:05:48 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Dec 16 22:52:27 2014 +0000
----------------------------------------------------------------------
.../database/postgresql/PostgreSqlNodeImpl.java | 30 +------
.../PostgreSqlRebindIntegrationTest.java | 59 +++++++++++++
.../PostgreSqlRestartIntegrationTest.java | 91 ++++++++++++++++++++
3 files changed, 152 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ccea3ecd/software/database/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlNodeImpl.java
----------------------------------------------------------------------
diff --git a/software/database/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlNodeImpl.java b/software/database/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlNodeImpl.java
index 8b0f636..71f63d9 100644
--- a/software/database/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlNodeImpl.java
+++ b/software/database/src/main/java/brooklyn/entity/database/postgresql/PostgreSqlNodeImpl.java
@@ -23,20 +23,12 @@ import org.slf4j.LoggerFactory;
import brooklyn.entity.basic.SoftwareProcessImpl;
import brooklyn.entity.effector.EffectorBody;
-import brooklyn.event.feed.ssh.SshFeed;
-import brooklyn.event.feed.ssh.SshPollConfig;
-import brooklyn.location.basic.Locations;
-import brooklyn.location.basic.SshMachineLocation;
import brooklyn.util.config.ConfigBag;
-import brooklyn.util.guava.Maybe;
-import brooklyn.util.time.Duration;
public class PostgreSqlNodeImpl extends SoftwareProcessImpl implements PostgreSqlNode {
private static final Logger LOG = LoggerFactory.getLogger(PostgreSqlNodeImpl.class);
- private SshFeed feed;
-
public Class<?> getDriverInterface() {
return PostgreSqlDriver.class;
}
@@ -68,31 +60,13 @@ public class PostgreSqlNodeImpl extends SoftwareProcessImpl implements PostgreSq
@Override
protected void connectSensors() {
super.connectSensors();
+ connectServiceUpIsRunning();
setAttribute(DATASTORE_URL, String.format("postgresql://%s:%s/", getAttribute(HOSTNAME), getAttribute(POSTGRESQL_PORT)));
-
- Maybe<SshMachineLocation> machine = Locations.findUniqueSshMachineLocation(getLocations());
-
- if (machine.isPresent()) {
- String cmd = getDriver().getStatusCmd();
-
- feed = SshFeed.builder()
- .entity(this)
- .machine(machine.get())
- .period(Duration.millis(getConfig(POLL_PERIOD)))
- .poll(new SshPollConfig<Boolean>(SERVICE_UP)
- .command(cmd)
- .setOnSuccess(true)
- .setOnFailureOrException(false))
- .build();
- } else {
- LOG.warn("Location set {} does not an ssh-machine location, so not polling for status; setting serviceUp immediately", getLocations());
- setAttribute(SERVICE_UP, true);
- }
}
@Override
protected void disconnectSensors() {
- if (feed != null) feed.stop();
+ disconnectServiceUpIsRunning();
super.disconnectSensors();
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ccea3ecd/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java
new file mode 100644
index 0000000..bff1cd2
--- /dev/null
+++ b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package brooklyn.entity.database.postgresql;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.rebind.RebindTestFixtureWithApp;
+import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import brooklyn.test.EntityTestUtils;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+
+public class PostgreSqlRebindIntegrationTest extends RebindTestFixtureWithApp {
+
+ private LocalhostMachineProvisioningLocation loc;
+
+ @BeforeMethod(alwaysRun=true)
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ loc = origApp.newLocalhostProvisioningLocation();
+ }
+
+ @Test(groups = {"Integration"})
+ public void testRebind() throws Exception {
+ origApp.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
+ .configure("mongodbConfTemplateUrl", "classpath:///test-mongodb.conf"));
+ origApp.start(ImmutableList.of(loc));
+
+ // rebind
+ rebind();
+ final PostgreSqlNode newEntity = (PostgreSqlNode) Iterables.find(newApp.getChildren(), Predicates.instanceOf(PostgreSqlNode.class));
+
+ // confirm effectors still work on entity
+ EntityTestUtils.assertAttributeEqualsEventually(newEntity, PostgreSqlNode.SERVICE_UP, true);
+ newEntity.stop();
+ EntityTestUtils.assertAttributeEqualsEventually(newEntity, PostgreSqlNode.SERVICE_UP, false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ccea3ecd/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java
new file mode 100644
index 0000000..ea15b79
--- /dev/null
+++ b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package brooklyn.entity.database.postgresql;
+
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.BrooklynAppLiveTestSupport;
+import brooklyn.entity.Effector;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.Lifecycle;
+import brooklyn.entity.basic.ServiceStateLogic;
+import brooklyn.entity.basic.SoftwareProcess.RestartSoftwareParameters;
+import brooklyn.entity.basic.SoftwareProcess.StopSoftwareParameters;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import brooklyn.test.EntityTestUtils;
+import brooklyn.util.collections.CollectionFunctionals;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests restart of the software *process* (as opposed to the VM).
+ */
+public class PostgreSqlRestartIntegrationTest extends BrooklynAppLiveTestSupport {
+
+ // TODO Remove duplication from TomcatServerRestartIntegrationTest, MySqlRestartIntegrationTest
+
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory.getLogger(PostgreSqlRestartIntegrationTest.class);
+
+ @Test(groups="Integration")
+ public void testStopProcessAndRestart() throws Exception {
+ runStopProcessAndRestart(
+ PostgreSqlNode.RESTART,
+ ImmutableMap.of(RestartSoftwareParameters.RESTART_MACHINE.getName(), RestartSoftwareParameters.RestartMachineMode.FALSE));
+ }
+
+ // TODO The second start() will fail because customize operations forbidden while there is existing data:
+ // "If you want to create a new database system, either remove or empty".
+ // I haven't checked whether it damaged the data in the database though!
+ @Test(enabled=false, groups={"Integration", "WIP"})
+ public void testStopProcessAndStart() throws Exception {
+ runStopProcessAndRestart(
+ PostgreSqlNode.START,
+ ImmutableMap.of("locations", ImmutableList.of()));
+ }
+
+ protected void runStopProcessAndRestart(Effector<?> restartEffector, Map<String, ?> args) throws Exception {
+ LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
+ PostgreSqlNode entity = app.createAndManageChild(EntitySpec.create(PostgreSqlNode.class));
+ app.start(ImmutableList.of(loc));
+
+ Entities.invokeEffector(app, entity, PostgreSqlNode.STOP, ImmutableMap.of(
+ StopSoftwareParameters.STOP_MACHINE.getName(), false))
+ .get();
+ EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_UP, false);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_PROCESS_IS_RUNNING, false);
+ EntityTestUtils.assertAttributeEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, CollectionFunctionals.<String>mapSizeEquals(1));
+
+ Entities.invokeEffector(app, entity, restartEffector, args).get();
+ EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_UP, true);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_PROCESS_IS_RUNNING, true);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, ImmutableMap.<String, Object>of());
+
+ EntityTestUtils.assertAttributeEqualsEventually(app, PostgreSqlNode.SERVICE_UP, true);
+ EntityTestUtils.assertAttributeEqualsEventually(app, PostgreSqlNode.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ }
+}
[5/7] incubator-brooklyn git commit: Add MongoDBRestartIntegrationTest
Posted by al...@apache.org.
Add MongoDBRestartIntegrationTest
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/ba5edf98
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/ba5edf98
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/ba5edf98
Branch: refs/heads/master
Commit: ba5edf9893dc052aa28d34d54c9d1ebc2f3b9222
Parents: ccea3ec
Author: Aled Sage <al...@gmail.com>
Authored: Tue Dec 16 21:06:02 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Dec 16 22:53:15 2014 +0000
----------------------------------------------------------------------
.../mongodb/MongoDBRestartIntegrationTest.java | 88 ++++++++++++++++++++
1 file changed, 88 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba5edf98/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
new file mode 100644
index 0000000..c7376fe
--- /dev/null
+++ b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package brooklyn.entity.nosql.mongodb;
+
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.BrooklynAppLiveTestSupport;
+import brooklyn.entity.Effector;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.Lifecycle;
+import brooklyn.entity.basic.ServiceStateLogic;
+import brooklyn.entity.basic.SoftwareProcess.RestartSoftwareParameters;
+import brooklyn.entity.basic.SoftwareProcess.StopSoftwareParameters;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import brooklyn.test.EntityTestUtils;
+import brooklyn.util.collections.CollectionFunctionals;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests restart of the software *process* (as opposed to the VM).
+ */
+public class MongoDBRestartIntegrationTest extends BrooklynAppLiveTestSupport {
+
+ // TODO Remove duplication from TomcatServerRestartIntegrationTest and MySqlRestartIntegrationTest
+
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory.getLogger(MongoDBRestartIntegrationTest.class);
+
+ @Test(groups="Integration")
+ public void testStopProcessAndRestart() throws Exception {
+ runStopProcessAndRestart(
+ MongoDBServer.RESTART,
+ ImmutableMap.of(RestartSoftwareParameters.RESTART_MACHINE.getName(), RestartSoftwareParameters.RestartMachineMode.FALSE));
+ }
+
+ @Test(groups="Integration")
+ public void testStopProcessAndStart() throws Exception {
+ runStopProcessAndRestart(
+ MongoDBServer.START,
+ ImmutableMap.of("locations", ImmutableList.of()));
+ }
+
+ protected void runStopProcessAndRestart(Effector<?> restartEffector, Map<String, ?> args) throws Exception {
+ LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
+ MongoDBServer entity = app.createAndManageChild(EntitySpec.create(MongoDBServer.class));
+ app.start(ImmutableList.of(loc));
+
+ Entities.invokeEffector(app, entity, MongoDBServer.STOP, ImmutableMap.of(
+ StopSoftwareParameters.STOP_MACHINE.getName(), false))
+ .get();
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_UP, false);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_PROCESS_IS_RUNNING, false);
+ EntityTestUtils.assertAttributeEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, CollectionFunctionals.<String>mapSizeEquals(1));
+
+ Entities.invokeEffector(app, entity, restartEffector, args).get();
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_UP, true);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_PROCESS_IS_RUNNING, true);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, ImmutableMap.<String, Object>of());
+
+ EntityTestUtils.assertAttributeEqualsEventually(app, MongoDBServer.SERVICE_UP, true);
+ EntityTestUtils.assertAttributeEqualsEventually(app, MongoDBServer.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ }
+}
[2/7] incubator-brooklyn git commit: RebindOptions (in tests): make
public
Posted by al...@apache.org.
RebindOptions (in tests): make public
- Let RebindOptions be used in downstream projects
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/43ace55d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/43ace55d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/43ace55d
Branch: refs/heads/master
Commit: 43ace55d9d1682d32a855b44e0e63ca4b41a2f5e
Parents: 970826d
Author: Aled Sage <al...@gmail.com>
Authored: Tue Dec 16 21:04:42 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Dec 16 21:04:42 2014 +0000
----------------------------------------------------------------------
.../brooklyn/entity/rebind/RebindOptions.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/43ace55d/core/src/test/java/brooklyn/entity/rebind/RebindOptions.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindOptions.java b/core/src/test/java/brooklyn/entity/rebind/RebindOptions.java
index 63bd1cc..f89863b 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindOptions.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindOptions.java
@@ -27,15 +27,15 @@ import brooklyn.management.ManagementContext;
* See {@link RebindTestFixture#rebind(RebindOptions)} and {@link RebindTestUtils#rebind(RebindOptions}}.
*/
public class RebindOptions {
- boolean checkSerializable;
- boolean terminateOrigManagementContext;
- RebindExceptionHandler exceptionHandler;
- ManagementContext origManagementContext;
- ManagementContext newManagementContext;
- File mementoDir;
- File mementoDirBackup;
- ClassLoader classLoader;
- PersistenceObjectStore objectStore;
+ public boolean checkSerializable;
+ public boolean terminateOrigManagementContext;
+ public RebindExceptionHandler exceptionHandler;
+ public ManagementContext origManagementContext;
+ public ManagementContext newManagementContext;
+ public File mementoDir;
+ public File mementoDirBackup;
+ public ClassLoader classLoader;
+ public PersistenceObjectStore objectStore;
public static RebindOptions create() {
return new RebindOptions();
[3/7] incubator-brooklyn git commit: Adds
YamlLauncher.launchAppYaml(Reader) for tests
Posted by al...@apache.org.
Adds YamlLauncher.launchAppYaml(Reader) for tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/99a2d2a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/99a2d2a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/99a2d2a6
Branch: refs/heads/master
Commit: 99a2d2a6b35199e6a2887af2bb01958a50be9e80
Parents: 43ace55
Author: Aled Sage <al...@gmail.com>
Authored: Tue Dec 16 21:05:09 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Dec 16 21:05:09 2014 +0000
----------------------------------------------------------------------
.../io/brooklyn/camp/brooklyn/YamlLauncherAbstract.java | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/99a2d2a6/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherAbstract.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherAbstract.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherAbstract.java
index d71e153..27f0ffb 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherAbstract.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/YamlLauncherAbstract.java
@@ -76,6 +76,16 @@ public abstract class YamlLauncherAbstract {
public Application launchAppYaml(String url) {
try {
Reader input = Streams.reader(new ResourceUtils(this).getResourceFromUrl(url));
+ Application app = launchAppYaml(input);
+ log.info("Application started from YAML file "+url+": "+app);
+ return app;
+ } catch (Exception e) {
+ throw Exceptions.propagate(e);
+ }
+ }
+
+ public Application launchAppYaml(Reader input) {
+ try {
AssemblyTemplate at = platform.pdp().registerDeploymentPlan(input);
Assembly assembly = at.getInstantiator().newInstance().instantiate(at, platform);
@@ -88,7 +98,7 @@ public abstract class YamlLauncherAbstract {
log.info("Waiting on "+tasks.size()+" task(s)");
for (Task<?> t: tasks) t.blockUntilEnded();
- log.info("Application started from YAML file "+url+": "+app);
+ log.info("Application started from YAML: "+app);
Entities.dumpInfo(app);
return (Application)app;
} catch (Exception e) {
[6/7] incubator-brooklyn git commit: restart/rebind tests:
incorporate review comments
Posted by al...@apache.org.
restart/rebind tests: incorporate review comments
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/4cd3d96e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/4cd3d96e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/4cd3d96e
Branch: refs/heads/master
Commit: 4cd3d96ee58441e236fef5de86bbac2f8d5a7ba2
Parents: ba5edf9
Author: Aled Sage <al...@gmail.com>
Authored: Fri Dec 19 23:03:03 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Dec 20 22:13:51 2014 +0000
----------------------------------------------------------------------
...ctSoftwareProcessRestartIntegrationTest.java | 93 ++++++++++++++++++++
.../mysql/MySqlRestartIntegrationTest.java | 60 ++-----------
.../PostgreSqlRebindIntegrationTest.java | 3 +-
.../PostgreSqlRestartIntegrationTest.java | 57 ++----------
.../mongodb/MongoDBRestartIntegrationTest.java | 60 ++-----------
.../TomcatServerRestartIntegrationTest.java | 58 ++----------
6 files changed, 123 insertions(+), 208 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cd3d96e/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java b/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java
new file mode 100644
index 0000000..c2c7291
--- /dev/null
+++ b/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package brooklyn.entity.basic;
+
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.BrooklynAppLiveTestSupport;
+import brooklyn.entity.Effector;
+import brooklyn.entity.basic.SoftwareProcess.RestartSoftwareParameters;
+import brooklyn.entity.basic.SoftwareProcess.StopSoftwareParameters;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import brooklyn.test.EntityTestUtils;
+import brooklyn.util.collections.CollectionFunctionals;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests restart of the software *process* (as opposed to the VM).
+ */
+public abstract class AbstractSoftwareProcessRestartIntegrationTest extends BrooklynAppLiveTestSupport {
+
+ // TODO Remove duplication from TomcatServerRestartIntegrationTest and MySqlRestartIntegrationTest
+
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractSoftwareProcessRestartIntegrationTest.class);
+
+ protected abstract EntitySpec<? extends SoftwareProcess> newEntitySpec();
+
+ @Test(groups="Integration")
+ public void testStopProcessAndRestart() throws Exception {
+ runStopProcessAndRestart(
+ SoftwareProcess.RESTART,
+ ImmutableMap.of(RestartSoftwareParameters.RESTART_MACHINE.getName(), RestartSoftwareParameters.RestartMachineMode.FALSE));
+ }
+
+ @Test(groups="Integration")
+ public void testStopProcessAndStart() throws Exception {
+ runStopProcessAndRestart(
+ SoftwareProcess.START,
+ ImmutableMap.of("locations", ImmutableList.of()));
+ }
+
+ protected void runStopProcessAndRestart(Effector<?> restartEffector, Map<String, ?> args) throws Exception {
+ LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
+ SoftwareProcess entity = app.createAndManageChild(newEntitySpec());
+
+ // Start the app
+ app.start(ImmutableList.of(loc));
+ EntityTestUtils.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_UP, true);
+ EntityTestUtils.assertAttributeEqualsEventually(app, SoftwareProcess.SERVICE_UP, true);
+
+ // Stop the process
+ Entities.invokeEffector(app, entity, SoftwareProcess.STOP, ImmutableMap.of(
+ StopSoftwareParameters.STOP_MACHINE.getName(), false))
+ .get();
+ EntityTestUtils.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_UP, false);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_PROCESS_IS_RUNNING, false);
+ EntityTestUtils.assertAttributeEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, CollectionFunctionals.<String>mapSizeEquals(1));
+
+ // Restart the process
+ Entities.invokeEffector(app, entity, restartEffector, args).get();
+ EntityTestUtils.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_UP, true);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_PROCESS_IS_RUNNING, true);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, ImmutableMap.<String, Object>of());
+
+ EntityTestUtils.assertAttributeEqualsEventually(app, SoftwareProcess.SERVICE_UP, true);
+ EntityTestUtils.assertAttributeEqualsEventually(app, SoftwareProcess.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cd3d96e/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlRestartIntegrationTest.java b/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlRestartIntegrationTest.java
index d850dca..50100cf 100644
--- a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlRestartIntegrationTest.java
+++ b/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlRestartIntegrationTest.java
@@ -18,71 +18,25 @@
*/
package brooklyn.entity.database.mysql;
-import java.util.Map;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
-import brooklyn.entity.BrooklynAppLiveTestSupport;
-import brooklyn.entity.Effector;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.Lifecycle;
-import brooklyn.entity.basic.ServiceStateLogic;
-import brooklyn.entity.basic.SoftwareProcess.RestartSoftwareParameters;
-import brooklyn.entity.basic.SoftwareProcess.StopSoftwareParameters;
+import brooklyn.entity.basic.AbstractSoftwareProcessRestartIntegrationTest;
+import brooklyn.entity.basic.SoftwareProcess;
import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.EntityTestUtils;
-import brooklyn.util.collections.CollectionFunctionals;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
/**
* Tests restart of the software *process* (as opposed to the VM).
*/
-public class MySqlRestartIntegrationTest extends BrooklynAppLiveTestSupport {
-
- // TODO Remove duplication from TomcatServerRestartIntegrationTest
+@Test(groups="Integration")
+public class MySqlRestartIntegrationTest extends AbstractSoftwareProcessRestartIntegrationTest {
@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(MySqlRestartIntegrationTest.class);
- @Test(groups="Integration")
- public void testStopProcessAndRestart() throws Exception {
- runStopProcessAndRestart(
- MySqlNode.RESTART,
- ImmutableMap.of(RestartSoftwareParameters.RESTART_MACHINE.getName(), RestartSoftwareParameters.RestartMachineMode.FALSE));
- }
-
- @Test(groups="Integration")
- public void testStopProcessAndStart() throws Exception {
- runStopProcessAndRestart(
- MySqlNode.START,
- ImmutableMap.of("locations", ImmutableList.of()));
- }
-
- protected void runStopProcessAndRestart(Effector<?> restartEffector, Map<String, ?> args) throws Exception {
- LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
- MySqlNode entity = app.createAndManageChild(EntitySpec.create(MySqlNode.class));
- app.start(ImmutableList.of(loc));
-
- Entities.invokeEffector(app, entity, MySqlNode.STOP, ImmutableMap.of(
- StopSoftwareParameters.STOP_MACHINE.getName(), false))
- .get();
- EntityTestUtils.assertAttributeEqualsEventually(entity, MySqlNode.SERVICE_UP, false);
- EntityTestUtils.assertAttributeEqualsEventually(entity, MySqlNode.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
- EntityTestUtils.assertAttributeEqualsEventually(entity, MySqlNode.SERVICE_PROCESS_IS_RUNNING, false);
- EntityTestUtils.assertAttributeEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, CollectionFunctionals.<String>mapSizeEquals(1));
-
- Entities.invokeEffector(app, entity, restartEffector, args).get();
- EntityTestUtils.assertAttributeEqualsEventually(entity, MySqlNode.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(entity, MySqlNode.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
- EntityTestUtils.assertAttributeEqualsEventually(entity, MySqlNode.SERVICE_PROCESS_IS_RUNNING, true);
- EntityTestUtils.assertAttributeEqualsEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, ImmutableMap.<String, Object>of());
-
- EntityTestUtils.assertAttributeEqualsEventually(app, MySqlNode.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(app, MySqlNode.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ @Override
+ protected EntitySpec<? extends SoftwareProcess> newEntitySpec() {
+ return EntitySpec.create(MySqlNode.class);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cd3d96e/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java
index bff1cd2..b58e685 100644
--- a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java
+++ b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java
@@ -43,8 +43,7 @@ public class PostgreSqlRebindIntegrationTest extends RebindTestFixtureWithApp {
@Test(groups = {"Integration"})
public void testRebind() throws Exception {
- origApp.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure("mongodbConfTemplateUrl", "classpath:///test-mongodb.conf"));
+ origApp.createAndManageChild(EntitySpec.create(PostgreSqlNode.class));
origApp.start(ImmutableList.of(loc));
// rebind
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cd3d96e/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java
index ea15b79..d26c7f4 100644
--- a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java
+++ b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java
@@ -18,42 +18,26 @@
*/
package brooklyn.entity.database.postgresql;
-import java.util.Map;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
-import brooklyn.entity.BrooklynAppLiveTestSupport;
-import brooklyn.entity.Effector;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.Lifecycle;
-import brooklyn.entity.basic.ServiceStateLogic;
-import brooklyn.entity.basic.SoftwareProcess.RestartSoftwareParameters;
-import brooklyn.entity.basic.SoftwareProcess.StopSoftwareParameters;
+import brooklyn.entity.basic.AbstractSoftwareProcessRestartIntegrationTest;
+import brooklyn.entity.basic.SoftwareProcess;
import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.EntityTestUtils;
-import brooklyn.util.collections.CollectionFunctionals;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
/**
* Tests restart of the software *process* (as opposed to the VM).
*/
-public class PostgreSqlRestartIntegrationTest extends BrooklynAppLiveTestSupport {
-
- // TODO Remove duplication from TomcatServerRestartIntegrationTest, MySqlRestartIntegrationTest
+@Test(groups="Integration")
+public class PostgreSqlRestartIntegrationTest extends AbstractSoftwareProcessRestartIntegrationTest {
@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(PostgreSqlRestartIntegrationTest.class);
- @Test(groups="Integration")
- public void testStopProcessAndRestart() throws Exception {
- runStopProcessAndRestart(
- PostgreSqlNode.RESTART,
- ImmutableMap.of(RestartSoftwareParameters.RESTART_MACHINE.getName(), RestartSoftwareParameters.RestartMachineMode.FALSE));
+ @Override
+ protected EntitySpec<? extends SoftwareProcess> newEntitySpec() {
+ return EntitySpec.create(PostgreSqlNode.class);
}
// TODO The second start() will fail because customize operations forbidden while there is existing data:
@@ -61,31 +45,6 @@ public class PostgreSqlRestartIntegrationTest extends BrooklynAppLiveTestSupport
// I haven't checked whether it damaged the data in the database though!
@Test(enabled=false, groups={"Integration", "WIP"})
public void testStopProcessAndStart() throws Exception {
- runStopProcessAndRestart(
- PostgreSqlNode.START,
- ImmutableMap.of("locations", ImmutableList.of()));
- }
-
- protected void runStopProcessAndRestart(Effector<?> restartEffector, Map<String, ?> args) throws Exception {
- LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
- PostgreSqlNode entity = app.createAndManageChild(EntitySpec.create(PostgreSqlNode.class));
- app.start(ImmutableList.of(loc));
-
- Entities.invokeEffector(app, entity, PostgreSqlNode.STOP, ImmutableMap.of(
- StopSoftwareParameters.STOP_MACHINE.getName(), false))
- .get();
- EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_UP, false);
- EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
- EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_PROCESS_IS_RUNNING, false);
- EntityTestUtils.assertAttributeEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, CollectionFunctionals.<String>mapSizeEquals(1));
-
- Entities.invokeEffector(app, entity, restartEffector, args).get();
- EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
- EntityTestUtils.assertAttributeEqualsEventually(entity, PostgreSqlNode.SERVICE_PROCESS_IS_RUNNING, true);
- EntityTestUtils.assertAttributeEqualsEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, ImmutableMap.<String, Object>of());
-
- EntityTestUtils.assertAttributeEqualsEventually(app, PostgreSqlNode.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(app, PostgreSqlNode.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ super.testStopProcessAndStart();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cd3d96e/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
index c7376fe..3d21055 100644
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
+++ b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
@@ -18,71 +18,25 @@
*/
package brooklyn.entity.nosql.mongodb;
-import java.util.Map;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
-import brooklyn.entity.BrooklynAppLiveTestSupport;
-import brooklyn.entity.Effector;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.Lifecycle;
-import brooklyn.entity.basic.ServiceStateLogic;
-import brooklyn.entity.basic.SoftwareProcess.RestartSoftwareParameters;
-import brooklyn.entity.basic.SoftwareProcess.StopSoftwareParameters;
+import brooklyn.entity.basic.AbstractSoftwareProcessRestartIntegrationTest;
+import brooklyn.entity.basic.SoftwareProcess;
import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.EntityTestUtils;
-import brooklyn.util.collections.CollectionFunctionals;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
/**
* Tests restart of the software *process* (as opposed to the VM).
*/
-public class MongoDBRestartIntegrationTest extends BrooklynAppLiveTestSupport {
-
- // TODO Remove duplication from TomcatServerRestartIntegrationTest and MySqlRestartIntegrationTest
+@Test(groups="Integration")
+public class MongoDBRestartIntegrationTest extends AbstractSoftwareProcessRestartIntegrationTest {
@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(MongoDBRestartIntegrationTest.class);
- @Test(groups="Integration")
- public void testStopProcessAndRestart() throws Exception {
- runStopProcessAndRestart(
- MongoDBServer.RESTART,
- ImmutableMap.of(RestartSoftwareParameters.RESTART_MACHINE.getName(), RestartSoftwareParameters.RestartMachineMode.FALSE));
- }
-
- @Test(groups="Integration")
- public void testStopProcessAndStart() throws Exception {
- runStopProcessAndRestart(
- MongoDBServer.START,
- ImmutableMap.of("locations", ImmutableList.of()));
- }
-
- protected void runStopProcessAndRestart(Effector<?> restartEffector, Map<String, ?> args) throws Exception {
- LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
- MongoDBServer entity = app.createAndManageChild(EntitySpec.create(MongoDBServer.class));
- app.start(ImmutableList.of(loc));
-
- Entities.invokeEffector(app, entity, MongoDBServer.STOP, ImmutableMap.of(
- StopSoftwareParameters.STOP_MACHINE.getName(), false))
- .get();
- EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_UP, false);
- EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
- EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_PROCESS_IS_RUNNING, false);
- EntityTestUtils.assertAttributeEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, CollectionFunctionals.<String>mapSizeEquals(1));
-
- Entities.invokeEffector(app, entity, restartEffector, args).get();
- EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
- EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_PROCESS_IS_RUNNING, true);
- EntityTestUtils.assertAttributeEqualsEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, ImmutableMap.<String, Object>of());
-
- EntityTestUtils.assertAttributeEqualsEventually(app, MongoDBServer.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(app, MongoDBServer.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ @Override
+ protected EntitySpec<? extends SoftwareProcess> newEntitySpec() {
+ return EntitySpec.create(MongoDBServer.class);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cd3d96e/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerRestartIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerRestartIntegrationTest.java
index 5c7e702..665cc69 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerRestartIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerRestartIntegrationTest.java
@@ -18,71 +18,27 @@
*/
package brooklyn.entity.webapp.tomcat;
-import java.util.Map;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
-import brooklyn.entity.BrooklynAppLiveTestSupport;
-import brooklyn.entity.Effector;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.Lifecycle;
-import brooklyn.entity.basic.ServiceStateLogic;
-import brooklyn.entity.basic.SoftwareProcess.RestartSoftwareParameters;
-import brooklyn.entity.basic.SoftwareProcess.StopSoftwareParameters;
+import brooklyn.entity.basic.AbstractSoftwareProcessRestartIntegrationTest;
+import brooklyn.entity.basic.SoftwareProcess;
import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.EntityTestUtils;
-import brooklyn.util.collections.CollectionFunctionals;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
/**
* Tests restart of the software *process* (as opposed to the VM).
*/
-public class TomcatServerRestartIntegrationTest extends BrooklynAppLiveTestSupport {
+@Test(groups="Integration")
+public class TomcatServerRestartIntegrationTest extends AbstractSoftwareProcessRestartIntegrationTest {
// TODO Remove duplication from MySqlRestartIntegrationTest
@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(TomcatServerRestartIntegrationTest.class);
-
- @Test(groups="Integration")
- public void testStopProcessAndRestart() throws Exception {
- runStopProcessAndRestart(
- TomcatServer.RESTART,
- ImmutableMap.of(RestartSoftwareParameters.RESTART_MACHINE.getName(), RestartSoftwareParameters.RestartMachineMode.FALSE));
- }
-
- @Test(groups="Integration")
- public void testStopProcessAndStart() throws Exception {
- runStopProcessAndRestart(
- TomcatServer.START,
- ImmutableMap.of("locations", ImmutableList.of()));
- }
-
- protected void runStopProcessAndRestart(Effector<?> restartEffector, Map<String, ?> args) throws Exception {
- LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
- TomcatServer entity = app.createAndManageChild(EntitySpec.create(TomcatServer.class));
- app.start(ImmutableList.of(loc));
-
- Entities.invokeEffector(app, entity, TomcatServer.STOP, ImmutableMap.of(
- StopSoftwareParameters.STOP_MACHINE.getName(), false))
- .get();
- EntityTestUtils.assertAttributeEqualsEventually(entity, TomcatServer.SERVICE_UP, false);
- EntityTestUtils.assertAttributeEqualsEventually(entity, TomcatServer.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
- EntityTestUtils.assertAttributeEqualsEventually(entity, TomcatServer.SERVICE_PROCESS_IS_RUNNING, false);
- EntityTestUtils.assertAttributeEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, CollectionFunctionals.<String>mapSizeEquals(1));
-
- Entities.invokeEffector(app, entity, restartEffector, args).get();
- EntityTestUtils.assertAttributeEqualsEventually(entity, TomcatServer.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(entity, TomcatServer.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
- EntityTestUtils.assertAttributeEqualsEventually(entity, TomcatServer.SERVICE_PROCESS_IS_RUNNING, true);
- EntityTestUtils.assertAttributeEqualsEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, ImmutableMap.<String, Object>of());
- EntityTestUtils.assertAttributeEqualsEventually(app, TomcatServer.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(app, TomcatServer.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ @Override
+ protected EntitySpec<? extends SoftwareProcess> newEntitySpec() {
+ return EntitySpec.create(TomcatServer.class);
}
}