removed chance of race condition due to duplicate tearDown methods

This commit is contained in:
Adrian Cole 2012-12-24 00:16:57 -08:00
parent e484d7033f
commit dadf142cac
31 changed files with 92 additions and 276 deletions

View File

@ -404,13 +404,13 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest
} }
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
if (server != null) if (server != null)
client.destroyServer(server.getUuid()); client.destroyServer(server.getUuid());
if (server != null) if (server != null)
client.destroyDrive(drive.getUuid()); client.destroyDrive(drive.getUuid());
if (cloudSigmaContext != null) super.tearDownContext();
cloudSigmaContext.close();
} }
@Test @Test

View File

@ -1,147 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudstack;
//
//import static org.testng.Assert.assertEquals;
//
//import java.io.IOException;
//import java.util.logging.Logger;
//
//import org.jclouds.compute.domain.ExecResponse;
//import org.jclouds.cloudstack.domain.Instance;
//import org.jclouds.cloudstack.domain.InstanceAction;
//import org.jclouds.cloudstack.domain.InstanceState;
//import org.jclouds.cloudstack.features.ReadOnlyCloudStackClientLiveTest;
//import org.jclouds.cloudstack.options.CreateInstanceOptions;
//import org.jclouds.domain.Credentials;
//import org.jclouds.http.HttpRequest;
//import com.google.common.net.HostAndPort;
//import org.jclouds.ssh.SshClient;
//import org.jclouds.ssh.jsch.config.JschSshClientModule;
//import org.testng.annotations.AfterGroups;
//import org.testng.annotations.Test;
//
//import com.google.common.collect.Iterables;
//import com.google.gson.Gson;
//import com.google.inject.Guice;
//
///**
// * Tests behavior of {@code CloudStackClient}
// *
// * @author Adrian Cole
// */
//@Test(groups = "live", singleThreaded = true, testName = "CloudStackClientLiveTest")
//public class CloudStackClientLiveTest extends ReadOnlyCloudStackClientLiveTest {
//
// protected String prefix = System.getProperty("user.name") + ".test";
// protected Instance instance;
//
// public void testCreateInstance() throws Exception {
// Logger.getAnonymousLogger().info("starting instance");
// instance = client.createInstance(Iterables.get(client.listImages(), 0).getId(),
// CreateInstanceOptions.Builder.named(prefix));
// instance = client.getInstance(instance.getHref());
// checkStartedInstance();
//
// Instance newInfo = client.getInstance(instance.getHref());
// checkInstanceMatchesGet(newInfo);
//
// }
//
// protected void checkInstanceMatchesGet(Instance newInfo) {
// assertEquals(newInfo.getHref(), instance.getHref());
// }
//
// protected void checkStartedInstance() {
// System.out.println(new Gson().toJson(instance));
// assertEquals(instance.getName(), prefix);
// assertEquals(instance.getState(), InstanceState.RUNNING);
// }
//
// @Test(dependsOnMethods = "testCreateInstance")
// public void testConnectivity() throws Exception {
// Logger.getAnonymousLogger().info("awaiting ssh");
// // TODO
// // assert socketTester.apply(HostAndPort.fromParts(Iterables.get(instance.getPublicAddresses(), 0),
// // 22)) : instance;
// // doConnectViaSsh(instance, getSshCredentials(instance));
// }
//
// private Credentials getSshCredentials(Instance instance2) {
// // TODO
// return null;
// }
//
// public HttpRequest refreshInstanceAndGetAction(InstanceAction action) {
// return client.getInstance(instance.getHref()).getActions().get(action);
// }
//
// @Test(dependsOnMethods = "testConnectivity")
// public void testLifeCycle() throws Exception {
// client.performAction(refreshInstanceAndGetAction(InstanceAction.STOP));
// assertEquals(client.getInstance(instance.getHref()).getState(), InstanceState.STOPPED);
//
// client.performAction(refreshInstanceAndGetAction(InstanceAction.START));
// assertEquals(client.getInstance(instance.getHref()).getState(), InstanceState.RUNNING);
//
// client.performAction(refreshInstanceAndGetAction(InstanceAction.REBOOT));
// assertEquals(client.getInstance(instance.getHref()).getState(), InstanceState.RUNNING);
//
// }
//
// @Test(dependsOnMethods = "testLifeCycle")
// public void testDestroyInstance() throws Exception {
// try {
// client.performAction(refreshInstanceAndGetAction(InstanceAction.STOP));
// assertEquals(client.getInstance(instance.getHref()).getState(), InstanceState.STOPPED);
// } catch (IllegalArgumentException e) {
// }
// client.performAction(refreshInstanceAndGetAction(InstanceAction.DESTROY));
// assertEquals(client.getInstance(instance.getHref()), null);
// }
//
// protected void doConnectViaSsh(Instance instance, Credentials creds) throws IOException {
// SshClient ssh = Guice.createInjector(new JschSshClientModule()).getInstance(SshClient.Factory.class)
// .create(HostAndPort.fromParts(Iterables.get(instance.getPublicAddresses(), 0), 22), creds);
// try {
// ssh.connect();
// ExecResponse hello = ssh.exec("echo hello");
// assertEquals(hello.getOutput().trim(), "hello");
// System.err.println(ssh.exec("df -k").getOutput());
// System.err.println(ssh.exec("mount").getOutput());
// System.err.println(ssh.exec("uname -a").getOutput());
// } finally {
// if (ssh != null)
// ssh.disconnect();
// }
// }
//
// @AfterGroups(groups = "live")
// @Override
// protected void tearDown() {
// try {
// testDestroyInstance();
// } catch (Exception e) {
// // no need to check null or anything as we swallow all
// }
// super.tearDown();
// }
//
// }

