You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/01/26 21:10:47 UTC

[1/4] incubator-brooklyn git commit: change-version: improve echo msg

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master f6134deca -> e14a16b72


change-version: improve echo msg

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

Branch: refs/heads/master
Commit: ba237881e6b51104fc496a22f35f93f3f0beb2dd
Parents: b50e176
Author: Aled Sage <al...@gmail.com>
Authored: Mon Jan 25 17:26:15 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Jan 25 17:26:15 2016 +0000

----------------------------------------------------------------------
 brooklyn-dist/release/change-version.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba237881/brooklyn-dist/release/change-version.sh
----------------------------------------------------------------------
diff --git a/brooklyn-dist/release/change-version.sh b/brooklyn-dist/release/change-version.sh
index 280c245..4b77749 100755
--- a/brooklyn-dist/release/change-version.sh
+++ b/brooklyn-dist/release/change-version.sh
@@ -66,5 +66,5 @@ if [ ${FILES_COUNT} -ne 0 ]; then
     sed -i.bak -e "/${VERSION_MARKER_NL}/{n;s/${CURRENT_VERSION}/${NEW_VERSION}/g;}" $FILES
 fi
 
-echo "Changed ${CURRENT_VERSION} to ${NEW_VERSION} for "${FILES_COUNT}" files"
+echo "Changed ${VERSION_MARKER} from ${CURRENT_VERSION} to ${NEW_VERSION} for "${FILES_COUNT}" files"
 echo "(Do a \`find . -name \"*.bak\" -delete\`  to delete the backup files.)"


[4/4] incubator-brooklyn git commit: This closes #1173

Posted by he...@apache.org.
This closes #1173


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

Branch: refs/heads/master
Commit: e14a16b72e663a84aa8b567908c4fdf3b97b5b77
Parents: f6134de 3070055
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Jan 26 20:10:28 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Jan 26 20:10:28 2016 +0000

----------------------------------------------------------------------
 brooklyn-dist/release/change-version.sh         |   2 +-
 .../apache/brooklyn/feed/ssh/SshPollConfig.java |  56 +++++-
 .../feed/ssh/SshFeedIntegrationTest.java        |  25 ++-
 .../apache/brooklyn/feed/ssh/SshFeedTest.java   | 188 +++++++++++++++++++
 4 files changed, 252 insertions(+), 19 deletions(-)
----------------------------------------------------------------------



[2/4] incubator-brooklyn git commit: SshFeedIntegrationTest: fix compile warnings

Posted by he...@apache.org.
SshFeedIntegrationTest: fix compile warnings

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

Branch: refs/heads/master
Commit: 7f302cab74aeb266bfc06f234c5062199ae98caf
Parents: ba23788
Author: Aled Sage <al...@gmail.com>
Authored: Mon Jan 25 17:27:51 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Jan 25 17:27:51 2016 +0000

----------------------------------------------------------------------
 .../feed/ssh/SshFeedIntegrationTest.java        | 25 +++++++++-----------
 1 file changed, 11 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7f302cab/brooklyn-server/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedIntegrationTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedIntegrationTest.java b/brooklyn-server/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedIntegrationTest.java
index 4559247..416ab9d 100644
--- a/brooklyn-server/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedIntegrationTest.java
+++ b/brooklyn-server/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedIntegrationTest.java
@@ -26,7 +26,7 @@ import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityAsserts;
 import org.apache.brooklyn.core.entity.EntityInternal;
 import org.apache.brooklyn.core.entity.EntityInternal.FeedSupport;
 import org.apache.brooklyn.core.sensor.Sensors;
@@ -37,14 +37,11 @@ import org.apache.brooklyn.feed.ssh.SshFeedIntegrationTest;
 import org.apache.brooklyn.feed.ssh.SshPollConfig;
 import org.apache.brooklyn.feed.ssh.SshPollValue;
 import org.apache.brooklyn.feed.ssh.SshValueFunctions;
-import org.apache.brooklyn.test.EntityTestUtils;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.stream.Streams;
 import org.apache.brooklyn.util.text.StringFunctions;
 import org.apache.brooklyn.util.text.StringPredicates;
