You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ri...@apache.org on 2015/07/27 12:25:03 UTC

[3/4] incubator-brooklyn git commit: Fix os-details.sh for suse, and test on aws

Fix os-details.sh for suse, and test on aws


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

Branch: refs/heads/master
Commit: cee066e75d5994d4d5efbf706530048c1cde6ef5
Parents: b2d3f33
Author: Aled Sage <al...@gmail.com>
Authored: Mon Jul 13 16:32:58 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Mon Jul 13 17:36:24 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/location/basic/os-details.sh       | 12 +++++
 .../brooklyn/entity/AbstractEc2LiveTest.java    |  6 +++
 .../machine/MachineEntityEc2LiveTest.java       | 57 ++++++++++++++++++++
 3 files changed, 75 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cee066e7/core/src/main/resources/brooklyn/location/basic/os-details.sh
----------------------------------------------------------------------
diff --git a/core/src/main/resources/brooklyn/location/basic/os-details.sh b/core/src/main/resources/brooklyn/location/basic/os-details.sh
index 8021516..d6f84c3 100755
--- a/core/src/main/resources/brooklyn/location/basic/os-details.sh
+++ b/core/src/main/resources/brooklyn/location/basic/os-details.sh
@@ -56,6 +56,18 @@ if [ -z $VERSION_ID ] && [ -f /etc/debian_version ]; then
     VERSION_ID=$(cat /etc/debian_version)
 fi
 
+# Suse doesn't have os-release or lsb_release
+if [ -z $VERSION_ID ] && [ -f /etc/SuSE-release  ]; then
+    NAME=Suse
+    VERSION_MAJOR=$(cat /etc/SuSE-release | grep VERSION | sed 's/VERSION \= //')
+    VERSION_PATCH=$(cat /etc/SuSE-release | grep PATCHLEVEL | sed 's/PATCHLEVEL \= //')
+    if [ -z $VERSION_PATCH ]; then
+        VERSION_ID=${VERSION_MAJOR}
+    else
+        VERSION_ID=${VERSION_MAJOR}.${VERSION_PATCH}
+    fi
+fi
+
 # Hardware info
 # Is the loss of precision converting bytes and kilobytes to megabytes acceptable?
 # We can do floating point calculations with precision with the bc program, but it

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cee066e7/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java b/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
index 7cf3ebc..daef751 100644
--- a/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
+++ b/software/base/src/test/java/brooklyn/entity/AbstractEc2LiveTest.java
@@ -119,6 +119,12 @@ public abstract class AbstractEc2LiveTest extends BrooklynAppLiveTestSupport {
         runTest(ImmutableMap.of("imageId", "us-east-1/ami-a35a33ca", "hardwareId", SMALL_HARDWARE_ID, JcloudsLocationConfig.OPEN_IPTABLES.getName(), "true"));
     }
     
+    @Test(groups = {"Live"})
+    public void test_Suse_11sp3() throws Exception {
+        // Image: {id=us-east-1/ami-c08fcba8, providerId=ami-c08fcba8, name=suse-sles-11-sp3-v20150127-pv-ssd-x86_64, location={scope=REGION, id=us-east-1, description=us-east-1, parent=aws-ec2, iso3166Codes=[US-VA]}, os={family=suse, arch=paravirtual, version=, description=amazon/suse-sles-11-sp3-v20150127-pv-ssd-x86_64, is64Bit=true}, description=SUSE Linux Enterprise Server 11 Service Pack 3 (PV, 64-bit, SSD-Backed), version=x86_64, status=AVAILABLE[available], loginUser=root, userMetadata={owner=013907871322, rootDeviceType=ebs, virtualizationType=paravirtual, hypervisor=xen}}
+        runTest(ImmutableMap.of("imageId", "us-east-1/ami-c08fcba8", "hardwareId", SMALL_HARDWARE_ID, "loginUser", "ec2-user"));//, JcloudsLocationConfig.OPEN_IPTABLES.getName(), "true"));
+    }
+    
     protected void runTest(Map<String,?> flags) throws Exception {
         Map<String,?> allFlags = MutableMap.<String,Object>builder()
                 .put("tags", ImmutableList.of(getClass().getName()))

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cee066e7/software/base/src/test/java/brooklyn/entity/machine/MachineEntityEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/machine/MachineEntityEc2LiveTest.java b/software/base/src/test/java/brooklyn/entity/machine/MachineEntityEc2LiveTest.java
new file mode 100644
index 0000000..4f792aa
--- /dev/null
+++ b/software/base/src/test/java/brooklyn/entity/machine/MachineEntityEc2LiveTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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 brooklyn.entity.machine;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+import brooklyn.entity.AbstractEc2LiveTest;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.location.Location;
+import brooklyn.test.Asserts;
+
+public class MachineEntityEc2LiveTest extends AbstractEc2LiveTest {
+
+    @Override
+    protected void doTest(Location loc) throws Exception {
+        final MachineEntity server = app.createAndManageChild(EntitySpec.create(MachineEntity.class));
+        
+        app.start(ImmutableList.of(loc));
+        
+        Asserts.succeedsEventually(new Runnable() {
+            @Override public void run() {
+                assertNotNull(server.getAttribute(MachineEntity.UPTIME));
+                assertNotNull(server.getAttribute(MachineEntity.LOAD_AVERAGE));
+                assertNotNull(server.getAttribute(MachineEntity.CPU_USAGE));
+                assertNotNull(server.getAttribute(MachineEntity.FREE_MEMORY));
+                assertNotNull(server.getAttribute(MachineEntity.TOTAL_MEMORY));
+                assertNotNull(server.getAttribute(MachineEntity.USED_MEMORY));
+            }});
+        
+        String result = server.execCommand("MY_ENV=myval && echo start $MY_ENV");
+        assertTrue(result.contains("start myval"), "result="+result);
+    }
+    
+    @Test(enabled=false)
+    public void testDummy() {} // Convince testng IDE integration that this really does have test methods
+}