brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [02/12] git commit: Test rebinding SshFeed
Date Thu, 25 Sep 2014 22:49:26 GMT
Test rebinding SshFeed


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

Branch: refs/heads/master
Commit: 05df686fe8e1f9b9ea768fd9502337e810c1f906
Parents: 9fe95f9
Author: Aled Sage <aled.sage@gmail.com>
Authored: Tue Aug 5 12:04:50 2014 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Thu Sep 4 08:46:49 2014 +0100

----------------------------------------------------------------------
 .../brooklyn/entity/rebind/RebindFeedTest.java  | 45 ++++++++++++++++++++
 1 file changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/05df686f/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
index a0b5f04..744f948 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindFeedTest.java
@@ -38,11 +38,18 @@ import brooklyn.event.feed.function.FunctionPollConfig;
 import brooklyn.event.feed.http.HttpFeed;
 import brooklyn.event.feed.http.HttpPollConfig;
 import brooklyn.event.feed.http.HttpValueFunctions;
+import brooklyn.event.feed.ssh.SshFeed;
+import brooklyn.event.feed.ssh.SshPollConfig;
+import brooklyn.event.feed.ssh.SshValueFunctions;
+import brooklyn.location.Location;
+import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import brooklyn.location.basic.SshMachineLocation;
 import brooklyn.test.EntityTestUtils;
 import brooklyn.test.entity.TestEntity;
 import brooklyn.test.entity.TestEntityImpl;
 import brooklyn.util.http.BetterMockWebServer;
 
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 import com.google.common.util.concurrent.Callables;
 import com.google.mockwebserver.MockResponse;
@@ -112,6 +119,30 @@ public class RebindFeedTest extends RebindTestFixtureWithApp {
         EntityTestUtils.assertAttributeEqualsEventually(newEntity, SENSOR_INT, (Integer)1);
     }
     
+    @Test(groups="Integration")
+    public void testSshFeedRegisteredInStartIsPersisted() throws Exception {
+        LocalhostMachineProvisioningLocation origLoc = origApp.newLocalhostProvisioningLocation();
+        SshMachineLocation origMachine = origLoc.obtain();
+
+        TestEntity origEntity = origApp.createAndManageChild(EntitySpec.create(TestEntity.class).impl(MyEntityWithSshFeedImpl.class)
+                .location(origMachine));
+        
+        origApp.start(ImmutableList.<Location>of());
+
+        EntityTestUtils.assertAttributeEqualsEventually(origEntity, SENSOR_INT, (Integer)0);
+        assertEquals(origEntity.getFeedSupport().getFeeds().size(), 1);
+
+        newApp = rebind(false);
+        TestEntity newEntity = (TestEntity) Iterables.getOnlyElement(newApp.getChildren());
+        
+        Collection<Feed> newFeeds = newEntity.getFeedSupport().getFeeds();
+        assertEquals(newFeeds.size(), 1);
+        
+        // Expect the feed to still be polling
+        newEntity.setAttribute(SENSOR_INT, null);
+        EntityTestUtils.assertAttributeEqualsEventually(newEntity, SENSOR_INT, (Integer)0);
+    }
+
     public static class MyEntityWithHttpFeedImpl extends TestEntityImpl {
         public static final ConfigKey<URL> BASE_URL = ConfigKeys.newConfigKey(URL.class,
"rebindFeedTest.baseUrl");
         
@@ -143,4 +174,18 @@ public class RebindFeedTest extends RebindTestFixtureWithApp {
                     .build());
         }
     }
+    
+    public static class MyEntityWithSshFeedImpl extends TestEntityImpl {
+        @Override
+        public void start(Collection<? extends Location> locs) {
+            // TODO Auto-generated method stub
+            super.start(locs);
+            addFeed(SshFeed.builder()
+                    .entity(this)
+                    .poll(new SshPollConfig<Integer>(SENSOR_INT)
+                        .command("true")
+                        .onSuccess(SshValueFunctions.exitStatus()))
+                    .build());
+        }
+    }
 }


Mime
View raw message