-import org.apache.brooklyn.util.time.Duration;
-import org.apache.brooklyn.util.time.Time;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
@@ -68,7 +65,7 @@ public class SshFeedIntegrationTest extends BrooklynAppUnitTestSupport {
 
     private LocalhostMachineProvisioningLocation loc;
     private SshMachineLocation machine;
-    private EntityLocal entity;
+    private TestEntity entity;
     private SshFeed feed;
     
     @BeforeMethod(alwaysRun=true)
@@ -104,7 +101,7 @@ public class SshFeedIntegrationTest extends BrooklynAppUnitTestSupport {
                         .onSuccess(SshValueFunctions.stdout()))
                 .build();
         
-        EntityTestUtils.assertAttributeEventuallyNonNull(entity2, SENSOR_STRING);
+        EntityAsserts.assertAttributeEventuallyNonNull(entity2, SENSOR_STRING);
         String val = entity2.getAttribute(SENSOR_STRING);
         Assert.assertTrue(val.contains("hello"), "val="+val);
         Assert.assertEquals(val.trim(), "hello");
@@ -135,7 +132,7 @@ public class SshFeedIntegrationTest extends BrooklynAppUnitTestSupport {
                         .onSuccess(SshValueFunctions.exitStatus()))
                 .build();
 
-        EntityTestUtils.assertAttributeEqualsEventually(entity, SENSOR_INT, 123);
+        EntityAsserts.assertAttributeEqualsEventually(entity, SENSOR_INT, 123);
     }
     
     @Test(groups="Integration")
@@ -148,7 +145,7 @@ public class SshFeedIntegrationTest extends BrooklynAppUnitTestSupport {
                         .onSuccess(SshValueFunctions.stdout()))
                 .build();
         
-        EntityTestUtils.assertAttributeEventually(entity, SENSOR_STRING, 
+        EntityAsserts.assertAttributeEventually(entity, SENSOR_STRING, 
             Predicates.compose(Predicates.equalTo("hello"), StringFunctions.trim()));
     }
 
@@ -164,7 +161,7 @@ public class SshFeedIntegrationTest extends BrooklynAppUnitTestSupport {
                         .onFailure(SshValueFunctions.stderr()))
                 .build();
         
-        EntityTestUtils.assertAttributeEventually(entity, SENSOR_STRING, StringPredicates.containsLiteral(cmd));
+        EntityAsserts.assertAttributeEventually(entity, SENSOR_STRING, StringPredicates.containsLiteral(cmd));
     }
     
     @Test(groups="Integration")
@@ -181,7 +178,7 @@ public class SshFeedIntegrationTest extends BrooklynAppUnitTestSupport {
                             }}))
                 .build();
         
-        EntityTestUtils.assertAttributeEventually(entity, SENSOR_STRING, StringPredicates.containsLiteral("Exit status 123"));
+        EntityAsserts.assertAttributeEventually(entity, SENSOR_STRING, StringPredicates.containsLiteral("Exit status 123"));
     }
     
     @Test(groups="Integration")
@@ -202,10 +199,10 @@ public class SshFeedIntegrationTest extends BrooklynAppUnitTestSupport {
             }));
 
         // TODO would be nice to hook in and assert no errors
-        EntityTestUtils.assertAttributeEqualsContinually(entity2, SENSOR_STRING, null);
+        EntityAsserts.assertAttributeEqualsContinually(entity2, SENSOR_STRING, null);
 
         entity2.sensors().set(Attributes.SERVICE_UP, true);
-        EntityTestUtils.assertAttributeEventually(entity2, SENSOR_STRING, StringPredicates.containsLiteral("hello"));
+        EntityAsserts.assertAttributeEventually(entity2, SENSOR_STRING, StringPredicates.containsLiteral("hello"));
     }
 
     
@@ -235,10 +232,10 @@ public class SshFeedIntegrationTest extends BrooklynAppUnitTestSupport {
                         .onSuccess(SshValueFunctions.stdout()))
                 .build();
         
