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 2015/11/14 16:26:47 UTC

[1/3] incubator-brooklyn git commit: Addressed review comments.

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 2b23266eb -> 89cf94fc0


Addressed review comments.

Changed how the task is submitted and waited upon until completion in ParallelTestCase. Functionally no change.
Added ParallelTestCase documentation to entities docs and minor cleanup.


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/cd8fae2d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/cd8fae2d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/cd8fae2d

Branch: refs/heads/master
Commit: cd8fae2d945fa45702eab810cdae38546718298f
Parents: ca89ed4
Author: Chris Burke <ch...@cloudsoft.io>
Authored: Fri Nov 13 11:05:03 2015 +0000
Committer: Chris Burke <ch...@cloudsoft.io>
Committed: Fri Nov 13 11:05:03 2015 +0000

----------------------------------------------------------------------
 usage/test-framework/README.md                  | 24 +++++++++---
 .../test/framework/ParallelTestCaseImpl.java    | 41 ++++++++++----------
 2 files changed, 38 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cd8fae2d/usage/test-framework/README.md
----------------------------------------------------------------------
diff --git a/usage/test-framework/README.md b/usage/test-framework/README.md
index 9c22e2b..3899bd3 100644
--- a/usage/test-framework/README.md
+++ b/usage/test-framework/README.md
@@ -1,17 +1,29 @@
 # Entities
 
 ## TestCase
-A logical grouping for tests eg Restart tests
+A logical grouping for tests, e.g. Restart tests.
+
 ```
 type: org.apache.brooklyn.test.framework.TestCase
-  name: Stop Test
-  brooklyn.children:
+name: Stop Test
+brooklyn.children:
+  - ***
+  - ***
+```
+
+## ParallelTestCase
+A logical grouping for tests where each child is started in parallel instead of being run sequentially.
+
+```
+type: org.apache.brooklyn.test.framework.ParallelTestCase
+name: Start Test
+brooklyn.children:
   - ***
   - ***
 ```
 
 ## TestSensor
-Entity that tests a sensor value on another entity eg service.isUp == TRUE
+Entity that tests a sensor value on another entity, e.g. service.isUp == TRUE.
 
 #### Configuration
 | Key | Description | Required |
@@ -37,7 +49,7 @@ timeout: 5m
 ```
 
 ## TestEffector
-Entity that invokes an effector on another entity eg restart
+Entity that invokes an effector on another entity, e.g. restart.
 
 #### Configuration
 | Key | Description | Required |
@@ -64,7 +76,7 @@ params:
 ```
 
 ## TestHtmlCall
-Entity that makes a HTTP Request and tests the response
+Entity that makes a HTTP Request and tests the response.
 
 #### Configuration
 | Key | Description | Required |

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cd8fae2d/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
index 3b06f23..2fcd83c 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
@@ -18,8 +18,9 @@
  */
 package org.apache.brooklyn.test.framework;
 
+import java.util.Collection;
+
 import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.api.mgmt.TaskAdaptable;
 import org.apache.brooklyn.core.entity.AbstractEntity;
 import org.apache.brooklyn.core.entity.Attributes;
