You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2014/12/23 05:27:01 UTC
[37/51] [partial] stratos git commit: dropping jclouds 1.8.0 clone
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java
deleted file mode 100644
index 4ffad1f..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * 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.jclouds.ec2.compute.options.EC2TemplateOptions.Builder.maxCount;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import javax.ws.rs.core.MediaType;
-import java.util.Set;
-
-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;
-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.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Tests the compute service abstraction of the EC2 api.
- */
-@Test(groups = "unit", testName = "EC2ComputeServiceExpectTest")
-public class EC2ComputeServiceExpectTest extends BaseEC2ComputeServiceExpectTest {
- protected HttpRequest createFirstTagRequest;
- protected HttpRequest createSecondTagRequest;
- protected HttpRequest createThirdTagRequest;
-
- @BeforeClass
- @Override
- protected void setupDefaultRequests() {
- super.setupDefaultRequests();
- createFirstTagRequest =
- 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-2ba64342" +
- "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" +
- "&SignatureMethod=HmacSHA256" +
- "&SignatureVersion=2" +
- "&Tag.1.Key=Name" +
- "&Tag.1.Value=test-2ba64342" +
- "&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
- "&Version=2010-08-31" +
- "&AWSAccessKeyId=identity",
- "application/x-www-form-urlencoded"))
- .build());
-
- createSecondTagRequest =
- 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-2bc64242" +
- "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" +
- "&SignatureMethod=HmacSHA256" +
- "&SignatureVersion=2" +
- "&Tag.1.Key=Name" +
- "&Tag.1.Value=test-2bc64242" +
- "&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
- "&Version=2010-08-31" +
- "&AWSAccessKeyId=identity",
- "application/x-www-form-urlencoded"))
- .build());
-
- createThirdTagRequest =
- 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-2be64332" +
- "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" +
- "&SignatureMethod=HmacSHA256" +
- "&SignatureVersion=2" +
- "&Tag.1.Key=Name" +
- "&Tag.1.Value=test-2be64332" +
- "&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
- "&Version=2010-08-31" +
- "&AWSAccessKeyId=identity",
- "application/x-www-form-urlencoded"))
- .build());
- }
-
- 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());
- assertTrue(node.getCredentials().getOptionalPrivateKey().isPresent());
- }
-
- public void testCreateThreeNodesWithMaxCountThree() 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(runThreeInstancesRequest, runThreeInstancesResponse);
- requestResponseMap.put(describeInstanceRequest, describeInstanceResponse);
- requestResponseMap.put(describeInstanceThreeIdsRequest, describeInstanceThreeIdsResponse);
- requestResponseMap.put(describeImageRequest, describeImagesResponse);
- requestResponseMap.put(createFirstTagRequest, createTagsResponse);
- requestResponseMap.put(createSecondTagRequest, createTagsResponse);
- requestResponseMap.put(createThirdTagRequest, createTagsResponse);
-
- ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build());
-
- NodeMetadata node = Iterables.getFirst(apiThatCreatesNode.createNodesInGroup("test", 3,
- maxCount(3).blockUntilRunning(false).overrideLoginUser("ec2-user")), null);
- assertNotNull(node, "Node should exist");
- assertEquals(node.getCredentials().getUser(), "ec2-user", "User should be ec2-user");
- }
-
- public void testCreateThreeNodesWithMaxCountFourGetThreeNodes() 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(runThreeToFourInstancesRequest, runThreeInstancesResponse);
- requestResponseMap.put(describeInstanceRequest, describeInstanceResponse);
- requestResponseMap.put(describeInstanceThreeIdsRequest, describeInstanceThreeIdsResponse);
- requestResponseMap.put(describeImageRequest, describeImagesResponse);
- requestResponseMap.put(createFirstTagRequest, createTagsResponse);
- requestResponseMap.put(createSecondTagRequest, createTagsResponse);
- requestResponseMap.put(createThirdTagRequest, createTagsResponse);
-
- ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build());
-
- NodeMetadata node = Iterables.getFirst(apiThatCreatesNode.createNodesInGroup("test", 3,
- maxCount(4).blockUntilRunning(false).overrideLoginUser("ec2-user")), null);
- assertNotNull(node, "Node should exist");
- assertEquals(node.getCredentials().getUser(), "ec2-user", "User should be ec2-user");
- }
-
- public void testCreateThreeNodesWithSpecifiedName() throws Exception {
- HttpRequest createFirstNamedTagRequest =
- 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-2ba64342" +
- "&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());
-
- HttpRequest createSecondNamedTagRequest =
- 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-2bc64242" +
- "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" +
- "&SignatureMethod=HmacSHA256" +
- "&SignatureVersion=2" +
- "&Tag.1.Key=Name" +
- "&Tag.1.Value=second-node" +
- "&Timestamp=2012-04-16T15%3A54%3A08.897Z" +
- "&Version=2010-08-31" +
- "&AWSAccessKeyId=identity",
- "application/x-www-form-urlencoded"))
- .build());
-
- HttpRequest createThirdNamedTagRequest =
- 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-2be64332" +
- "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" +
- "&SignatureMethod=HmacSHA256" +
- "&SignatureVersion=2" +
- "&Tag.1.Key=Name" +
- "&Tag.1.Value=third-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(runThreeInstancesRequest, runThreeInstancesResponse);
- requestResponseMap.put(describeInstanceRequest, describeNamedInstanceResponse);
- requestResponseMap.put(describeInstanceThreeIdsRequest, describeInstanceThreeIdsResponse);
- requestResponseMap.put(describeImageRequest, describeImagesResponse);
- requestResponseMap.put(createFirstNamedTagRequest, createTagsResponse);
- requestResponseMap.put(createSecondNamedTagRequest, createTagsResponse);
- requestResponseMap.put(createThirdNamedTagRequest, createTagsResponse);
-
- ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build());
-
- Set<? extends NodeMetadata> nodes = apiThatCreatesNode.createNodesInGroup("test", 3,
- maxCount(3).blockUntilRunning(false).overrideLoginUser("ec2-user").nodeNames(ImmutableSet.of("test-node", "second-node", "third-node")));
-
- NodeMetadata node = Iterables.get(nodes, 0);
- assertEquals(node.getName(), "test-node");
-
- NodeMetadata secondNode = Iterables.get(nodes, 1);
- assertEquals(secondNode.getName(), "second-node");
-
- NodeMetadata thirdNode = Iterables.get(nodes, 2);
- assertEquals(thirdNode.getName(), "third-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");
- assertTrue(node.getCredentials().getOptionalPrivateKey().isPresent());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java
deleted file mode 100644
index 1fa7e4b..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * 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.security.SecureRandom;
-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;
-
-@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 {
- final SecureRandom random = new SecureRandom();
-
- 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);
- options.as(EC2TemplateOptions.class).clientToken(Integer.toHexString(random.nextInt(65536 * 1024)));
-
- 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;
-
- // Verify that the output of createNodesInGroup is the same.
- assertEquals(client.createNodesInGroup(group, 1, options), nodes, "Idempotency failing - got different instances");
-
- 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/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java
deleted file mode 100644
index 349da8e..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java
deleted file mode 100644
index 0d21500..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * 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.compute.strategy.GetImageStrategy;
-import org.jclouds.compute.suppliers.ImageCacheSupplier;
-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
- */
-@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);
- GetImageStrategy getImageStrategy = createMock(GetImageStrategy.class);
-
- expect(optionsProvider.get()).andReturn(defaultOptions);
-
- replay(optionsProvider);
- replay(templateBuilderProvider);
- replay(getImageStrategy);
- 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, new ImageCacheSupplier(images, 60), sizes, Suppliers.ofInstance(location), optionsProvider,
- templateBuilderProvider, getImageStrategy, 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/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java
deleted file mode 100644
index 863229a..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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;
-
-@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/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java
deleted file mode 100644
index cd0170c..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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;
-
-@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/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java
deleted file mode 100644
index 4ca6c62..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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;
-
-@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/stratos/blob/a9834e9e/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java
deleted file mode 100644
index 3be04db..0000000
--- a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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
- */
-@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();
- }
-
-}