View File

@ -217,9 +217,10 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
} }
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
if (vm != null) if (vm != null)
adapter.destroyNode(vm.getNodeId()); adapter.destroyNode(vm.getNodeId());
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -62,11 +62,12 @@ public class AddressClientLiveTest extends BaseCloudStackClientLiveTest {
} }
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
if (ip != null) { if (ip != null) {
client.getAddressClient().disassociateIPAddress(ip.getId()); client.getAddressClient().disassociateIPAddress(ip.getId());
} }
super.tearDown(); super.tearDownContext();
} }
public void testListPublicIPAddresss() throws Exception { public void testListPublicIPAddresss() throws Exception {

View File

@ -154,7 +154,8 @@ public class FirewallClientLiveTest extends BaseCloudStackClientLiveTest {
} }
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
if (firewallRule != null) { if (firewallRule != null) {
client.getFirewallClient().deleteFirewallRule(firewallRule.getId()); client.getFirewallClient().deleteFirewallRule(firewallRule.getId());
} }
@ -167,7 +168,7 @@ public class FirewallClientLiveTest extends BaseCloudStackClientLiveTest {
if (ip != null) { if (ip != null) {
client.getAddressClient().disassociateIPAddress(ip.getId()); client.getAddressClient().disassociateIPAddress(ip.getId());
} }
super.tearDown(); super.tearDownContext();
} }
protected void checkFirewallRule(FirewallRule rule) { protected void checkFirewallRule(FirewallRule rule) {

View File

@ -21,7 +21,6 @@ package org.jclouds.cloudstack.features;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import java.util.Set; import java.util.Set;

View File

@ -35,6 +35,7 @@ import org.jclouds.cloudstack.options.CreatePodOptions;
import org.jclouds.cloudstack.options.ListPodsOptions; import org.jclouds.cloudstack.options.ListPodsOptions;
import org.jclouds.cloudstack.options.UpdatePodOptions; import org.jclouds.cloudstack.options.UpdatePodOptions;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Strings; import com.google.common.base.Strings;
@ -117,8 +118,9 @@ public class GlobalPodClientLiveTest extends BaseCloudStackClientLiveTest {
assertEquals(updated.getAllocationState(), AllocationState.DISABLED); assertEquals(updated.getAllocationState(), AllocationState.DISABLED);
} }
@AfterClass @AfterGroups(groups = "live")
public void testFixtureTearDown() { @Override
protected void tearDownContext() {
if (pod != null) { if (pod != null) {
globalAdminClient.getPodClient().deletePod(pod.getId()); globalAdminClient.getPodClient().deletePod(pod.getId());
pod = null; pod = null;
@ -127,5 +129,6 @@ public class GlobalPodClientLiveTest extends BaseCloudStackClientLiveTest {
globalAdminClient.getZoneClient().deleteZone(zone.getId()); globalAdminClient.getZoneClient().deleteZone(zone.getId());
zone = null; zone = null;
} }
super.tearDownContext();
} }
} }