@@ -30,9 +31,11 @@ import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Collection;
-import java.util.concurrent.ExecutionException;
-
+/**
+ * This implementation will start all child entities in parallel.
+ * 
+ * @author Chris Burke
+ */
 public class ParallelTestCaseImpl extends AbstractEntity implements ParallelTestCase {
 
     private static final Logger logger = LoggerFactory.getLogger(ParallelTestCaseImpl.class);
@@ -40,7 +43,7 @@ public class ParallelTestCaseImpl extends AbstractEntity implements ParallelTest
     /**
      * {@inheritDoc}
      */
-    public void start(Collection<? extends Location> locations) {
+    public void start(final Collection<? extends Location> locations) {
         // Let everyone know we're starting up (so that the GUI shows the correct icon).
         sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STARTING);
         try {
@@ -77,6 +80,7 @@ public class ParallelTestCaseImpl extends AbstractEntity implements ParallelTest
             // Submit the task to the ExecutionManager so that they actually get stopped
             // and then wait until all the parallel entities have completed.
             submitTaskAndWait(taskAdaptable);
+            
             // Let everyone know we've stopped successfully (changes the icon in the GUI).
             logger.debug("Tasks successfully run. Update state of {} to STOPPED.", this);
             setServiceState(false, Lifecycle.STOPPED);
@@ -115,27 +119,22 @@ public class ParallelTestCaseImpl extends AbstractEntity implements ParallelTest
 
     /**
      * Submits the task to the ExecutionManager and then waits until the task has completed.
-     *
+     * 
      * @param taskAdaptable the TaskAdaptable to submit for execution.
-     * @throws ExecutionException   if the task threw an exception
-     * @throws InterruptedException if the current thread was interrupted while waiting
      */
-    private void submitTaskAndWait(final TaskAdaptable<?> taskAdaptable)
-            throws InterruptedException, ExecutionException {
-        logger.debug("{}, Submitting taskAdaptable: {}", this, taskAdaptable);
+    private void submitTaskAndWait(final TaskAdaptable<?> taskAdaptable) {
         // Submit the task to the ExecutionManager.
-        final Task<?> task = DynamicTasks.submit(taskAdaptable, this);
-
-        // Block until the task has completed.
-        logger.debug("{}, Blocking until task complete.", this);
-        task.blockUntilEnded();
-        logger.debug("{}, Task complete.", this);
-
-        // Get the result of the task. We don't really care about the
-        // actual result but this will throw an exception if the task failed.
-        task.get();
+        DynamicTasks.queue(taskAdaptable);
+        // Block until the task has completed. This will also throw if anything went wrong.
+        DynamicTasks.waitForLast();
     }
 
+    /**
+     * Sets the state of the Entity. Useful so that the GUI shows the correct icon.
+     * 
+     * @param serviceUpState Whether or not the entity is up.
+     * @param serviceStateActual The actual state of the entity.
+     */
     private void setServiceState(final boolean serviceUpState, final Lifecycle serviceStateActual) {
         sensors().set(SERVICE_UP, serviceUpState);
         sensors().set(Attributes.SERVICE_STATE_ACTUAL, serviceStateActual);


[3/3] incubator-brooklyn git commit: This closes #1029

Posted by al...@apache.org.
This closes #1029


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/89cf94fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/89cf94fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/89cf94fc

Branch: refs/heads/master
Commit: 89cf94fc09081df17d6fbcc1ec85786a7556e22e
Parents: 2b23266 1dc4e69
Author: Aled Sage <al...@gmail.com>
Authored: Sat Nov 14 15:26:23 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Nov 14 15:26:23 2015 +0000

----------------------------------------------------------------------
 docs/guide/index.md                             |   1 +
 docs/guide/test/entities.md                     | 143 +++++++++++++++++++
 docs/guide/test/index.md                        |   8 ++
 usage/test-framework/README.md                  | 129 -----------------
 .../test/framework/ParallelTestCaseImpl.java    |  41 +++---
 5 files changed, 172 insertions(+), 150 deletions(-)
----------------------------------------------------------------------



[2/3] incubator-brooklyn git commit: Move test framework documentation to within brooklyn docs guide.

Posted by al...@apache.org.
Move test framework documentation to within brooklyn docs guide.


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/1dc4e690
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/1dc4e690
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/1dc4e690

Branch: refs/heads/master
Commit: 1dc4e6905ca9d6457a0fde3220e389f72f640e40
Parents: cd8fae2
Author: Chris Burke <ch...@cloudsoft.io>
Authored: Fri Nov 13 13:48:00 2015 +0000
Committer: Chris Burke <ch...@cloudsoft.io>
Committed: Fri Nov 13 13:48:00 2015 +0000

----------------------------------------------------------------------
 docs/guide/index.md            |   1 +
 docs/guide/test/entities.md    | 143 ++++++++++++++++++++++++++++++++++++
 docs/guide/test/index.md       |   8 ++
 usage/test-framework/README.md | 141 -----------------------------------
 4 files changed, 152 insertions(+), 141 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1dc4e690/docs/guide/index.md
----------------------------------------------------------------------
diff --git a/docs/guide/index.md b/docs/guide/index.md
index cdb3b46..7ada3f2 100644
--- a/docs/guide/index.md
+++ b/docs/guide/index.md
@@ -12,6 +12,7 @@ children:
 - { path: /guide/java/index.md }
 - { path: /guide/ops/index.md }
 - { path: /guide/misc/index.md }
+- { path: /guide/test/index.md }
 ---
 
 This is the Brooklyn User Guide for v{{ site.brooklyn-version }}:

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1dc4e690/docs/guide/test/entities.md
----------------------------------------------------------------------
diff --git a/docs/guide/test/entities.md b/docs/guide/test/entities.md
new file mode 100644
index 0000000..d96eeaf
--- /dev/null
+++ b/docs/guide/test/entities.md
@@ -0,0 +1,143 @@
+---
+title: Entities
+layout: website-normal
+---
+## TestCase
+A logical grouping for tests, e.g. Restart tests.
+
+```
+type: org.apache.brooklyn.test.framework.TestCase
+name: Stop Test
+brooklyn.children:
+  - ***
+  - ***
+```
+
+## ParallelTestCase
+A logical grouping for tests where each child is started in parallel instead of being run sequentially.
+
+```
+type: org.apache.brooklyn.test.framework.ParallelTestCase
+name: Start Test
+brooklyn.children:
+  - ***
+  - ***
+```
+
+## TestSensor
+Entity that tests a sensor value on another entity, e.g. service.isUp == TRUE.
+
+#### Configuration
+| Key | Description | Required |
+| --- | ----------- | -------- |
+| target | The target entity to test | yes (no if *targetId* is supplied) |
+| targetId | The id of the target entity to test | yes (no if *target* is supplied) |
+| assert | Assertions to be evaluated | yes |
+| timeout | The duration to wait on a result | no |
+
+##### Assertions
+| Key | Description |
+| --- | ----------- |
+| equal | Sensor value equals  |
+| regex | Sensor value matches regex |
+| isNull | Sensor value has not been set |
+
+```
+type: org.apache.brooklyn.test.framework.TestSensor
+target: $brooklyn:component("nginx1")
+sensor: service.isUp
+equals: true
+timeout: 5m
+```
+
+## TestEffector
+Entity that invokes an effector on another entity, e.g. restart.
+
+#### Configuration
+| Key | Description | Required |
+| --- | ----------- | -------- |
+| target | The target entity to effect | yes (no if *targetId* is supplied) |
+| targetId | The id of the target entity to effect | yes (no if *target* is supplied) |
+| effector | The name of the effector to invoke | yes |
+| params | Parameters to pass to the effector | no |
+| timeout | The duration to wait on a response from an effector | no |
+
+#### Sensors
+| Key | Description |
+| --- | ----------- |
+| result | The result of invoking the effector (null if no result) |
+
+```
+type: org.apache.brooklyn.test.framework.TestEffector
+name: Deploy WAR
+target: $brooklyn:component("tomcat")
+effector: deploy
+params:
+  url: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
+  targetName: sample1
+```
+
+## TestHtmlCall
+Entity that makes a HTTP Request and tests the response.
+
+#### Configuration
+| Key | Description | Required |
+| --- | ----------- | -------- |
+| url | The URL to test | yes |
+| assert | Assertions to be evaluated | yes |
+| timeout | The duration to wait for assertion result | no |
+
+##### Assertions
+| Key | Description |
+| --- | ----------- |
+| string | HTTP body contains text |
+| regex | HTTP body matches regex |
+| status | HTTP status code equals |
+
+```
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 200
+    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    timeout: 1m
+    assert:
+      status: 200
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    timeout: 1m
+    assert:
+      bodyContains: Sample Brooklyn Deployed
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 404
+    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
+    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
+    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+```
+
+
+
+----
+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.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1dc4e690/docs/guide/test/index.md
----------------------------------------------------------------------
diff --git a/docs/guide/test/index.md b/docs/guide/test/index.md
new file mode 100644
index 0000000..72501bf
--- /dev/null
+++ b/docs/guide/test/index.md
@@ -0,0 +1,8 @@
+---
+title: QA Test Framework
+layout: website-normal
+children:
+  - entities.md
+---
+
+{% include list-children.html %}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1dc4e690/usage/test-framework/README.md
----------------------------------------------------------------------
diff --git a/usage/test-framework/README.md b/usage/test-framework/README.md
deleted file mode 100644
index 3899bd3..0000000
--- a/usage/test-framework/README.md
+++ /dev/null
@@ -1,141 +0,0 @@
-# Entities
-
-## TestCase
-A logical grouping for tests, e.g. Restart tests.
-
-```
-type: org.apache.brooklyn.test.framework.TestCase
-name: Stop Test
-brooklyn.children:
-  - ***
-  - ***
-```
-
-## ParallelTestCase
-A logical grouping for tests where each child is started in parallel instead of being run sequentially.
-
-```
-type: org.apache.brooklyn.test.framework.ParallelTestCase
-name: Start Test
-brooklyn.children:
-  - ***
-  - ***
-```
-
-## TestSensor
-Entity that tests a sensor value on another entity, e.g. service.isUp == TRUE.
-
-#### Configuration
-| Key | Description | Required |
-| --- | ----------- | -------- |
-| target | The target entity to test | yes (no if *targetId* is supplied) |
-| targetId | The id of the target entity to test | yes (no if *target* is supplied) |
-| assert | Assertions to be evaluated | yes |
-| timeout | The duration to wait on a result | no |
-
-##### Assertions
-| Key | Description |
-| --- | ----------- |
-| equal | Sensor value equals  |
-| regex | Sensor value matches regex |
-| isNull | Sensor value has not been set |
-
-```
-type: org.apache.brooklyn.test.framework.TestSensor
-target: $brooklyn:component("nginx1")
-sensor: service.isUp
-equals: true
-timeout: 5m
-```
-
-## TestEffector
-Entity that invokes an effector on another entity, e.g. restart.
-
-#### Configuration
-| Key | Description | Required |
-| --- | ----------- | -------- |
-| target | The target entity to effect | yes (no if *targetId* is supplied) |
-| targetId | The id of the target entity to effect | yes (no if *target* is supplied) |
-| effector | The name of the effector to invoke | yes |
-| params | Parameters to pass to the effector | no |
-| timeout | The duration to wait on a response from an effector | no |
-
-#### Sensors
-| Key | Description |
-| --- | ----------- |
-| result | The result of invoking the effector (null if no result) |
-
-```
-type: org.apache.brooklyn.test.framework.TestEffector
-name: Deploy WAR
-target: $brooklyn:component("tomcat")
-effector: deploy
-params:
-  url: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
-  targetName: sample1
-```
-
-## TestHtmlCall
-Entity that makes a HTTP Request and tests the response.
-
-#### Configuration
-| Key | Description | Required |
-| --- | ----------- | -------- |
-| url | The URL to test | yes |
-| assert | Assertions to be evaluated | yes |
-| timeout | The duration to wait for assertion result | no |
-
-##### Assertions
-| Key | Description |
-| --- | ----------- |
-| string | HTTP body contains text |
-| regex | HTTP body matches regex |
-| status | HTTP status code equals |
-
-```
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Status Code 200
-    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
-    timeout: 1m
-    assert:
-      status: 200
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: String match
-    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
-    timeout: 1m
-    assert:
-      bodyContains: Sample Brooklyn Deployed
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Status Code 404
-    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))
-    assert:
-      status: 404
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Regex match
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
-    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
-    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
-    assert:
-      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
-```
-
-
-
-----
-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.
\ No newline at end of file