Fix EC2 live tests

This removes
org.jclouds.ec2.compute.functions.PasswordCredentialsFromWindowsInstanceLiveTest
due to there not being an easily detectable valid AMI for it to run,
and low interest in actually running it in the first place.
This commit is contained in:
Andrew Bayer 2013-09-26 13:05:20 -07:00
parent ddfefd7ec7
commit 962f98969f
13 changed files with 190 additions and 165 deletions

View File

@ -37,8 +37,10 @@
<test.ec2.build-version />
<test.ec2.identity>${test.aws.identity}</test.ec2.identity>
<test.ec2.credential>${test.aws.credential}</test.ec2.credential>
<test.ec2.template />
<test.ec2.ebs-template>hardwareId=m1.small,imageId=us-west-2/ami-38c64a08</test.ec2.ebs-template>
<!-- default template pattern gets a problematic Ubuntu 10.04 AMI -->
<test.ec2.template>hardwareId=m1.small,imageId=us-east-1/ami-1ab3ce73</test.ec2.template>
<!-- Active EBS template as of 9/25/2013 -->
<test.ec2.ebs-template>hardwareId=m1.small,imageId=us-east-1/ami-53b1ff3a</test.ec2.ebs-template>
<!-- Windows_Server-2008-R2 with WinRM enabled (setup instructions at http://www.frontiertown.co.uk/2011/12/overthere-control-windows-from-java/) -->
<test.ec2.windows-template>hardwareId=m1.small,imageId=us-east-1/ami-0cb76d65</test.ec2.windows-template>
<jclouds.osgi.export>org.jclouds.ec2*;version="${project.version}"</jclouds.osgi.export>

View File

@ -148,6 +148,7 @@ public class EC2ComputeService extends BaseComputeService {
throws RunNodesException {
Set<? extends NodeMetadata> nodes = super.createNodesInGroup(group, count, template);
String region = AWSUtils.getRegionFromLocationOrNull(template.getLocation());
if (client.getTagApiForRegion(region).isPresent()) {
Map<String, String> common = metadataAndTagsAsValuesOfEmptyString(template.getOptions());
if (common.size() > 0 || generateInstanceNames) {

View File

@ -35,7 +35,6 @@ 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.EC2ApiMetadata;
import org.jclouds.ec2.EC2Api;
import org.jclouds.ec2.compute.options.EC2TemplateOptions;
import org.jclouds.ec2.domain.BlockDevice;
@ -45,11 +44,11 @@ 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.reference.EC2Constants;
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;
@ -59,9 +58,9 @@ 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.collect.Sets;
import com.google.common.net.HostAndPort;
import com.google.inject.Module;
@ -88,10 +87,20 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
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);
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();
@ -150,12 +159,11 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
assertEquals(instance.getKeyName(), group);
// make sure we made our dummy group and also let in the user's group
assertEquals(Sets.newTreeSet(instance.getGroupNames()), ImmutableSortedSet.<String> of("jclouds#" + group + "#"
+ instance.getRegion(), 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 + "#" + instance.getRegion()));
"jclouds#" + group));
assert secgroup.size() == 0 : secgroup;
// try to run a script with the original keyPair
@ -184,9 +192,14 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
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);
context.getComputeService().createNodesInGroup(group, 1, options);
assertEquals(nodes.size(), 1, "One node should have been created");
// Get public IPs (We should get 1)
@ -269,6 +282,9 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
// 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());

View File

@ -16,6 +16,12 @@
*/
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.ImageExtension;
import org.jclouds.compute.extensions.internal.BaseImageExtensionLiveTest;
import org.jclouds.sshj.config.SshjSshClientModule;
@ -31,11 +37,26 @@ import com.google.inject.Module;
*/
@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();

View File

@ -1,87 +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.functions;
import static org.jclouds.compute.options.TemplateOptions.Builder.inboundPorts;
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import java.util.Properties;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilderSpec;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.compute.predicates.NodePredicates;
import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule;
import org.testng.annotations.Test;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.inject.Module;
/**
* Tests behavior of {@code WindowsApi}
*
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true, testName = "PasswordCredentialsFromWindowsInstanceLiveTest")
public class PasswordCredentialsFromWindowsInstanceLiveTest extends BaseComputeServiceContextLiveTest {
protected TemplateBuilderSpec windowsTemplate;
public PasswordCredentialsFromWindowsInstanceLiveTest() {
provider = "ec2";
}
@Override
protected Properties setupProperties() {
Properties overrides = super.setupProperties();
String windowsSpec = setIfTestSystemPropertyPresent(overrides, provider + ".windows-template");
if (Strings.emptyToNull(windowsSpec) != null) {
windowsTemplate = TemplateBuilderSpec.parse(windowsSpec);
}
String windowsOwner = setIfTestSystemPropertyPresent(overrides, provider + ".windows-owner");
if (Strings.emptyToNull(windowsOwner) != null) {
overrides.setProperty(PROPERTY_EC2_AMI_OWNERS, windowsOwner);
}
return overrides;
}
// TODO: refactor so that we don't need to use bouncycastle
@Override
protected Iterable<Module> setupModules() {
return ImmutableSet.<Module> builder().addAll(super.setupModules()).add(new BouncyCastleCryptoModule()).build();
}
@Test
public void testWindowsAdminWorks() throws Exception {
String group = "winadm";
// Spin up a new node. Make sure to open the RDP port 3389
Template template = view.getComputeService().templateBuilder().from(windowsTemplate).options(inboundPorts(3389))
.build();
try {
NodeMetadata node = Iterables.getOnlyElement(view.getComputeService().createNodesInGroup(group, 1, template));
assertEquals(node.getCredentials().getUser(), "Administrator");
assertFalse(Strings.isNullOrEmpty(node.getCredentials().getPassword()));
} finally {
view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
}
}
}

View File

@ -27,12 +27,12 @@ import java.util.SortedSet;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.ec2.EC2Api;
import org.jclouds.ec2.EC2ApiMetadata;
import org.jclouds.ec2.domain.AvailabilityZoneInfo;
import org.jclouds.ec2.domain.Snapshot;
import org.jclouds.ec2.domain.Volume;
import org.jclouds.ec2.predicates.SnapshotCompleted;
import org.jclouds.ec2.predicates.VolumeAvailable;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -220,4 +220,17 @@ public class ElasticBlockStoreApiLiveTest extends BaseComputeServiceContextLiveT
assert client.describeSnapshotsInRegion(snapshot.getRegion(), snapshotIds(snapshot.getId())).size() == 0;
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
try {
client.deleteSnapshotInRegion(snapshot.getRegion(), snapshot.getId());
client.deleteVolumeInRegion(defaultRegion, volumeId);
} catch (Exception e) {
// we don't really care about any exception here, so just delete away.
}
super.tearDownContext();
}
}

View File

@ -24,8 +24,8 @@ import java.util.SortedSet;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.ec2.EC2Api;
import org.jclouds.ec2.EC2ApiMetadata;
import org.jclouds.ec2.domain.KeyPair;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -94,4 +94,17 @@ public class KeyPairApiLiveTest extends BaseComputeServiceContextLiveTest {
assertEquals(listPair.getSha1OfPrivateKey(), result.getSha1OfPrivateKey());
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
String keyName = PREFIX + "1";
try {
client.deleteKeyPairInRegion(null, keyName);
} catch (Exception e) {
}
super.tearDownContext();
}
}

View File

@ -18,6 +18,8 @@ package org.jclouds.compute.domain.internal;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.ComparisonChain.start;
import static com.google.common.collect.Ordering.natural;
import java.net.URI;
import java.util.Map;
@ -26,6 +28,7 @@ import java.util.Set;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.domain.Location;
import org.jclouds.domain.ResourceMetadata;
import org.jclouds.domain.internal.ResourceMetadataImpl;
import com.google.common.base.Objects;
@ -74,6 +77,23 @@ public class ComputeMetadataImpl extends ResourceMetadataImpl<ComputeType> imple
return tags;
}
/**
* {@inheritDoc}
*/
@Override
public int compareTo(ResourceMetadata<ComputeType> that) {
if (that instanceof ComputeMetadata) {
ComputeMetadata thatMetadata = ComputeMetadata.class.cast(that);
return start()
.compare(this.getId(), thatMetadata.getId())
.compare(this.getType(), thatMetadata.getType())
.compare(this.getName(), that.getName(), natural().nullsLast())
.result();
} else {
return super.compareTo(that);
}
}
@Override
public boolean equals(Object o) {
if (this == o)

View File

@ -165,7 +165,6 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
return hostname;
}
// equals and toString from super are sufficient to establish identity equivalence
protected ToStringHelper string() {

View File

@ -17,6 +17,7 @@
package org.jclouds.compute.extensions.internal;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jclouds.compute.predicates.NodePredicates.inGroup;
import static org.jclouds.util.Predicates2.retry;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@ -37,6 +38,7 @@ import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger;
import org.jclouds.ssh.SshClient;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import com.google.common.base.Optional;
@ -56,6 +58,8 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
protected final String imageGroup = "test-create-image";
protected String imageId;
/**
@ -98,20 +102,20 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte
Template template = getNodeTemplate();
NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup("test-create-image", 1, template));
NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup(imageGroup, 1, template));
checkReachable(node);
logger.info("Creating image from node %s, started with template: %s", node, template);
ImageTemplate newImageTemplate = imageExtension.get().buildImageTemplateFromNode("test-create-image",
node.getId());
ImageTemplate newImageTemplate = imageExtension.get().buildImageTemplateFromNode(imageGroup,
node.getId());
Image image = imageExtension.get().createImage(newImageTemplate).get();
logger.info("Image created: %s", image);
assertEquals("test-create-image", image.getName());
assertEquals(imageGroup, image.getName());
imageId = image.getId();
@ -120,7 +124,6 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte
Optional<? extends Image> optImage = getImage();
assertTrue(optImage.isPresent());
}
@Test(groups = { "integration", "live" }, singleThreaded = true, dependsOnMethods = "testCreateImage")
@ -132,7 +135,7 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte
assertTrue(optImage.isPresent());
NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup("test-create-image", 1, view
NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup(imageGroup, 1, view
.getComputeService()
// fromImage does not use the arg image's id (but we do need to set location)
.templateBuilder().imageId(optImage.get().getId()).fromImage(optImage.get()).build()));
@ -183,4 +186,26 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte
}
}, getSpawnNodeMaxWait(), 1l, SECONDS).apply(client));
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
try {
view.getComputeService().destroyNodesMatching(inGroup(imageGroup));
Optional<? extends Image> image = getImage();
if (image.isPresent() && image.get().getStatus() != Image.Status.DELETED) {
Optional<ImageExtension> imageExtension = view.getComputeService().getImageExtension();
if (imageExtension.isPresent()) {
imageExtension.get().deleteImage(image.get().getId());
}
}
} catch (Exception e) {
// Any exception is most likely due to nodes/images not existing, which is the desired result
// anyway, so discarding the exception.
}
super.tearDownContext();
}
}

View File

@ -16,14 +16,9 @@
*/
package org.jclouds.compute.extensions.internal;
import static java.util.concurrent.TimeUnit.SECONDS;
import static com.google.common.base.Predicates.equalTo;
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.compute.predicates.NodePredicates.inGroup;
import static org.jclouds.util.Predicates2.retry;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.util.Set;
@ -34,20 +29,16 @@ import javax.inject.Named;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.RunNodesException;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.SecurityGroup;
import org.jclouds.compute.domain.SecurityGroupBuilder;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.extensions.SecurityGroupExtension;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Location;
import org.jclouds.logging.Logger;
import org.jclouds.net.domain.IpPermission;
import org.jclouds.net.domain.IpProtocol;
import org.jclouds.ssh.SshClient;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import com.google.common.base.Optional;
@ -62,7 +53,7 @@ import com.google.common.collect.Sets;
/**
* Base test for {@link SecurityGroupExtension} implementations.
*
* @author David Alves
* @author Andrew Bayer
*
*/
public abstract class BaseSecurityGroupExtensionLiveTest extends BaseComputeServiceContextLiveTest {
@ -71,19 +62,20 @@ public abstract class BaseSecurityGroupExtensionLiveTest extends BaseComputeServ
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL;
protected final String secGroupName = "test-create-security-group";
protected final String nodeGroup = "test-create-node-with-group";
protected String groupId;
/**
* Returns the template for the base node, override to test different templates.
*
*
* @return
*/
public Template getNodeTemplate() {
return view.getComputeService().templateBuilder().build();
}
@Test(groups = { "integration", "live" }, singleThreaded = true)
public void testCreateSecurityGroup() throws RunNodesException, InterruptedException, ExecutionException {
@ -95,11 +87,11 @@ public abstract class BaseSecurityGroupExtensionLiveTest extends BaseComputeServ
assertTrue(securityGroupExtension.isPresent(), "security extension was not present");
SecurityGroup group = securityGroupExtension.get().createSecurityGroup("test-create-security-group", location);
SecurityGroup group = securityGroupExtension.get().createSecurityGroup(secGroupName, location);
logger.info("Group created: %s", group);
assertTrue(group.getName().contains("test-create-security-group"));
assertTrue(group.getName().contains(secGroupName));
groupId = group.getId();
}
@ -119,7 +111,7 @@ public abstract class BaseSecurityGroupExtensionLiveTest extends BaseComputeServ
logger.info("Group found: %s", group);
assertTrue(group.getName().contains("test-create-security-group"));
assertTrue(group.getName().contains(secGroupName));
}
@Test(groups = { "integration", "live" }, singleThreaded = true, dependsOnMethods = "testGetSecurityGroupById")
@ -273,7 +265,8 @@ public abstract class BaseSecurityGroupExtensionLiveTest extends BaseComputeServ
assertTrue(thirdNewGroup.getIpPermissions().contains(thirdPerm));
}
}
/*
@Test(groups = { "integration", "live" }, singleThreaded = true, dependsOnMethods = "testAddIpPermissionsFromSpec")
public void testCreateNodeWithSecurityGroup() throws RunNodesException, InterruptedException, ExecutionException {
@ -287,7 +280,7 @@ public abstract class BaseSecurityGroupExtensionLiveTest extends BaseComputeServ
.options(TemplateOptions.Builder.securityGroups(groupId))
.build();
NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup("test-create-node-with-group", 1, template));
NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup(nodeGroup, 1, template));
Set<SecurityGroup> groups = securityGroupExtension.get().listSecurityGroupsForNode(node.getId());
@ -307,11 +300,10 @@ public abstract class BaseSecurityGroupExtensionLiveTest extends BaseComputeServ
}
*/
// testDeleteSecurityGroup currently disabled until I can find a way to get it to delete the security group while a terminated
// instance is still floating around in EC2. - abayer, 6/14/13
/*
@Test(groups = { "integration", "live" }, singleThreaded = true, dependsOnMethods = "testCreateNodeWithSecurityGroup")
@Test(groups = { "integration", "live" }, singleThreaded = true, dependsOnMethods = "testAddIpPermissionsFromSpec")
public void testDeleteSecurityGroup() {
ComputeService computeService = view.getComputeService();
@ -327,7 +319,6 @@ public abstract class BaseSecurityGroupExtensionLiveTest extends BaseComputeServ
assertTrue(securityGroupExtension.get().removeSecurityGroup(group.getId()));
}
*/
private Multimap<String, String> emptyMultimap() {
return LinkedHashMultimap.create();
@ -345,4 +336,42 @@ public abstract class BaseSecurityGroupExtensionLiveTest extends BaseComputeServ
}
});
}
private void cleanup() {
ComputeService computeService = view.getComputeService();
Location location = getNodeTemplate().getLocation();
Optional<SecurityGroupExtension> securityGroupExtension = computeService.getSecurityGroupExtension();
if (securityGroupExtension.isPresent()) {
SecurityGroup group = Iterables.getFirst(filter(securityGroupExtension.get().listSecurityGroups(),
new Predicate<SecurityGroup>() {
@Override
public boolean apply(SecurityGroup input) {
return secGroupName.equals(input.getName());
}
}), null);
if (group != null) {
securityGroupExtension.get().removeSecurityGroup(group.getId());
}
}
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
try {
view.getComputeService().destroyNodesMatching(inGroup(nodeGroup));
cleanup();
} catch (Exception e) {
}
super.tearDownContext();
}
}