View File

@ -37,7 +37,7 @@ import org.jclouds.cloudstack.options.CreateVlanIPRangeOptions;
import org.jclouds.cloudstack.options.ListVlanIPRangesOptions; import org.jclouds.cloudstack.options.ListVlanIPRangesOptions;
import org.jclouds.cloudstack.predicates.NetworkOfferingPredicates; import org.jclouds.cloudstack.predicates.NetworkOfferingPredicates;
import org.jclouds.cloudstack.predicates.ZonePredicates; import org.jclouds.cloudstack.predicates.ZonePredicates;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -121,8 +121,9 @@ public class GlobalVlanClientLiveTest extends BaseCloudStackClientLiveTest {
); );
} }
@AfterClass @AfterGroups(groups = "live")
public void testFixtureTearDown() { @Override
protected void tearDownContext() {
if (range != null) { if (range != null) {
globalAdminClient.getVlanClient().deleteVlanIPRange(range.getId()); globalAdminClient.getVlanClient().deleteVlanIPRange(range.getId());
range = null; range = null;
@ -131,6 +132,7 @@ public class GlobalVlanClientLiveTest extends BaseCloudStackClientLiveTest {
client.getNetworkClient().deleteNetwork(network.getId()); client.getNetworkClient().deleteNetwork(network.getId());
network = null; network = null;
} }
super.tearDownContext();
} }
} }

View File

