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/02/01 18:49:50 UTC

[46/50] brooklyn-server git commit: Deprecate BrooklynMachinePool

Deprecate BrooklynMachinePool

- made start at fixing live test, but it still fails; marked as WIP

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

Branch: refs/heads/0.6.0
Commit: 7029c372c5ddd90dc2c70bd7ed8a690d81082cc6
Parents: 408296c
Author: Aled Sage <al...@gmail.com>
Authored: Fri Nov 15 15:23:48 2013 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Nov 15 15:23:48 2013 +0000

----------------------------------------------------------------------
 .../location/jclouds/BrooklynMachinePool.java   |  4 ++
 .../location/jclouds/pool/MachinePool.java      |  3 ++
 .../pool/JcloudsMachinePoolLiveTest.java        | 51 ++++++++++++++++----
 3 files changed, 49 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7029c372/locations/jclouds/src/main/java/brooklyn/location/jclouds/BrooklynMachinePool.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/BrooklynMachinePool.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/BrooklynMachinePool.java
index 3e7eee8..66ed9e5 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/BrooklynMachinePool.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/BrooklynMachinePool.java
@@ -24,6 +24,10 @@ import brooklyn.util.task.BasicExecutionContext;
 import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableList;
 
+/**
+ * @deprecated since 0.6.0; never used in production setting, and thus of dubious value; best avoided as unlikely to be supported in future versions
+ */
+@Deprecated
 public class BrooklynMachinePool extends MachinePool {
 
     private static final Logger log = LoggerFactory.getLogger(BrooklynMachinePool.class);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7029c372/locations/jclouds/src/main/java/brooklyn/location/jclouds/pool/MachinePool.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/pool/MachinePool.java b/locations/jclouds/src/main/java/brooklyn/location/jclouds/pool/MachinePool.java
index 2f2588e..971867b 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/pool/MachinePool.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/pool/MachinePool.java
@@ -47,7 +47,10 @@ import com.google.common.collect.Iterables;
  * If underlying provisioning/destroying operations fail, the pool
  * currently may be in an unknown state, currently.
  * If more robustness is needed this can be added.
+ * 
+ * @deprecated since 0.6.0; never used in production setting, and thus of dubious value; best avoided as unlikely to be supported in future versions
  */
+@Deprecated
 public class MachinePool {
     
     private static final Logger log = LoggerFactory.getLogger(MachinePool.class);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7029c372/locations/jclouds/src/test/java/brooklyn/location/jclouds/pool/JcloudsMachinePoolLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/brooklyn/location/jclouds/pool/JcloudsMachinePoolLiveTest.java b/locations/jclouds/src/test/java/brooklyn/location/jclouds/pool/JcloudsMachinePoolLiveTest.java
index 4858bfe..8cb1aa7 100644
--- a/locations/jclouds/src/test/java/brooklyn/location/jclouds/pool/JcloudsMachinePoolLiveTest.java
+++ b/locations/jclouds/src/test/java/brooklyn/location/jclouds/pool/JcloudsMachinePoolLiveTest.java
@@ -10,13 +10,16 @@ import org.jclouds.sshj.config.SshjSshClientModule;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import brooklyn.location.jclouds.pool.JcloudsMachinePoolLiveTest;
-import brooklyn.location.jclouds.pool.MachinePool;
-import brooklyn.location.jclouds.pool.MachinePoolPredicates;
-import brooklyn.location.jclouds.pool.MachineSet;
-import brooklyn.location.jclouds.pool.ReusableMachineTemplate;
+import brooklyn.config.BrooklynProperties;
+import brooklyn.entity.basic.Entities;
+import brooklyn.location.jclouds.JcloudsLocation;
+import brooklyn.management.internal.LocalManagementContext;
+
+import com.google.common.collect.ImmutableSet;
 
 public class JcloudsMachinePoolLiveTest {
 
@@ -56,12 +59,42 @@ public class JcloudsMachinePoolLiveTest {
         return result;
     }
 
-    @Test(groups="Live")
-    public void buildClaimAndDestroy() {
-        ComputeServiceContext context = ContextBuilder.newBuilder("aws-ec2")
+    private LocalManagementContext managementContext;
+    private JcloudsLocation jcloudsLocation;
+    private ComputeServiceContext context;
+    
+    @BeforeMethod(alwaysRun=true)
+    public void setUp() throws Exception {
+        // Don't let any defaults from brooklyn.properties (except credentials) interfere with test
+        BrooklynProperties brooklynProperties = BrooklynProperties.Factory.newDefault();
+        for (String key : ImmutableSet.copyOf(brooklynProperties.asMapWithStringKeys().keySet())) {
+            if (key.startsWith("brooklyn.jclouds") && !(key.endsWith("identity") || key.endsWith("credential"))) {
+                brooklynProperties.remove(key);
+            }
+            
+            // Also removes scriptHeader (e.g. if doing `. ~/.bashrc` and `. ~/.profile`, then that can cause "stdin: is not a tty")
+            if (key.startsWith("brooklyn.ssh")) {
+                brooklynProperties.remove(key);
+            }
+        }
+        
+        managementContext = new LocalManagementContext(brooklynProperties);
+        jcloudsLocation = (JcloudsLocation) managementContext.getLocationRegistry().resolve("aws-ec2:eu-west-1");
+        
+        context = ContextBuilder.newBuilder("aws-ec2")
                 .modules(Arrays.asList(new SshjSshClientModule(), new SLF4JLoggingModule()))
-                .credentials(getRequiredSystemProperty("identity"), getRequiredSystemProperty("credential"))
+                .credentials(jcloudsLocation.getIdentity(), jcloudsLocation.getCredential())
                 .build(ComputeServiceContext.class);
+    }
+    
+    @AfterMethod(alwaysRun=true)
+    public void tearDown() throws Exception {
+        if (managementContext != null) Entities.destroyAll(managementContext);
+        if (context != null) context.close();
+    }
+    
+    @Test(groups={"Live","WIP"})
+    public void buildClaimAndDestroy() {
         ComputeService svc = context.getComputeService();
         SamplePool p = new SamplePool(svc);
         log.info("buildClaimAndDestroy: created pool");