View File

@ -15,6 +15,7 @@
* limitations under the License.
*/
package org.jclouds.compute.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Predicates.and;
import static com.google.common.base.Predicates.not;
@ -343,7 +344,8 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet()));
throw e;
}
assertEquals(nodes.size(), 2);
assertEquals(nodes.size(), 2, "expected two nodes but was " + nodes);
checkNodes(nodes, group, "bootstrap");
NodeMetadata node1 = nodes.first();
NodeMetadata node2 = nodes.last();
@ -855,8 +857,12 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
if (nodes != null) {
testDestroyNodes();
try {
if (nodes != null) {
client.destroyNodesMatching(inGroup(group));
}
} catch (Exception e) {
}
super.tearDownContext();
}

View File

@ -1,33 +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.aws.ec2.compute.functions;
import org.jclouds.ec2.compute.functions.PasswordCredentialsFromWindowsInstanceLiveTest;
import org.testng.annotations.Test;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true, testName = "AWSPasswordCredentialsFromWindowsInstanceLiveTest")
public class AWSPasswordCredentialsFromWindowsInstanceLiveTest extends PasswordCredentialsFromWindowsInstanceLiveTest {
public AWSPasswordCredentialsFromWindowsInstanceLiveTest() {
provider = "aws-ec2";
}
}