@ -179,7 +179,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
} }
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
if (rule != null) { if (rule != null) {
assertTrue(jobComplete.apply(client.getLoadBalancerClient().deleteLoadBalancerRule(rule.getId()))); assertTrue(jobComplete.apply(client.getLoadBalancerClient().deleteLoadBalancerRule(rule.getId())));
} }
@ -189,7 +190,7 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
if (ip != null) { if (ip != null) {
client.getAddressClient().disassociateIPAddress(ip.getId()); client.getAddressClient().disassociateIPAddress(ip.getId());
} }
super.tearDown(); super.tearDownContext();
} }
public void testListLoadBalancerRules() throws Exception { public void testListLoadBalancerRules() throws Exception {

View File

@ -36,6 +36,7 @@ import org.jclouds.cloudstack.options.AccountInDomainOptions;
import org.jclouds.cloudstack.options.DeployVirtualMachineOptions; import org.jclouds.cloudstack.options.DeployVirtualMachineOptions;
import org.jclouds.cloudstack.options.ListSecurityGroupsOptions; import org.jclouds.cloudstack.options.ListSecurityGroupsOptions;
import org.jclouds.util.Strings2; import org.jclouds.util.Strings2;
import org.testng.SkipException;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -98,11 +99,16 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
connection.connect(); connection.connect();
return Strings2.toStringAndClose(connection.getInputStream()).trim() + "/32"; return Strings2.toStringAndClose(connection.getInputStream()).trim() + "/32";
} }
protected void skipIfSecurityGroupsNotSupported() {
if (!securityGroupsSupported) {
throw new SkipException("Test cannot run without security groups supported in a zone");
}
}
@Test(dependsOnMethods = "testCreateDestroySecurityGroup") @Test(dependsOnMethods = "testCreateDestroySecurityGroup")
public void testCreateIngress() throws Exception { public void testCreateIngress() throws Exception {
if (!securityGroupsSupported) skipIfSecurityGroupsNotSupported();
return;
String cidr = getCurrentCIDR(); String cidr = getCurrentCIDR();
ImmutableSet<String> cidrs = ImmutableSet.of(cidr); ImmutableSet<String> cidrs = ImmutableSet.of(cidr);
assertTrue(jobComplete.apply(client.getSecurityGroupClient().authorizeIngressICMPToCIDRs(group.getId(), 0, 8, cidrs)), group.toString()); assertTrue(jobComplete.apply(client.getSecurityGroupClient().authorizeIngressICMPToCIDRs(group.getId(), 0, 8, cidrs)), group.toString());
@ -163,16 +169,14 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
} }
public void testListSecurityGroup() throws Exception { public void testListSecurityGroup() throws Exception {
if (!securityGroupsSupported) skipIfSecurityGroupsNotSupported();
return;
for (SecurityGroup securityGroup : client.getSecurityGroupClient().listSecurityGroups()) for (SecurityGroup securityGroup : client.getSecurityGroupClient().listSecurityGroups())
checkGroup(securityGroup); checkGroup(securityGroup);
} }
@Test(dependsOnMethods = "testCreateIngress") @Test(dependsOnMethods = "testCreateIngress")
public void testCreateVMInSecurityGroup() throws Exception { public void testCreateVMInSecurityGroup() throws Exception {
if (!securityGroupsSupported) skipIfSecurityGroupsNotSupported();
return;
String defaultTemplate = template != null ? template.getImageId() : null; String defaultTemplate = template != null ? template.getImageId() : null;
vm = VirtualMachineClientLiveTest.createVirtualMachineWithSecurityGroupInZone(zone.getId(), vm = VirtualMachineClientLiveTest.createVirtualMachineWithSecurityGroupInZone(zone.getId(),
defaultTemplateOrPreferredInZone(defaultTemplate, client, zone.getId()), group.getId(), client, defaultTemplateOrPreferredInZone(defaultTemplate, client, zone.getId()), group.getId(), client,
@ -200,8 +204,7 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
@Test @Test
public void testCreateVMWithoutSecurityGroupAssignsDefault() throws Exception { public void testCreateVMWithoutSecurityGroupAssignsDefault() throws Exception {
if (!securityGroupsSupported) skipIfSecurityGroupsNotSupported();
return;
String defaultTemplate = template != null ? template.getImageId() : null; String defaultTemplate = template != null ? template.getImageId() : null;
VirtualMachine newVm = VirtualMachineClientLiveTest.createVirtualMachineWithOptionsInZone(DeployVirtualMachineOptions.NONE, VirtualMachine newVm = VirtualMachineClientLiveTest.createVirtualMachineWithOptionsInZone(DeployVirtualMachineOptions.NONE,
zone.getId(), defaultTemplateOrPreferredInZone(defaultTemplate, client, zone.getId()), client, zone.getId(), defaultTemplateOrPreferredInZone(defaultTemplate, client, zone.getId()), client,
@ -216,7 +219,8 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
} }
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
if (vm != null) { if (vm != null) {
assertTrue(jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vm.getId()))); assertTrue(jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vm.getId())));
} }
@ -226,7 +230,7 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
client.getSecurityGroupClient().deleteSecurityGroup(group.getId()); client.getSecurityGroupClient().deleteSecurityGroup(group.getId());
assertEquals(client.getSecurityGroupClient().getSecurityGroup(group.getId()), null); assertEquals(client.getSecurityGroupClient().getSecurityGroup(group.getId()), null);
} }
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -195,7 +195,8 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
if (vmForCreation != null) { if (vmForCreation != null) {
assertTrue(jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForCreation.getId())), vmForCreation.toString()); assertTrue(jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForCreation.getId())), vmForCreation.toString());
assertTrue(jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vmForCreation.getId())), vmForCreation.toString()); assertTrue(jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vmForCreation.getId())), vmForCreation.toString());
@ -214,7 +215,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
AsyncCreateResponse deleteJob = client.getTemplateClient().deleteTemplate(registeredTemplate.getId()); AsyncCreateResponse deleteJob = client.getTemplateClient().deleteTemplate(registeredTemplate.getId());
assertTrue(jobComplete.apply(deleteJob.getJobId())); assertTrue(jobComplete.apply(deleteJob.getJobId()));
} }
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -62,11 +62,12 @@ public class VMGroupClientLiveTest extends BaseCloudStackClientLiveTest {
} }
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
if (groupCreated != null) { if (groupCreated != null) {
client.getVMGroupClient().deleteInstanceGroup(groupCreated.getId()); client.getVMGroupClient().deleteInstanceGroup(groupCreated.getId());
} }
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -326,12 +326,13 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
} }
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
if (vm != null) { if (vm != null) {
destroyMachine(vm); destroyMachine(vm);
vm = null; vm = null;
} }
super.tearDown(); super.tearDownContext();
} }
@Test @Test