-        EntityTestUtils.assertAttributeEventuallyNonNull(entity2, SENSOR_STRING);        
+        EntityAsserts.assertAttributeEventuallyNonNull(entity2, SENSOR_STRING);
         final String val1 = assertDifferentOneInOutput(entity2);
         
-        EntityTestUtils.assertAttributeEventually(entity2, SENSOR_STRING, Predicates.not(Predicates.equalTo(val1)));        
+        EntityAsserts.assertAttributeEventually(entity2, SENSOR_STRING, Predicates.not(Predicates.equalTo(val1)));        
         final String val2 = assertDifferentOneInOutput(entity2);
         log.info("vals from dynamic sensors are: "+val1.trim()+" and "+val2.trim());
     }


[3/4] incubator-brooklyn git commit: SshFeed: if same cmd, then share result

Posted by he...@apache.org.
SshFeed: if same cmd, then share result

- Fix the avoidance of executing the same command repeatedly, if an
  SshFeed is configured with multiple sensors that use the output
  of the same command.

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

Branch: refs/heads/master
Commit: 3070055048e4cd6cd2544461bf7a42aa9884732d
Parents: 7f302ca
Author: Aled Sage <al...@gmail.com>
Authored: Mon Jan 25 17:35:11 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Jan 25 17:35:11 2016 +0000

----------------------------------------------------------------------
 .../apache/brooklyn/feed/ssh/SshPollConfig.java |  56 +++++-
 .../apache/brooklyn/feed/ssh/SshFeedTest.java   | 188 +++++++++++++++++++
 2 files changed, 240 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/30700550/brooklyn-server/core/src/main/java/org/apache/brooklyn/feed/ssh/SshPollConfig.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/main/java/org/apache/brooklyn/feed/ssh/SshPollConfig.java b/brooklyn-server/core/src/main/java/org/apache/brooklyn/feed/ssh/SshPollConfig.java
index 8fec87f..7839fde 100644
--- a/brooklyn-server/core/src/main/java/org/apache/brooklyn/feed/ssh/SshPollConfig.java
+++ b/brooklyn-server/core/src/main/java/org/apache/brooklyn/feed/ssh/SshPollConfig.java
@@ -18,6 +18,8 @@
  */
 package org.apache.brooklyn.feed.ssh;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -29,6 +31,7 @@ import org.apache.brooklyn.core.feed.PollConfig;
 import org.apache.brooklyn.util.collections.MutableList;
 import org.apache.brooklyn.util.collections.MutableMap;
 
+import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicate;
 import com.google.common.base.Supplier;
@@ -67,7 +70,12 @@ public class SshPollConfig<T> extends PollConfig<SshPollValue, T, SshPollConfig<
     public Map<String, String> getEnv() {
         return getEnvSupplier().get();
     }
+    
+    @SuppressWarnings("unused")
     public Supplier<Map<String,String>> getEnvSupplier() {
+        if (true) return new CombiningEnvSupplier(dynamicEnvironmentSupplier);
+        
+        // TODO Kept in case it's persisted; new code will not use this.
         return new Supplier<Map<String,String>>() {
             @Override
             public Map<String, String> get() {
@@ -82,13 +90,53 @@ public class SshPollConfig<T> extends PollConfig<SshPollValue, T, SshPollConfig<
                 }
                 return result;
             }
+            private void mergeEnvMaps(Map<String,String> supplied, Map<String,String> target) {
+                if (supplied==null) return;
+                // as the value is a string there is no need to look at deep merge behaviour
+                target.putAll(supplied);
+            }
         };
     }
     
