You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2014/04/02 11:14:23 UTC
[11/25] forking jclouds ec2 api
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParamsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParamsTest.java
new file mode 100644
index 0000000..a58d480
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParamsTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.jclouds.ec2.binders;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.File;
+
+import org.jclouds.http.HttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code BindUserGroupsToIndexedFormParams}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class BindUserGroupsToIndexedFormParamsTest {
+ Injector injector = Guice.createInjector();
+ BindUserGroupsToIndexedFormParams binder = injector.getInstance(BindUserGroupsToIndexedFormParams.class);
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testOnlyAllIsValid() {
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ binder.bindToRequest(request, ImmutableSet.of("alpha"));
+ }
+
+ public void test() {
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ request = binder.bindToRequest(request, ImmutableSet.of("all"));
+ assertEquals(request.getPayload().getRawContent(), "UserGroup.1=all");
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testMustBeIterable() {
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ binder.bindToRequest(request, new File("foo"));
+ }
+
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testNullIsBad() {
+ HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
+ binder.bindToRequest(request, null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParamsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParamsTest.java
new file mode 100644
index 0000000..eb8e9f8
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParamsTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.jclouds.ec2.binders;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.File;
+
+import org.jclouds.ec2.domain.UserIdGroupPair;
+import org.jclouds.http.HttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code BindUserIdGroupPairToSourceSecurityGroupFormParams}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class BindUserIdGroupPairToSourceSecurityGroupFormParamsTest {
+ Injector injector = Guice.createInjector();
+ BindUserIdGroupPairToSourceSecurityGroupFormParams binder = injector
+ .getInstance(BindUserIdGroupPairToSourceSecurityGroupFormParams.class);
+
+ public void testUserIdGroupPair() {
+ UserIdGroupPair pair = new UserIdGroupPair("id", "group");
+
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ request = binder.bindToRequest(request, pair);
+ assertEquals(request.getPayload().getRawContent(), "SourceSecurityGroupOwnerId=id&SourceSecurityGroupName=group");
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testMustBeUserIdGroupPair() {
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ binder.bindToRequest(request, new File("foo"));
+ }
+
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testNullIsBad() {
+ HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
+ binder.bindToRequest(request, null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParamsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParamsTest.java
new file mode 100644
index 0000000..d816836
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParamsTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.jclouds.ec2.binders;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.File;
+
+import org.jclouds.http.HttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code BindUserIdsToIndexedFormParams}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class BindUserIdsToIndexedFormParamsTest {
+ Injector injector = Guice.createInjector();
+ BindUserIdsToIndexedFormParams binder = injector.getInstance(BindUserIdsToIndexedFormParams.class);
+
+ public void test() {
+
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ request = binder.bindToRequest(request, ImmutableSet.of("alpha", "omega"));
+ assertEquals(request.getPayload().getRawContent(), "UserId.1=alpha&UserId.2=omega");
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testMustBeIterable() {
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ binder.bindToRequest(request, new File("foo"));
+ }
+
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testNullIsBad() {
+ HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
+ binder.bindToRequest(request, null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParamsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParamsTest.java
new file mode 100644
index 0000000..8208879
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParamsTest.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 org.jclouds.ec2.binders;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.File;
+
+import org.jclouds.http.HttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code BindVolumeIdsToIndexedFormParams}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class BindVolumeIdsToIndexedFormParamsTest {
+ Injector injector = Guice.createInjector();
+ BindVolumeIdsToIndexedFormParams binder = injector.getInstance(BindVolumeIdsToIndexedFormParams.class);
+
+ public void test() {
+
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ request = binder.bindToRequest(request, new String[] { "alpha", "omega" });
+ assertEquals(request.getPayload().getRawContent(), "VolumeId.1=alpha&VolumeId.2=omega");
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testMustBeArray() {
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ binder.bindToRequest(request, new File("foo"));
+ }
+
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testNullIsBad() {
+ HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
+ binder.bindToRequest(request, null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParamTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParamTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParamTest.java
new file mode 100644
index 0000000..6ef7514
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParamTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.jclouds.ec2.binders;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertSame;
+
+import java.io.File;
+
+import org.jclouds.http.HttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code IfNotNullBindAvailabilityZoneToFormParam}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public class IfNotNullBindAvailabilityZoneToFormParamTest {
+ Injector injector = Guice.createInjector();
+ IfNotNullBindAvailabilityZoneToFormParam binder = injector
+ .getInstance(IfNotNullBindAvailabilityZoneToFormParam.class);
+
+ public void test() {
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ request = binder.bindToRequest(request, "us-east-1a");
+ assertEquals(request.getPayload().getRawContent(), "Placement.AvailabilityZone=us-east-1a");
+ }
+
+ public void testWhenNullReturnsSame() {
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ HttpRequest request2 = binder.bindToRequest(request, null);
+ assertSame(request, request2);
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testMustBeString() {
+ HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
+ binder.bindToRequest(request, new File("foo"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java
new file mode 100644
index 0000000..24e03cf
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java
@@ -0,0 +1,148 @@
+/*
+ * 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.jclouds.ec2.compute;
+
+import static org.jclouds.ec2.compute.options.EC2TemplateOptions.Builder.blockUntilRunning;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.ec2.compute.internal.BaseEC2ComputeServiceExpectTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests the compute service abstraction of the EC2 api.
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "EC2ComputeServiceExpectTest")
+public class EC2ComputeServiceExpectTest extends BaseEC2ComputeServiceExpectTest {
+
+ public void testCreateNodeWithGeneratedKeyPairAndOverriddenLoginUser() throws Exception {
+ Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+ requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+ requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+ requestResponseMap.put(describeImagesRequest, describeImagesResponse);
+ requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+ requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+ requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse);
+ requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse);
+ requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse);
+ requestResponseMap.put(runInstancesRequest, runInstancesResponse);
+ requestResponseMap.put(describeInstanceRequest, describeInstanceResponse);
+ requestResponseMap.put(describeInstanceMultiIdsRequest, describeInstanceMultiIdsResponse);
+ requestResponseMap.put(describeImageRequest, describeImagesResponse);
+ requestResponseMap.put(createTagsRequest, createTagsResponse);
+
+ ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build());
+
+ NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1,
+ blockUntilRunning(false).overrideLoginUser("ec2-user")));
+ assertEquals(node.getCredentials().getUser(), "ec2-user");
+ System.out.println(node.getImageId());
+ assertNotNull(node.getCredentials().getPrivateKey());
+ }
+
+ public void testCreateNodeWithSpecifiedName() throws Exception {
+ HttpRequest createNamedTagsRequest =
+ formSigner.filter(HttpRequest.builder()
+ .method("POST")
+ .endpoint("https://ec2.us-east-1.amazonaws.com/")
+ .addHeader("Host", "ec2.us-east-1.amazonaws.com")
+ .payload(
+ payloadFromStringWithContentType(
+ "Action=CreateTags" +
+ "&ResourceId.1=i-2baa5550" +
+ "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" +
+ "&SignatureMethod=HmacSHA256" +
+ "&SignatureVersion=2" +
+ "&Tag.1.Key=Name" +
+ "&Tag.1.Value=test-node" +
+ "&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
+ "&Version=2010-08-31" +
+ "&AWSAccessKeyId=identity",
+ "application/x-www-form-urlencoded"))
+ .build());
+
+ HttpResponse describeNamedInstanceResponse =
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResourceWithContentType(
+ "/describe_instances_running-named.xml", MediaType.APPLICATION_XML)).build();
+
+
+ Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+ requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+ requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+ requestResponseMap.put(describeImagesRequest, describeImagesResponse);
+ requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+ requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+ requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse);
+ requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse);
+ requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse);
+ requestResponseMap.put(runInstancesRequest, runInstancesResponse);
+ requestResponseMap.put(describeInstanceRequest, describeNamedInstanceResponse);
+ requestResponseMap.put(describeInstanceMultiIdsRequest, describeInstanceMultiIdsResponse);
+ requestResponseMap.put(describeImageRequest, describeImagesResponse);
+ requestResponseMap.put(createNamedTagsRequest, createTagsResponse);
+
+ ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build());
+
+ NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1,
+ blockUntilRunning(false).overrideLoginUser("ec2-user").nodeNames(ImmutableSet.of("test-node"))));
+ assertEquals(node.getCredentials().getUser(), "ec2-user");
+ assertNotNull(node.getCredentials().getPrivateKey());
+ assertEquals(node.getName(), "test-node");
+ }
+
+ //FIXME - issue-1051
+ @Test(enabled = false)
+ public void testCreateNodeWithGeneratedKeyPairAndOverriddenLoginUserWithTemplateBuilder() throws Exception {
+ Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+ requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+ requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+ requestResponseMap.put(describeImagesRequest, describeImagesResponse);
+ requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+ requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+ requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse);
+ requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse);
+ requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse);
+ requestResponseMap.put(runInstancesRequest, runInstancesResponse);
+ requestResponseMap.put(describeInstanceRequest, describeInstanceResponse);
+ requestResponseMap.put(describeInstanceMultiIdsRequest, describeInstanceMultiIdsResponse);
+ requestResponseMap.put(describeImageRequest, describeImagesResponse);
+ requestResponseMap.put(createTagsRequest, createTagsResponse);
+
+ ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build());
+
+ NodeMetadata node = Iterables.getOnlyElement(
+ apiThatCreatesNode.createNodesInGroup("test", 1,
+ apiThatCreatesNode.templateBuilder().from("osDescriptionMatches=.*fedora.*,loginUser=ec2-user").build()));
+ assertEquals(node.getCredentials().getUser(), "ec2-user");
+ assertNotNull(node.getCredentials().getPrivateKey());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java
new file mode 100644
index 0000000..e37e881
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java
@@ -0,0 +1,362 @@
+/*
+ * 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.jclouds.ec2.compute;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.domain.TemplateBuilderSpec;
+import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.compute.predicates.NodePredicates;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.ec2.EC2Api;
+import org.jclouds.ec2.compute.options.EC2TemplateOptions;
+import org.jclouds.ec2.domain.BlockDevice;
+import org.jclouds.ec2.domain.KeyPair;
+import org.jclouds.ec2.domain.PublicIpInstanceIdPair;
+import org.jclouds.ec2.domain.RunningInstance;
+import org.jclouds.ec2.domain.SecurityGroup;
+import org.jclouds.ec2.domain.Snapshot;
+import org.jclouds.ec2.domain.Volume;
+import org.jclouds.ec2.features.ElasticBlockStoreApi;
+import org.jclouds.ec2.features.InstanceApi;
+import org.jclouds.ec2.features.KeyPairApi;
+import org.jclouds.ec2.features.SecurityGroupApi;
+import org.jclouds.ec2.reference.EC2Constants;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.scriptbuilder.domain.Statements;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.jclouds.util.InetAddresses2;
+import org.testng.SkipException;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
+import com.google.common.collect.Iterables;
+import com.google.common.net.HostAndPort;
+import com.google.inject.Module;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true)
+public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
+
+ protected TemplateBuilderSpec ebsTemplate;
+
+ public EC2ComputeServiceLiveTest() {
+ provider = "ec2";
+ }
+
+ @Override
+ protected Module getSshModule() {
+ return new SshjSshClientModule();
+ }
+
+ @Override
+ protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) {
+ if (view.unwrapApi(EC2Api.class).getTagApi().isPresent()) {
+ super.checkUserMetadataContains(node, userMetadata);
+ } else {
+ assertTrue(node.getUserMetadata().isEmpty(), "not expecting metadata when tag extension isn't present: " + node);
+ }
+ }
+
+ @Override
+ protected void checkTagsInNodeEquals(NodeMetadata node, ImmutableSet<String> tags) {
+ if (view.unwrapApi(EC2Api.class).getTagApi().isPresent()) {
+ super.checkTagsInNodeEquals(node, tags);
+ } else {
+ assertTrue(node.getTags().isEmpty(), "not expecting tags when tag extension isn't present: " + node);
+ }
+ }
+
+
+ @Test(enabled = true, dependsOnMethods = "testCorrectAuthException")
+ public void testImagesResolveCorrectly() {
+ Template defaultTemplate = client.templateBuilder().build();
+ assertEquals(defaultTemplate.getImage().getId(), defaultTemplate.getImage().getLocation().getId() + "/"
+ + defaultTemplate.getImage().getProviderId());
+ Template byId = client.templateBuilder().imageId(defaultTemplate.getImage().getId()).build();
+ assertEquals(byId.getImage(), defaultTemplate.getImage());
+ }
+
+ @Test(enabled = true, dependsOnMethods = "testCompareSizes")
+ public void testExtendedOptionsAndLogin() throws Exception {
+ SecurityGroupApi securityGroupClient = view.unwrapApi(EC2Api.class)
+ .getSecurityGroupApi().get();
+
+ KeyPairApi keyPairClient = view.unwrapApi(EC2Api.class)
+ .getKeyPairApi().get();
+
+ InstanceApi instanceClient = view.unwrapApi(EC2Api.class)
+ .getInstanceApi().get();
+
+ String group = this.group + "o";
+
+ TemplateOptions options = client.templateOptions();
+
+ options.as(EC2TemplateOptions.class).securityGroups(group);
+
+ String startedId = null;
+ try {
+ cleanupExtendedStuffInRegion(null, securityGroupClient, keyPairClient, group);
+
+ // create a security group that allows ssh in so that our scripts later
+ // will work
+ securityGroupClient.createSecurityGroupInRegion(null, group, group);
+ securityGroupClient.authorizeSecurityGroupIngressInRegion(null, group, IpProtocol.TCP, 22, 22, "0.0.0.0/0");
+
+ // create a keypair to pass in as well
+ KeyPair result = keyPairClient.createKeyPairInRegion(null, group);
+ options.as(EC2TemplateOptions.class).keyPair(result.getKeyName());
+
+ // pass in the private key, so that we can run a script with it
+ assert result.getKeyMaterial() != null : result;
+ options.overrideLoginPrivateKey(result.getKeyMaterial());
+
+ // an arbitrary command to run
+ options.runScript(Statements.exec("find /usr"));
+
+ Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
+ NodeMetadata first = Iterables.get(nodes, 0);
+ assert first.getCredentials() != null : first;
+ assert first.getCredentials().identity != null : first;
+
+ startedId = Iterables.getOnlyElement(nodes).getProviderId();
+
+ RunningInstance instance = getInstance(instanceClient, startedId);
+
+ assertEquals(instance.getKeyName(), group);
+
+ // make sure we made our dummy group and also let in the user's group
+ assertEquals(ImmutableSortedSet.copyOf(instance.getGroupNames()), ImmutableSortedSet.<String> of("jclouds#" + group, group));
+
+ // make sure our dummy group has no rules
+ SecurityGroup secgroup = Iterables.getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(null,
+ "jclouds#" + group));
+ assert secgroup.size() == 0 : secgroup;
+
+ // try to run a script with the original keyPair
+ runScriptWithCreds(group, first.getOperatingSystem(),
+ LoginCredentials.builder().user(first.getCredentials().identity).privateKey(result.getKeyMaterial())
+ .build());
+
+ } finally {
+ client.destroyNodesMatching(NodePredicates.inGroup(group));
+ if (startedId != null) {
+ // ensure we didn't delete these resources!
+ assertEquals(keyPairClient.describeKeyPairsInRegion(null, group).size(), 1);
+ assertEquals(securityGroupClient.describeSecurityGroupsInRegion(null, group).size(), 1);
+ }
+ cleanupExtendedStuffInRegion(null, securityGroupClient, keyPairClient, group);
+ }
+ }
+
+ @Test(enabled = true) //, dependsOnMethods = "testCompareSizes")
+ public void testAutoIpAllocation() throws Exception {
+ ComputeServiceContext context = null;
+ String group = this.group + "aip";
+ try {
+ Properties overrides = setupProperties();
+ overrides.setProperty(EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "true");
+
+ context = createView(overrides, setupModules());
+
+ TemplateOptions options = client.templateOptions();
+
+ options.blockOnPort(22, 300);
+ options.inboundPorts(22);
+
+ // create a node
+ Set<? extends NodeMetadata> nodes =
+ context.getComputeService().createNodesInGroup(group, 1, options);
+ assertEquals(nodes.size(), 1, "One node should have been created");
+
+ // Get public IPs (We should get 1)
+ NodeMetadata node = Iterables.get(nodes, 0);
+ String region = node.getLocation().getParent().getId();
+ Set<String> publicIps = node.getPublicAddresses();
+ assertFalse(Iterables.isEmpty(publicIps), String.format("no public addresses attached to node %s", node));
+ assertEquals(Iterables.size(publicIps), 1);
+
+ // Check that the address is public and port 22 is accessible
+ String ip = Iterables.getOnlyElement(publicIps);
+ assertFalse(InetAddresses2.isPrivateIPAddress(ip));
+ HostAndPort socket = HostAndPort.fromParts(ip, 22);
+ assertTrue(socketTester.apply(socket), String.format("failed to open socket %s on node %s", socket, node));
+
+ // check that there is an elastic ip correlating to it
+ EC2Api ec2 = context.unwrapApi(EC2Api.class);
+ Set<PublicIpInstanceIdPair> ipidpairs =
+ ec2.getElasticIPAddressApi().get().describeAddressesInRegion(region, publicIps.toArray(new String[0]));
+ assertEquals(ipidpairs.size(), 1, String.format("there should only be one address pair (%s)",
+ Iterables.toString(ipidpairs)));
+
+ // check that the elastic ip is in node.publicAddresses
+ PublicIpInstanceIdPair ipidpair = Iterables.get(ipidpairs, 0);
+ assertEquals(region + "/" + ipidpair.getInstanceId(), node.getId());
+
+ // delete the node
+ context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
+
+ // check that the ip is deallocated
+ Set<PublicIpInstanceIdPair> ipidcheck =
+ ec2.getElasticIPAddressApi().get().describeAddressesInRegion(region, ipidpair.getPublicIp());
+ assertTrue(Iterables.isEmpty(ipidcheck), String.format("there should be no address pairs (%s)",
+ Iterables.toString(ipidcheck)));
+ } finally {
+ context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
+ if (context != null)
+ context.close();
+ }
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties overrides = super.setupProperties();
+ String ebsSpec = setIfTestSystemPropertyPresent(overrides, provider + ".ebs-template");
+ if (ebsSpec != null)
+ ebsTemplate = TemplateBuilderSpec.parse(ebsSpec);
+ return overrides;
+ }
+
+ /**
+ * Note we cannot use the micro size as it has no ephemeral space.
+ */
+ @Test
+ public void testMapEBS() throws Exception {
+ if (ebsTemplate == null) {
+ throw new SkipException("Test cannot run without the parameter test." + provider
+ + ".ebs-template; this property should be in the format defined in TemplateBuilderSpec");
+ }
+ InstanceApi instanceClient = view.unwrapApi(EC2Api.class)
+ .getInstanceApi().get();
+
+ ElasticBlockStoreApi ebsClient = view.unwrapApi(EC2Api.class)
+ .getElasticBlockStoreApi().get();
+
+ String group = this.group + "e";
+ int volumeSize = 8;
+
+ final Template template = view.getComputeService().templateBuilder().from(ebsTemplate).build();
+
+ Location zone = Iterables.find(view.getComputeService().listAssignableLocations(), new Predicate<Location>() {
+
+ @Override
+ public boolean apply(Location arg0) {
+ return arg0.getScope() == LocationScope.ZONE
+ && arg0.getParent().getId().equals(template.getLocation().getId());
+ }
+
+ });
+
+ // create volume only to make a snapshot
+ Volume volume = ebsClient.createVolumeInAvailabilityZone(zone.getId(), 4);
+ // Sleep for 5 seconds to make sure the volume creation finishes.
+ Thread.sleep(5000);
+
+ Snapshot snapshot = ebsClient.createSnapshotInRegion(volume.getRegion(), volume.getId());
+ ebsClient.deleteVolumeInRegion(volume.getRegion(), volume.getId());
+
+ template.getOptions().as(EC2TemplateOptions.class)//
+ // .unmapDeviceNamed("/dev/foo)
+ .mapEphemeralDeviceToDeviceName("/dev/sdm", "ephemeral0")//
+ .mapNewVolumeToDeviceName("/dev/sdn", volumeSize, true)//
+ .mapEBSSnapshotToDeviceName("/dev/sdo", snapshot.getId(), volumeSize, true);
+
+ try {
+ NodeMetadata node = Iterables.getOnlyElement(client.createNodesInGroup(group, 1, template));
+
+ // TODO figure out how to validate the ephemeral drive. perhaps with df -k?
+
+ Map<String, BlockDevice> devices = instanceClient.getBlockDeviceMappingForInstanceInRegion(node.getLocation()
+ .getParent().getId(), node.getProviderId());
+
+ BlockDevice device = devices.get("/dev/sdn");
+ // check delete on termination
+ assertTrue(device.isDeleteOnTermination());
+
+ volume = Iterables.getOnlyElement(ebsClient.describeVolumesInRegion(node.getLocation().getParent().getId(),
+ device.getVolumeId()));
+ // check volume size
+ assertEquals(volumeSize, volume.getSize());
+
+ device = devices.get("/dev/sdo");
+ // check delete on termination
+ assertTrue(device.isDeleteOnTermination());
+
+ volume = Iterables.getOnlyElement(ebsClient.describeVolumesInRegion(node.getLocation().getParent().getId(),
+ device.getVolumeId()));
+ // check volume size
+ assertEquals(volumeSize, volume.getSize());
+ // check volume's snapshot id
+ assertEquals(snapshot.getId(), volume.getSnapshotId());
+
+ } finally {
+ client.destroyNodesMatching(NodePredicates.inGroup(group));
+ ebsClient.deleteSnapshotInRegion(snapshot.getRegion(), snapshot.getId());
+ }
+ }
+
+ /**
+ * Gets the instance with the given ID from the default region
+ *
+ * @throws NoSuchElementException If no instance with that id exists, or the instance is in a different region
+ */
+ public static RunningInstance getInstance(InstanceApi instanceClient, String id) {
+ RunningInstance instance = Iterables.getOnlyElement(Iterables.getOnlyElement(instanceClient
+ .describeInstancesInRegion(null, id)));
+ return instance;
+ }
+
+ protected static void cleanupExtendedStuffInRegion(String region, SecurityGroupApi securityGroupClient,
+ KeyPairApi keyPairClient, String group) throws InterruptedException {
+ try {
+ for (SecurityGroup secgroup : securityGroupClient.describeSecurityGroupsInRegion(region))
+ if (secgroup.getName().startsWith("jclouds#" + group) || secgroup.getName().equals(group)) {
+ securityGroupClient.deleteSecurityGroupInRegion(region, secgroup.getName());
+ }
+ } catch (Exception e) {
+
+ }
+ try {
+ for (KeyPair pair : keyPairClient.describeKeyPairsInRegion(region))
+ if (pair.getKeyName().startsWith("jclouds#" + group) || pair.getKeyName().equals(group)) {
+ keyPairClient.deleteKeyPairInRegion(region, pair.getKeyName());
+ }
+ } catch (Exception e) {
+
+ }
+ Thread.sleep(2000);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java
new file mode 100644
index 0000000..349da8e
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.jclouds.ec2.compute;
+
+import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getArgsForRequestAtIndex;
+import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getInvokerOfRequest;
+import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getInvokerOfRequestAtIndex;
+import static org.testng.Assert.assertEquals;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest;
+import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions;
+import org.jclouds.ec2.options.DescribeImagesOptions;
+import org.jclouds.ec2.options.DescribeRegionsOptions;
+import org.jclouds.ec2.features.AMIApi;
+import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi;
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService;
+import org.jclouds.logging.log4j.config.Log4JLoggingModule;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.inject.Module;
+
+public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
+
+ @Test
+ public void testTemplateBuilderCanUseImageIdWithoutFetchingAllImages() throws Exception {
+ Template defaultTemplate = view.getComputeService().templateBuilder().build();
+ String defaultImageId = defaultTemplate.getImage().getId();
+ String defaultImageProviderId = defaultTemplate.getImage().getProviderId();
+
+ ComputeServiceContext context = null;
+ try {
+ // Track http commands
+ final List<HttpCommand> commandsInvoked = Lists.newArrayList();
+ context = createView(
+ setupProperties(),
+ ImmutableSet.<Module> of(new Log4JLoggingModule(),
+ TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked)));
+
+ Template template = context.getComputeService().templateBuilder().imageId(defaultImageId)
+ .build();
+ assertEquals(template.getImage(), defaultTemplate.getImage());
+
+ Collection<HttpCommand> filteredCommandsInvoked = Collections2.filter(commandsInvoked, new Predicate<HttpCommand>() {
+ private final Collection<Method> ignored = ImmutableSet.of(
+ AvailabilityZoneAndRegionApi.class.getMethod("describeRegions", DescribeRegionsOptions[].class),
+ AvailabilityZoneAndRegionApi.class.getMethod("describeAvailabilityZonesInRegion", String.class, DescribeAvailabilityZonesOptions[].class));
+ @Override
+ public boolean apply(HttpCommand input) {
+ return !ignored.contains(getInvokerOfRequest(input));
+ }
+ });
+
+ assert filteredCommandsInvoked.size() == 1 : commandsInvoked;
+ assertEquals(getInvokerOfRequestAtIndex(filteredCommandsInvoked, 0), AMIApi.class
+ .getMethod("describeImagesInRegion", String.class, DescribeImagesOptions[].class));
+ assertDescribeImagesOptionsEquals((DescribeImagesOptions[])getArgsForRequestAtIndex(filteredCommandsInvoked, 0).get(1),
+ defaultImageProviderId);
+
+ } finally {
+ if (context != null)
+ context.close();
+ }
+ }
+
+ private static void assertDescribeImagesOptionsEquals(DescribeImagesOptions[] actual, String expectedImageId) {
+ assertEquals(actual.length, 1);
+ assertEquals(actual[0].getImageIds(), ImmutableSet.of(expectedImageId));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java
new file mode 100644
index 0000000..e581605
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java
@@ -0,0 +1,240 @@
+/*
+ * 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.jclouds.ec2.compute;
+
+import static java.lang.String.format;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_medium;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c1_xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc1_4xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.g2_2xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_large;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_small;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m1_xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_2xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_4xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.m2_xlarge;
+import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.t1_micro;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import javax.inject.Provider;
+
+import org.jclouds.compute.domain.ComputeMetadata;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.functions.ImagesToRegionAndIdMap;
+import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.base.Functions;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests compute service specifically to EC2.
+ *
+ * These tests are designed to verify the local functionality of jclouds, rather than the
+ * interaction with Amazon Web Services.
+ *
+ * @see EC2ComputeServiceLiveTest
+ *
+ * @author Oleksiy Yarmula
+ */
+@Test(testName = "EC2TemplateBuilderTest")
+public class EC2TemplateBuilderTest {
+ Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("aws-ec2").description("aws-ec2").build();
+
+ protected Location location = new LocationBuilder().scope(LocationScope.REGION).id("us-east-1").description("us-east-1")
+ .parent(provider).build();
+
+ public static final Hardware CC1_4XLARGE = cc1_4xlarge().supportsImageIds(ImmutableSet.of("us-east-1/cc-image"))
+ .build();
+
+ /**
+ * Verifies that {@link TemplateBuilderImpl} would choose the correct size of the instance, based
+ * on {@link org.jclouds.compute.domain.Hardware} from {@link EC2Hardware}.
+ *
+ * Expected size: m2.xlarge
+ */
+ @Test
+ public void testTemplateChoiceForInstanceByhardwareId() throws Exception {
+ Template template = newTemplateBuilder().os64Bit(true).hardwareId("m2.xlarge").locationId("us-east-1").build();
+
+ assert template != null : "The returned template was null, but it should have a value.";
+ // assert m2_xlarge().build().equals(template.getHardware()) : format(
+ // "Incorrect image determined by the template. Expected: %s. Found: %s.", "m2.xlarge",
+ // String.valueOf(template.getHardware()));
+ assertEquals(m2_xlarge().build().getId(), template.getHardware().getId());
+ }
+
+ @Test
+ public void testTemplateChoiceForInstanceByCChardwareId() throws Exception {
+ Template template = newTemplateBuilder().fastest().build();
+
+ assert template != null : "The returned template was null, but it should have a value.";
+ assert CC1_4XLARGE.equals(template.getHardware()) : format(
+ "Incorrect image determined by the template. Expected: %s. Found: %s.", CC1_4XLARGE.getId(), template
+ .getHardware().getId());
+ }
+
+ /**
+ * Verifies that {@link TemplateBuilderImpl} would choose the correct size of the instance, based
+ * on physical attributes (# of cores, ram, etc).
+ *
+ * Expected size: CC1_4XLARGE
+ */
+ @Test
+ public void testTemplateChoiceForInstanceByAttributes() throws Exception {
+ Template template = newTemplateBuilder().os64Bit(true).minRam(17510).minCores(6.5).smallest().locationId(
+ "us-east-1").build();
+
+ assert template != null : "The returned template was null, but it should have a value.";
+ assertEquals(template.getHardware().getId(), "cc1.4xlarge");
+ }
+
+ /**
+ * Negative test version of {@link #testTemplateChoiceForInstanceByAttributes}.
+ *
+ * Verifies that {@link TemplateBuilderImpl} would not choose the insufficient size of the
+ * instance, based on physical attributes (# of cores, ram, etc).
+ *
+ * Expected size: anything but m2.xlarge
+ */
+ @Test
+ public void testNegativeTemplateChoiceForInstanceByAttributes() throws Exception {
+ Template template = newTemplateBuilder().os64Bit(true).minRam(17510).minCores(6.7).smallest().locationId(
+ "us-east-1").build();
+
+ assert template != null : "The returned template was null, but it should have a value.";
+ assert !m2_xlarge().build().equals(template.getHardware()) : format(
+ "Incorrect image determined by the template. Expected: not %s. Found: %s.", "m2.xlarge", template
+ .getHardware().getId());
+ }
+
+ @Test
+ public void testTemplateChoiceForInstanceByImageId() throws Exception {
+ Template template = newTemplateBuilder().imageId("us-east-1/cc-image").build();
+
+ assert template != null : "The returned template was null, but it should have a value.";
+ assertEquals(template.getImage().getId(), "us-east-1/cc-image");
+ }
+
+ @Test
+ public void testTemplateChoiceForInstanceByImageIdDoesNotGetAllImages() throws Exception {
+ @SuppressWarnings("unchecked")
+ Supplier<Set<? extends Image>> images = createMock(Supplier.class);
+ replay(images);
+
+ final Image image = new ImageBuilder().providerId("cc-image").name("image").id("us-east-1/cc-image").location(location)
+ .operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "hvm", "ubuntu", true))
+ .description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build())
+ .status(Image.Status.AVAILABLE)
+ .build();
+ Map<RegionAndName, Image> imageMap = ImmutableMap.of(
+ new RegionAndName(image.getLocation().getId(), image.getProviderId()), image);
+
+ // weird compilation error means have to declare extra generics for call to build() - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
+ Supplier<LoadingCache<RegionAndName, ? extends Image>> imageCache = Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(
+ CacheBuilder.newBuilder().<RegionAndName,Image>build(CacheLoader.from(Functions.forMap(imageMap))));
+
+ Template template = newTemplateBuilder(images, imageCache).imageId("us-east-1/cc-image").build();
+
+ assert template != null : "The returned template was null, but it should have a value.";
+ assertEquals(template.getImage().getId(), "us-east-1/cc-image");
+ }
+
+ @Test(expectedExceptions={NoSuchElementException.class})
+ public void testNegativeTemplateChoiceForInstanceByImageId() throws Exception {
+ newTemplateBuilder().imageId("wrongregion/wrongimageid").build();
+ }
+
+ private TemplateBuilder newTemplateBuilder() {
+ final Supplier<Set<? extends Image>> images = Suppliers.<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of(
+ new ImageBuilder().providerId("cc-image").name("image").id("us-east-1/cc-image").location(location)
+ .operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "hvm", "ubuntu", true))
+ .description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build())
+ .status(Image.Status.AVAILABLE)
+ .build(),
+ new ImageBuilder().providerId("normal-image").name("image").id("us-east-1/normal-image").location(location)
+ .operatingSystem(new OperatingSystem(OsFamily.UBUNTU, null, "1.0", "paravirtual", "ubuntu", true))
+ .description("description").version("1.0").defaultCredentials(LoginCredentials.builder().user("root").build())
+ .status(Image.Status.AVAILABLE)
+ .build()));
+
+ // weird compilation error means have to cast this - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
+ @SuppressWarnings("unchecked")
+ ImmutableMap<RegionAndName, Image> imageMap = (ImmutableMap<RegionAndName, Image>) ImagesToRegionAndIdMap.imagesToMap(images.get());
+ Supplier<LoadingCache<RegionAndName, ? extends Image>> imageCache = Suppliers.<LoadingCache<RegionAndName, ? extends Image>> ofInstance(
+ CacheBuilder.newBuilder().<RegionAndName,Image>build(CacheLoader.from(Functions.forMap(imageMap))));
+
+ return newTemplateBuilder(images, imageCache);
+ }
+
+ @SuppressWarnings("unchecked")
+ private TemplateBuilder newTemplateBuilder(Supplier<Set<? extends Image>> images, Supplier<LoadingCache<RegionAndName, ? extends Image>> imageCache) {
+ Provider<TemplateOptions> optionsProvider = createMock(Provider.class);
+ Provider<TemplateBuilder> templateBuilderProvider = createMock(Provider.class);
+ TemplateOptions defaultOptions = createMock(TemplateOptions.class);
+
+ expect(optionsProvider.get()).andReturn(defaultOptions);
+
+ replay(optionsProvider);
+ replay(templateBuilderProvider);
+ Supplier<Set<? extends Location>> locations = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet
+ .<Location> of(location));
+ Supplier<Set<? extends Hardware>> sizes = Suppliers.<Set<? extends Hardware>> ofInstance(ImmutableSet
+ .<Hardware> of(t1_micro().build(), c1_medium().build(), c1_xlarge().build(), m1_large().build(),
+ m1_small().build(), m1_xlarge().build(), m2_xlarge().build(), m2_2xlarge().build(),
+ m2_4xlarge().build(),g2_2xlarge().build(),CC1_4XLARGE));
+
+ return new EC2TemplateBuilderImpl(locations, images, sizes, Suppliers.ofInstance(location), optionsProvider,
+ templateBuilderProvider, imageCache) {
+ };
+ }
+
+ Function<ComputeMetadata, String> indexer() {
+ return new Function<ComputeMetadata, String>() {
+ @Override
+ public String apply(ComputeMetadata from) {
+ return from.getProviderId();
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java
new file mode 100644
index 0000000..e4e5761
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.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 org.jclouds.ec2.compute;
+
+import org.jclouds.compute.RunNodesException;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.compute.predicates.NodePredicates;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Throwables;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", testName="TestCanRecreateGroupLiveTest")
+public class TestCanRecreateGroupLiveTest extends BaseComputeServiceContextLiveTest {
+ public TestCanRecreateGroupLiveTest() {
+ provider = "ec2";
+ }
+
+ public void testCanRecreateGroup() throws Exception {
+
+ String tag = PREFIX + "recreate";
+ view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag));
+
+ try {
+ Template template = view.getComputeService().templateBuilder().build();
+ view.getComputeService().createNodesInGroup(tag, 1, template);
+ view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag));
+ view.getComputeService().createNodesInGroup(tag, 1, template);
+ } catch (RunNodesException e) {
+ System.err.println(e.getNodeErrors().keySet());
+ Throwables.propagate(e);
+ } finally {
+ view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag));
+ }
+ }
+
+ public static final String PREFIX = System.getProperty("user.name") + "ec2";
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java
new file mode 100644
index 0000000..d240ef5
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.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.jclouds.ec2.compute.config;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.testng.Assert.fail;
+
+import org.jclouds.compute.domain.Image;
+import org.jclouds.ec2.compute.domain.RegionAndName;
+import org.jclouds.ec2.compute.loaders.RegionAndIdToImage;
+import org.jclouds.rest.AuthorizationException;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.cache.CacheLoader;
+
+/**
+ * @author Aled Sage
+ */
+@Test(groups = "unit")
+public class EC2ComputeServiceContextModuleTest {
+
+ @Test
+ public void testCacheLoaderDoesNotReloadAfterAuthorizationException() throws Exception {
+ EC2ComputeServiceContextModule module = new EC2ComputeServiceContextModule() {
+ public Supplier<CacheLoader<RegionAndName, Image>> provideRegionAndNameToImageSupplierCacheLoader(RegionAndIdToImage delegate) {
+ return super.provideRegionAndNameToImageSupplierCacheLoader(delegate);
+ }
+ };
+
+ RegionAndName regionAndName = new RegionAndName("myregion", "myname");
+ AuthorizationException authException = new AuthorizationException();
+
+ RegionAndIdToImage mockRegionAndIdToImage = createMock(RegionAndIdToImage.class);
+ expect(mockRegionAndIdToImage.load(regionAndName)).andThrow(authException).once();
+ replay(mockRegionAndIdToImage);
+
+ CacheLoader<RegionAndName, Image> cacheLoader = module.provideRegionAndNameToImageSupplierCacheLoader(mockRegionAndIdToImage).get();
+
+ for (int i = 0; i < 2; i++) {
+ try {
+ Image image = cacheLoader.load(regionAndName);
+ fail("Expected Authorization exception, but got " + image);
+ } catch (AuthorizationException e) {
+ // success
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java
new file mode 100644
index 0000000..d23ca07
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.jclouds.ec2.compute.extensions;
+
+import static org.testng.Assert.assertEquals;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.ImageTemplate;
+import org.jclouds.compute.extensions.ImageExtension;
+import org.jclouds.ec2.compute.internal.BaseEC2ComputeServiceExpectTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.util.concurrent.Futures;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "EC2ImageExtensionExpectTest")
+public class EC2ImageExtensionExpectTest extends BaseEC2ComputeServiceExpectTest {
+
+ public void testCreateImage() {
+ Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+ requestResponseMap.put(describeRegionsRequest, describeRegionsResponse);
+ requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse);
+ requestResponseMap.put(describeImagesRequest, describeImagesResponse);
+ requestResponseMap.put(createKeyPairRequest, createKeyPairResponse);
+ requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse);
+ requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse);
+ requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse);
+ requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse);
+ requestResponseMap.put(describeInstanceRequest, describeInstanceResponse);
+
+ HttpRequest createImageRequest = formSigner.filter(HttpRequest.builder().method("POST")
+ .endpoint("https://ec2." + region + ".amazonaws.com/")
+ .addHeader("Host", "ec2." + region + ".amazonaws.com")
+ .addFormParam("Action", "CreateImage")
+ .addFormParam("InstanceId", "i-2baa5550")
+ .addFormParam("Name", "test").build());
+
+ HttpResponse createImageResponse = HttpResponse.builder()
+ .statusCode(200)
+ .payload(payloadFromStringWithContentType(
+ "<CreateImageResponse><imageId>ami-be3adfd7</imageId></CreateImageResponse>", MediaType.APPLICATION_XML)).build();
+
+ requestResponseMap.put(createImageRequest, createImageResponse);
+
+ HttpRequest describeImageRequest = formSigner.filter(HttpRequest.builder().method("POST")
+ .endpoint("https://ec2." + region + ".amazonaws.com/")
+ .addHeader("Host", "ec2." + region + ".amazonaws.com")
+ .addFormParam("Action", "DescribeImages")
+ .addFormParam("ImageId.1", "ami-be3adfd7").build());
+
+ requestResponseMap.put(describeImageRequest, describeImagesResponse);
+
+ ImageExtension apiThatCreatesImage = requestsSendResponses(requestResponseMap.build()).getImageExtension().get();
+
+ ImageTemplate newImageTemplate = apiThatCreatesImage.buildImageTemplateFromNode("test", "us-east-1/i-2baa5550");
+
+ Image image = Futures.getUnchecked(apiThatCreatesImage.createImage(newImageTemplate));
+ assertEquals(image.getId(), "us-east-1/ami-be3adfd7");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/58fe66df/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java
new file mode 100644
index 0000000..1f29e66
--- /dev/null
+++ b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.jclouds.ec2.compute.extensions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Properties;
+
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.domain.TemplateBuilderSpec;
+import org.jclouds.compute.extensions.internal.BaseImageExtensionLiveTest;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.Test;
+
+import com.google.inject.Module;
+
+/**
+ * Live test for ec2 {@link ImageExtension} implementation
+ *
+ * @author David Alves
+ *
+ */
+@Test(groups = "live", singleThreaded = true, testName = "EC2ImageExtensionLiveTest")
+public class EC2ImageExtensionLiveTest extends BaseImageExtensionLiveTest {
+ protected TemplateBuilderSpec ebsTemplate;
+
+ public EC2ImageExtensionLiveTest() {
+ provider = "ec2";
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties overrides = super.setupProperties();
+ String ebsSpec = checkNotNull(setIfTestSystemPropertyPresent(overrides, provider + ".ebs-template"), provider
+ + ".ebs-template");
+ ebsTemplate = TemplateBuilderSpec.parse(ebsSpec);
+ return overrides;
+ }
+
+ @Override
+ public Template getNodeTemplate() {
+ return view.getComputeService().templateBuilder().from(ebsTemplate).build();
+ }
+
+ @Override
+ protected Module getSshModule() {
+ return new SshjSshClientModule();
+ }
+
+}