You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sj...@apache.org on 2014/12/19 12:51:56 UTC
[1/3] incubator-brooklyn git commit: RebindOptions: declare fields
public
Repository: incubator-brooklyn
Updated Branches:
refs/heads/master d77e1b091 -> d26463b65
RebindOptions: declare fields public
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/02bb7c76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/02bb7c76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/02bb7c76
Branch: refs/heads/master
Commit: 02bb7c7630d8a16fd24d4f7313826799eeabfbf0
Parents: 0faf4d9
Author: Aled Sage <al...@gmail.com>
Authored: Thu Dec 18 10:29:18 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Dec 18 10:29:18 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/02bb7c76/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();
[2/3] incubator-brooklyn git commit: Extracts AbstractBlueprintTest
and marks MongoDbBlueprintTest as WIP
Posted by sj...@apache.org.
Extracts AbstractBlueprintTest and marks MongoDbBlueprintTest as WIP
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/51ffe808
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/51ffe808
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/51ffe808
Branch: refs/heads/master
Commit: 51ffe808258a964710776b820ddce29ec50c34e6
Parents: 02bb7c7
Author: Aled Sage <al...@gmail.com>
Authored: Thu Dec 18 10:30:25 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Dec 18 10:30:54 2014 +0000
----------------------------------------------------------------------
.../blueprints/AbstractBlueprintTest.java | 193 +++++++++++++++++++
.../blueprints/MongoDbBlueprintTest.java | 77 ++------
2 files changed, 208 insertions(+), 62 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/51ffe808/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java b/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
new file mode 100644
index 0000000..e9df79c
--- /dev/null
+++ b/usage/launcher/src/test/java/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
@@ -0,0 +1,193 @@
+/*
+ * 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.launcher.blueprints;
+
+import static org.testng.Assert.assertNotEquals;
+import io.brooklyn.camp.brooklyn.BrooklynCampPlatformLauncherAbstract;
+
+import java.io.File;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Collection;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+
+import brooklyn.entity.Application;
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.Attributes;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.Lifecycle;
+import brooklyn.entity.basic.SoftwareProcess;
+import brooklyn.entity.rebind.RebindOptions;
+import brooklyn.entity.rebind.RebindTestUtils;
+import brooklyn.entity.rebind.persister.FileBasedObjectStore;
+import brooklyn.launcher.BrooklynLauncher;
+import brooklyn.launcher.SimpleYamlLauncherForTests;
+import brooklyn.launcher.camp.BrooklynCampPlatformLauncher;
+import brooklyn.management.ManagementContext;
+import brooklyn.management.internal.LocalManagementContext;
+import brooklyn.test.Asserts;
+import brooklyn.test.EntityTestUtils;
+import brooklyn.util.ResourceUtils;
+import brooklyn.util.os.Os;
+
+public abstract class AbstractBlueprintTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractBlueprintTest.class);
+
+ private File mementoDir;
+ private ClassLoader classLoader = AbstractBlueprintTest.class.getClassLoader();
+
+ private ManagementContext mgmt;
+ private SimpleYamlLauncherForTests launcher;
+ private BrooklynLauncher viewer;
+
+ @BeforeMethod(alwaysRun=true)
+ public void setUp() throws Exception {
+ mementoDir = Os.newTempDir(getClass());
+ mgmt = createOrigManagementContext();
+ LOG.info("Test "+getClass()+" persisting to "+mementoDir);
+
+ launcher = new SimpleYamlLauncherForTests() {
+ @Override
+ protected BrooklynCampPlatformLauncherAbstract newPlatformLauncher() {
+ return new BrooklynCampPlatformLauncher() {
+ protected ManagementContext newManagementContext() {
+ return AbstractBlueprintTest.this.mgmt;
+ }
+ };
+ }
+ };
+ viewer = BrooklynLauncher.newInstance()
+ .managementContext(mgmt)
+ .start();
+ }
+
+ @AfterMethod(alwaysRun=true)
+ public void tearDown() throws Exception {
+ try {
+ if (mgmt != null) {
+ for (Application app: mgmt.getApplications()) {
+ LOG.debug("destroying app "+app+" (managed? "+Entities.isManaged(app)+"; mgmt is "+mgmt+")");
+ try {
+ Entities.destroy(app);
+ LOG.debug("destroyed app "+app+"; mgmt now "+mgmt);
+ } catch (Exception e) {
+ LOG.error("problems destroying app "+app, e);
+ }
+ }
+ }
+ if (launcher != null) launcher.destroyAll();
+ if (viewer != null) viewer.terminate();
+ if (mgmt != null) Entities.destroyAll(mgmt);
+ if (mementoDir != null) FileBasedObjectStore.deleteCompletely(mementoDir);
+ } catch (Throwable t) {
+ LOG.error("Caught exception in tearDown method", t);
+ } finally {
+ mgmt = null;
+ launcher = null;
+ }
+ }
+
+ protected void runTest(String yamlFile) throws Exception {
+ final Application app = launcher.launchAppYaml(yamlFile);
+
+ assertNoFires(app);
+
+ Application newApp = rebind();
+ assertNoFires(newApp);
+ }
+
+ protected void assertNoFires(final Entity app) {
+ EntityTestUtils.assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true);
+ EntityTestUtils.assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+
+ Asserts.succeedsEventually(new Runnable() {
+ public void run() {
+ for (Entity entity : Entities.descendants(app)) {
+ assertNotEquals(entity.getAttribute(Attributes.SERVICE_STATE_ACTUAL), Lifecycle.ON_FIRE);
+ assertNotEquals(entity.getAttribute(Attributes.SERVICE_UP), false);
+
+ if (entity instanceof SoftwareProcess) {
+ EntityTestUtils.assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ EntityTestUtils.assertAttributeEquals(entity, Attributes.SERVICE_UP, Boolean.TRUE);
+ }
+ }
+ }});
+ }
+
+ protected Reader loadYaml(String url, String location) {
+ String yaml =
+ "location: "+location+"\n"+
+ new ResourceUtils(this).getResourceAsString(url);
+ return new StringReader(yaml);
+ }
+
+
+ //////////////////////////////////////////////////////////////////
+ // FOR REBIND //
+ // See brooklyn.entity.rebind.RebindTestFixture in core's tests //
+ //////////////////////////////////////////////////////////////////
+
+ /** rebinds, and sets newApp */
+ protected Application rebind() throws Exception {
+ return rebind(RebindOptions.create());
+ }
+
+ protected Application rebind(RebindOptions options) throws Exception {
+ ManagementContext origMgmt = mgmt;
+ ManagementContext newMgmt = createNewManagementContext();
+ Collection<Application> origApps = origMgmt.getApplications();
+
+ options = RebindOptions.create(options);
+ if (options.classLoader == null) options.classLoader(classLoader);
+ if (options.mementoDir == null) options.mementoDir(mementoDir);
+ if (options.origManagementContext == null) options.origManagementContext(origMgmt);
+ if (options.newManagementContext == null) options.newManagementContext(newMgmt);
+
+ for (Application origApp : origApps) {
+ RebindTestUtils.waitForPersisted(origApp);
+ }
+
+ mgmt = options.newManagementContext;
+ Application newApp = RebindTestUtils.rebind(options);
+ return newApp;
+ }
+
+ /** @return A started management context */
+ protected LocalManagementContext createOrigManagementContext() {
+ return RebindTestUtils.managementContextBuilder(mementoDir, classLoader)
+ .persistPeriodMillis(1)
+ .forLive(true)
+ .emptyCatalog(true)
+ .buildStarted();
+ }
+
+ /** @return An unstarted management context */
+ protected LocalManagementContext createNewManagementContext() {
+ return RebindTestUtils.managementContextBuilder(mementoDir, classLoader)
+ .persistPeriodMillis(1)
+ .forLive(true)
+ .emptyCatalog(true)
+ .buildUnstarted();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/51ffe808/usage/launcher/src/test/java/brooklyn/launcher/blueprints/MongoDbBlueprintTest.java
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/java/brooklyn/launcher/blueprints/MongoDbBlueprintTest.java b/usage/launcher/src/test/java/brooklyn/launcher/blueprints/MongoDbBlueprintTest.java
index c3e6d18..53dd416 100644
--- a/usage/launcher/src/test/java/brooklyn/launcher/blueprints/MongoDbBlueprintTest.java
+++ b/usage/launcher/src/test/java/brooklyn/launcher/blueprints/MongoDbBlueprintTest.java
@@ -18,81 +18,34 @@
*/
package brooklyn.launcher.blueprints;
-import static org.testng.Assert.assertNotEquals;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import brooklyn.entity.Application;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.Attributes;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.Lifecycle;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.launcher.SimpleYamlLauncherForTests;
-import brooklyn.test.Asserts;
-import brooklyn.test.EntityTestUtils;
-
-public class MongoDbBlueprintTest {
+public class MongoDbBlueprintTest extends AbstractBlueprintTest {
// TODO Some tests are failing! Needs investigated.
- private SimpleYamlLauncherForTests launcher;
-
- // The "viewer" is just for having a Brooklyn web-console available for visual inspection;
- // could be removed without affecting behaviour
- private BrooklynLauncher viewer;
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- launcher = new SimpleYamlLauncherForTests();
- viewer = BrooklynLauncher.newInstance().managementContext(launcher.getManagementContext()).start();
- }
-
- @AfterMethod(alwaysRun=true)
- public void tearDown() throws Exception {
- if (launcher != null) launcher.destroyAll();
- if (viewer != null) viewer.terminate();
- }
-
- @Test(groups="Integration")
- public void testMongoSharded() {
- runAppAndAssertNoFires("mongo-sharded.yaml");
+ @Test(groups={"Integration", "WIP"})
+ public void testMongoSharded() throws Exception {
+ runTest("mongo-sharded.yaml");
}
- @Test(groups="Integration")
- public void testMongoReplicaSet() {
- runAppAndAssertNoFires("mongo-blueprint.yaml");
+ @Test(groups={"Integration", "WIP"})
+ public void testMongoReplicaSet() throws Exception {
+ runTest("mongo-blueprint.yaml");
}
- @Test(groups="Integration")
- public void testMongoClientAndSingleServer() {
- runAppAndAssertNoFires("mongo-client-single-server.yaml");
+ @Test(groups={"Integration", "WIP"})
+ public void testMongoClientAndSingleServer() throws Exception {
+ runTest("mongo-client-single-server.yaml");
}
- @Test(groups="Integration")
- public void testMongoScripts() {
- runAppAndAssertNoFires("mongo-scripts.yaml");
+ @Test(groups={"Integration", "WIP"})
+ public void testMongoScripts() throws Exception {
+ runTest("mongo-scripts.yaml");
}
@Test(groups="Integration")
- public void testMongoSingleServer() {
- runAppAndAssertNoFires("mongo-single-server-blueprint.yaml");
- }
-
- protected void runAppAndAssertNoFires(String yamlFile) {
- final Application app = launcher.launchAppYaml(yamlFile);
-
- EntityTestUtils.assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
-
- Asserts.succeedsEventually(new Runnable() {
- public void run() {
- for (Entity entity : Entities.descendants(app)) {
- assertNotEquals(entity.getAttribute(Attributes.SERVICE_STATE_ACTUAL), Lifecycle.ON_FIRE);
- assertNotEquals(entity.getAttribute(Attributes.SERVICE_UP), false);
- }
- }});
+ public void testMongoSingleServer() throws Exception {
+ runTest("mongo-single-server-blueprint.yaml");
}
}
[3/3] incubator-brooklyn git commit: This closes #345
Posted by sj...@apache.org.
This closes #345
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/d26463b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/d26463b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/d26463b6
Branch: refs/heads/master
Commit: d26463b659fe940f526df0f3558e2eab5b9bb787
Parents: d77e1b0 51ffe80
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Fri Dec 19 11:38:14 2014 +0000
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Fri Dec 19 11:38:14 2014 +0000
----------------------------------------------------------------------
.../brooklyn/entity/rebind/RebindOptions.java | 18 +-
.../blueprints/AbstractBlueprintTest.java | 193 +++++++++++++++++++
.../blueprints/MongoDbBlueprintTest.java | 77 ++------
3 files changed, 217 insertions(+), 71 deletions(-)
----------------------------------------------------------------------