-    protected void mergeEnvMaps(Map<String,String> supplied, Map<String,String> target) {
-        if (supplied==null) return;
-        // as the value is a string there is no need to look at deep merge behaviour
-        target.putAll(supplied);
+    private static class CombiningEnvSupplier implements Supplier<Map<String,String>> {
+        private final List<Supplier<Map<String, String>>> dynamicEnvironmentSupplier;
+        
+        public CombiningEnvSupplier(List<Supplier<Map<String,String>>> dynamicEnvironmentSupplier) {
+            this.dynamicEnvironmentSupplier = checkNotNull(dynamicEnvironmentSupplier, "dynamicEnvironmentSupplier");
+        }
+        @Override
+        public Map<String, String> get() {
+            Map<String,String> result = MutableMap.of();
+            for (Supplier<Map<String, String>> envS: dynamicEnvironmentSupplier) {
+                if (envS!=null) {
+                    Map<String, String> envM = envS.get();
+                    if (envM!=null) {
+                        mergeEnvMaps(envM, result);
+                    }
+                }
+            }
+            return result;
+        }
+        protected void mergeEnvMaps(Map<String,String> supplied, Map<String,String> target) {
+            if (supplied==null) return;
+            // as the value is a string there is no need to look at deep merge behaviour
+            target.putAll(supplied);
+        }
+        @Override
+        public int hashCode() {
+            return dynamicEnvironmentSupplier.hashCode();
+        }
+        @Override
+        public boolean equals(Object obj) {
+            if (!(obj instanceof CombiningEnvSupplier)) return false;
+            CombiningEnvSupplier o = (CombiningEnvSupplier) obj;
+            
+            return Objects.equal(dynamicEnvironmentSupplier, o.dynamicEnvironmentSupplier);
+        }
+        @Override
+        public String toString() {
+            return "CombiningEnvSupplier("+dynamicEnvironmentSupplier+")";
+        }
     }
 
     public SshPollConfig<T> command(String val) { return command(Suppliers.ofInstance(val)); }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/30700550/brooklyn-server/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedTest.java b/brooklyn-server/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedTest.java
new file mode 100644
index 0000000..a3f22dd
--- /dev/null
+++ b/brooklyn-server/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedTest.java
@@ -0,0 +1,188 @@
+/*
+ * 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.feed.ssh;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.brooklyn.api.entity.EntityLocal;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.core.sensor.Sensors;
+import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
+import org.apache.brooklyn.test.Asserts;
+import org.apache.brooklyn.util.stream.Streams;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Functions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+
+public class SshFeedTest extends BrooklynAppUnitTestSupport {
+
+    private static final Logger log = LoggerFactory.getLogger(SshFeedTest.class);
+    
+    final static AttributeSensor<String> SENSOR_STRING = Sensors.newStringSensor("aString", "");
+    final static AttributeSensor<String> SENSOR_STRING2 = Sensors.newStringSensor("aString2", "");
+
+    private LocalhostMachineProvisioningLocation loc;
+    private EntityLocal entity;
+    private SshFeed feed;
+    
+    @BeforeMethod(alwaysRun=true)
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        loc = app.newLocalhostProvisioningLocation();
+        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
+        RecordingSshMachineLocation.execScriptCalls.clear();
+    }
+
+    @AfterMethod(alwaysRun=true)
+    @Override
+    public void tearDown() throws Exception {
+        if (feed != null) feed.stop();
+        super.tearDown();
+        if (loc != null) Streams.closeQuietly(loc);
+        RecordingSshMachineLocation.execScriptCalls.clear();
+    }
+    
+    @Test(groups="Integration") // integration because slow 
+    public void testSharesCallWhenSameCommand() throws Exception {
+        final RecordingSshMachineLocation recordingMachine = mgmt.getLocationManager().createLocation(LocationSpec.create(RecordingSshMachineLocation.class));
+        app.start(ImmutableList.of(recordingMachine));
+        
+        final String cmd = "myCommand";
+        
+        feed = SshFeed.builder()
+                .period(Duration.PRACTICALLY_FOREVER)
+                .entity(entity)
+                .poll(new SshPollConfig<String>(SENSOR_STRING)
+                        .env(ImmutableMap.of("mykey", "myval"))
+                        .command(cmd)
+                        .onSuccess(Functions.constant("success")))
+                .poll(new SshPollConfig<String>(SENSOR_STRING2)
+                        .env(ImmutableMap.of("mykey", "myval"))
+                        .command(cmd)
+                        .onSuccess(Functions.constant("success2")))
+                .build();
+        
+        // Expect it to only execute once (i.e. share exec result for both sensors).
+        // Wait several seconds, in case it takes a while to do the second exec.
+        Asserts.succeedsEventually(new Runnable() {
+            public void run() {
+                assertEquals(RecordingSshMachineLocation.execScriptCalls, ImmutableList.of(ImmutableList.of(cmd)));
+            }});
+        Asserts.succeedsContinually(ImmutableMap.of("timeout", Duration.FIVE_SECONDS), new Runnable() {
+            public void run() {
+                assertEquals(RecordingSshMachineLocation.execScriptCalls, ImmutableList.of(ImmutableList.of(cmd)));
+            }});
+    }
+
+    @Test
+    public void testDifferentCallsWhenDifferentCommands() throws Exception {
+        final RecordingSshMachineLocation recordingMachine = mgmt.getLocationManager().createLocation(LocationSpec.create(RecordingSshMachineLocation.class));
+        app.start(ImmutableList.of(recordingMachine));
+        
+        final String cmd = "myCommand";
+        final String cmd2 = "myCommand2";
+        
+        feed = SshFeed.builder()
+                .period(Duration.PRACTICALLY_FOREVER)
+                .entity(entity)
+                .poll(new SshPollConfig<String>(SENSOR_STRING)
+                        .command(cmd)
+                        .onSuccess(Functions.constant("success")))
+                .poll(new SshPollConfig<String>(SENSOR_STRING2)
+                        .command(cmd2)
+                        .onSuccess(Functions.constant("success")))
+                .build();
+        
+        // Expect it to execute the different commands (i.e. not share)
+        Asserts.succeedsEventually(new Runnable() {
+            public void run() {
+                assertEquals(ImmutableSet.copyOf(RecordingSshMachineLocation.execScriptCalls), ImmutableSet.of(ImmutableList.of(cmd), ImmutableList.of(cmd2)));
+            }});
+    }
+
+    @Test
+    public void testDifferentCallsWhenDifferentEnv() throws Exception {
+        final RecordingSshMachineLocation recordingMachine = mgmt.getLocationManager().createLocation(LocationSpec.create(RecordingSshMachineLocation.class));
+        app.start(ImmutableList.of(recordingMachine));
+        
+        final String cmd = "myCommand";
+        
+        feed = SshFeed.builder()
+                .period(Duration.PRACTICALLY_FOREVER)
+                .entity(entity)
+                .poll(new SshPollConfig<String>(SENSOR_STRING)
+                        .env(ImmutableMap.of("mykey", "myval"))
+                        .command(cmd)
+                        .onSuccess(Functions.constant("success")))
+                .poll(new SshPollConfig<String>(SENSOR_STRING2)
+                        .env(ImmutableMap.of("mykey", "myval2"))
+                        .command(cmd)
+                        .onSuccess(Functions.constant("success")))
+                .build();
+        
+        // Expect it to execute the command twice, with different envs (i.e. not share)
+        Asserts.succeedsEventually(new Runnable() {
+            public void run() {
+                assertEquals(RecordingSshMachineLocation.execScriptCalls, ImmutableList.of(ImmutableList.of(cmd), ImmutableList.of(cmd)));
+            }});
+    }
+
+    public static class RecordingSshMachineLocation extends SshMachineLocation {
+        public static List<List<String>> execScriptCalls = Lists.newCopyOnWriteArrayList();
+
+        @Override 
+        public int execScript(String summary, List<String> cmds) {
+            execScriptCalls.add(cmds);
+            return 0;
+        }
+        @Override 
+        public int execScript(Map<String,?> props, String summaryForLogging, List<String> cmds) {
+            execScriptCalls.add(cmds);
+            return 0;
+        }
+        @Override 
+        public int execScript(String summaryForLogging, List<String> cmds, Map<String,?> env) {
+            execScriptCalls.add(cmds);
+            return 0;
+        }
+        @Override 
+        public int execScript(Map<String,?> props, String summaryForLogging, List<String> cmds, Map<String,?> env) {
+            execScriptCalls.add(cmds);
+            return 0;
+        }
+    }
+}