You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sv...@apache.org on 2016/11/03 06:31:46 UTC
[1/2] brooklyn-server git commit: Adds TestCaseYamlTest
Repository: brooklyn-server
Updated Branches:
refs/heads/master 4fab5b1a8 -> 7d9fe8144
Adds TestCaseYamlTest
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/54adf41d
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/54adf41d
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/54adf41d
Branch: refs/heads/master
Commit: 54adf41d3972ed8e02ad7c254be016c3bcce858c
Parents: 4fab5b1
Author: Aled Sage <al...@gmail.com>
Authored: Wed Nov 2 17:48:05 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Nov 2 17:48:05 2016 +0000
----------------------------------------------------------------------
.../camp/brooklyn/AbstractYamlRebindTest.java | 8 ++
.../camp/brooklyn/AbstractYamlTest.java | 22 ++++
test-framework/pom.xml | 18 ++--
.../test/framework/yaml/TestCaseYamlTest.java | 105 +++++++++++++++++++
4 files changed, 147 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/54adf41d/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlRebindTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlRebindTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlRebindTest.java
index 6982507..5eae76c 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlRebindTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlRebindTest.java
@@ -158,6 +158,14 @@ public class AbstractYamlRebindTest extends RebindTestFixture<StartableApplicati
return app;
}
+ protected Entity createStartWaitAndLogApplication(String... input) throws Exception {
+ return createStartWaitAndLogApplication(joinLines(input));
+ }
+
+ protected Entity createStartWaitAndLogApplication(String input) throws Exception {
+ return createStartWaitAndLogApplication(new StringReader(input));
+ }
+
protected Entity createStartWaitAndLogApplication(Reader input) throws Exception {
Entity app = createAndStartApplication(input);
waitForApplicationTasks(app);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/54adf41d/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java
index 4f4f1a4..20b31ae 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/AbstractYamlTest.java
@@ -140,12 +140,34 @@ public abstract class AbstractYamlTest {
return app;
}
+ protected Entity createAndStartApplicationAsync(String... multiLineYaml) throws Exception {
+ return createAndStartApplicationAsync(joinLines(multiLineYaml));
+ }
+
+ protected Entity createAndStartApplicationAsync(String yaml) throws Exception {
+ return createAndStartApplicationAsync(yaml, MutableMap.<String,String>of());
+ }
+
+ protected Entity createAndStartApplicationAsync(String yaml, Map<String,?> startParameters) throws Exception {
+ EntitySpec<?> spec =
+ mgmt().getTypeRegistry().createSpecFromPlan(CampTypePlanTransformer.FORMAT, yaml, RegisteredTypeLoadingContexts.spec(Application.class), EntitySpec.class);
+ final Entity app = brooklynMgmt.getEntityManager().createEntity(spec);
+ // start the app (happens automatically if we use camp to instantiate, but not if we use create spec approach).
+ // Note calling .get() on task, so this is non-blocking.
+ app.invoke(Startable.START, startParameters);
+ return app;
+ }
+
/** @deprecated since 0.10.0, use {@link #createStartWaitAndLogApplication(String)} instead */
@Deprecated
protected Entity createStartWaitAndLogApplication(Reader input) throws Exception {
return createStartWaitAndLogApplication(Streams.readFully(input));
}
+ protected Entity createStartWaitAndLogApplication(String... input) throws Exception {
+ return createStartWaitAndLogApplication(joinLines(input));
+ }
+
protected Entity createStartWaitAndLogApplication(String input) throws Exception {
Entity app = createAndStartApplication(input);
waitForApplicationTasks(app);
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/54adf41d/test-framework/pom.xml
----------------------------------------------------------------------
diff --git a/test-framework/pom.xml b/test-framework/pom.xml
index 5faf6f7..72bbb2b 100644
--- a/test-framework/pom.xml
+++ b/test-framework/pom.xml
@@ -41,6 +41,11 @@
</dependency>
<dependency>
<groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-software-base</artifactId>
+ <version>${brooklyn.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.brooklyn</groupId>
<artifactId>brooklyn-camp</artifactId>
<version>${brooklyn.version}</version>
</dependency>
@@ -55,7 +60,6 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -79,6 +83,13 @@
<classifier>tests</classifier>
</dependency>
<dependency>
+ <groupId>org.apache.brooklyn</groupId>
+ <artifactId>brooklyn-camp</artifactId>
+ <version>${brooklyn.version}</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+ <dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
@@ -92,11 +103,6 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
- <version>3.3</version>
- <configuration>
- <source>${java.version}</source>
- <target>${java.version}</target>
- </configuration>
</plugin>
</plugins>
</build>
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/54adf41d/test-framework/src/test/java/org/apache/brooklyn/test/framework/yaml/TestCaseYamlTest.java
----------------------------------------------------------------------
diff --git a/test-framework/src/test/java/org/apache/brooklyn/test/framework/yaml/TestCaseYamlTest.java b/test-framework/src/test/java/org/apache/brooklyn/test/framework/yaml/TestCaseYamlTest.java
new file mode 100644
index 0000000..53f6e87
--- /dev/null
+++ b/test-framework/src/test/java/org/apache/brooklyn/test/framework/yaml/TestCaseYamlTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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 org.apache.brooklyn.test.framework.yaml;
+
+import org.apache.brooklyn.camp.brooklyn.AbstractYamlRebindTest;
+import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
+import org.apache.brooklyn.entity.machine.MachineEntity;
+import org.apache.brooklyn.entity.stock.BasicApplication;
+import org.apache.brooklyn.test.framework.TestCase;
+import org.apache.brooklyn.test.framework.TestEffector;
+import org.apache.brooklyn.test.framework.TestSensor;
+import org.apache.brooklyn.test.framework.TestSshCommand;
+import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+//Checks that the test cases work in YAML
+@Test
+public class TestCaseYamlTest extends AbstractYamlRebindTest {
+
+ // TODO Would like this test to be in brooklyn-camp, but that would create a circular dependency.
+ // brooklyn-test-framework depends on brooklyn-camp.
+ // To remove that dependency, we could move the DslComponent etc into brooklyn-core.
+
+ @SuppressWarnings("unused")
+ private static final Logger log = LoggerFactory.getLogger(TestCaseYamlTest.class);
+
+ @BeforeMethod(alwaysRun=true)
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ RecordingSshTool.clear();
+ }
+
+ @AfterMethod(alwaysRun=true)
+ @Override
+ public void tearDown() throws Exception {
+ try {
+ super.tearDown();
+ } finally {
+ RecordingSshTool.clear();
+ }
+ }
+
+ @Test
+ public void testSimpleTestCases() throws Exception {
+ RecordingSshTool.setCustomResponse(".*myCommand.*", new RecordingSshTool.CustomResponse(0, "myResponse", null));
+
+ origApp = (BasicApplication) createStartWaitAndLogApplication(
+ "location:",
+ " localhost:",
+ " sshToolClass: "+RecordingSshTool.class.getName(),
+ "services:",
+ "- type: " + MachineEntity.class.getName(),
+ " id: target-app",
+ " brooklyn.config:",
+ " sshMonitoring.enabled: false",
+ " "+BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION.getName()+": true",
+ "- type: " + TestCase.class.getName(),
+ " brooklyn.config:",
+ " targetId: target-app",
+ " brooklyn.children:",
+ " - type: " + TestSensor.class.getName(),
+ " brooklyn.config:",
+ " sensor: service.isUp",
+ " assert:",
+ " - equals: true",
+ " - type: " + TestEffector.class.getName(),
+ " brooklyn.config:",
+ " effector: execCommand",
+ " params:",
+ " command: myCommand",
+ " assert:",
+ " - contains: myResponse",
+ " - type: " + TestSshCommand.class.getName(),
+ " brooklyn.config:",
+ " command: myCommand",
+ " assertStatus:",
+ " - equals: 0",
+ " assertOut:",
+ " - contains: myResponse"
+ );
+
+ rebind();
+ }
+}
[2/2] brooklyn-server git commit: Closes #399
Posted by sv...@apache.org.
Closes #399
Adds TestCaseYamlTest
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/7d9fe814
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/7d9fe814
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/7d9fe814
Branch: refs/heads/master
Commit: 7d9fe8144222f514d0ff5483f36709c45f6529e2
Parents: 4fab5b1 54adf41
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Thu Nov 3 08:31:32 2016 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Thu Nov 3 08:31:32 2016 +0200
----------------------------------------------------------------------
.../camp/brooklyn/AbstractYamlRebindTest.java | 8 ++
.../camp/brooklyn/AbstractYamlTest.java | 22 ++++
test-framework/pom.xml | 18 ++--
.../test/framework/yaml/TestCaseYamlTest.java | 105 +++++++++++++++++++
4 files changed, 147 insertions(+), 6 deletions(-)
----------------------------------------------------------------------