View File

@ -108,7 +108,8 @@ public class StaticNATVirtualMachineInNetworkLiveTest extends NATClientLiveTest
} }
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
if (rule != null) { if (rule != null) {
client.getNATClient().deleteIPForwardingRule(rule.getId()); client.getNATClient().deleteIPForwardingRule(rule.getId());
} }
@ -118,7 +119,7 @@ public class StaticNATVirtualMachineInNetworkLiveTest extends NATClientLiveTest
if (ip != null) { if (ip != null) {
client.getAddressClient().disassociateIPAddress(ip.getId()); client.getAddressClient().disassociateIPAddress(ip.getId());
} }
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -58,7 +58,6 @@ import org.jclouds.rest.RestContext;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.SkipException; import org.testng.SkipException;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -283,10 +282,4 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
} }
} }
@AfterGroups(groups = "live")
protected void tearDown() {
if (cloudStackContext != null)
cloudStackContext.close();
}
} }

View File

@ -299,7 +299,8 @@ public class ElasticStackClientLiveTest extends BaseComputeServiceContextLiveTes
} }
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
try { try {
client.destroyServer(server.getUuid()); client.destroyServer(server.getUuid());
} catch (Exception e) { } catch (Exception e) {
@ -310,8 +311,7 @@ public class ElasticStackClientLiveTest extends BaseComputeServiceContextLiveTes
} catch (Exception e) { } catch (Exception e) {
} }
if (cloudStackContext != null) super.tearDownContext();
cloudStackContext.close();
} }
private DriveInfo drive2; private DriveInfo drive2;

View File

