brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/4] brooklyn-server git commit: Add/improve jclouds live tests
Date Mon, 19 Dec 2016 15:51:10 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 3b4f394fc -> 5f1588ed2


Add/improve jclouds live tests


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

Branch: refs/heads/master
Commit: e0a9d53f3bab07107ced8612337baa20450c8f4a
Parents: 3b4f394
Author: Aled Sage <aled.sage@gmail.com>
Authored: Fri Dec 16 14:02:52 2016 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Mon Dec 19 11:09:05 2016 +0000

----------------------------------------------------------------------
 .../jclouds/AbstractJcloudsLiveTest.java        | 10 ++-
 .../jclouds/JcloudsWinrmingLiveTest.java        | 42 +++++++++--
 .../provider/AwsEc2LocationLiveTest.java        | 11 ++-
 .../jclouds/provider/GceLocationLiveTest.java   | 74 ++++++++++++++++++++
 .../provider/SoftlayerLocationLiveTest.java     | 65 +++++++++++++++++
 5 files changed, 192 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0a9d53f/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsLiveTest.java
b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsLiveTest.java
index f2b79d2..706d308 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsLiveTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/AbstractJcloudsLiveTest.java
@@ -22,6 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 
+import java.net.InetAddress;
 import java.util.List;
 import java.util.Map;
 
