brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geom...@apache.org
Subject [06/10] brooklyn-server git commit: use iteration limit to make several tests run quicker (not wait 1s)
Date Fri, 28 Apr 2017 13:53:44 GMT
use iteration limit to make several tests run quicker (not wait 1s)


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

Branch: refs/heads/master
Commit: 661d92f5692b62e9130ed0f3d79fc6c5597f214d
Parents: bd461ad
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Apr 25 16:10:02 2017 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri Apr 28 14:09:51 2017 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/brooklyn/test/framework/BaseTest.java | 6 ++++++
 .../org/apache/brooklyn/test/framework/TestSensorImpl.java     | 2 +-
 .../apache/brooklyn/test/framework/TestWinrmCommandImpl.java   | 1 +
 .../apache/brooklyn/test/framework/TestWinrmCommandTest.java   | 6 ++++++
 4 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/661d92f5/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
----------------------------------------------------------------------
diff --git a/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
index 2ae552d..5689b6c 100644
--- a/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
+++ b/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
@@ -45,6 +45,12 @@ public interface BaseTest extends TargetableTestComponent, Startable {
         Duration.seconds(1));
 
     /**
+     * The max number of iterations to run before throwing an exception.
+     */
+    ConfigKey<Integer> ITERATION_LIMIT = ConfigKeys.newConfigKey(Integer.class, "iterations",
"Max iterations to try to get result",
+        Integer.MAX_VALUE);
+
+    /**
      * Max time between checking the assertion (exponential backoff to this limit).
      */
     ConfigKey<Duration> BACKOFF_TO_PERIOD = ConfigKeys.newConfigKey(Duration.class,
"backoffToPeriod", 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/661d92f5/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
----------------------------------------------------------------------
diff --git a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
index 6dae5ea..9cf5b21 100644
--- a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
+++ b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
@@ -77,7 +77,7 @@ public class TestSensorImpl extends TargetableTestComponentImpl implements
TestS
                 }
             };
             TestFrameworkAssertions.checkAssertionsEventually(new AssertionOptions(sensor.get(),
supplier)
-                    .timeout(timeout).backoffToPeriod(backoffToPeriod)
+                    .maxAttempts(getConfig(ITERATION_LIMIT)).timeout(timeout).backoffToPeriod(backoffToPeriod)
                     .assertions(assertions).abortConditions(abortConditions));
 
             setUpAndRunState(true, Lifecycle.RUNNING);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/661d92f5/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestWinrmCommandImpl.java
----------------------------------------------------------------------
diff --git a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestWinrmCommandImpl.java
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestWinrmCommandImpl.java
index 3dc2545..f0d5b8b 100644
--- a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestWinrmCommandImpl.java
+++ b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestWinrmCommandImpl.java
@@ -107,6 +107,7 @@ public class TestWinrmCommandImpl extends TargetableTestComponentImpl
implements
             // See identical comment in `TestSshCommandImpl`.
             ReferenceWithError<Boolean> result = Repeater.create("Running winrm-command
tests")
                     .limitTimeTo(timeout)
+                    .limitIterationsTo(getRequiredConfig(ITERATION_LIMIT))
                     .backoffTo((backoffToPeriod != null) ? backoffToPeriod : Duration.millis(500))
                     .until(new Callable<Boolean>() {
                         @Override

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/661d92f5/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestWinrmCommandTest.java
----------------------------------------------------------------------
diff --git a/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestWinrmCommandTest.java
b/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestWinrmCommandTest.java
index ff387e5..e5a2c52 100644
--- a/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestWinrmCommandTest.java
+++ b/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestWinrmCommandTest.java
@@ -37,6 +37,7 @@ import java.util.Map;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
 import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.location.winrm.WinRmMachineLocation;
@@ -141,6 +142,7 @@ public class TestWinrmCommandTest extends BrooklynAppUnitTestSupport {
         RecordingWinRmTool.setCustomResponse(cmd, new RecordingWinRmTool.CustomResponse(1,
null, null));
         
         TestWinrmCommand test = app.createAndManageChild(EntitySpec.create(TestWinrmCommand.class)
+            .configure(TestWinrmCommand.ITERATION_LIMIT, 1)
             .configure(TARGET_ENTITY, testEntity)
             .configure(COMMAND, cmd));
 
@@ -177,6 +179,7 @@ public class TestWinrmCommandTest extends BrooklynAppUnitTestSupport {
         RecordingWinRmTool.setCustomResponse(cmd, new RecordingWinRmTool.CustomResponse(0,
"wrongstdout", null));
         
         TestWinrmCommand test = app.createAndManageChild(EntitySpec.create(TestWinrmCommand.class)
+            .configure(TestWinrmCommand.ITERATION_LIMIT, 1)
             .configure(TARGET_ENTITY, testEntity)
             .configure(COMMAND, cmd)
             .configure(ASSERT_OUT, makeAssertions(ImmutableMap.of(CONTAINS, "mystdout"))));
@@ -197,6 +200,7 @@ public class TestWinrmCommandTest extends BrooklynAppUnitTestSupport {
         RecordingWinRmTool.setCustomResponse(cmd, new RecordingWinRmTool.CustomResponse(0,
null, "wrongstderr"));
         
         TestWinrmCommand test = app.createAndManageChild(EntitySpec.create(TestWinrmCommand.class)
+            .configure(TestWinrmCommand.ITERATION_LIMIT, 1)
             .configure(TARGET_ENTITY, testEntity)
             .configure(COMMAND, cmd)
             .configure(ASSERT_ERR, makeAssertions(ImmutableMap.of(CONTAINS, "mystderr"))));
@@ -218,6 +222,7 @@ public class TestWinrmCommandTest extends BrooklynAppUnitTestSupport {
         Map<String, ?> equals255 = ImmutableMap.of(EQUALS, 255);
 
         TestWinrmCommand test = app.createAndManageChild(EntitySpec.create(TestWinrmCommand.class)
+            .configure(TestWinrmCommand.ITERATION_LIMIT, 1)
             .configure(TARGET_ENTITY, testEntity)
             .configure(COMMAND, "uptime")
             .configure(ASSERT_STATUS, makeAssertions(equalsOne, equals255)));
@@ -226,6 +231,7 @@ public class TestWinrmCommandTest extends BrooklynAppUnitTestSupport {
             app.start(ImmutableList.<Location>of());
             Asserts.shouldHaveFailedPreviously();
         } catch (Exception e) {
+            Entities.dumpInfo(app);
             Asserts.expectedFailureContains(e, "exit code expected equals 1 but found 0",
"exit code expected equals 255 but found 0");
         }
 


Mime
View raw message