brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [6/8] incubator-brooklyn git commit: Fix SshCommandIntegrationTest
Date Thu, 13 Nov 2014 23:12:52 GMT
Fix SshCommandIntegrationTest

- Change sensor period to 100ms, from default 5 mins.
  Otherwise if first poll happens before serviceUp=true, it will
  timeout in 30 seconds without a second poll.


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

Branch: refs/heads/master
Commit: 4de878ccc4723ecf27069ff6b177576355bc1b98
Parents: d21654c
Author: Aled Sage <aled.sage@gmail.com>
Authored: Thu Nov 13 12:48:59 2014 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Thu Nov 13 23:10:04 2014 +0000

----------------------------------------------------------------------
 .../software/ssh/SshCommandIntegrationTest.java     | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4de878cc/software/base/src/test/java/brooklyn/entity/software/ssh/SshCommandIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/software/ssh/SshCommandIntegrationTest.java
b/software/base/src/test/java/brooklyn/entity/software/ssh/SshCommandIntegrationTest.java
index 09af6c2..c3358f2 100644
--- a/software/base/src/test/java/brooklyn/entity/software/ssh/SshCommandIntegrationTest.java
+++ b/software/base/src/test/java/brooklyn/entity/software/ssh/SshCommandIntegrationTest.java
@@ -36,11 +36,13 @@ import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.event.AttributeSensor;
 import brooklyn.event.basic.Sensors;
 import brooklyn.location.Location;
-import brooklyn.test.Asserts;
+import brooklyn.location.basic.SshMachineLocation;
+import brooklyn.test.EntityTestUtils;
 import brooklyn.test.entity.TestApplication;
 import brooklyn.test.entity.TestEntity;
 import brooklyn.util.collections.MutableMap;
 import brooklyn.util.config.ConfigBag;
+import brooklyn.util.time.Duration;
 
 import com.google.common.collect.ImmutableList;
 
@@ -51,12 +53,14 @@ public class SshCommandIntegrationTest {
     final static Effector<String> EFFECTOR_SAY_HI = Effectors.effector(String.class,
"sayHi").buildAbstract();
 
     private TestApplication app;
+    private SshMachineLocation machine;
     private EntityLocal entity;
     
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         app = TestApplication.Factory.newManagedInstanceForTests();
-        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(app.newLocalhostProvisioningLocation().obtain()));
+        machine = app.newLocalhostProvisioningLocation().obtain();
+        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
         app.start(ImmutableList.<Location>of());
     }
 
@@ -70,18 +74,14 @@ public class SshCommandIntegrationTest {
         File tempFile = File.createTempFile("testSshCommand", "txt");
         tempFile.deleteOnExit();
         new SshCommandSensor<String>(ConfigBag.newInstance()
+                .configure(SshCommandSensor.SENSOR_PERIOD, Duration.millis(100))
                 .configure(SshCommandSensor.SENSOR_NAME, SENSOR_STRING.getName())
                 .configure(SshCommandSensor.SENSOR_COMMAND, "echo foo > "+tempFile.getAbsolutePath()+"\n"
                     + "wc "+tempFile.getAbsolutePath()))
             .apply(entity);
         entity.setAttribute(Attributes.SERVICE_UP, true);
 
-        Asserts.succeedsEventually(new Runnable() {
-            public void run() {
-                String val = entity.getAttribute(SENSOR_STRING);
-                assertTrue(val != null);
-            }});
-        String val = entity.getAttribute(SENSOR_STRING);
+        String val = EntityTestUtils.assertAttributeEventuallyNonNull(entity, SENSOR_STRING);
         assertTrue(val.contains("1"), "val="+val);
         String[] counts = val.trim().split("\\s+");
         Assert.assertEquals(counts.length, 4, "val="+val);


Mime
View raw message