@@ -144,7 +145,14 @@ public class AbstractJcloudsLiveTest {
     }
 
     protected void assertWinrmable(WinRmMachineLocation machine) {
-        WinRmToolResponse result = machine.executeCommand(ImmutableList.of("echo mySimpleWinrmCmd"));
+        // Assumes that tests are letting Brooklyn or the cloud auto-generate the password,
so ok to log it.
+        // If the assertion fails, we want to know that it had a plausible-looking password
etc.
+        WinRmToolResponse result;
+        try {
+            result = machine.executeCommand(ImmutableList.of("echo mySimpleWinrmCmd"));
+        } catch (Exception e) {
+            throw new RuntimeException("Error executing WinRM command on " + machine + "
with config " + machine.config().getAllLocalRaw(), e);
+        }
         assertEquals(result.getStatusCode(), 0, "stdout="+result.getStdOut()+"; stderr="+result.getStdErr());
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0a9d53f/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsWinrmingLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsWinrmingLiveTest.java
b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsWinrmingLiveTest.java
index 1c3e63e..df9fefc 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsWinrmingLiveTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsWinrmingLiveTest.java
@@ -18,30 +18,60 @@
  */
 package org.apache.brooklyn.location.jclouds;
 
+import java.util.Map;
+
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.jclouds.compute.domain.OsFamily;
+import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
 
 /**
  * Tests the initial WinRM command execution, for a VM provisioned through jclouds.
  */
 public class JcloudsWinrmingLiveTest extends AbstractJcloudsLiveTest {
 
-    public static final String AWS_EC2_LOCATION_SPEC = "jclouds:" + AWS_EC2_PROVIDER + ":"
+ AWS_EC2_EUWEST_REGION_NAME;
+    // TODO GCE fails with the default user ("Administrator").
+    //  - https://issues.apache.org/jira/browse/BROOKLYN-415 (worked around with `loginUser:
myname`)
+    
+    // TODO Softlayer provisioning fails (therefore not included):
+    //     new Object[] { SOFTLAYER_LOCATION_SPEC, null, ImmutableMap.of(JcloudsLocation.IMAGE_ID.getName(),
SOFTLAYER_IMAGE_ID, JcloudsLocation.VM_NAME_MAX_LENGTH.getName(), 15) }
+    //
+    // - https://issues.apache.org/jira/browse/BROOKLYN-414 (worked around with `vmNameMaxLength:
15`)
+    // - https://issues.apache.org/jira/browse/BROOKLYN-413
+    // - https://issues.apache.org/jira/browse/BROOKLYN-411
+
+    public static final String AWS_EC2_LOCATION_SPEC = "jclouds:" + AWS_EC2_PROVIDER + ":"
+ AWS_EC2_USEAST_REGION_NAME;
     public static final String AWS_EC2_IMAGE_NAME_REGEX = "Windows_Server-2012-R2_RTM-English-64Bit-Base-.*";
 
-    @Test(groups = {"Live"})
-    public void testCreatesWindowsVm() throws Exception {
-        jcloudsLocation = (JcloudsLocation) managementContext.getLocationRegistry().getLocationManaged(AWS_EC2_LOCATION_SPEC);
-        
+    public static final String GCE_LOCATION_SPEC = "jclouds:" + GCE_PROVIDER + ":" + GCE_USCENTRAL_REGION_NAME;
+    public static final String GCE_IMAGE_NAME_REGEX = "windows-server-2012-r2-.*";
+
+    public static final String SOFTLAYER_LOCATION_SPEC = "jclouds:" + SOFTLAYER_PROVIDER;
+    public static final String SOFTLAYER_IMAGE_ID = "WIN_2012-STD-R2_64";
+
+    @DataProvider(name = "cloudAndImageNames")
+    public Object[][] cloudAndImageNames() {
+        return new Object[][] {
+                new Object[] { AWS_EC2_LOCATION_SPEC, AWS_EC2_IMAGE_NAME_REGEX, ImmutableMap.of()
},
+                new Object[] { GCE_LOCATION_SPEC, GCE_IMAGE_NAME_REGEX, ImmutableMap.of(JcloudsLocation.LOGIN_USER.getName(),
"myname") },
+            };
+    }
+
+    @Test(groups = "Live", dataProvider="cloudAndImageNames")
+    public void testCreatesWindowsVm(String locationSpec, String imageNameRegex, Map<String,
?> additionalConfig) throws Exception {
+        jcloudsLocation = (JcloudsLocation) managementContext.getLocationRegistry().getLocationManaged(locationSpec);
+
         JcloudsWinRmMachineLocation machine = obtainWinrmMachine(MutableMap.<String,Object>builder()
                 .putIfAbsent("inboundPorts", ImmutableList.of(5986, 5985, 3389))
-                .put(JcloudsLocation.IMAGE_NAME_REGEX.getName(), AWS_EC2_IMAGE_NAME_REGEX)
+                .put(JcloudsLocation.IMAGE_NAME_REGEX.getName(), imageNameRegex)
                 .put(JcloudsLocation.USE_JCLOUDS_SSH_INIT.getName(), false)
                 .put(JcloudsLocation.OS_FAMILY_OVERRIDE.getName(), OsFamily.WINDOWS)
+                .putAll(additionalConfig != null ? additionalConfig : ImmutableMap.<String,
Object>of())
                 .build());
         assertWinrmable(machine);
     }
+    
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0a9d53f/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/AwsEc2LocationLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/AwsEc2LocationLiveTest.java
b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/AwsEc2LocationLiveTest.java
index 6644645..9ebd2e8 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/AwsEc2LocationLiveTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/AwsEc2LocationLiveTest.java
@@ -21,15 +21,20 @@ package org.apache.brooklyn.location.jclouds.provider;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
+/**
+ * Tests basic provisioning to aws-ec2.
+ * 
+ * Requires AWS credentials be set up in {@code ~/.brooklyn/brooklyn.properties}.
+ */
 public class AwsEc2LocationLiveTest extends AbstractJcloudsLocationTest {
 
     private static final String PROVIDER = "aws-ec2";
     private static final String EUWEST_REGION_NAME = "eu-west-1";
     private static final String USEAST_REGION_NAME = "us-east-1";
-    private static final String EUWEST_IMAGE_ID = EUWEST_REGION_NAME+"/"+"ami-89def4fd";
// RightImage_CentOS_5.4_i386_v5.5.9_EBS
-    private static final String USEAST_IMAGE_ID = USEAST_REGION_NAME+"/"+"ami-2342a94a";
// RightImage_CentOS_5.4_i386_v5.5.9_EBS
+    private static final String EUWEST_IMAGE_ID = EUWEST_REGION_NAME+"/"+"ami-69841c1e";
// RightImage_CentOS_7.0_x64_v14.2.1_HVM_EBS
+    private static final String USEAST_IMAGE_ID = USEAST_REGION_NAME+"/"+"ami-5492ba3c";
// RightImage_CentOS_7.0_x64_v14.2.1_HVM_EBS
     private static final String IMAGE_OWNER = "411009282317";
-    private static final String IMAGE_PATTERN = "RightImage_CentOS_5.4_i386_v5.5.9_EBS";
+    private static final String IMAGE_PATTERN = "RightImage_CentOS_7.0_x64_v14.2.1.*";
 
     public AwsEc2LocationLiveTest() {
         super(PROVIDER);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0a9d53f/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GceLocationLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GceLocationLiveTest.java
b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GceLocationLiveTest.java
new file mode 100644
index 0000000..89906f1
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/GceLocationLiveTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.location.jclouds.provider;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.testng.annotations.DataProvider;
+
+/**
+ * Tests basic provisioning to GCE.
+ * 
+ * Requires AWS credentials be set up in {@code ~/.brooklyn/brooklyn.properties}.
+ */
+public class GceLocationLiveTest extends AbstractJcloudsLocationTest {
+
+    // TODO Would be nice to support short-form of imageId and hardwareId!
+    
+    private static final String PROVIDER = "google-compute-engine";
+    private static final String IMAGE_ID = "https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20161129";
+    private static final String IMAGE_PATTERN = "centos-6-.*";
+    private static final String REGION_NAME = null;
+    private static final String IMAGE_OWNER = null;
+    
+    protected BrooklynProperties brooklynProperties;
+    protected ManagementContext ctx;
+    
+    protected TestApplication app;
+    protected Location jcloudsLocation;
+    
+    public GceLocationLiveTest() {
+        super(PROVIDER);
+    }
+
+    @Override
+    @DataProvider(name = "fromImageId")
+    public Object[][] cloudAndImageIds() {
+        return new Object[][] {
+                new Object[] { REGION_NAME, IMAGE_ID, IMAGE_OWNER }
+            };
+    }
+
+    // For GCE, use "imageNamePattern" instead
+    @Override
+    @DataProvider(name = "fromImageDescriptionPattern")
+    public Object[][] cloudAndImageDescriptionPatterns() {
+        return new Object[][] {};
+    }
+
+    @Override
+    @DataProvider(name = "fromImageNamePattern")
+    public Object[][] cloudAndImageNamePatterns() {
+        return new Object[][] {
+                new Object[] { REGION_NAME, IMAGE_PATTERN, IMAGE_OWNER }
+            };
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/e0a9d53f/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/SoftlayerLocationLiveTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/SoftlayerLocationLiveTest.java
b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/SoftlayerLocationLiveTest.java
new file mode 100644
index 0000000..8c6fe3c
--- /dev/null
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/provider/SoftlayerLocationLiveTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.location.jclouds.provider;
+
+import org.testng.annotations.DataProvider;
+
+/**
+ * Tests basic provisioning to Softlayer.
+ * 
+ * Requires AWS credentials be set up in {@code ~/.brooklyn/brooklyn.properties}.
+ */
+public class SoftlayerLocationLiveTest extends AbstractJcloudsLocationTest {
+
+    private static final String PROVIDER = "softlayer";
+    private static final String IMAGE_ID = "CENTOS_6_64"; // Image: {id=CENTOS_6_64, providerId=CENTOS_6_64,
os={family=centos, version=6.5, description=CentOS / CentOS / 6.5-64 LAMP for Bare Metal,
is64Bit=true}, description=CENTOS_6_64, status=AVAILABLE, loginUser=root}
+    private static final String IMAGE_PATTERN = "CENTOS_6_64.*";
+    private static final String REGION_NAME = null;//FIXME "ams06";
+    private static final String IMAGE_OWNER = null;
+    
+//    public static final int MAX_TAG_LENGTH = 20;
+//    public static final int MAX_VM_NAME_LENGTH = 30;
+
+    public SoftlayerLocationLiveTest() {
+        super(PROVIDER);
+    }
+
+    @Override
+    @DataProvider(name = "fromImageId")
+    public Object[][] cloudAndImageIds() {
+        return new Object[][] {
+                new Object[] { REGION_NAME, IMAGE_ID, IMAGE_OWNER }
+            };
+    }
+
+    @Override
+    @DataProvider(name = "fromImageDescriptionPattern")
+    public Object[][] cloudAndImageDescriptionPatterns() {
+        return new Object[][] {
+                new Object[] { REGION_NAME, IMAGE_PATTERN, IMAGE_OWNER }
+            };
+    }
+
+    // For Softlayer, use "imageDescriptionPattern" instead
+    @Override
+    @DataProvider(name = "fromImageDescriptionPattern")
+    public Object[][] cloudAndImageNamePatterns() {
+        return new Object[][] {};
+    }
+}


Mime
View raw message