@ -21,12 +21,11 @@ package org.jclouds.openstack.keystone.v2_0.internal;
import java.util.Properties; import java.util.Properties;
import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata; import org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi; import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -59,13 +58,7 @@ public class BaseKeystoneApiLiveTest extends BaseContextLiveTest<RestContext<? e
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
return props; return props;
} }
@AfterGroups(groups = "live")
protected void tearDown() {
if (keystoneContext != null)
keystoneContext.close();
}
@Override @Override
protected TypeToken<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>> contextType() { protected TypeToken<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>> contextType() {
return KeystoneApiMetadata.CONTEXT_TOKEN; return KeystoneApiMetadata.CONTEXT_TOKEN;

View File

@ -23,7 +23,6 @@ import org.jclouds.rest.RestContext;
import org.jclouds.snia.cdmi.v1.CDMIApi; import org.jclouds.snia.cdmi.v1.CDMIApi;
import org.jclouds.snia.cdmi.v1.CDMIApiMetadata; import org.jclouds.snia.cdmi.v1.CDMIApiMetadata;
import org.jclouds.snia.cdmi.v1.CDMIAsyncApi; import org.jclouds.snia.cdmi.v1.CDMIAsyncApi;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -49,13 +48,7 @@ public class BaseCDMIApiLiveTest extends BaseContextLiveTest<RestContext<CDMIApi
super.setupContext(); super.setupContext();
cdmiContext = context; cdmiContext = context;
} }
@AfterGroups(groups = "live")
protected void tearDown() {
if (cdmiContext != null)
cdmiContext.close();
}
@Override @Override
protected TypeToken<RestContext<CDMIApi, CDMIAsyncApi>> contextType() { protected TypeToken<RestContext<CDMIApi, CDMIAsyncApi>> contextType() {
return CDMIApiMetadata.CONTEXT_TOKEN; return CDMIApiMetadata.CONTEXT_TOKEN;

View File

@ -151,13 +151,14 @@ public class MachineApiLiveTest extends BaseJoyentCloudApiLiveTest {
api.delete(machine.getId()); api.delete(machine.getId());
} }
@Override
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { @Override
protected void tearDownContext() {
if (machine != null) if (machine != null)
api.delete(machine.getId()); api.delete(machine.getId());
cloudApiContext.getApi().getKeyApi().delete(fingerprint); cloudApiContext.getApi().getKeyApi().delete(fingerprint);
super.tearDown(); super.tearDownContext();
} }
@Override @Override

View File

@ -19,11 +19,10 @@
package org.jclouds.joyent.cloudapi.v6_5.internal; package org.jclouds.joyent.cloudapi.v6_5.internal;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudAsyncApi;
import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi; import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudApi;
import org.jclouds.joyent.cloudapi.v6_5.JoyentCloudAsyncApi;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -50,12 +49,6 @@ public class BaseJoyentCloudApiLiveTest extends BaseComputeServiceContextLiveTes
cloudApiContext = view.unwrap(); cloudApiContext = view.unwrap();
} }
@AfterGroups(groups = "live")
protected void tearDown() {
if (cloudApiContext != null)
cloudApiContext.close();
}
@Override @Override
protected Module getSshModule() { protected Module getSshModule() {
return new SshjSshClientModule(); return new SshjSshClientModule();

View File

@ -59,12 +59,6 @@ public class BaseGlanceApiLiveTest extends BaseContextLiveTest<RestContext<Glanc
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
return props; return props;
} }
@AfterGroups(groups = "live")
protected void tearDown() {
if (glanceContext != null)
glanceContext.close();
}
@Override @Override
protected TypeToken<RestContext<GlanceApi, GlanceAsyncApi>> contextType() { protected TypeToken<RestContext<GlanceApi, GlanceAsyncApi>> contextType() {

View File

@ -22,11 +22,10 @@ import java.util.Properties;
import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.openstack.quantum.v1_0.QuantumApi;
import org.jclouds.openstack.quantum.v1_0.QuantumApiMetadata; import org.jclouds.openstack.quantum.v1_0.QuantumApiMetadata;
import org.jclouds.openstack.quantum.v1_0.QuantumAsyncApi; import org.jclouds.openstack.quantum.v1_0.QuantumAsyncApi;
import org.jclouds.openstack.quantum.v1_0.QuantumApi;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -59,12 +58,6 @@ public class BaseQuantumApiLiveTest extends BaseContextLiveTest<RestContext<Quan
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
return props; return props;
} }
@AfterGroups(groups = "live")
protected void tearDown() {
if (quantumContext != null)
quantumContext.close();
}
@Override @Override
protected TypeToken<RestContext<QuantumApi, QuantumAsyncApi>> contextType() { protected TypeToken<RestContext<QuantumApi, QuantumAsyncApi>> contextType() {

View File

@ -26,7 +26,6 @@ import org.jclouds.openstack.swift.v1.SwiftApi;
import org.jclouds.openstack.swift.v1.SwiftApiMetadata; import org.jclouds.openstack.swift.v1.SwiftApiMetadata;
import org.jclouds.openstack.swift.v1.SwiftAsyncApi; import org.jclouds.openstack.swift.v1.SwiftAsyncApi;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
@ -57,12 +56,6 @@ public class BaseSwiftApiLiveTest extends BaseContextLiveTest<RestContext<SwiftA
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE); setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
return props; return props;
} }
@AfterGroups(groups = "live")
protected void tearDown() {
if (swiftContext != null)
swiftContext.close();
}
@Override @Override
protected TypeToken<RestContext<SwiftApi, SwiftAsyncApi>> contextType() { protected TypeToken<RestContext<SwiftApi, SwiftAsyncApi>> contextType() {

View File

@ -91,7 +91,8 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
} }
@AfterClass(alwaysRun = true) @AfterClass(alwaysRun = true)
public void tearDown() { @Override
protected void tearDownContext() {
if (media != null) { if (media != null) {
try { try {
Task remove = context.getApi().getMediaApi().remove(media.getId()); Task remove = context.getApi().getMediaApi().remove(media.getId());
@ -116,6 +117,7 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest {
} }
} }
} }
super.tearDownContext();
} }
@Test(description = "GET /catalog/{id}") @Test(description = "GET /catalog/{id}")

View File

@ -55,7 +55,6 @@ import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndDelete
import org.jclouds.virtualbox.util.MachineController; import org.jclouds.virtualbox.util.MachineController;
import org.jclouds.virtualbox.util.MachineUtils; import org.jclouds.virtualbox.util.MachineUtils;
import org.jclouds.virtualbox.util.NetworkUtils; import org.jclouds.virtualbox.util.NetworkUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterSuite; import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -211,12 +210,6 @@ public class BaseVirtualBoxClientLiveTest extends BaseComputeServiceContextLiveT
return new SshjSshClientModule(); return new SshjSshClientModule();
} }
@AfterClass(groups = "live")
protected void tearDown() throws Exception {
if (view != null)
view.close();
}
@AfterSuite @AfterSuite
protected void destroyMaster() { protected void destroyMaster() {
if (System.getProperty(DONT_DESTROY_MASTER) == null if (System.getProperty(DONT_DESTROY_MASTER) == null

View File

@ -35,7 +35,7 @@ import org.jclouds.domain.LoginCredentials;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest; import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
import org.jclouds.virtualbox.functions.IMachineToSshClient; import org.jclouds.virtualbox.functions.IMachineToSshClient;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.virtualbox_4_1.IMachine; import org.virtualbox_4_1.IMachine;
@ -88,11 +88,11 @@ public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClien
assertFalse(Iterables.isEmpty(iMageIterable)); assertFalse(Iterables.isEmpty(iMageIterable));
} }
@AfterClass @AfterGroups(groups = "live")
@Override @Override
protected void tearDown() throws Exception { protected void tearDownContext() {
if (machine != null) if (machine != null)
adapter.destroyNode(machine.getNodeId() + ""); adapter.destroyNode(machine.getNodeId() + "");
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -34,7 +34,7 @@ import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
import org.jclouds.virtualbox.domain.NetworkSpec; import org.jclouds.virtualbox.domain.NetworkSpec;
import org.jclouds.virtualbox.domain.StorageController; import org.jclouds.virtualbox.domain.StorageController;
import org.jclouds.virtualbox.domain.VmSpec; import org.jclouds.virtualbox.domain.VmSpec;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.virtualbox_4_1.CleanupMode; import org.virtualbox_4_1.CleanupMode;
@ -116,13 +116,13 @@ public class CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest exten
} }
} }
@AfterGroups(groups = "live")
@Override @Override
@AfterClass(groups = "live") protected void tearDownContext() {
protected void tearDown() throws Exception {
for (String vmName : ImmutableSet.of(instanceName)) { for (String vmName : ImmutableSet.of(instanceName)) {
undoVm(vmName); undoVm(vmName);
} }
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -22,8 +22,8 @@ package org.jclouds.virtualbox.functions;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX; import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE; import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import java.net.URI; import java.net.URI;
import java.util.Map; import java.util.Map;
@ -49,7 +49,7 @@ import org.jclouds.virtualbox.domain.NetworkSpec;
import org.jclouds.virtualbox.domain.StorageController; import org.jclouds.virtualbox.domain.StorageController;
import org.jclouds.virtualbox.domain.VmSpec; import org.jclouds.virtualbox.domain.VmSpec;
import org.jclouds.virtualbox.predicates.SshResponds; import org.jclouds.virtualbox.predicates.SshResponds;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.virtualbox_4_1.CleanupMode; import org.virtualbox_4_1.CleanupMode;
@ -164,12 +164,12 @@ public class CreateAndInstallVmLiveTest extends BaseVirtualBoxClientLiveTest {
} }
} }
@AfterGroups(groups = "live")
@Override @Override
@AfterClass(groups = "live") protected void tearDownContext() {
protected void tearDown() throws Exception {
for (String vmName : ImmutableSet.of(instanceName)) { for (String vmName : ImmutableSet.of(instanceName)) {
undoVm(vmName); undoVm(vmName);
} }
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -33,7 +33,7 @@ import org.jclouds.virtualbox.domain.NetworkInterfaceCard;
import org.jclouds.virtualbox.domain.NetworkSpec; import org.jclouds.virtualbox.domain.NetworkSpec;
import org.jclouds.virtualbox.domain.StorageController; import org.jclouds.virtualbox.domain.StorageController;
import org.jclouds.virtualbox.domain.VmSpec; import org.jclouds.virtualbox.domain.VmSpec;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.virtualbox_4_1.CleanupMode; import org.virtualbox_4_1.CleanupMode;
import org.virtualbox_4_1.IMachine; import org.virtualbox_4_1.IMachine;
@ -118,11 +118,11 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends B
} }
} }
@AfterGroups(groups = "live")
@Override @Override
@AfterMethod(groups = "live") protected void tearDownContext() {
protected void tearDown() throws Exception {
undoVm(vmName); undoVm(vmName);
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -37,7 +37,7 @@ import org.jclouds.virtualbox.domain.StorageController;
import org.jclouds.virtualbox.domain.VmSpec; import org.jclouds.virtualbox.domain.VmSpec;
import org.jclouds.virtualbox.functions.CloneAndRegisterMachineFromIMachineIfNotAlreadyExists; import org.jclouds.virtualbox.functions.CloneAndRegisterMachineFromIMachineIfNotAlreadyExists;
import org.jclouds.virtualbox.functions.CreateAndInstallVm; import org.jclouds.virtualbox.functions.CreateAndInstallVm;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.virtualbox_4_1.CleanupMode; import org.virtualbox_4_1.CleanupMode;
@ -119,12 +119,12 @@ public class IMachinePredicatesLiveTest extends BaseVirtualBoxClientLiveTest {
} }
} }
@AfterGroups(groups = "live")
@Override @Override
@AfterClass(groups = "live") protected void tearDownContext() {
protected void tearDown() throws Exception {
for (String vmName : ImmutableSet.of(instanceName)) { for (String vmName : ImmutableSet.of(instanceName)) {
undoVm(vmName); undoVm(vmName);
} }
super.tearDown(); super.tearDownContext();
} }
} }

View File

@ -23,7 +23,6 @@ import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE; import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
import org.jclouds.config.ValueOfConfigurationKeyOrNull; import org.jclouds.config.ValueOfConfigurationKeyOrNull;
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest; import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
@ -38,7 +37,7 @@ import org.jclouds.virtualbox.domain.StorageController;
import org.jclouds.virtualbox.domain.VmSpec; import org.jclouds.virtualbox.domain.VmSpec;
import org.jclouds.virtualbox.functions.CloneAndRegisterMachineFromIMachineIfNotAlreadyExists; import org.jclouds.virtualbox.functions.CloneAndRegisterMachineFromIMachineIfNotAlreadyExists;
import org.jclouds.virtualbox.functions.CreateAndInstallVm; import org.jclouds.virtualbox.functions.CreateAndInstallVm;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import org.virtualbox_4_1.CleanupMode; import org.virtualbox_4_1.CleanupMode;
@ -135,12 +134,12 @@ public class MachineControllerLiveTest extends BaseVirtualBoxClientLiveTest {
} }
} }
@AfterGroups(groups = "live")
@Override @Override
@AfterClass(groups = "live") protected void tearDownContext() {
protected void tearDown() throws Exception {
for (String vmName : ImmutableSet.of(instanceName)) { for (String vmName : ImmutableSet.of(instanceName)) {
undoVm(vmName); undoVm(vmName);
} }
super.tearDown(); super.tearDownContext();
} }
} }