mirror of https://github.com/apache/jclouds.git
moved all code off use of RestContext except CloudStackContext, which will use it until 1.7
This commit is contained in:
parent
bf0a0aa781
commit
39f3dba5ef
|
@ -47,7 +47,6 @@ import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
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.annotations.AfterGroups;
|
import org.testng.annotations.AfterGroups;
|
||||||
|
@ -78,7 +77,6 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest
|
||||||
protected int maxDriveImageTime = 300;
|
protected int maxDriveImageTime = 300;
|
||||||
protected String vncPassword = "Il0veVNC";
|
protected String vncPassword = "Il0veVNC";
|
||||||
protected CloudSigmaClient client;
|
protected CloudSigmaClient client;
|
||||||
protected RestContext<CloudSigmaClient, CloudSigmaAsyncClient> cloudSigmaContext;
|
|
||||||
protected Predicate<HostAndPort> socketTester;
|
protected Predicate<HostAndPort> socketTester;
|
||||||
|
|
||||||
protected Predicate<DriveInfo> driveNotClaimed;
|
protected Predicate<DriveInfo> driveNotClaimed;
|
||||||
|
@ -88,9 +86,8 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
cloudSigmaContext = view.unwrap();
|
|
||||||
|
|
||||||
client = cloudSigmaContext.getApi();
|
client = view.utils().injector().getInstance(CloudSigmaClient.class);
|
||||||
driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
|
driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
|
||||||
SocketOpen socketOpten = context.utils().injector().getInstance(SocketOpen.class);
|
SocketOpen socketOpten = context.utils().injector().getInstance(SocketOpen.class);
|
||||||
socketTester = retry(socketOpten, maxDriveImageTime, 1, SECONDS);
|
socketTester = retry(socketOpten, maxDriveImageTime, 1, SECONDS);
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.jclouds.cloudstack;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.internal.CloudStackContextImpl;
|
import org.jclouds.cloudstack.internal.CloudStackContextImpl;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
|
|
||||||
import com.google.inject.ImplementedBy;
|
import com.google.inject.ImplementedBy;
|
||||||
|
|
||||||
|
@ -33,8 +32,24 @@ import com.google.inject.ImplementedBy;
|
||||||
@ImplementedBy(CloudStackContextImpl.class)
|
@ImplementedBy(CloudStackContextImpl.class)
|
||||||
public interface CloudStackContext extends ComputeServiceContext {
|
public interface CloudStackContext extends ComputeServiceContext {
|
||||||
|
|
||||||
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext();
|
CloudStackClient getApi();
|
||||||
|
|
||||||
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> getGlobalContext();
|
/**
|
||||||
|
* @deprecated please use {@link #getDomainApi()} as
|
||||||
|
* async interface will be removed in jclouds 1.7.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
org.jclouds.rest.RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext();
|
||||||
|
|
||||||
|
CloudStackDomainClient getDomainApi();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated please use {@link #getGlobalApi()} as
|
||||||
|
* async interface will be removed in jclouds 1.7.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
org.jclouds.rest.RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> getGlobalContext();
|
||||||
|
|
||||||
|
CloudStackGlobalClient getGlobalApi();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.Context;
|
import org.jclouds.Context;
|
||||||
|
import org.jclouds.cloudstack.CloudStackClient;
|
||||||
import org.jclouds.cloudstack.CloudStackContext;
|
import org.jclouds.cloudstack.CloudStackContext;
|
||||||
import org.jclouds.cloudstack.CloudStackDomainAsyncClient;
|
import org.jclouds.cloudstack.CloudStackDomainAsyncClient;
|
||||||
import org.jclouds.cloudstack.CloudStackDomainClient;
|
import org.jclouds.cloudstack.CloudStackDomainClient;
|
||||||
|
@ -31,7 +32,6 @@ import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.Utils;
|
import org.jclouds.compute.Utils;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
import org.jclouds.location.Provider;
|
import org.jclouds.location.Provider;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
|
@ -40,26 +40,43 @@ import com.google.common.reflect.TypeToken;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class CloudStackContextImpl extends ComputeServiceContextImpl implements CloudStackContext {
|
public class CloudStackContextImpl extends ComputeServiceContextImpl implements CloudStackContext {
|
||||||
private final RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext;
|
private final CloudStackClient client;
|
||||||
private final RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext;
|
private final org.jclouds.rest.RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext;
|
||||||
|
private final org.jclouds.rest.RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CloudStackContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
|
CloudStackContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
|
||||||
ComputeService computeService, Utils utils,
|
ComputeService computeService, Utils utils, CloudStackClient client,
|
||||||
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext,
|
org.jclouds.rest.RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext,
|
||||||
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext) {
|
org.jclouds.rest.RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext) {
|
||||||
super(backend, backendType, computeService, utils);
|
super(backend, backendType, computeService, utils);
|
||||||
|
this.client = client;
|
||||||
this.domainContext = domainContext;
|
this.domainContext = domainContext;
|
||||||
this.globalContext = globalContext;
|
this.globalContext = globalContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext() {
|
public CloudStackClient getApi() {
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CloudStackDomainClient getDomainApi() {
|
||||||
|
return domainContext.getApi();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CloudStackGlobalClient getGlobalApi() {
|
||||||
|
return globalContext.getApi();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.jclouds.rest.RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext() {
|
||||||
return domainContext;
|
return domainContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> getGlobalContext() {
|
public org.jclouds.rest.RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> getGlobalContext() {
|
||||||
return globalContext;
|
return globalContext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
|
||||||
}).annotatedWith(Memoized.class).to(NetworksForCurrentUser.class).in(Scopes.SINGLETON);
|
}).annotatedWith(Memoized.class).to(NetworksForCurrentUser.class).in(Scopes.SINGLETON);
|
||||||
bind(new TypeLiteral<Map<String, Credentials>>() {
|
bind(new TypeLiteral<Map<String, Credentials>>() {
|
||||||
}).toInstance(credentialStore);
|
}).toInstance(credentialStore);
|
||||||
bind(CloudStackClient.class).toInstance(cloudStackContext.getApi());
|
bind(CloudStackClient.class).toInstance(client);
|
||||||
bind(new TypeLiteral<Map<NetworkType, ? extends OptionsConverter>>() {}).
|
bind(new TypeLiteral<Map<NetworkType, ? extends OptionsConverter>>() {}).
|
||||||
toInstance(new CloudStackComputeServiceContextModule().optionsConverters());
|
toInstance(new CloudStackComputeServiceContextModule().optionsConverters());
|
||||||
bind(String.class).annotatedWith(Names.named(PROPERTY_SESSION_INTERVAL)).toInstance("60");
|
bind(String.class).annotatedWith(Names.named(PROPERTY_SESSION_INTERVAL)).toInstance("60");
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deleteNetworksInZoneWithVlanId(String zoneId, String vlanId) {
|
protected void deleteNetworksInZoneWithVlanId(String zoneId, String vlanId) {
|
||||||
Set<Network> networks = domainAdminContext.getApi().getNetworkClient().listNetworks(
|
Set<Network> networks = domainAdminClient.getNetworkClient().listNetworks(
|
||||||
ListNetworksOptions.Builder
|
ListNetworksOptions.Builder
|
||||||
.isDefault(false)
|
.isDefault(false)
|
||||||
.isSystem(false)
|
.isSystem(false)
|
||||||
|
@ -63,7 +63,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
URI broadcastUri = URI.create("vlan://" + vlanId);
|
URI broadcastUri = URI.create("vlan://" + vlanId);
|
||||||
for (Network net : networks) {
|
for (Network net : networks) {
|
||||||
if (broadcastUri.equals(net.getBroadcastURI())) {
|
if (broadcastUri.equals(net.getBroadcastURI())) {
|
||||||
String jobId = domainAdminContext.getApi().getNetworkClient().deleteNetwork(net.getId());
|
String jobId = domainAdminClient.getNetworkClient().deleteNetwork(net.getId());
|
||||||
adminJobComplete.apply(jobId);
|
adminJobComplete.apply(jobId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
cloudStackContext.getApi().getOfferingClient().listNetworkOfferings(specifyVLAN(true).zoneId(zoneId)), 0).getId();
|
cloudStackContext.getApi().getOfferingClient().listNetworkOfferings(specifyVLAN(true).zoneId(zoneId)), 0).getId();
|
||||||
|
|
||||||
// create an arbitrary network
|
// create an arbitrary network
|
||||||
network = domainAdminContext.getApi()
|
network = domainAdminClient
|
||||||
.getNetworkClient()
|
.getNetworkClient()
|
||||||
// startIP/endIP/netmask/gateway must be specified together
|
// startIP/endIP/netmask/gateway must be specified together
|
||||||
.createNetworkInZone(zoneId, offeringId, group, group,
|
.createNetworkInZone(zoneId, offeringId, group, group,
|
||||||
|
@ -117,7 +117,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
if (nodes != null)
|
if (nodes != null)
|
||||||
view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
|
view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
|
||||||
if (network != null)
|
if (network != null)
|
||||||
domainAdminContext.getApi().getNetworkClient().deleteNetwork(network.getId());
|
domainAdminClient.getNetworkClient().deleteNetwork(network.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,6 @@ public class DomainDomainClientExpectTest extends BaseCloudStackExpectTest<Domai
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DomainDomainClient clientFrom(CloudStackContext context) {
|
protected DomainDomainClient clientFrom(CloudStackContext context) {
|
||||||
return context.getDomainContext().getApi().getDomainClient();
|
return context.getDomainApi().getDomainClient();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
Network network = null;
|
Network network = null;
|
||||||
try {
|
try {
|
||||||
network = domainAdminContext.getApi()
|
network = domainAdminClient
|
||||||
.getNetworkClient()
|
.getNetworkClient()
|
||||||
// startIP/endIP/netmask/gateway must be specified together
|
// startIP/endIP/netmask/gateway must be specified together
|
||||||
.createNetworkInZone(zone.getId(), offering.getId(), name, name,
|
.createNetworkInZone(zone.getId(), offering.getId(), name, name,
|
||||||
|
|
|
@ -67,8 +67,7 @@ public class OfferingClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
// This bug is present both in 2.2.8 and 2.2.12
|
// This bug is present both in 2.2.8 and 2.2.12
|
||||||
assertTrue(Predicates.in(ImmutableSet.of("2.2.8", "2.2.12")).apply(
|
assertTrue(Predicates.in(ImmutableSet.of("2.2.8", "2.2.12")).apply(apiVersion));
|
||||||
cloudStackContext.getProviderMetadata().getApiMetadata().getVersion()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ public class SessionClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
public void testCreateContextUsingUserAndPasswordAuthentication() {
|
public void testCreateContextUsingUserAndPasswordAuthentication() {
|
||||||
skipIfNotGlobalAdmin();
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
String endpoint = cloudStackContext.getProviderMetadata().getEndpoint();
|
|
||||||
Account testAccount = null;
|
Account testAccount = null;
|
||||||
User testUser = null;
|
User testUser = null;
|
||||||
|
|
||||||
|
@ -79,7 +78,6 @@ public class SessionClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test(expectedExceptions = AuthorizationException.class)
|
@Test(expectedExceptions = AuthorizationException.class)
|
||||||
public void testTryToGetApiKeypairWithWrongCredentials() {
|
public void testTryToGetApiKeypairWithWrongCredentials() {
|
||||||
String endpoint = cloudStackContext.getProviderMetadata().getEndpoint();
|
|
||||||
ApiKeyPairs.loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair(
|
ApiKeyPairs.loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair(
|
||||||
URI.create(endpoint), "dummy-missing-user", "with-a-wrong-password", "");
|
URI.create(endpoint), "dummy-missing-user", "with-a-wrong-password", "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,9 @@ package org.jclouds.cloudstack.internal;
|
||||||
import static com.google.common.collect.Iterables.filter;
|
import static com.google.common.collect.Iterables.filter;
|
||||||
import static com.google.common.collect.Iterables.get;
|
import static com.google.common.collect.Iterables.get;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
|
import static org.jclouds.cloudstack.domain.Account.Type.ADMIN;
|
||||||
|
import static org.jclouds.cloudstack.domain.Account.Type.DOMAIN_ADMIN;
|
||||||
|
import static org.jclouds.cloudstack.domain.Account.Type.USER;
|
||||||
import static org.jclouds.reflect.Reflection2.typeToken;
|
import static org.jclouds.reflect.Reflection2.typeToken;
|
||||||
import static org.jclouds.util.Predicates2.retry;
|
import static org.jclouds.util.Predicates2.retry;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
@ -30,17 +33,15 @@ import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.CloudStackAsyncClient;
|
|
||||||
import org.jclouds.cloudstack.CloudStackClient;
|
import org.jclouds.cloudstack.CloudStackClient;
|
||||||
import org.jclouds.cloudstack.CloudStackContext;
|
import org.jclouds.cloudstack.CloudStackContext;
|
||||||
import org.jclouds.cloudstack.CloudStackDomainAsyncClient;
|
|
||||||
import org.jclouds.cloudstack.CloudStackDomainClient;
|
import org.jclouds.cloudstack.CloudStackDomainClient;
|
||||||
import org.jclouds.cloudstack.CloudStackGlobalAsyncClient;
|
|
||||||
import org.jclouds.cloudstack.CloudStackGlobalClient;
|
import org.jclouds.cloudstack.CloudStackGlobalClient;
|
||||||
import org.jclouds.cloudstack.domain.Account;
|
import org.jclouds.cloudstack.domain.Account;
|
||||||
import org.jclouds.cloudstack.domain.Template;
|
import org.jclouds.cloudstack.domain.Template;
|
||||||
import org.jclouds.cloudstack.domain.User;
|
import org.jclouds.cloudstack.domain.User;
|
||||||
import org.jclouds.cloudstack.domain.VirtualMachine;
|
import org.jclouds.cloudstack.domain.VirtualMachine;
|
||||||
|
import org.jclouds.cloudstack.features.AccountClient;
|
||||||
import org.jclouds.cloudstack.functions.ReuseOrAssociateNewPublicIPAddress;
|
import org.jclouds.cloudstack.functions.ReuseOrAssociateNewPublicIPAddress;
|
||||||
import org.jclouds.cloudstack.options.ListTemplatesOptions;
|
import org.jclouds.cloudstack.options.ListTemplatesOptions;
|
||||||
import org.jclouds.cloudstack.predicates.CorrectHypervisorForZone;
|
import org.jclouds.cloudstack.predicates.CorrectHypervisorForZone;
|
||||||
|
@ -55,7 +56,6 @@ import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.internal.BaseGenericComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseGenericComputeServiceContextLiveTest;
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
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;
|
||||||
|
@ -151,7 +151,7 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
|
||||||
protected String prefix = System.getProperty("user.name");
|
protected String prefix = System.getProperty("user.name");
|
||||||
|
|
||||||
protected ComputeService computeClient;
|
protected ComputeService computeClient;
|
||||||
protected RestContext<CloudStackClient, CloudStackAsyncClient> cloudStackContext;
|
protected CloudStackContext cloudStackContext;
|
||||||
protected CloudStackClient client;
|
protected CloudStackClient client;
|
||||||
protected CloudStackClient adminClient;
|
protected CloudStackClient adminClient;
|
||||||
protected User user;
|
protected User user;
|
||||||
|
@ -171,13 +171,11 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
|
||||||
|
|
||||||
protected boolean domainAdminEnabled;
|
protected boolean domainAdminEnabled;
|
||||||
protected CloudStackContext domainAdminComputeContext;
|
protected CloudStackContext domainAdminComputeContext;
|
||||||
protected RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainAdminContext;
|
|
||||||
protected CloudStackDomainClient domainAdminClient;
|
protected CloudStackDomainClient domainAdminClient;
|
||||||
protected User domainAdminUser;
|
protected User domainAdminUser;
|
||||||
|
|
||||||
protected boolean globalAdminEnabled;
|
protected boolean globalAdminEnabled;
|
||||||
protected CloudStackContext globalAdminComputeContext;
|
protected CloudStackContext globalAdminComputeContext;
|
||||||
protected RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalAdminContext;
|
|
||||||
protected CloudStackGlobalClient globalAdminClient;
|
protected CloudStackGlobalClient globalAdminClient;
|
||||||
protected User globalAdminUser;
|
protected User globalAdminUser;
|
||||||
|
|
||||||
|
@ -200,26 +198,25 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
computeClient = view.getComputeService();
|
computeClient = view.getComputeService();
|
||||||
cloudStackContext = view.unwrap();
|
cloudStackContext = CloudStackContext.class.cast(view);
|
||||||
client = cloudStackContext.getApi();
|
client = cloudStackContext.getApi();
|
||||||
user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER);
|
user = verifyCurrentUserIsOfType(identity, client.getAccountClient(), USER);
|
||||||
|
|
||||||
domainAdminEnabled = setupDomainAdminProperties() != null;
|
domainAdminEnabled = setupDomainAdminProperties() != null;
|
||||||
if (domainAdminEnabled) {
|
if (domainAdminEnabled) {
|
||||||
domainAdminComputeContext = createView(setupDomainAdminProperties(), setupModules());
|
domainAdminComputeContext = createView(setupDomainAdminProperties(), setupModules());
|
||||||
domainAdminContext = domainAdminComputeContext.getDomainContext();
|
domainAdminClient = domainAdminComputeContext.getDomainApi();
|
||||||
domainAdminClient = domainAdminContext.getApi();
|
domainAdminUser = verifyCurrentUserIsOfType(domainAdminIdentity, domainAdminClient.getAccountClient(),
|
||||||
domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN);
|
DOMAIN_ADMIN);
|
||||||
adminClient = domainAdminContext.getApi();
|
adminClient = domainAdminClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
globalAdminEnabled = setupGlobalAdminProperties() != null;
|
globalAdminEnabled = setupGlobalAdminProperties() != null;
|
||||||
if (globalAdminEnabled) {
|
if (globalAdminEnabled) {
|
||||||
globalAdminComputeContext = createView(setupGlobalAdminProperties(), setupModules());
|
globalAdminComputeContext = createView(setupGlobalAdminProperties(), setupModules());
|
||||||
globalAdminContext = globalAdminComputeContext.getGlobalContext();
|
globalAdminClient = globalAdminComputeContext.getGlobalApi();
|
||||||
globalAdminClient = globalAdminContext.getApi();
|
globalAdminUser = verifyCurrentUserIsOfType(globalAdminIdentity, globalAdminClient.getAccountClient(), ADMIN);
|
||||||
globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN);
|
adminClient = globalAdminClient;
|
||||||
adminClient = globalAdminContext.getApi();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
injector = cloudStackContext.utils().injector();
|
injector = cloudStackContext.utils().injector();
|
||||||
|
@ -250,10 +247,9 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
|
||||||
return new SshjSshClientModule();
|
return new SshjSshClientModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static User verifyCurrentUserIsOfType(
|
private static User verifyCurrentUserIsOfType(String identity, AccountClient accountClient, Account.Type type) {
|
||||||
RestContext<? extends CloudStackClient, ? extends CloudStackAsyncClient> context, Account.Type type) {
|
Iterable<User> users = Iterables.concat(accountClient.listAccounts());
|
||||||
Iterable<User> users = Iterables.concat(context.getApi().getAccountClient().listAccounts());
|
Predicate<User> apiKeyMatches = UserPredicates.apiKeyEquals(identity);
|
||||||
Predicate<User> apiKeyMatches = UserPredicates.apiKeyEquals(context.getIdentity());
|
|
||||||
User currentUser;
|
User currentUser;
|
||||||
try {
|
try {
|
||||||
currentUser = Iterables.find(users, apiKeyMatches);
|
currentUser = Iterables.find(users, apiKeyMatches);
|
||||||
|
|
|
@ -25,46 +25,29 @@ import static org.jclouds.util.Predicates2.retry;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseContextLiveTest;
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.cloudwatch.domain.Dimension;
|
import org.jclouds.cloudwatch.domain.Dimension;
|
||||||
import org.jclouds.cloudwatch.domain.MetricDatum;
|
import org.jclouds.cloudwatch.domain.MetricDatum;
|
||||||
import org.jclouds.cloudwatch.domain.Unit;
|
import org.jclouds.cloudwatch.domain.Unit;
|
||||||
import org.jclouds.cloudwatch.options.ListMetricsOptions;
|
import org.jclouds.cloudwatch.options.ListMetricsOptions;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code CloudWatch}.
|
* Tests behavior of {@code CloudWatch}.
|
||||||
*
|
*
|
||||||
* @author Jeremy Whitlock
|
* @author Jeremy Whitlock
|
||||||
*/
|
*/
|
||||||
public class CloudWatchLiveTest extends BaseContextLiveTest<RestContext<CloudWatchApi, CloudWatchAsyncApi>> {
|
public class CloudWatchLiveTest extends BaseApiLiveTest<CloudWatchApi> {
|
||||||
|
|
||||||
public CloudWatchLiveTest() {
|
public CloudWatchLiveTest() {
|
||||||
provider = "cloudwatch";
|
provider = "cloudwatch";
|
||||||
}
|
}
|
||||||
|
|
||||||
private CloudWatchApi api;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
|
||||||
public void setupContext() {
|
|
||||||
super.setupContext();
|
|
||||||
api = context.getApi();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeToken<RestContext<CloudWatchApi, CloudWatchAsyncApi>> contextType() {
|
|
||||||
return CloudWatchApiMetadata.CONTEXT_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
protected void testCloudWatchListMetrics() {
|
protected void testCloudWatchListMetrics() {
|
||||||
// Just make sure there is at least one metric returned (Much better if the account you use has more than 500)
|
// Just make sure there is at least one metric returned (Much better if the account you use has more than 500)
|
||||||
|
|
|
@ -303,6 +303,6 @@ public class MetricApiLiveTest extends BaseCloudWatchApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MetricApi api() {
|
protected MetricApi api() {
|
||||||
return context.getApi().getMetricApiForRegion(null);
|
return api.getMetricApiForRegion(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,29 +18,17 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudwatch.internal;
|
package org.jclouds.cloudwatch.internal;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseContextLiveTest;
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.cloudwatch.CloudWatchApiMetadata;
|
|
||||||
import org.jclouds.cloudwatch.CloudWatchAsyncApi;
|
|
||||||
import org.jclouds.cloudwatch.CloudWatchApi;
|
import org.jclouds.cloudwatch.CloudWatchApi;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class BaseCloudWatchApiLiveTest extends BaseContextLiveTest<RestContext<CloudWatchApi, CloudWatchAsyncApi>> {
|
public class BaseCloudWatchApiLiveTest extends BaseApiLiveTest<CloudWatchApi> {
|
||||||
|
|
||||||
public BaseCloudWatchApiLiveTest() {
|
public BaseCloudWatchApiLiveTest() {
|
||||||
provider = "cloudwatch";
|
provider = "cloudwatch";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeToken<RestContext<CloudWatchApi, CloudWatchAsyncApi>> contextType() {
|
|
||||||
return CloudWatchApiMetadata.CONTEXT_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class SubnetApiLiveTest extends BaseEC2ApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SubnetApi api() {
|
private SubnetApi api() {
|
||||||
Optional<? extends SubnetApi> subnetOption = context.getApi().getSubnetApi();
|
Optional<? extends SubnetApi> subnetOption = api.getSubnetApi();
|
||||||
if (!subnetOption.isPresent())
|
if (!subnetOption.isPresent())
|
||||||
throw new SkipException("subnet api not present");
|
throw new SkipException("subnet api not present");
|
||||||
return subnetOption.get();
|
return subnetOption.get();
|
||||||
|
|
|
@ -31,7 +31,7 @@ import com.google.common.base.Optional;
|
||||||
public class WindowsApiLiveTest extends BaseEC2ApiLiveTest {
|
public class WindowsApiLiveTest extends BaseEC2ApiLiveTest {
|
||||||
|
|
||||||
protected WindowsApi api() {
|
protected WindowsApi api() {
|
||||||
Optional<? extends WindowsApi> windowsOption = context.getApi().getWindowsApi();
|
Optional<? extends WindowsApi> windowsOption = api.getWindowsApi();
|
||||||
if (!windowsOption.isPresent())
|
if (!windowsOption.isPresent())
|
||||||
throw new SkipException("windows api not present");
|
throw new SkipException("windows api not present");
|
||||||
return windowsOption.get();
|
return windowsOption.get();
|
||||||
|
|
|
@ -119,8 +119,8 @@ public abstract class BaseTagApiLiveTest extends BaseEC2ApiLiveTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass(groups = "live")
|
@BeforeClass(groups = "live")
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
resource = checkNotNull(createResourceForTagging(System.getProperty("user.name") + "-tag"), "resource");
|
resource = checkNotNull(createResourceForTagging(System.getProperty("user.name") + "-tag"), "resource");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,16 +146,16 @@ public abstract class BaseTagApiLiveTest extends BaseEC2ApiLiveTest {
|
||||||
protected abstract void cleanupResource(Resource resource);
|
protected abstract void cleanupResource(Resource resource);
|
||||||
|
|
||||||
protected TagApi api() {
|
protected TagApi api() {
|
||||||
Optional<? extends TagApi> tagOption = context.getApi().getTagApi();
|
Optional<? extends TagApi> tagOption = api.getTagApi();
|
||||||
if (!tagOption.isPresent())
|
if (!tagOption.isPresent())
|
||||||
throw new SkipException("tag api not present");
|
throw new SkipException("tag api not present");
|
||||||
return tagOption.get();
|
return tagOption.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = "live")
|
@AfterClass(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
if (resource != null)
|
if (resource != null)
|
||||||
cleanupResource(resource);
|
cleanupResource(resource);
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,14 @@
|
||||||
package org.jclouds.ec2.internal;
|
package org.jclouds.ec2.internal;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseContextLiveTest;
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.ec2.EC2Api;
|
import org.jclouds.ec2.EC2Api;
|
||||||
import org.jclouds.ec2.EC2AsyncApi;
|
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class BaseEC2ApiLiveTest extends BaseContextLiveTest<RestContext<? extends EC2Api, ? extends EC2AsyncApi>> {
|
public class BaseEC2ApiLiveTest extends BaseApiLiveTest<EC2Api> {
|
||||||
|
|
||||||
public BaseEC2ApiLiveTest() {
|
public BaseEC2ApiLiveTest() {
|
||||||
provider = "ec2";
|
provider = "ec2";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeToken<RestContext<? extends EC2Api, ? extends EC2AsyncApi>> contextType() {
|
|
||||||
return new TypeToken<RestContext<? extends EC2Api, ? extends EC2AsyncApi>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package org.jclouds.ec2.internal;
|
|
||||||
|
|
||||||
import org.jclouds.apis.BaseContextLiveTest;
|
|
||||||
import org.jclouds.ec2.EC2ApiMetadata;
|
|
||||||
import org.jclouds.ec2.EC2AsyncClient;
|
|
||||||
import org.jclouds.ec2.EC2Client;
|
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class BaseEC2ClientLiveTest extends BaseContextLiveTest<RestContext<? extends EC2Client, ? extends EC2AsyncClient>> {
|
|
||||||
|
|
||||||
public BaseEC2ClientLiveTest() {
|
|
||||||
provider = "ec2";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeToken<RestContext<? extends EC2Client, ? extends EC2AsyncClient>> contextType() {
|
|
||||||
return EC2ApiMetadata.CONTEXT_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -44,7 +44,6 @@ import org.jclouds.elasticstack.predicates.DriveClaimed;
|
||||||
import org.jclouds.elasticstack.util.Servers;
|
import org.jclouds.elasticstack.util.Servers;
|
||||||
import org.jclouds.io.Payloads;
|
import org.jclouds.io.Payloads;
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
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.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
|
@ -76,7 +75,6 @@ public class ElasticStackClientLiveTest extends BaseComputeServiceContextLiveTes
|
||||||
protected int maxDriveImageTime = 360;
|
protected int maxDriveImageTime = 360;
|
||||||
protected String vncPassword = "Il0veVNC";
|
protected String vncPassword = "Il0veVNC";
|
||||||
protected ElasticStackClient client;
|
protected ElasticStackClient client;
|
||||||
protected RestContext<ElasticStackClient, ElasticStackAsyncClient> cloudStackContext;
|
|
||||||
protected Predicate<HostAndPort> socketTester;
|
protected Predicate<HostAndPort> socketTester;
|
||||||
protected Predicate<DriveInfo> driveNotClaimed;
|
protected Predicate<DriveInfo> driveNotClaimed;
|
||||||
protected String imageId;
|
protected String imageId;
|
||||||
|
@ -87,7 +85,7 @@ public class ElasticStackClientLiveTest extends BaseComputeServiceContextLiveTes
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
imageId = view.getComputeService().templateBuilder().build().getImage().getId();
|
imageId = view.getComputeService().templateBuilder().build().getImage().getId();
|
||||||
|
|
||||||
client = view.unwrap(ElasticStackApiMetadata.CONTEXT_TOKEN).getApi();
|
client = view.utils().injector().getInstance(ElasticStackClient.class);
|
||||||
driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
|
driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
|
||||||
SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class);
|
SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class);
|
||||||
socketTester = retry(socketOpen, maxDriveImageTime, 1, SECONDS);
|
socketTester = retry(socketOpen, maxDriveImageTime, 1, SECONDS);
|
||||||
|
|
|
@ -57,16 +57,16 @@ public class VolumeAndSnapshotApiLiveTest extends BaseCinderApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
zone = Iterables.getLast(cinder.getApi().getConfiguredZones(), "nova");
|
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
volumeApi = cinder.getApi().getVolumeApiForZone(zone);
|
volumeApi = api.getVolumeApiForZone(zone);
|
||||||
snapshotApi = cinder.getApi().getSnapshotApiForZone(zone);
|
snapshotApi = api.getSnapshotApiForZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
if (testSnapshot != null) {
|
if (testSnapshot != null) {
|
||||||
assertTrue(snapshotApi.delete(testSnapshot.getId()));
|
assertTrue(snapshotApi.delete(testSnapshot.getId()));
|
||||||
assertTrue(SnapshotPredicates.awaitDeleted(snapshotApi).apply(testSnapshot));
|
assertTrue(SnapshotPredicates.awaitDeleted(snapshotApi).apply(testSnapshot));
|
||||||
|
@ -77,7 +77,7 @@ public class VolumeAndSnapshotApiLiveTest extends BaseCinderApiLiveTest {
|
||||||
assertTrue(VolumePredicates.awaitDeleted(volumeApi).apply(testVolume));
|
assertTrue(VolumePredicates.awaitDeleted(volumeApi).apply(testVolume));
|
||||||
}
|
}
|
||||||
|
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateVolume() {
|
public void testCreateVolume() {
|
||||||
|
|
|
@ -42,16 +42,16 @@ public class VolumeTypeApiLiveTest extends BaseCinderApiLiveTest {
|
||||||
|
|
||||||
@BeforeGroups(groups = {"integration", "live"})
|
@BeforeGroups(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
zone = Iterables.getLast(cinder.getApi().getConfiguredZones(), "nova");
|
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
volumeTypeApi = cinder.getApi().getVolumeTypeApiForZone(zone);
|
volumeTypeApi = api.getVolumeTypeApiForZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListAndGetVolumeTypes() {
|
public void testListAndGetVolumeTypes() {
|
||||||
|
|
|
@ -20,46 +20,25 @@ package org.jclouds.openstack.cinder.v1.internal;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseContextLiveTest;
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.openstack.cinder.v1.CinderApi;
|
import org.jclouds.openstack.cinder.v1.CinderApi;
|
||||||
import org.jclouds.openstack.cinder.v1.CinderApiMetadata;
|
|
||||||
import org.jclouds.openstack.cinder.v1.CinderAsyncApi;
|
|
||||||
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.testng.annotations.BeforeGroups;
|
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of CinderApi
|
* Tests behavior of CinderApi
|
||||||
*
|
*
|
||||||
* @author Everett Toews
|
* @author Everett Toews
|
||||||
*/
|
*/
|
||||||
public class BaseCinderApiLiveTest extends BaseContextLiveTest<RestContext<CinderApi, CinderAsyncApi>> {
|
public class BaseCinderApiLiveTest extends BaseApiLiveTest<CinderApi> {
|
||||||
|
|
||||||
public BaseCinderApiLiveTest() {
|
public BaseCinderApiLiveTest() {
|
||||||
provider = "openstack-cinder";
|
provider = "openstack-cinder";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RestContext<CinderApi, CinderAsyncApi> cinder;
|
|
||||||
|
|
||||||
@BeforeGroups(groups = { "integration", "live" })
|
|
||||||
@Override
|
|
||||||
public void setupContext() {
|
|
||||||
super.setupContext();
|
|
||||||
cinder = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
Properties props = super.setupProperties();
|
Properties props = super.setupProperties();
|
||||||
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
|
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeToken<RestContext<CinderApi, CinderAsyncApi>> contextType() {
|
|
||||||
return CinderApiMetadata.CONTEXT_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.testng.annotations.Test;
|
||||||
public class KeystoneApiLiveTest extends BaseKeystoneApiLiveTest {
|
public class KeystoneApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
public void testGetApiMetaData() {
|
public void testGetApiMetaData() {
|
||||||
ApiMetadata result = keystoneContext.getApi().getApiMetadata();
|
ApiMetadata result = api.getApiMetadata();
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertNotNull(result.getId());
|
assertNotNull(result.getId());
|
||||||
assertNotNull(result.getStatus());
|
assertNotNull(result.getStatus());
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.testng.annotations.Test;
|
||||||
public class ServiceApiLiveTest extends BaseKeystoneApiLiveTest {
|
public class ServiceApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
public void testTenants() {
|
public void testTenants() {
|
||||||
ServiceApi api = keystoneContext.getApi().getServiceApi();
|
ServiceApi api = this.api.getServiceApi();
|
||||||
Set<? extends Tenant> result = api.listTenants();
|
Set<? extends Tenant> result = api.listTenants();
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertFalse(result.isEmpty());
|
assertFalse(result.isEmpty());
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.testng.annotations.Test;
|
||||||
public class TenantApiLiveTest extends BaseKeystoneApiLiveTest {
|
public class TenantApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
public void testTenants() {
|
public void testTenants() {
|
||||||
TenantApi api = keystoneContext.getApi().getTenantApi().get();
|
TenantApi api = this.api.getTenantApi().get();
|
||||||
Set<? extends Tenant> result = api.list().concat().toSet();
|
Set<? extends Tenant> result = api.list().concat().toSet();
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertFalse(result.isEmpty());
|
assertFalse(result.isEmpty());
|
||||||
|
@ -54,7 +54,7 @@ public class TenantApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
public void testTenantsByName() {
|
public void testTenantsByName() {
|
||||||
|
|
||||||
TenantApi api = keystoneContext.getApi().getTenantApi().get();
|
TenantApi api = this.api.getTenantApi().get();
|
||||||
|
|
||||||
for (Tenant tenant : api.list().concat()) {
|
for (Tenant tenant : api.list().concat()) {
|
||||||
Tenant aTenant = api.getByName(tenant.getName());
|
Tenant aTenant = api.getByName(tenant.getName());
|
||||||
|
|
|
@ -24,18 +24,21 @@ import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
import static org.testng.AssertJUnit.assertTrue;
|
import static org.testng.AssertJUnit.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
|
import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.Token;
|
import org.jclouds.openstack.keystone.v2_0.domain.Token;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
import org.jclouds.openstack.keystone.v2_0.domain.User;
|
||||||
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
|
||||||
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneApiLiveTest;
|
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneApiLiveTest;
|
||||||
import org.testng.annotations.BeforeMethod;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests TokenApi
|
* Tests TokenApi
|
||||||
|
@ -47,17 +50,22 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
protected String token;
|
protected String token;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected KeystoneApi create(Properties props, Iterable<Module> modules) {
|
||||||
|
Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
|
||||||
|
grabToken(injector.getInstance(AuthenticateRequest.class));
|
||||||
|
return injector.getInstance(KeystoneApi.class);
|
||||||
|
}
|
||||||
|
|
||||||
// Get the token currently in use (there's currently no listTokens())
|
// Get the token currently in use (there's currently no listTokens())
|
||||||
@BeforeMethod
|
private void grabToken(AuthenticateRequest ar) {
|
||||||
public void grabToken() {
|
HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(endpoint).build());
|
||||||
AuthenticateRequest ar = keystoneContext.getUtils().getInjector().getInstance(AuthenticateRequest.class);
|
|
||||||
HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(context.getProviderMetadata().getEndpoint()).build());
|
|
||||||
token = Iterables.getOnlyElement(test.getHeaders().get("X-Auth-Token"));
|
token = Iterables.getOnlyElement(test.getHeaders().get("X-Auth-Token"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testToken() {
|
public void testToken() {
|
||||||
|
|
||||||
TokenApi api = keystoneContext.getApi().getTokenApi().get();
|
TokenApi api = this.api.getTokenApi().get();
|
||||||
assertTrue(api.isValid(token));
|
assertTrue(api.isValid(token));
|
||||||
Token result = api.get(token);
|
Token result = api.get(token);
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
|
@ -73,7 +81,7 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
public void testInvalidToken() {
|
public void testInvalidToken() {
|
||||||
|
|
||||||
TokenApi api = keystoneContext.getApi().getTokenApi().get();
|
TokenApi api = this.api.getTokenApi().get();
|
||||||
assertFalse(api.isValid("thisisnotarealtoken!"));
|
assertFalse(api.isValid("thisisnotarealtoken!"));
|
||||||
assertNull(api.get("thisisnotarealtoken!"));
|
assertNull(api.get("thisisnotarealtoken!"));
|
||||||
|
|
||||||
|
@ -81,7 +89,7 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
public void testTokenEndpoints() {
|
public void testTokenEndpoints() {
|
||||||
|
|
||||||
TokenApi api = keystoneContext.getApi().getTokenApi().get();
|
TokenApi api = this.api.getTokenApi().get();
|
||||||
Set<? extends Endpoint> endpoints = api.listEndpointsForToken(token);
|
Set<? extends Endpoint> endpoints = api.listEndpointsForToken(token);
|
||||||
assertNotNull(endpoints);
|
assertNotNull(endpoints);
|
||||||
assertFalse(endpoints.isEmpty());
|
assertFalse(endpoints.isEmpty());
|
||||||
|
@ -90,7 +98,7 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
public void testInvalidTokenEndpoints() {
|
public void testInvalidTokenEndpoints() {
|
||||||
|
|
||||||
TokenApi api = keystoneContext.getApi().getTokenApi().get();
|
TokenApi api = this.api.getTokenApi().get();
|
||||||
assertTrue(api.listEndpointsForToken("thisisnotarealtoken!").isEmpty());
|
assertTrue(api.listEndpointsForToken("thisisnotarealtoken!").isEmpty());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
public void testUsers() {
|
public void testUsers() {
|
||||||
|
|
||||||
UserApi api = keystoneContext.getApi().getUserApi().get();
|
UserApi api = this.api.getUserApi().get();
|
||||||
Set<? extends User> users = api.list().concat().toSet();
|
Set<? extends User> users = api.list().concat().toSet();
|
||||||
assertNotNull(users);
|
assertNotNull(users);
|
||||||
assertFalse(users.isEmpty());
|
assertFalse(users.isEmpty());
|
||||||
|
@ -53,8 +53,8 @@ public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
public void testUserRolesOnTenant() {
|
public void testUserRolesOnTenant() {
|
||||||
|
|
||||||
UserApi api = keystoneContext.getApi().getUserApi().get();
|
UserApi api = this.api.getUserApi().get();
|
||||||
Set<? extends Tenant> tenants = keystoneContext.getApi().getTenantApi().get().list().concat().toSet();
|
Set<? extends Tenant> tenants = this.api.getTenantApi().get().list().concat().toSet();
|
||||||
|
|
||||||
for (User user : api.list().concat()) {
|
for (User user : api.list().concat()) {
|
||||||
for (Tenant tenant : tenants) {
|
for (Tenant tenant : tenants) {
|
||||||
|
@ -69,7 +69,7 @@ public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
public void testListRolesOfUser() {
|
public void testListRolesOfUser() {
|
||||||
|
|
||||||
UserApi api = keystoneContext.getApi().getUserApi().get();
|
UserApi api = this.api.getUserApi().get();
|
||||||
for (User user : api.list().concat()) {
|
for (User user : api.list().concat()) {
|
||||||
Set<? extends Role> roles = api.listRolesOfUser(user.getId());
|
Set<? extends Role> roles = api.listRolesOfUser(user.getId());
|
||||||
for (Role role : roles) {
|
for (Role role : roles) {
|
||||||
|
@ -81,7 +81,7 @@ public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
|
||||||
|
|
||||||
public void testUsersByName() {
|
public void testUsersByName() {
|
||||||
|
|
||||||
UserApi api = keystoneContext.getApi().getUserApi().get();
|
UserApi api = this.api.getUserApi().get();
|
||||||
for (User user : api.list().concat()) {
|
for (User user : api.list().concat()) {
|
||||||
User aUser = api.getByName(user.getName());
|
User aUser = api.getByName(user.getName());
|
||||||
assertEquals(aUser, user);
|
assertEquals(aUser, user);
|
||||||
|
|
|
@ -20,48 +20,27 @@ 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.BaseApiLiveTest;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata;
|
|
||||||
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi;
|
|
||||||
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.testng.annotations.BeforeGroups;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code KeystoneApi}
|
* Tests behavior of {@code KeystoneApi}
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class BaseKeystoneApiLiveTest extends BaseContextLiveTest<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>> {
|
public class BaseKeystoneApiLiveTest extends BaseApiLiveTest<KeystoneApi> {
|
||||||
|
|
||||||
public BaseKeystoneApiLiveTest() {
|
public BaseKeystoneApiLiveTest() {
|
||||||
provider = "openstack-keystone";
|
provider = "openstack-keystone";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi> keystoneContext;
|
|
||||||
|
|
||||||
@BeforeGroups(groups = { "integration", "live" })
|
|
||||||
@Override
|
|
||||||
public void setupContext() {
|
|
||||||
super.setupContext();
|
|
||||||
keystoneContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
Properties props = super.setupProperties();
|
Properties props = super.setupProperties();
|
||||||
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
|
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeToken<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>> contextType() {
|
|
||||||
return KeystoneApiMetadata.CONTEXT_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,13 +62,13 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
|
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
serverApi = novaContext.getApi().getServerApiForZone(zone);
|
serverApi = api.getServerApiForZone(zone);
|
||||||
extensionApi = novaContext.getApi().getExtensionApiForZone(zone);
|
extensionApi = api.getExtensionApiForZone(zone);
|
||||||
imageApi = novaContext.getApi().getImageApiForZone(zone);
|
imageApi = api.getImageApiForZone(zone);
|
||||||
apiOption = novaContext.getApi().getServerAdminExtensionForZone(zone);
|
apiOption = api.getServerAdminExtensionForZone(zone);
|
||||||
if (apiOption.isPresent()) {
|
if (apiOption.isPresent()) {
|
||||||
testServerId = createServerInZone(zone).getId();
|
testServerId = createServerInZone(zone).getId();
|
||||||
}
|
}
|
||||||
|
@ -76,16 +76,16 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
if (apiOption.isPresent()) {
|
if (apiOption.isPresent()) {
|
||||||
if (testServerId != null) {
|
if (testServerId != null) {
|
||||||
assertTrue(novaContext.getApi().getServerApiForZone(zone).delete(testServerId));
|
assertTrue(api.getServerApiForZone(zone).delete(testServerId));
|
||||||
}
|
}
|
||||||
if (backupImageId != null) {
|
if (backupImageId != null) {
|
||||||
imageApi.delete(backupImageId);
|
imageApi.delete(backupImageId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void skipOnAdminExtensionAbsent() {
|
protected void skipOnAdminExtensionAbsent() {
|
||||||
|
|
|
@ -52,22 +52,22 @@ public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
|
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
flavorApi = novaContext.getApi().getFlavorApiForZone(zone);
|
flavorApi = api.getFlavorApiForZone(zone);
|
||||||
apiOption = novaContext.getApi().getFlavorExtraSpecsExtensionForZone(zone);
|
apiOption = api.getFlavorExtraSpecsExtensionForZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
if (apiOption.isPresent() && testFlavor != null) {
|
if (apiOption.isPresent() && testFlavor != null) {
|
||||||
for(String key : testSpecs.keySet()) {
|
for(String key : testSpecs.keySet()) {
|
||||||
assertTrue(apiOption.get().deleteMetadataKey(testFlavor.getId(), key));
|
assertTrue(apiOption.get().deleteMetadataKey(testFlavor.getId(), key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateExtraSpecs() {
|
public void testCreateExtraSpecs() {
|
||||||
|
|
|
@ -47,8 +47,8 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListFloatingIPs() throws Exception {
|
public void testListFloatingIPs() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
|
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
|
||||||
if (!apiOption.isPresent())
|
if (!apiOption.isPresent())
|
||||||
continue;
|
continue;
|
||||||
FloatingIPApi api = apiOption.get();
|
FloatingIPApi api = apiOption.get();
|
||||||
|
@ -69,8 +69,8 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllocateAndDecreateFloatingIPs() throws Exception {
|
public void testAllocateAndDecreateFloatingIPs() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
|
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
|
||||||
if (!apiOption.isPresent())
|
if (!apiOption.isPresent())
|
||||||
continue;
|
continue;
|
||||||
FloatingIPApi api = apiOption.get();
|
FloatingIPApi api = apiOption.get();
|
||||||
|
@ -100,12 +100,12 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddAndRemoveFloatingIp() throws Exception {
|
public void testAddAndRemoveFloatingIp() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
|
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
|
||||||
if (!apiOption.isPresent())
|
if (!apiOption.isPresent())
|
||||||
continue;
|
continue;
|
||||||
FloatingIPApi api = apiOption.get();
|
FloatingIPApi api = apiOption.get();
|
||||||
ServerApi serverApi = novaContext.getApi().getServerApiForZone(zoneId);
|
ServerApi serverApi = this.api.getServerApiForZone(zoneId);
|
||||||
Server server = createServerInZone(zoneId);
|
Server server = createServerInZone(zoneId);
|
||||||
FloatingIP floatingIP = api.create();
|
FloatingIP floatingIP = api.create();
|
||||||
assertNotNull(floatingIP);
|
assertNotNull(floatingIP);
|
||||||
|
|
|
@ -53,12 +53,12 @@ public class HostAdministrationApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@BeforeGroups(groups = {"integration", "live"})
|
@BeforeGroups(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
|
|
||||||
if (identity.endsWith(":admin")) {
|
if (identity.endsWith(":admin")) {
|
||||||
String zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
|
String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
optApi = novaContext.getApi().getHostAdministrationExtensionForZone(zone);
|
optApi = api.getHostAdministrationExtensionForZone(zone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,20 +51,20 @@ public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
String zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
|
String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
apiOption = novaContext.getApi().getHostAggregateExtensionForZone(zone);
|
apiOption = api.getHostAggregateExtensionForZone(zone);
|
||||||
hostAdminOption = novaContext.getApi().getHostAdministrationExtensionForZone(zone);
|
hostAdminOption = api.getHostAdministrationExtensionForZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
if (testAggregate != null) {
|
if (testAggregate != null) {
|
||||||
assertTrue(apiOption.get().delete(testAggregate.getId()));
|
assertTrue(apiOption.get().delete(testAggregate.getId()));
|
||||||
}
|
}
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateAggregate() {
|
public void testCreateAggregate() {
|
||||||
|
|
|
@ -35,8 +35,8 @@ import com.google.common.collect.FluentIterable;
|
||||||
public class KeyPairApiLiveTest extends BaseNovaApiLiveTest {
|
public class KeyPairApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
public void testListKeyPairs() throws Exception {
|
public void testListKeyPairs() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
KeyPairApi api = novaContext.getApi().getKeyPairExtensionForZone(zoneId).get();
|
KeyPairApi api = this.api.getKeyPairExtensionForZone(zoneId).get();
|
||||||
FluentIterable<? extends KeyPair> keyPairsList = api.list();
|
FluentIterable<? extends KeyPair> keyPairsList = api.list();
|
||||||
assertNotNull(keyPairsList);
|
assertNotNull(keyPairsList);
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,8 @@ public class KeyPairApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
public void testCreateAndDeleteKeyPair() throws Exception {
|
public void testCreateAndDeleteKeyPair() throws Exception {
|
||||||
final String KEYPAIR_NAME = "testkp";
|
final String KEYPAIR_NAME = "testkp";
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
KeyPairApi api = novaContext.getApi().getKeyPairExtensionForZone(zoneId).get();
|
KeyPairApi api = this.api.getKeyPairExtensionForZone(zoneId).get();
|
||||||
KeyPair keyPair = null;
|
KeyPair keyPair = null;
|
||||||
try {
|
try {
|
||||||
keyPair = api.create(KEYPAIR_NAME);
|
keyPair = api.create(KEYPAIR_NAME);
|
||||||
|
@ -62,8 +62,8 @@ public class KeyPairApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
final String KEYPAIR_NAME = "testkp";
|
final String KEYPAIR_NAME = "testkp";
|
||||||
final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002";
|
final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002";
|
||||||
|
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
KeyPairApi api = novaContext.getApi().getKeyPairExtensionForZone(zoneId).get();
|
KeyPairApi api = this.api.getKeyPairExtensionForZone(zoneId).get();
|
||||||
KeyPair keyPair = null;
|
KeyPair keyPair = null;
|
||||||
try {
|
try {
|
||||||
keyPair = api.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
|
keyPair = api.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
|
||||||
|
|
|
@ -41,11 +41,11 @@ public class QuotaApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
tenant = identity.split(":")[0];
|
tenant = identity.split(":")[0];
|
||||||
String zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
|
String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
apiOption = novaContext.getApi().getQuotaExtensionForZone(zone);
|
apiOption = api.getQuotaExtensionForZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetQuotasForCurrentTenant() {
|
public void testGetQuotasForCurrentTenant() {
|
||||||
|
|
|
@ -41,10 +41,10 @@ public class QuotaClassApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
|
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
apiOption = novaContext.getApi().getQuotaClassExtensionForZone(zone);
|
apiOption = api.getQuotaClassExtensionForZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateAndGetQuotaClass() {
|
public void testUpdateAndGetQuotaClass() {
|
||||||
|
|
|
@ -42,16 +42,16 @@ public class SecurityGroupApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
public static final String SECURITY_GROUP_NAME = "testsg";
|
public static final String SECURITY_GROUP_NAME = "testsg";
|
||||||
|
|
||||||
public void list() throws Exception {
|
public void list() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
SecurityGroupApi api = novaContext.getApi().getSecurityGroupExtensionForZone(zoneId).get();
|
SecurityGroupApi api = this.api.getSecurityGroupExtensionForZone(zoneId).get();
|
||||||
Set<? extends SecurityGroup> securityGroupsList = api.list().toSet();
|
Set<? extends SecurityGroup> securityGroupsList = api.list().toSet();
|
||||||
assertNotNull(securityGroupsList);
|
assertNotNull(securityGroupsList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createGetAndDeleteSecurityGroup() throws Exception {
|
public void createGetAndDeleteSecurityGroup() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
SecurityGroupApi api = novaContext.getApi().getSecurityGroupExtensionForZone(zoneId).get();
|
SecurityGroupApi api = this.api.getSecurityGroupExtensionForZone(zoneId).get();
|
||||||
SecurityGroup securityGroup = null;
|
SecurityGroup securityGroup = null;
|
||||||
String id;
|
String id;
|
||||||
try {
|
try {
|
||||||
|
@ -70,8 +70,8 @@ public class SecurityGroupApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createAndDeleteSecurityGroupRule() throws Exception {
|
public void createAndDeleteSecurityGroupRule() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
SecurityGroupApi api = novaContext.getApi().getSecurityGroupExtensionForZone(zoneId).get();
|
SecurityGroupApi api = this.api.getSecurityGroupExtensionForZone(zoneId).get();
|
||||||
SecurityGroup securityGroup = null;
|
SecurityGroup securityGroup = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -46,11 +46,11 @@ public class ServerWithSecurityGroupsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@BeforeGroups(groups = {"integration", "live"})
|
@BeforeGroups(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
|
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
serverApi = novaContext.getApi().getServerApiForZone(zone);
|
serverApi = api.getServerApiForZone(zone);
|
||||||
apiOption = novaContext.getApi().getServerWithSecurityGroupsExtensionForZone(zone);
|
apiOption = api.getServerWithSecurityGroupsExtensionForZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetServer() {
|
public void testGetServer() {
|
||||||
|
|
|
@ -37,8 +37,8 @@ import com.google.common.base.Optional;
|
||||||
public class SimpleTenantUsageApiLiveTest extends BaseNovaApiLiveTest {
|
public class SimpleTenantUsageApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
public void testList() throws Exception {
|
public void testList() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
Optional<? extends SimpleTenantUsageApi> optApi = novaContext.getApi().getSimpleTenantUsageExtensionForZone(zoneId);
|
Optional<? extends SimpleTenantUsageApi> optApi = api.getSimpleTenantUsageExtensionForZone(zoneId);
|
||||||
if (optApi.isPresent() && identity.endsWith(":admin")) {
|
if (optApi.isPresent() && identity.endsWith(":admin")) {
|
||||||
SimpleTenantUsageApi api = optApi.get();
|
SimpleTenantUsageApi api = optApi.get();
|
||||||
Set<? extends SimpleTenantUsage> usages = api.list().toSet();
|
Set<? extends SimpleTenantUsage> usages = api.list().toSet();
|
||||||
|
|
|
@ -44,10 +44,10 @@ public class VirtualInterfaceApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
|
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
apiOption = novaContext.getApi().getVirtualInterfaceExtensionForZone(zone);
|
apiOption = api.getVirtualInterfaceExtensionForZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListVirtualInterfaces() {
|
public void testListVirtualInterfaces() {
|
||||||
|
@ -62,7 +62,7 @@ public class VirtualInterfaceApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (testServer != null) {
|
if (testServer != null) {
|
||||||
novaContext.getApi().getServerApiForZone(zone).delete(testServer.getId());
|
api.getServerApiForZone(zone).delete(testServer.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,15 +56,15 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
|
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
volumeOption = novaContext.getApi().getVolumeExtensionForZone(zone);
|
volumeOption = api.getVolumeExtensionForZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
if (volumeOption.isPresent()) {
|
if (volumeOption.isPresent()) {
|
||||||
if (testSnapshot != null) {
|
if (testSnapshot != null) {
|
||||||
final String snapshotId = testSnapshot.getId();
|
final String snapshotId = testSnapshot.getId();
|
||||||
|
@ -85,7 +85,7 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
}, 180 * 1000L).apply(volumeOption.get()));
|
}, 180 * 1000L).apply(volumeOption.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateVolume() {
|
public void testCreateVolume() {
|
||||||
|
@ -268,7 +268,7 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (server_id != null)
|
if (server_id != null)
|
||||||
novaContext.getApi().getServerApiForZone(zone).delete(server_id);
|
api.getServerApiForZone(zone).delete(server_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,16 +54,16 @@ public class VolumeAttachmentApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
|
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
volumeApi = novaContext.getApi().getVolumeExtensionForZone(zone);
|
volumeApi = api.getVolumeExtensionForZone(zone);
|
||||||
volumeAttachmentApi = novaContext.getApi().getVolumeAttachmentExtensionForZone(zone);
|
volumeAttachmentApi = api.getVolumeAttachmentExtensionForZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
if (volumeApi.isPresent()) {
|
if (volumeApi.isPresent()) {
|
||||||
if (testVolume != null) {
|
if (testVolume != null) {
|
||||||
final String volumeId = testVolume.getId();
|
final String volumeId = testVolume.getId();
|
||||||
|
@ -76,7 +76,7 @@ public class VolumeAttachmentApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateVolume() {
|
public void testCreateVolume() {
|
||||||
|
@ -150,7 +150,7 @@ public class VolumeAttachmentApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (server_id != null)
|
if (server_id != null)
|
||||||
novaContext.getApi().getServerApiForZone(zone).delete(server_id);
|
api.getServerApiForZone(zone).delete(server_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,16 +53,16 @@ public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@BeforeGroups(groups = {"integration", "live"})
|
@BeforeGroups(groups = {"integration", "live"})
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
|
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
|
||||||
volumeTypeOption = novaContext.getApi().getVolumeTypeExtensionForZone(zone);
|
volumeTypeOption = api.getVolumeTypeExtensionForZone(zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
if (volumeTypeOption.isPresent()) {
|
if (volumeTypeOption.isPresent()) {
|
||||||
if (testVolumeType != null) {
|
if (testVolumeType != null) {
|
||||||
final String id = testVolumeType.getId();
|
final String id = testVolumeType.getId();
|
||||||
|
@ -74,7 +74,7 @@ public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
}, 5 * 1000L).apply(volumeTypeOption.get()));
|
}, 5 * 1000L).apply(volumeTypeOption.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateVolumeType() {
|
public void testCreateVolumeType() {
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class ExtensionApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test(description = "GET /v${apiVersion}/{tenantId}/extensions")
|
@Test(description = "GET /v${apiVersion}/{tenantId}/extensions")
|
||||||
public void testListExtensions() throws Exception {
|
public void testListExtensions() throws Exception {
|
||||||
for (String zoneId : zones) {
|
for (String zoneId : zones) {
|
||||||
ExtensionApi api = novaContext.getApi().getExtensionApiForZone(zoneId);
|
ExtensionApi api = this.api.getExtensionApiForZone(zoneId);
|
||||||
Set<? extends Extension> response = api.list();
|
Set<? extends Extension> response = api.list();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertFalse(response.isEmpty());
|
assertFalse(response.isEmpty());
|
||||||
|
@ -68,7 +68,7 @@ public class ExtensionApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test(description = "GET /v${apiVersion}/{tenantId}/extensions/{alias}", dependsOnMethods = { "testListExtensions" })
|
@Test(description = "GET /v${apiVersion}/{tenantId}/extensions/{alias}", dependsOnMethods = { "testListExtensions" })
|
||||||
public void testGetExtensionByAlias() throws Exception {
|
public void testGetExtensionByAlias() throws Exception {
|
||||||
for (String zoneId : zones) {
|
for (String zoneId : zones) {
|
||||||
ExtensionApi api = novaContext.getApi().getExtensionApiForZone(zoneId);
|
ExtensionApi api = this.api.getExtensionApiForZone(zoneId);
|
||||||
Set<? extends Extension> response = api.list();
|
Set<? extends Extension> response = api.list();
|
||||||
for (Extension extension : response) {
|
for (Extension extension : response) {
|
||||||
Extension details = api.get(extension.getId());
|
Extension details = api.get(extension.getId());
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class FlavorApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test(description = "GET /v${apiVersion}/{tenantId}/flavors")
|
@Test(description = "GET /v${apiVersion}/{tenantId}/flavors")
|
||||||
public void testListFlavors() throws Exception {
|
public void testListFlavors() throws Exception {
|
||||||
for (String zoneId : zones) {
|
for (String zoneId : zones) {
|
||||||
FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId);
|
FlavorApi api = this.api.getFlavorApiForZone(zoneId);
|
||||||
Set<? extends Resource> response = api.list().concat().toSet();
|
Set<? extends Resource> response = api.list().concat().toSet();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertFalse(response.isEmpty());
|
assertFalse(response.isEmpty());
|
||||||
|
@ -66,7 +66,7 @@ public class FlavorApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test(description = "GET /v${apiVersion}/{tenantId}/flavors/detail")
|
@Test(description = "GET /v${apiVersion}/{tenantId}/flavors/detail")
|
||||||
public void testListFlavorsInDetail() throws Exception {
|
public void testListFlavorsInDetail() throws Exception {
|
||||||
for (String zoneId : zones) {
|
for (String zoneId : zones) {
|
||||||
FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId);
|
FlavorApi api = this.api.getFlavorApiForZone(zoneId);
|
||||||
Set<? extends Flavor> response = api.listInDetail().concat().toSet();
|
Set<? extends Flavor> response = api.listInDetail().concat().toSet();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertFalse(response.isEmpty());
|
assertFalse(response.isEmpty());
|
||||||
|
@ -89,7 +89,7 @@ public class FlavorApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test(description = "GET /v${apiVersion}/{tenantId}/flavors/{id}", dependsOnMethods = { "testListFlavorsInDetail" })
|
@Test(description = "GET /v${apiVersion}/{tenantId}/flavors/{id}", dependsOnMethods = { "testListFlavorsInDetail" })
|
||||||
public void testGetFlavorById() throws Exception {
|
public void testGetFlavorById() throws Exception {
|
||||||
for (String zoneId : zones) {
|
for (String zoneId : zones) {
|
||||||
FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId);
|
FlavorApi api = this.api.getFlavorApiForZone(zoneId);
|
||||||
Set<? extends Flavor> response = api.listInDetail().concat().toSet();
|
Set<? extends Flavor> response = api.listInDetail().concat().toSet();
|
||||||
for (Flavor flavor : response) {
|
for (Flavor flavor : response) {
|
||||||
Flavor details = api.get(flavor.getId());
|
Flavor details = api.get(flavor.getId());
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class ImageApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test(description = "GET /v${apiVersion}/{tenantId}/images")
|
@Test(description = "GET /v${apiVersion}/{tenantId}/images")
|
||||||
public void testListImages() throws Exception {
|
public void testListImages() throws Exception {
|
||||||
for (String zoneId : zones) {
|
for (String zoneId : zones) {
|
||||||
ImageApi api = novaContext.getApi().getImageApiForZone(zoneId);
|
ImageApi api = this.api.getImageApiForZone(zoneId);
|
||||||
Set<? extends Resource> response = api.list().concat().toSet();
|
Set<? extends Resource> response = api.list().concat().toSet();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertFalse(response.isEmpty());
|
assertFalse(response.isEmpty());
|
||||||
|
@ -55,8 +55,8 @@ public class ImageApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@Test(description = "GET /v${apiVersion}/{tenantId}/images/detail")
|
@Test(description = "GET /v${apiVersion}/{tenantId}/images/detail")
|
||||||
public void testListImagesInDetail() throws Exception {
|
public void testListImagesInDetail() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
ImageApi api = novaContext.getApi().getImageApiForZone(zoneId);
|
ImageApi api = this.api.getImageApiForZone(zoneId);
|
||||||
Set<? extends Image> response = api.listInDetail().concat().toSet();
|
Set<? extends Image> response = api.listInDetail().concat().toSet();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertFalse(response.isEmpty());
|
assertFalse(response.isEmpty());
|
||||||
|
@ -79,8 +79,8 @@ public class ImageApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
@Test(description = "GET /v${apiVersion}/{tenantId}/images/{id}", dependsOnMethods = { "testListImagesInDetail" })
|
@Test(description = "GET /v${apiVersion}/{tenantId}/images/{id}", dependsOnMethods = { "testListImagesInDetail" })
|
||||||
public void testGetImageById() throws Exception {
|
public void testGetImageById() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : api.getConfiguredZones()) {
|
||||||
ImageApi api = novaContext.getApi().getImageApiForZone(zoneId);
|
ImageApi api = this.api.getImageApiForZone(zoneId);
|
||||||
Set<? extends Image> response = api.listInDetail().concat().toSet();
|
Set<? extends Image> response = api.listInDetail().concat().toSet();
|
||||||
for (Image image : response) {
|
for (Image image : response) {
|
||||||
Image details = api.get(image.getId());
|
Image details = api.get(image.getId());
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test(description = "GET /v${apiVersion}/{tenantId}/servers")
|
@Test(description = "GET /v${apiVersion}/{tenantId}/servers")
|
||||||
public void testListServers() throws Exception {
|
public void testListServers() throws Exception {
|
||||||
for (String zoneId : zones) {
|
for (String zoneId : zones) {
|
||||||
ServerApi api = novaContext.getApi().getServerApiForZone(zoneId);
|
ServerApi api = this.api.getServerApiForZone(zoneId);
|
||||||
for (Resource server : api.list().concat()) {
|
for (Resource server : api.list().concat()) {
|
||||||
checkResource(server);
|
checkResource(server);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test(description = "GET /v${apiVersion}/{tenantId}/servers/detail")
|
@Test(description = "GET /v${apiVersion}/{tenantId}/servers/detail")
|
||||||
public void testListServersInDetail() throws Exception {
|
public void testListServersInDetail() throws Exception {
|
||||||
for (String zoneId : zones) {
|
for (String zoneId : zones) {
|
||||||
ServerApi api = novaContext.getApi().getServerApiForZone(zoneId);
|
ServerApi api = this.api.getServerApiForZone(zoneId);
|
||||||
for (Server server : api.listInDetail().concat()) {
|
for (Server server : api.listInDetail().concat()) {
|
||||||
checkServer(server);
|
checkServer(server);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test(description = "GET /v${apiVersion}/{tenantId}/servers/{id}", dependsOnMethods = { "testListServersInDetail" })
|
@Test(description = "GET /v${apiVersion}/{tenantId}/servers/{id}", dependsOnMethods = { "testListServersInDetail" })
|
||||||
public void testGetServerById() throws Exception {
|
public void testGetServerById() throws Exception {
|
||||||
for (String zoneId : zones) {
|
for (String zoneId : zones) {
|
||||||
ServerApi api = novaContext.getApi().getServerApiForZone(zoneId);
|
ServerApi api = this.api.getServerApiForZone(zoneId);
|
||||||
for (Resource server : api.list().concat()) {
|
for (Resource server : api.list().concat()) {
|
||||||
Server details = api.get(server.getId());
|
Server details = api.get(server.getId());
|
||||||
assertEquals(details.getId(), server.getId());
|
assertEquals(details.getId(), server.getId());
|
||||||
|
|
|
@ -21,10 +21,9 @@ package org.jclouds.openstack.nova.v2_0.internal;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
|
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
import org.jclouds.openstack.nova.v2_0.NovaApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
|
|
||||||
import org.jclouds.openstack.nova.v2_0.config.NovaProperties;
|
import org.jclouds.openstack.nova.v2_0.config.NovaProperties;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
|
||||||
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
import org.jclouds.openstack.nova.v2_0.domain.Server;
|
||||||
|
@ -34,7 +33,6 @@ import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
|
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
|
||||||
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
|
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
|
||||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -49,7 +47,7 @@ import com.google.common.collect.Ordering;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
|
public class BaseNovaApiLiveTest extends BaseApiLiveTest<NovaApi> {
|
||||||
protected String hostName = System.getProperty("user.name").replace('.','-').toLowerCase();
|
protected String hostName = System.getProperty("user.name").replace('.','-').toLowerCase();
|
||||||
|
|
||||||
public BaseNovaApiLiveTest() {
|
public BaseNovaApiLiveTest() {
|
||||||
|
@ -57,16 +55,14 @@ public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set<String> zones;
|
protected Set<String> zones;
|
||||||
protected RestContext<NovaApi, NovaAsyncApi> novaContext;
|
|
||||||
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
novaContext = view.unwrap();
|
zones = api.getConfiguredZones();
|
||||||
zones = novaContext.getApi().getConfiguredZones();
|
|
||||||
for (String zone : zones){
|
for (String zone : zones){
|
||||||
ServerApi api = novaContext.getApi().getServerApiForZone(zone);
|
ServerApi api = this.api.getServerApiForZone(zone);
|
||||||
for (Resource server : api.list().concat()){
|
for (Resource server : api.list().concat()){
|
||||||
if (server.getName().equals(hostName))
|
if (server.getName().equals(hostName))
|
||||||
api.delete(server.getId());
|
api.delete(server.getId());
|
||||||
|
@ -83,7 +79,7 @@ public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Server createServerInZone(String zoneId) {
|
protected Server createServerInZone(String zoneId) {
|
||||||
ServerApi serverApi = novaContext.getApi().getServerApiForZone(zoneId);
|
ServerApi serverApi = api.getServerApiForZone(zoneId);
|
||||||
ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), flavorRefForZone(zoneId));
|
ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), flavorRefForZone(zoneId));
|
||||||
blockUntilServerInState(server.getId(), serverApi, Status.ACTIVE);
|
blockUntilServerInState(server.getId(), serverApi, Status.ACTIVE);
|
||||||
return serverApi.get(server.getId());
|
return serverApi.get(server.getId());
|
||||||
|
@ -108,12 +104,12 @@ public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String imageIdForZone(String zoneId) {
|
protected String imageIdForZone(String zoneId) {
|
||||||
ImageApi imageApi = novaContext.getApi().getImageApiForZone(zoneId);
|
ImageApi imageApi = api.getImageApiForZone(zoneId);
|
||||||
return Iterables.getLast(imageApi.list().concat()).getId();
|
return Iterables.getLast(imageApi.list().concat()).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String flavorRefForZone(String zoneId) {
|
protected String flavorRefForZone(String zoneId) {
|
||||||
FlavorApi flavorApi = novaContext.getApi().getFlavorApiForZone(zoneId);
|
FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
|
||||||
return DEFAULT_FLAVOR_ORDERING.min(flavorApi.listInDetail().concat()).getId();
|
return DEFAULT_FLAVOR_ORDERING.min(flavorApi.listInDetail().concat()).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ public class AccessRuleApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
|
|
||||||
accessRule1 = AccessRule.deny("206.160.163.21");
|
accessRule1 = AccessRule.deny("206.160.163.21");
|
||||||
accessRule2 = AccessRule.deny("206.160.165.11");
|
accessRule2 = AccessRule.deny("206.160.165.11");
|
||||||
|
@ -76,57 +76,57 @@ public class AccessRuleApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
||||||
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
||||||
|
|
||||||
zone = "ORD";//Iterables.getFirst(clbApi.getConfiguredZones(), null);
|
zone = "ORD";//Iterables.getFirst(api.getConfiguredZones(), null);
|
||||||
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
|
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testCreateAccessList() throws Exception {
|
public void testCreateAccessList() throws Exception {
|
||||||
clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).create(accessRules.values());
|
api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).create(accessRules.values());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
assertExpectedAccessRules(accessRules);
|
assertExpectedAccessRules(accessRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateAccessList")
|
@Test(dependsOnMethods = "testCreateAccessList")
|
||||||
public void testRemoveSingleAccessRule() throws Exception {
|
public void testRemoveSingleAccessRule() throws Exception {
|
||||||
Iterable<AccessRuleWithId> actualAccessList = clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
Iterable<AccessRuleWithId> actualAccessList = api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
||||||
AccessRuleWithId removedAccessRule = Iterables.getFirst(actualAccessList, null);
|
AccessRuleWithId removedAccessRule = Iterables.getFirst(actualAccessList, null);
|
||||||
accessRules.remove(removedAccessRule.getAddress());
|
accessRules.remove(removedAccessRule.getAddress());
|
||||||
|
|
||||||
assertTrue(clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedAccessRule.getId()));
|
assertTrue(api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedAccessRule.getId()));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
assertExpectedAccessRules(accessRules);
|
assertExpectedAccessRules(accessRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testRemoveSingleAccessRule")
|
@Test(dependsOnMethods = "testRemoveSingleAccessRule")
|
||||||
public void testRemoveManyAccessRules() throws Exception {
|
public void testRemoveManyAccessRules() throws Exception {
|
||||||
Iterable<AccessRuleWithId> actualAccessList = clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
Iterable<AccessRuleWithId> actualAccessList = api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
||||||
AccessRuleWithId removedAccessRule1 = Iterables.getFirst(actualAccessList, null);
|
AccessRuleWithId removedAccessRule1 = Iterables.getFirst(actualAccessList, null);
|
||||||
AccessRuleWithId removedAccessRule2 = Iterables.getLast(actualAccessList);
|
AccessRuleWithId removedAccessRule2 = Iterables.getLast(actualAccessList);
|
||||||
List<Integer> removedAccessRuleIds = ImmutableList.<Integer> of(removedAccessRule1.getId(), removedAccessRule2.getId());
|
List<Integer> removedAccessRuleIds = ImmutableList.<Integer> of(removedAccessRule1.getId(), removedAccessRule2.getId());
|
||||||
accessRules.remove(removedAccessRule1.getAddress());
|
accessRules.remove(removedAccessRule1.getAddress());
|
||||||
accessRules.remove(removedAccessRule2.getAddress());
|
accessRules.remove(removedAccessRule2.getAddress());
|
||||||
|
|
||||||
assertTrue(clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedAccessRuleIds));
|
assertTrue(api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedAccessRuleIds));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
assertExpectedAccessRules(accessRules);
|
assertExpectedAccessRules(accessRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testRemoveManyAccessRules")
|
@Test(dependsOnMethods = "testRemoveManyAccessRules")
|
||||||
public void testRemoveAllAccessRules() throws Exception {
|
public void testRemoveAllAccessRules() throws Exception {
|
||||||
assertTrue(clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).deleteAll());
|
assertTrue(api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).deleteAll());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
assertExpectedAccessRules(new HashMap<String, AccessRule>());
|
assertExpectedAccessRules(new HashMap<String, AccessRule>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertExpectedAccessRules(Map<String, AccessRule> expectedAccessList) {
|
private void assertExpectedAccessRules(Map<String, AccessRule> expectedAccessList) {
|
||||||
Iterable<AccessRuleWithId> actualAccessList = clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
Iterable<AccessRuleWithId> actualAccessList = api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
||||||
|
|
||||||
for (AccessRule actualAccessRule: actualAccessList) {
|
for (AccessRule actualAccessRule: actualAccessList) {
|
||||||
assertEquals(expectedAccessList.containsKey(actualAccessRule.getAddress()), true,
|
assertEquals(expectedAccessList.containsKey(actualAccessRule.getAddress()), true,
|
||||||
|
@ -136,10 +136,10 @@ public class AccessRuleApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
||||||
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,63 +49,63 @@ public class ConnectionApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
||||||
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
||||||
|
|
||||||
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
|
zone = Iterables.getFirst(api.getConfiguredZones(), null);
|
||||||
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
|
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testCreateAndGetConnectionThrottling() throws Exception {
|
public void testCreateAndGetConnectionThrottling() throws Exception {
|
||||||
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdateConnectionThrottle(
|
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdateConnectionThrottle(
|
||||||
ConnectionApiExpectTest.getConnectionThrottle());
|
ConnectionApiExpectTest.getConnectionThrottle());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
ConnectionThrottle connectionThrottle =
|
ConnectionThrottle connectionThrottle =
|
||||||
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).getConnectionThrottle();
|
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).getConnectionThrottle();
|
||||||
|
|
||||||
assertEquals(connectionThrottle, ConnectionApiExpectTest.getConnectionThrottle());
|
assertEquals(connectionThrottle, ConnectionApiExpectTest.getConnectionThrottle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateAndGetConnectionThrottling")
|
@Test(dependsOnMethods = "testCreateAndGetConnectionThrottling")
|
||||||
public void testRemoveAndGetConnectionThrottle() throws Exception {
|
public void testRemoveAndGetConnectionThrottle() throws Exception {
|
||||||
assertTrue(clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).deleteConnectionThrottle());
|
assertTrue(api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).deleteConnectionThrottle());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
ConnectionThrottle connectionThrottle =
|
ConnectionThrottle connectionThrottle =
|
||||||
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).getConnectionThrottle();
|
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).getConnectionThrottle();
|
||||||
|
|
||||||
assertNull(connectionThrottle);
|
assertNull(connectionThrottle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testRemoveAndGetConnectionThrottle")
|
@Test(dependsOnMethods = "testRemoveAndGetConnectionThrottle")
|
||||||
public void testEnableAndIsConnectionLogging() throws Exception {
|
public void testEnableAndIsConnectionLogging() throws Exception {
|
||||||
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).enableConnectionLogging();
|
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).enableConnectionLogging();
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
boolean isConnectionLogging =
|
boolean isConnectionLogging =
|
||||||
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).isConnectionLogging();
|
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).isConnectionLogging();
|
||||||
|
|
||||||
assertTrue(isConnectionLogging);
|
assertTrue(isConnectionLogging);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testEnableAndIsConnectionLogging")
|
@Test(dependsOnMethods = "testEnableAndIsConnectionLogging")
|
||||||
public void testDisableAndIsConnectionLogging() throws Exception {
|
public void testDisableAndIsConnectionLogging() throws Exception {
|
||||||
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).disableConnectionLogging();
|
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).disableConnectionLogging();
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
boolean isConnectionLogging =
|
boolean isConnectionLogging =
|
||||||
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).isConnectionLogging();
|
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).isConnectionLogging();
|
||||||
|
|
||||||
assertFalse(isConnectionLogging);
|
assertFalse(isConnectionLogging);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
||||||
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,40 +46,40 @@ public class ContentCachingApiLiveTest extends BaseCloudLoadBalancersApiLiveTest
|
||||||
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
||||||
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
||||||
|
|
||||||
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
|
zone = Iterables.getFirst(api.getConfiguredZones(), null);
|
||||||
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
|
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testEnableAndIsContentCaching() throws Exception {
|
public void testEnableAndIsContentCaching() throws Exception {
|
||||||
clbApi.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).enable();
|
api.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).enable();
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
boolean isContentCaching =
|
boolean isContentCaching =
|
||||||
clbApi.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).isContentCaching();
|
api.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).isContentCaching();
|
||||||
|
|
||||||
assertTrue(isContentCaching);
|
assertTrue(isContentCaching);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testEnableAndIsContentCaching")
|
@Test(dependsOnMethods = "testEnableAndIsContentCaching")
|
||||||
public void testDisableAndIsContentCaching() throws Exception {
|
public void testDisableAndIsContentCaching() throws Exception {
|
||||||
clbApi.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).disable();
|
api.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).disable();
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
boolean isContentCaching =
|
boolean isContentCaching =
|
||||||
clbApi.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).isContentCaching();
|
api.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).isContentCaching();
|
||||||
|
|
||||||
assertFalse(isContentCaching);
|
assertFalse(isContentCaching);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
||||||
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@ public class ErrorPageApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
|
|
||||||
contentExpected = ErrorPageApiExpectTest.getContentExpected();
|
contentExpected = ErrorPageApiExpectTest.getContentExpected();
|
||||||
contentEscaped = ErrorPageApiExpectTest.getContentEscaped();
|
contentEscaped = ErrorPageApiExpectTest.getContentEscaped();
|
||||||
|
@ -58,38 +58,38 @@ public class ErrorPageApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
||||||
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
||||||
|
|
||||||
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
|
zone = Iterables.getFirst(api.getConfiguredZones(), null);
|
||||||
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
|
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testCreateAndGetErrorPage() throws Exception {
|
public void testCreateAndGetErrorPage() throws Exception {
|
||||||
clbApi.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).create(contentEscaped);
|
api.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).create(contentEscaped);
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
String content = clbApi.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
String content = api.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
||||||
|
|
||||||
assertEquals(content, contentExpected);
|
assertEquals(content, contentExpected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateAndGetErrorPage")
|
@Test(dependsOnMethods = "testCreateAndGetErrorPage")
|
||||||
public void testRemoveAndGetErrorPage() throws Exception {
|
public void testRemoveAndGetErrorPage() throws Exception {
|
||||||
assertTrue(clbApi.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
|
assertTrue(api.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
String content = clbApi.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
String content = api.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
||||||
|
|
||||||
assertTrue(content.contains("Service Unavailable"));
|
assertTrue(content.contains("Service Unavailable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
||||||
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,41 +48,41 @@ public class HealthMonitorApiLiveTest extends BaseCloudLoadBalancersApiLiveTest
|
||||||
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
||||||
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
||||||
|
|
||||||
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
|
zone = Iterables.getFirst(api.getConfiguredZones(), null);
|
||||||
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
|
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testCreateAndGetHealthMonitor() throws Exception {
|
public void testCreateAndGetHealthMonitor() throws Exception {
|
||||||
clbApi.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdate(
|
api.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdate(
|
||||||
HealthMonitorApiExpectTest.getConnectHealthMonitor());
|
HealthMonitorApiExpectTest.getConnectHealthMonitor());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
HealthMonitor healthMonitor =
|
HealthMonitor healthMonitor =
|
||||||
clbApi.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
api.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
||||||
|
|
||||||
assertEquals(healthMonitor, HealthMonitorApiExpectTest.getConnectHealthMonitor());
|
assertEquals(healthMonitor, HealthMonitorApiExpectTest.getConnectHealthMonitor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateAndGetHealthMonitor")
|
@Test(dependsOnMethods = "testCreateAndGetHealthMonitor")
|
||||||
public void testRemoveAndGetHealthMonitor() throws Exception {
|
public void testRemoveAndGetHealthMonitor() throws Exception {
|
||||||
assertTrue(clbApi.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
|
assertTrue(api.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
HealthMonitor healthMonitor =
|
HealthMonitor healthMonitor =
|
||||||
clbApi.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
api.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
||||||
|
|
||||||
assertNull(healthMonitor);
|
assertNull(healthMonitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
||||||
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,20 +53,20 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
for (LoadBalancer lb: lbs) {
|
for (LoadBalancer lb: lbs) {
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
clbApi.getLoadBalancerApiForZone(lb.getRegion()).delete(lb.getId());
|
api.getLoadBalancerApiForZone(lb.getRegion()).delete(lb.getId());
|
||||||
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
}
|
}
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateLoadBalancer() throws Exception {
|
public void testCreateLoadBalancer() throws Exception {
|
||||||
for (String zone: clbApi.getConfiguredZones()) {
|
for (String zone: api.getConfiguredZones()) {
|
||||||
Logger.getAnonymousLogger().info("starting lb in region " + zone);
|
Logger.getAnonymousLogger().info("starting lb in region " + zone);
|
||||||
|
|
||||||
LoadBalancer lb = clbApi.getLoadBalancerApiForZone(zone).create(
|
LoadBalancer lb = api.getLoadBalancerApiForZone(zone).create(
|
||||||
CreateLoadBalancer.builder()
|
CreateLoadBalancer.builder()
|
||||||
.name(prefix + "-" + zone)
|
.name(prefix + "-" + zone)
|
||||||
.protocol("HTTP")
|
.protocol("HTTP")
|
||||||
|
@ -83,9 +83,9 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
|
|
||||||
lbs.add(lb);
|
lbs.add(lb);
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
|
|
||||||
LoadBalancer newLb = clbApi.getLoadBalancerApiForZone(zone).get(lb.getId());
|
LoadBalancer newLb = api.getLoadBalancerApiForZone(zone).get(lb.getId());
|
||||||
checkLBInRegion(zone, newLb, prefix + "-" + zone);
|
checkLBInRegion(zone, newLb, prefix + "-" + zone);
|
||||||
|
|
||||||
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
|
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
|
||||||
|
@ -95,12 +95,12 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testUpdateLoadBalancer() throws Exception {
|
public void testUpdateLoadBalancer() throws Exception {
|
||||||
for (LoadBalancer lb: lbs) {
|
for (LoadBalancer lb: lbs) {
|
||||||
clbApi.getLoadBalancerApiForZone(lb.getRegion()).update(lb.getId(),
|
api.getLoadBalancerApiForZone(lb.getRegion()).update(lb.getId(),
|
||||||
UpdateLoadBalancer.builder().name("foo" + "-" + lb.getRegion()).build());
|
UpdateLoadBalancer.builder().name("foo" + "-" + lb.getRegion()).build());
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
|
|
||||||
LoadBalancer newLb = clbApi.getLoadBalancerApiForZone(lb.getRegion()).get(lb.getId());
|
LoadBalancer newLb = api.getLoadBalancerApiForZone(lb.getRegion()).get(lb.getId());
|
||||||
checkLBInRegion(newLb.getRegion(), newLb, "foo" + "-" + lb.getRegion());
|
checkLBInRegion(newLb.getRegion(), newLb, "foo" + "-" + lb.getRegion());
|
||||||
|
|
||||||
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
|
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
|
||||||
|
@ -109,9 +109,9 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testUpdateLoadBalancer")
|
@Test(dependsOnMethods = "testUpdateLoadBalancer")
|
||||||
public void testListLoadBalancers() throws Exception {
|
public void testListLoadBalancers() throws Exception {
|
||||||
for (String zone: clbApi.getConfiguredZones()) {
|
for (String zone: api.getConfiguredZones()) {
|
||||||
|
|
||||||
Set<LoadBalancer> response = clbApi.getLoadBalancerApiForZone(zone).list().concat().toSet();
|
Set<LoadBalancer> response = api.getLoadBalancerApiForZone(zone).list().concat().toSet();
|
||||||
|
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertTrue(response.size() >= 0);
|
assertTrue(response.size() >= 0);
|
||||||
|
@ -131,7 +131,7 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
// node info not available during list;
|
// node info not available during list;
|
||||||
assert lb.getNodes().size() == 0 : lb;
|
assert lb.getNodes().size() == 0 : lb;
|
||||||
|
|
||||||
LoadBalancer getDetails = clbApi.getLoadBalancerApiForZone(zone).get(lb.getId());
|
LoadBalancer getDetails = api.getLoadBalancerApiForZone(zone).get(lb.getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assertEquals(getDetails.getRegion(), lb.getRegion());
|
assertEquals(getDetails.getRegion(), lb.getRegion());
|
||||||
|
@ -160,27 +160,27 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
"key2", "value2",
|
"key2", "value2",
|
||||||
"key3", "value3");
|
"key3", "value3");
|
||||||
|
|
||||||
Metadata metadata = clbApi.getLoadBalancerApiForZone(lb.getRegion()).createMetadata(lb.getId(), metadataMap);
|
Metadata metadata = api.getLoadBalancerApiForZone(lb.getRegion()).createMetadata(lb.getId(), metadataMap);
|
||||||
assertEquals(metadata, getExpectedMetadata());
|
assertEquals(metadata, getExpectedMetadata());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
|
|
||||||
metadata = clbApi.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
|
metadata = api.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
|
||||||
assertEquals(metadata, getExpectedMetadata());
|
assertEquals(metadata, getExpectedMetadata());
|
||||||
|
|
||||||
assertTrue(clbApi.getLoadBalancerApiForZone(lb.getRegion()).updateMetadatum(lb.getId(), metadata.getId("key1"), "key1-updated"));
|
assertTrue(api.getLoadBalancerApiForZone(lb.getRegion()).updateMetadatum(lb.getId(), metadata.getId("key1"), "key1-updated"));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
metadata = clbApi.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
|
metadata = api.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
|
||||||
assertEquals(metadata.get("key1"), "key1-updated");
|
assertEquals(metadata.get("key1"), "key1-updated");
|
||||||
|
|
||||||
assertTrue(clbApi.getLoadBalancerApiForZone(lb.getRegion()).deleteMetadatum(lb.getId(), metadata.getId("key1")));
|
assertTrue(api.getLoadBalancerApiForZone(lb.getRegion()).deleteMetadatum(lb.getId(), metadata.getId("key1")));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
metadata = clbApi.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
|
metadata = api.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
|
||||||
assertNull(metadata.get("key1"));
|
assertNull(metadata.get("key1"));
|
||||||
|
|
||||||
assertTrue(clbApi.getLoadBalancerApiForZone(lb.getRegion()).deleteMetadata(lb.getId(),
|
assertTrue(api.getLoadBalancerApiForZone(lb.getRegion()).deleteMetadata(lb.getId(),
|
||||||
ImmutableList.<Integer> of(metadata.getId("key2"), metadata.getId("key3"))));
|
ImmutableList.<Integer> of(metadata.getId("key2"), metadata.getId("key3"))));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
metadata = clbApi.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
|
metadata = api.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
|
||||||
assertEquals(metadata.size(), 0);
|
assertEquals(metadata.size(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,16 +57,16 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
private Map<LoadBalancer, Set<Node>> nodes = Maps.newHashMap();
|
private Map<LoadBalancer, Set<Node>> nodes = Maps.newHashMap();
|
||||||
|
|
||||||
public void testCreateLoadBalancers() {
|
public void testCreateLoadBalancers() {
|
||||||
assertTrue(clbApi.getConfiguredZones().size() > 0, "Need to have some zones!");
|
assertTrue(api.getConfiguredZones().size() > 0, "Need to have some zones!");
|
||||||
Logger.getAnonymousLogger().info("running against zones " + clbApi.getConfiguredZones());
|
Logger.getAnonymousLogger().info("running against zones " + api.getConfiguredZones());
|
||||||
for (String zone : clbApi.getConfiguredZones()) {
|
for (String zone : api.getConfiguredZones()) {
|
||||||
Logger.getAnonymousLogger().info("starting lb in zone " + zone);
|
Logger.getAnonymousLogger().info("starting lb in zone " + zone);
|
||||||
LoadBalancer lb = clbApi.getLoadBalancerApiForZone(zone).create(
|
LoadBalancer lb = api.getLoadBalancerApiForZone(zone).create(
|
||||||
CreateLoadBalancer.builder().name(prefix + "-" + zone).protocol("HTTP").port(80).virtualIPType(
|
CreateLoadBalancer.builder().name(prefix + "-" + zone).protocol("HTTP").port(80).virtualIPType(
|
||||||
Type.PUBLIC).node(AddNode.builder().address("192.168.1.1").port(8080).build()).build());
|
Type.PUBLIC).node(AddNode.builder().address("192.168.1.1").port(8080).build()).build());
|
||||||
nodes.put(lb, new HashSet<Node>());
|
nodes.put(lb, new HashSet<Node>());
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,17 +77,17 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
Set<Node> nodeSet = entry.getValue();
|
Set<Node> nodeSet = entry.getValue();
|
||||||
String region = lb.getRegion();
|
String region = lb.getRegion();
|
||||||
Logger.getAnonymousLogger().info("starting node on loadbalancer " + lb.getId() + " in region " + region);
|
Logger.getAnonymousLogger().info("starting node on loadbalancer " + lb.getId() + " in region " + region);
|
||||||
Set<Node> newNodes = clbApi.getNodeApiForZoneAndLoadBalancer(region, lb.getId()).add(
|
Set<Node> newNodes = api.getNodeApiForZoneAndLoadBalancer(region, lb.getId()).add(
|
||||||
ImmutableSet.<AddNode> of(AddNode.builder().address("192.168.1.2").port(8080).build()));
|
ImmutableSet.<AddNode> of(AddNode.builder().address("192.168.1.2").port(8080).build()));
|
||||||
|
|
||||||
for (Node n : newNodes) {
|
for (Node n : newNodes) {
|
||||||
assertEquals(n.getStatus(), Node.Status.ONLINE);
|
assertEquals(n.getStatus(), Node.Status.ONLINE);
|
||||||
nodeSet.add(n);
|
nodeSet.add(n);
|
||||||
assertEquals(clbApi.getNodeApiForZoneAndLoadBalancer(region, lb.getId()).get(n.getId()).getStatus(),
|
assertEquals(api.getNodeApiForZoneAndLoadBalancer(region, lb.getId()).get(n.getId()).getStatus(),
|
||||||
Node.Status.ONLINE);
|
Node.Status.ONLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,12 +96,12 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
|
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
|
||||||
for (Node n : entry.getValue()) {
|
for (Node n : entry.getValue()) {
|
||||||
String region = entry.getKey().getRegion();
|
String region = entry.getKey().getRegion();
|
||||||
clbApi.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).update(n.getId(),
|
api.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).update(n.getId(),
|
||||||
UpdateNode.builder().weight(23).build());
|
UpdateNode.builder().weight(23).build());
|
||||||
assertEquals(clbApi.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId())
|
assertEquals(api.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId())
|
||||||
.getStatus(), Node.Status.ONLINE);
|
.getStatus(), Node.Status.ONLINE);
|
||||||
|
|
||||||
Node newNode = clbApi.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId());
|
Node newNode = api.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId());
|
||||||
assertEquals(newNode.getStatus(), Node.Status.ONLINE);
|
assertEquals(newNode.getStatus(), Node.Status.ONLINE);
|
||||||
assertEquals(newNode.getWeight(), (Integer) 23);
|
assertEquals(newNode.getWeight(), (Integer) 23);
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
@Test(dependsOnMethods = "testModifyNode")
|
@Test(dependsOnMethods = "testModifyNode")
|
||||||
public void testListNodes() throws Exception {
|
public void testListNodes() throws Exception {
|
||||||
for (LoadBalancer lb : nodes.keySet()) {
|
for (LoadBalancer lb : nodes.keySet()) {
|
||||||
Set<Node> response = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).list().concat().toSet();
|
Set<Node> response = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).list().concat().toSet();
|
||||||
assert null != response;
|
assert null != response;
|
||||||
assertTrue(response.size() >= 0);
|
assertTrue(response.size() >= 0);
|
||||||
for (Node n : response) {
|
for (Node n : response) {
|
||||||
|
@ -123,7 +123,7 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
assert !Arrays.asList(LoadBalancer.WEIGHTED_ALGORITHMS).contains(lb.getAlgorithm())
|
assert !Arrays.asList(LoadBalancer.WEIGHTED_ALGORITHMS).contains(lb.getAlgorithm())
|
||||||
|| n.getWeight() != null : n;
|
|| n.getWeight() != null : n;
|
||||||
|
|
||||||
Node getDetails = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).get(n.getId());
|
Node getDetails = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).get(n.getId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assertEquals(getDetails.getId(), n.getId());
|
assertEquals(getDetails.getId(), n.getId());
|
||||||
|
@ -151,45 +151,45 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
"key2", "value2",
|
"key2", "value2",
|
||||||
"key3", "value3");
|
"key3", "value3");
|
||||||
|
|
||||||
Metadata metadata = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).createMetadata(node.getId(), metadataMap);
|
Metadata metadata = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).createMetadata(node.getId(), metadataMap);
|
||||||
assertEquals(metadata, getExpectedMetadata());
|
assertEquals(metadata, getExpectedMetadata());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
|
|
||||||
metadata = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
|
metadata = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
|
||||||
assertEquals(metadata, getExpectedMetadata());
|
assertEquals(metadata, getExpectedMetadata());
|
||||||
|
|
||||||
assertTrue(clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).updateMetadatum(node.getId(), metadata.getId("key1"), "key1-updated"));
|
assertTrue(api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).updateMetadatum(node.getId(), metadata.getId("key1"), "key1-updated"));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
metadata = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
|
metadata = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
|
||||||
assertEquals(metadata.get("key1"), "key1-updated");
|
assertEquals(metadata.get("key1"), "key1-updated");
|
||||||
|
|
||||||
assertTrue(clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).deleteMetadatum(node.getId(), metadata.getId("key1")));
|
assertTrue(api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).deleteMetadatum(node.getId(), metadata.getId("key1")));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
metadata = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
|
metadata = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
|
||||||
assertNull(metadata.get("key1"));
|
assertNull(metadata.get("key1"));
|
||||||
|
|
||||||
assertTrue(clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).deleteMetadata(node.getId(),
|
assertTrue(api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).deleteMetadata(node.getId(),
|
||||||
ImmutableList.<Integer> of(metadata.getId("key2"), metadata.getId("key3"))));
|
ImmutableList.<Integer> of(metadata.getId("key2"), metadata.getId("key3"))));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
metadata = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
|
metadata = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
|
||||||
assertEquals(metadata.size(), 0);
|
assertEquals(metadata.size(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
|
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
|
||||||
LoadBalancer lb = entry.getKey();
|
LoadBalancer lb = entry.getKey();
|
||||||
LoadBalancerApi lbClient = clbApi.getLoadBalancerApiForZone(lb.getRegion());
|
LoadBalancerApi lbClient = api.getLoadBalancerApiForZone(lb.getRegion());
|
||||||
|
|
||||||
if (lbClient.get(lb.getId()).getStatus() != Status.DELETED) {
|
if (lbClient.get(lb.getId()).getStatus() != Status.DELETED) {
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
lbClient.delete(lb.getId());
|
lbClient.delete(lb.getId());
|
||||||
}
|
}
|
||||||
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
|
||||||
}
|
}
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Metadata getExpectedMetadata() {
|
private Metadata getExpectedMetadata() {
|
||||||
|
|
|
@ -56,10 +56,10 @@ public class ReportApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
||||||
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
||||||
|
|
||||||
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
|
zone = Iterables.getFirst(api.getConfiguredZones(), null);
|
||||||
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
|
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
|
@ -69,20 +69,20 @@ public class ReportApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
Date yesterday = calendar.getTime();
|
Date yesterday = calendar.getTime();
|
||||||
Date today = new Date();
|
Date today = new Date();
|
||||||
|
|
||||||
FluentIterable<LoadBalancer> loadBalancers = clbApi.getReportApiForZone(zone).listBillableLoadBalancers(yesterday, today).concat();
|
FluentIterable<LoadBalancer> loadBalancers = api.getReportApiForZone(zone).listBillableLoadBalancers(yesterday, today).concat();
|
||||||
assertNotNull(loadBalancers);
|
assertNotNull(loadBalancers);
|
||||||
|
|
||||||
HistoricalUsage historicalUsage = clbApi.getReportApiForZone(zone).getHistoricalUsage(yesterday, today);
|
HistoricalUsage historicalUsage = api.getReportApiForZone(zone).getHistoricalUsage(yesterday, today);
|
||||||
assertNotEquals(historicalUsage.getAccountId(), 0);
|
assertNotEquals(historicalUsage.getAccountId(), 0);
|
||||||
|
|
||||||
FluentIterable<LoadBalancerUsage> loadBalancerUsages = clbApi.getReportApiForZone(zone).listLoadBalancerUsage(lb.getId(), yesterday, today).concat();
|
FluentIterable<LoadBalancerUsage> loadBalancerUsages = api.getReportApiForZone(zone).listLoadBalancerUsage(lb.getId(), yesterday, today).concat();
|
||||||
assertNotNull(loadBalancerUsages);
|
assertNotNull(loadBalancerUsages);
|
||||||
|
|
||||||
loadBalancerUsages = clbApi.getReportApiForZone(zone).listCurrentLoadBalancerUsage(lb.getId()).concat();
|
loadBalancerUsages = api.getReportApiForZone(zone).listCurrentLoadBalancerUsage(lb.getId()).concat();
|
||||||
assertNotNull(loadBalancerUsages);
|
assertNotNull(loadBalancerUsages);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LoadBalancerStats loadBalancerStats = clbApi.getReportApiForZone(zone).getLoadBalancerStats(lb.getId());
|
LoadBalancerStats loadBalancerStats = api.getReportApiForZone(zone).getLoadBalancerStats(lb.getId());
|
||||||
assertNotNull(loadBalancerStats);
|
assertNotNull(loadBalancerStats);
|
||||||
}
|
}
|
||||||
catch (HttpResponseException e) {
|
catch (HttpResponseException e) {
|
||||||
|
@ -92,19 +92,19 @@ public class ReportApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterable<Protocol> protocols = clbApi.getReportApiForZone(zone).listProtocols();
|
Iterable<Protocol> protocols = api.getReportApiForZone(zone).listProtocols();
|
||||||
assertTrue(!Iterables.isEmpty(protocols));
|
assertTrue(!Iterables.isEmpty(protocols));
|
||||||
|
|
||||||
Iterable<String> algorithms = clbApi.getReportApiForZone(zone).listAlgorithms();
|
Iterable<String> algorithms = api.getReportApiForZone(zone).listAlgorithms();
|
||||||
assertTrue(!Iterables.isEmpty(algorithms));
|
assertTrue(!Iterables.isEmpty(algorithms));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
||||||
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,41 +48,41 @@ public class SSLTerminationApiLiveTest extends BaseCloudLoadBalancersApiLiveTest
|
||||||
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
||||||
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
||||||
|
|
||||||
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
|
zone = Iterables.getFirst(api.getConfiguredZones(), null);
|
||||||
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
|
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testCreateAndGetSSLTermination() throws Exception {
|
public void testCreateAndGetSSLTermination() throws Exception {
|
||||||
clbApi.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdate(
|
api.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdate(
|
||||||
SSLTerminationApiExpectTest.getSSLTermination());
|
SSLTerminationApiExpectTest.getSSLTermination());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
SSLTermination sslTermination =
|
SSLTermination sslTermination =
|
||||||
clbApi.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
api.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
||||||
|
|
||||||
assertEquals(sslTermination, SSLTerminationApiExpectTest.getSSLTermination());
|
assertEquals(sslTermination, SSLTerminationApiExpectTest.getSSLTermination());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateAndGetSSLTermination")
|
@Test(dependsOnMethods = "testCreateAndGetSSLTermination")
|
||||||
public void testRemoveAndGetSSLTermination() throws Exception {
|
public void testRemoveAndGetSSLTermination() throws Exception {
|
||||||
assertTrue(clbApi.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
|
assertTrue(api.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
SSLTermination sslTermination =
|
SSLTermination sslTermination =
|
||||||
clbApi.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
api.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
||||||
|
|
||||||
assertNull(sslTermination);
|
assertNull(sslTermination);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
||||||
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,40 +48,40 @@ public class SessionPersistenceApiLiveTest extends BaseCloudLoadBalancersApiLive
|
||||||
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
||||||
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
||||||
|
|
||||||
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
|
zone = Iterables.getFirst(api.getConfiguredZones(), null);
|
||||||
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
|
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testCreateAndGetSessionPersistence() throws Exception {
|
public void testCreateAndGetSessionPersistence() throws Exception {
|
||||||
clbApi.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).create(SessionPersistence.HTTP_COOKIE);
|
api.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).create(SessionPersistence.HTTP_COOKIE);
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
SessionPersistence sessionPersistence =
|
SessionPersistence sessionPersistence =
|
||||||
clbApi.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
api.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
||||||
|
|
||||||
assertEquals(sessionPersistence, SessionPersistence.HTTP_COOKIE);
|
assertEquals(sessionPersistence, SessionPersistence.HTTP_COOKIE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateAndGetSessionPersistence")
|
@Test(dependsOnMethods = "testCreateAndGetSessionPersistence")
|
||||||
public void testRemoveAndGetSessionPersistence() throws Exception {
|
public void testRemoveAndGetSessionPersistence() throws Exception {
|
||||||
clbApi.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).delete();
|
api.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).delete();
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
SessionPersistence sessionPersistence =
|
SessionPersistence sessionPersistence =
|
||||||
clbApi.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
api.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).get();
|
||||||
|
|
||||||
assertNull(sessionPersistence);
|
assertNull(sessionPersistence);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
||||||
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,60 +52,60 @@ public class VirtualIPApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
|
||||||
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
|
||||||
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
|
||||||
|
|
||||||
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
|
zone = Iterables.getFirst(api.getConfiguredZones(), null);
|
||||||
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
|
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
|
||||||
|
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
@Test(dependsOnMethods = "testCreateLoadBalancer")
|
||||||
public void testCreateVirtualIPs() throws Exception {
|
public void testCreateVirtualIPs() throws Exception {
|
||||||
clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
|
api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
|
api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
|
api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
Iterable<VirtualIPWithId> actualVirtualIPs = clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
Iterable<VirtualIPWithId> actualVirtualIPs = api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
||||||
|
|
||||||
assertEquals(Iterators.size(actualVirtualIPs.iterator()), 5);
|
assertEquals(Iterators.size(actualVirtualIPs.iterator()), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateVirtualIPs")
|
@Test(dependsOnMethods = "testCreateVirtualIPs")
|
||||||
public void testRemoveSingleVirtualIP() throws Exception {
|
public void testRemoveSingleVirtualIP() throws Exception {
|
||||||
Iterable<VirtualIPWithId> actualVirtualIPs = clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
Iterable<VirtualIPWithId> actualVirtualIPs = api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
||||||
VirtualIPWithId removedVirtualIP = Iterables.getFirst(actualVirtualIPs, null);
|
VirtualIPWithId removedVirtualIP = Iterables.getFirst(actualVirtualIPs, null);
|
||||||
|
|
||||||
assertTrue(clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedVirtualIP.getId()));
|
assertTrue(api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedVirtualIP.getId()));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
actualVirtualIPs = clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
actualVirtualIPs = api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
||||||
|
|
||||||
assertEquals(Iterators.size(actualVirtualIPs.iterator()), 4);
|
assertEquals(Iterators.size(actualVirtualIPs.iterator()), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testRemoveSingleVirtualIP")
|
@Test(dependsOnMethods = "testRemoveSingleVirtualIP")
|
||||||
public void testRemoveManyVirtualIPs() throws Exception {
|
public void testRemoveManyVirtualIPs() throws Exception {
|
||||||
Iterable<VirtualIPWithId> actualVirtualIPs = clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
Iterable<VirtualIPWithId> actualVirtualIPs = api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
||||||
VirtualIPWithId removedVirtualIP1 = Iterables.getFirst(actualVirtualIPs, null);
|
VirtualIPWithId removedVirtualIP1 = Iterables.getFirst(actualVirtualIPs, null);
|
||||||
VirtualIPWithId removedVirtualIP2 = Iterables.getLast(actualVirtualIPs);
|
VirtualIPWithId removedVirtualIP2 = Iterables.getLast(actualVirtualIPs);
|
||||||
List<Integer> removedVirtualIPIds = ImmutableList.<Integer> of(removedVirtualIP1.getId(), removedVirtualIP2.getId());
|
List<Integer> removedVirtualIPIds = ImmutableList.<Integer> of(removedVirtualIP1.getId(), removedVirtualIP2.getId());
|
||||||
|
|
||||||
assertTrue(clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedVirtualIPIds));
|
assertTrue(api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedVirtualIPIds));
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
|
|
||||||
actualVirtualIPs = clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
actualVirtualIPs = api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
|
||||||
|
|
||||||
assertEquals(Iterators.size(actualVirtualIPs.iterator()), 2);
|
assertEquals(Iterators.size(actualVirtualIPs.iterator()), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
|
||||||
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
|
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,22 +21,16 @@ package org.jclouds.rackspace.cloudloadbalancers.v1.internal;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseContextLiveTest;
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
|
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
|
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApiMetadata;
|
|
||||||
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersAsyncApi;
|
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class BaseCloudLoadBalancersApiLiveTest extends BaseContextLiveTest<RestContext<CloudLoadBalancersApi, CloudLoadBalancersAsyncApi>> {
|
public class BaseCloudLoadBalancersApiLiveTest extends BaseApiLiveTest<CloudLoadBalancersApi> {
|
||||||
protected CloudLoadBalancersApi clbApi;
|
|
||||||
|
|
||||||
public BaseCloudLoadBalancersApiLiveTest() {
|
public BaseCloudLoadBalancersApiLiveTest() {
|
||||||
provider = "rackspace-cloudloadbalancers";
|
provider = "rackspace-cloudloadbalancers";
|
||||||
|
@ -44,12 +38,9 @@ public class BaseCloudLoadBalancersApiLiveTest extends BaseContextLiveTest<RestC
|
||||||
|
|
||||||
@BeforeGroups(groups = { "integration", "live" })
|
@BeforeGroups(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
|
Logger.getAnonymousLogger().info("running against zones " + api.getConfiguredZones());
|
||||||
clbApi = context.getApi();
|
|
||||||
|
|
||||||
Logger.getAnonymousLogger().info("running against zones " + clbApi.getConfiguredZones());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,9 +49,4 @@ public class BaseCloudLoadBalancersApiLiveTest extends BaseContextLiveTest<RestC
|
||||||
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
|
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeToken<RestContext<CloudLoadBalancersApi, CloudLoadBalancersAsyncApi>> contextType() {
|
|
||||||
return CloudLoadBalancersApiMetadata.CONTEXT_TOKEN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,6 @@ public class Route53ApiLiveTest extends BaseRoute53ApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
protected void testGetChangeReturnsNullOnNotFound() {
|
protected void testGetChangeReturnsNullOnNotFound() {
|
||||||
assertNull(api().getChange("FOOOBAR"));
|
assertNull(api.getChange("FOOOBAR"));
|
||||||
}
|
|
||||||
|
|
||||||
protected Route53Api api() {
|
|
||||||
return context.getApi();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,6 @@ public class HostedZoneApiLiveTest extends BaseRoute53ApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HostedZoneApi api() {
|
protected HostedZoneApi api() {
|
||||||
return context.getApi().getHostedZoneApi();
|
return api.getHostedZoneApi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class ResourceRecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAllRRs(String zoneId) {
|
private void checkAllRRs(String zoneId) {
|
||||||
HostedZone zone = context.getApi().getHostedZoneApi().get(zoneId).getZone();
|
HostedZone zone = api.getHostedZoneApi().get(zoneId).getZone();
|
||||||
List<ResourceRecordSet> records = api(zone.getId()).list().concat().toList();
|
List<ResourceRecordSet> records = api(zone.getId()).list().concat().toList();
|
||||||
assertEquals(zone.getResourceRecordSetCount(), records.size());
|
assertEquals(zone.getResourceRecordSetCount(), records.size());
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ public class ResourceRecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
|
||||||
clearAndDeleteHostedZonesNamed(name);
|
clearAndDeleteHostedZonesNamed(name);
|
||||||
String nonce = name + " @ " + new Date();
|
String nonce = name + " @ " + new Date();
|
||||||
String comment = name + " for " + JcloudsVersion.get();
|
String comment = name + " for " + JcloudsVersion.get();
|
||||||
NewHostedZone newHostedZone = context.getApi().getHostedZoneApi()
|
NewHostedZone newHostedZone = api.getHostedZoneApi()
|
||||||
.createWithReferenceAndComment(name, nonce, comment);
|
.createWithReferenceAndComment(name, nonce, comment);
|
||||||
getAnonymousLogger().info("created zone: " + newHostedZone);
|
getAnonymousLogger().info("created zone: " + newHostedZone);
|
||||||
assertTrue(inSync.apply(newHostedZone.getChange()), "zone didn't sync " + newHostedZone);
|
assertTrue(inSync.apply(newHostedZone.getChange()), "zone didn't sync " + newHostedZone);
|
||||||
|
@ -191,12 +191,12 @@ public class ResourceRecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearAndDeleteHostedZonesNamed(String name) {
|
private void clearAndDeleteHostedZonesNamed(String name) {
|
||||||
for (HostedZone zone : context.getApi().getHostedZoneApi().list().concat().filter(nameEquals(name))) {
|
for (HostedZone zone : api.getHostedZoneApi().list().concat().filter(nameEquals(name))) {
|
||||||
getAnonymousLogger().info("clearing and deleting zone: " + zone);
|
getAnonymousLogger().info("clearing and deleting zone: " + zone);
|
||||||
Set<ResourceRecordSet> remaining = refresh(zone.getId()).concat().filter(not(requiredRRTypes)).toSet();
|
Set<ResourceRecordSet> remaining = refresh(zone.getId()).concat().filter(not(requiredRRTypes)).toSet();
|
||||||
if (!remaining.isEmpty())
|
if (!remaining.isEmpty())
|
||||||
sync(api(zone.getId()).apply(deleteAll(remaining)));
|
sync(api(zone.getId()).apply(deleteAll(remaining)));
|
||||||
sync(context.getApi().getHostedZoneApi().delete(zone.getId()));
|
sync(api.getHostedZoneApi().delete(zone.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,13 +209,13 @@ public class ResourceRecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private PagedIterable<HostedZone> zones() {
|
private PagedIterable<HostedZone> zones() {
|
||||||
PagedIterable<HostedZone> zones = context.getApi().getHostedZoneApi().list();
|
PagedIterable<HostedZone> zones = api.getHostedZoneApi().list();
|
||||||
if (zones.get(0).isEmpty())
|
if (zones.get(0).isEmpty())
|
||||||
throw new SkipException("no zones in context: " + context);
|
throw new SkipException("no zones in context: " + identity);
|
||||||
return zones;
|
return zones;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResourceRecordSetApi api(String zoneId) {
|
private ResourceRecordSetApi api(String zoneId) {
|
||||||
return context.getApi().getResourceRecordSetApiForHostedZone(zoneId);
|
return api.getResourceRecordSetApiForHostedZone(zoneId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,25 +22,20 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static org.jclouds.route53.domain.Change.Status.INSYNC;
|
import static org.jclouds.route53.domain.Change.Status.INSYNC;
|
||||||
import static org.jclouds.util.Predicates2.retry;
|
import static org.jclouds.util.Predicates2.retry;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseContextLiveTest;
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.route53.Route53ApiMetadata;
|
|
||||||
import org.jclouds.route53.Route53AsyncApi;
|
|
||||||
import org.jclouds.route53.Route53Api;
|
import org.jclouds.route53.Route53Api;
|
||||||
import org.jclouds.route53.domain.Change;
|
import org.jclouds.route53.domain.Change;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class BaseRoute53ApiLiveTest extends
|
public class BaseRoute53ApiLiveTest extends BaseApiLiveTest<Route53Api> {
|
||||||
BaseContextLiveTest<RestContext<? extends Route53Api, ? extends Route53AsyncApi>> {
|
|
||||||
|
|
||||||
public BaseRoute53ApiLiveTest() {
|
public BaseRoute53ApiLiveTest() {
|
||||||
provider = "route53";
|
provider = "route53";
|
||||||
|
@ -50,17 +45,12 @@ public class BaseRoute53ApiLiveTest extends
|
||||||
|
|
||||||
@BeforeClass(groups = "live")
|
@BeforeClass(groups = "live")
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
inSync = retry(new Predicate<Change>() {
|
inSync = retry(new Predicate<Change>() {
|
||||||
public boolean apply(Change input) {
|
public boolean apply(Change input) {
|
||||||
return context.getApi().getChange(input.getId()).getStatus() == INSYNC;
|
return api.getChange(input.getId()).getStatus() == INSYNC;
|
||||||
}
|
}
|
||||||
}, 600, 1, 5, SECONDS);
|
}, 600, 1, 5, SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeToken<RestContext<? extends Route53Api, ? extends Route53AsyncApi>> contextType() {
|
|
||||||
return Route53ApiMetadata.CONTEXT_TOKEN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.ContextBuilder;
|
import org.jclouds.ContextBuilder;
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.s3.domain.S3Object;
|
import org.jclouds.s3.domain.S3Object;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ public class S3ClientMockTest {
|
||||||
private static final Set<Module> modules = ImmutableSet.<Module> of(
|
private static final Set<Module> modules = ImmutableSet.<Module> of(
|
||||||
new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()));
|
new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()));
|
||||||
|
|
||||||
static RestContext<? extends S3Client,? extends S3AsyncClient> getContext(URL server) {
|
static S3Client getS3Client(URL server) {
|
||||||
Properties overrides = new Properties();
|
Properties overrides = new Properties();
|
||||||
overrides.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
|
overrides.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
|
||||||
// prevent expect-100 bug http://code.google.com/p/mockwebserver/issues/detail?id=6
|
// prevent expect-100 bug http://code.google.com/p/mockwebserver/issues/detail?id=6
|
||||||
|
@ -66,7 +65,7 @@ public class S3ClientMockTest {
|
||||||
.endpoint(server.toString())
|
.endpoint(server.toString())
|
||||||
.modules(modules)
|
.modules(modules)
|
||||||
.overrides(overrides)
|
.overrides(overrides)
|
||||||
.build(S3ApiMetadata.CONTEXT_TOKEN);
|
.buildApi(S3Client.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testZeroLengthPutHasContentLengthHeader() throws IOException, InterruptedException {
|
public void testZeroLengthPutHasContentLengthHeader() throws IOException, InterruptedException {
|
||||||
|
@ -74,7 +73,7 @@ public class S3ClientMockTest {
|
||||||
server.enqueue(new MockResponse().setBody("").addHeader(ETAG, "ABCDEF"));
|
server.enqueue(new MockResponse().setBody("").addHeader(ETAG, "ABCDEF"));
|
||||||
server.play();
|
server.play();
|
||||||
|
|
||||||
S3Client client = getContext(server.getUrl("/")).getApi();
|
S3Client client = getS3Client(server.getUrl("/"));
|
||||||
S3Object nada = client.newS3Object();
|
S3Object nada = client.newS3Object();
|
||||||
nada.getMetadata().setKey("object");
|
nada.getMetadata().setKey("object");
|
||||||
nada.setPayload(new byte[] {});
|
nada.setPayload(new byte[] {});
|
||||||
|
@ -94,7 +93,7 @@ public class S3ClientMockTest {
|
||||||
server.enqueue(new MockResponse().setBody("").addHeader(ETAG, "ABCDEF"));
|
server.enqueue(new MockResponse().setBody("").addHeader(ETAG, "ABCDEF"));
|
||||||
server.play();
|
server.play();
|
||||||
|
|
||||||
S3Client client = getContext(server.getUrl("/")).getApi();
|
S3Client client = getS3Client(server.getUrl("/"));
|
||||||
S3Object fileInDir = client.newS3Object();
|
S3Object fileInDir = client.newS3Object();
|
||||||
fileInDir.getMetadata().setKey("someDir/fileName");
|
fileInDir.getMetadata().setKey("someDir/fileName");
|
||||||
fileInDir.setPayload(new byte[] { 1, 2, 3, 4 });
|
fileInDir.setPayload(new byte[] { 1, 2, 3, 4 });
|
||||||
|
|
|
@ -63,14 +63,14 @@ public class BulkMessageApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
recreateQueueInRegion(prefix, null);
|
recreateQueueInRegion(prefix, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSendMessages() {
|
public void testSendMessages() {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
BatchResult<? extends MessageIdAndMD5> acks = api().getMessageApiForQueue(queue).send(idPayload);
|
BatchResult<? extends MessageIdAndMD5> acks = api.getMessageApiForQueue(queue).send(idPayload);
|
||||||
|
|
||||||
assertEquals(acks.size(), idPayload.size(), "error sending " + acks);
|
assertEquals(acks.size(), idPayload.size(), "error sending " + acks);
|
||||||
assertEquals(acks.keySet(), idPayload.keySet());
|
assertEquals(acks.keySet(), idPayload.keySet());
|
||||||
|
@ -87,7 +87,7 @@ public class BulkMessageApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
@Test(dependsOnMethods = "testSendMessages")
|
@Test(dependsOnMethods = "testSendMessages")
|
||||||
public void testChangeMessageVisibility() {
|
public void testChangeMessageVisibility() {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
MessageApi api = api().getMessageApiForQueue(queue);
|
MessageApi api = this.api.getMessageApiForQueue(queue);
|
||||||
|
|
||||||
Set<Message> messages = collectMessages(api);
|
Set<Message> messages = collectMessages(api);
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ public class BulkMessageApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
@Test(dependsOnMethods = "testChangeMessageVisibility")
|
@Test(dependsOnMethods = "testChangeMessageVisibility")
|
||||||
public void testDeleteMessage() throws InterruptedException {
|
public void testDeleteMessage() throws InterruptedException {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
BatchResult<String> acks = api().getMessageApiForQueue(queue).delete(receiptHandles);
|
BatchResult<String> acks = api.getMessageApiForQueue(queue).delete(receiptHandles);
|
||||||
assertEquals(acks.size(), Iterables.size(receiptHandles), "error deleting messages " + acks);
|
assertEquals(acks.size(), Iterables.size(receiptHandles), "error deleting messages " + acks);
|
||||||
assertNoMessages(queue);
|
assertNoMessages(queue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ public class MessageApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
recreateQueueInRegion(prefix, null);
|
recreateQueueInRegion(prefix, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,14 +55,14 @@ public class MessageApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
|
|
||||||
public void testSendMessage() {
|
public void testSendMessage() {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
assertEquals(api().getMessageApiForQueue(queue).send(message).getMD5(), md5);
|
assertEquals(api.getMessageApiForQueue(queue).send(message).getMD5(), md5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testSendMessage")
|
@Test(dependsOnMethods = "testSendMessage")
|
||||||
public void testReceiveMessageWithoutHidingMessage() {
|
public void testReceiveMessageWithoutHidingMessage() {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
assertEquals(api().getMessageApiForQueue(queue).receive(attribute("All").visibilityTimeout(0)).getMD5(), md5);
|
assertEquals(api.getMessageApiForQueue(queue).receive(attribute("All").visibilityTimeout(0)).getMD5(), md5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class MessageApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
@Test(dependsOnMethods = "testReceiveMessageWithoutHidingMessage")
|
@Test(dependsOnMethods = "testReceiveMessageWithoutHidingMessage")
|
||||||
public void testChangeMessageVisibility() {
|
public void testChangeMessageVisibility() {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
MessageApi api = api().getMessageApiForQueue(queue);
|
MessageApi api = this.api.getMessageApiForQueue(queue);
|
||||||
// start hiding it at 5 seconds
|
// start hiding it at 5 seconds
|
||||||
receiptHandle = api.receive(attribute("None").visibilityTimeout(5)).getReceiptHandle();
|
receiptHandle = api.receive(attribute("None").visibilityTimeout(5)).getReceiptHandle();
|
||||||
// hidden message, so we can't see it
|
// hidden message, so we can't see it
|
||||||
|
@ -86,7 +86,7 @@ public class MessageApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
@Test(dependsOnMethods = "testChangeMessageVisibility")
|
@Test(dependsOnMethods = "testChangeMessageVisibility")
|
||||||
public void testDeleteMessage() throws InterruptedException {
|
public void testDeleteMessage() throws InterruptedException {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
api().getMessageApiForQueue(queue).delete(receiptHandle);
|
api.getMessageApiForQueue(queue).delete(receiptHandle);
|
||||||
assertNoMessages(queue);
|
assertNoMessages(queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,8 @@ public class PermissionApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
recreateQueueInRegion(prefix, null);
|
recreateQueueInRegion(prefix, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,17 +77,17 @@ public class PermissionApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
|
|
||||||
public void testAddAnonymousPermission() throws InterruptedException {
|
public void testAddAnonymousPermission() throws InterruptedException {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
QueueAttributes attributes = api().getQueueApi().getAttributes(queue);
|
QueueAttributes attributes = api.getQueueApi().getAttributes(queue);
|
||||||
assertNoPermissions(queue);
|
assertNoPermissions(queue);
|
||||||
|
|
||||||
String accountToAuthorize = getOwner(queue);
|
String accountToAuthorize = getOwner(queue);
|
||||||
api().getPermissionApiForQueue(queue).addPermissionToAccount("fubar", Action.GET_QUEUE_ATTRIBUTES,
|
api.getPermissionApiForQueue(queue).addPermissionToAccount("fubar", Action.GET_QUEUE_ATTRIBUTES,
|
||||||
accountToAuthorize);
|
accountToAuthorize);
|
||||||
|
|
||||||
String policyForAuthorizationByAccount = assertPolicyPresent(queue);
|
String policyForAuthorizationByAccount = assertPolicyPresent(queue);
|
||||||
|
|
||||||
String policyForAnonymous = policyForAuthorizationByAccount.replace("\"" + accountToAuthorize + "\"", "\"*\"");
|
String policyForAnonymous = policyForAuthorizationByAccount.replace("\"" + accountToAuthorize + "\"", "\"*\"");
|
||||||
api().getQueueApi().setAttribute(queue, "Policy", policyForAnonymous);
|
api.getQueueApi().setAttribute(queue, "Policy", policyForAnonymous);
|
||||||
|
|
||||||
assertEquals(getAnonymousAttributesApi(queue).getQueueArn(), attributes.getQueueArn());
|
assertEquals(getAnonymousAttributesApi(queue).getQueueArn(), attributes.getQueueArn());
|
||||||
}
|
}
|
||||||
|
@ -96,18 +96,17 @@ public class PermissionApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
@Test(dependsOnMethods = "testAddAnonymousPermission")
|
@Test(dependsOnMethods = "testAddAnonymousPermission")
|
||||||
public void testRemovePermission() throws InterruptedException {
|
public void testRemovePermission() throws InterruptedException {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
api().getPermissionApiForQueue(queue).remove("fubar");
|
api.getPermissionApiForQueue(queue).remove("fubar");
|
||||||
assertNoPermissions(queue);
|
assertNoPermissions(queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AnonymousAttributesApi getAnonymousAttributesApi(URI queue) {
|
private AnonymousAttributesApi getAnonymousAttributesApi(URI queue) {
|
||||||
return ContextBuilder
|
return ContextBuilder.newBuilder(
|
||||||
.newBuilder(
|
|
||||||
forClientMappedToAsyncClientOnEndpoint(AnonymousAttributesApi.class,
|
forClientMappedToAsyncClientOnEndpoint(AnonymousAttributesApi.class,
|
||||||
AnonymousAttributesAsyncApi.class, queue.toASCIIString()))
|
AnonymousAttributesAsyncApi.class, queue.toASCIIString()))
|
||||||
.modules(ImmutableSet.<Module> of(new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor())))
|
.modules(ImmutableSet.<Module> of(new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor())))
|
||||||
.buildInjector().getInstance(AnonymousAttributesApi.class);
|
.buildApi(AnonymousAttributesApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class QueueApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void listQueuesInRegion(String region) throws InterruptedException {
|
protected void listQueuesInRegion(String region) throws InterruptedException {
|
||||||
FluentIterable<URI> allResults = api().getQueueApiForRegion(region).list();
|
FluentIterable<URI> allResults = api.getQueueApiForRegion(region).list();
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
if (allResults.size() >= 1) {
|
if (allResults.size() >= 1) {
|
||||||
URI queue = getLast(allResults);
|
URI queue = getLast(allResults);
|
||||||
|
@ -60,7 +60,7 @@ public class QueueApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGracefulNoQueue() throws InterruptedException {
|
public void testGracefulNoQueue() throws InterruptedException {
|
||||||
assertNull(api().getQueueApi().get(UUID.randomUUID().toString()));
|
assertNull(api.getQueueApi().get(UUID.randomUUID().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -72,37 +72,37 @@ public class QueueApiLiveTest extends BaseSQSApiLiveTest {
|
||||||
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
|
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
|
||||||
public void testCreateQueueWhenAlreadyExistsReturnsURI() {
|
public void testCreateQueueWhenAlreadyExistsReturnsURI() {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
assertEquals(api().getQueueApi().create(prefix), queue);
|
assertEquals(api.getQueueApi().create(prefix), queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
|
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
|
||||||
public void testGet() {
|
public void testGet() {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
assertEquals(api().getQueueApi().get(prefix), queue);
|
assertEquals(api.getQueueApi().get(prefix), queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
|
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
|
||||||
public void testGetInAccount() {
|
public void testGetInAccount() {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
assertEquals(api().getQueueApi().getInAccount(prefix, getOwner(queue)), queue);
|
assertEquals(api.getQueueApi().getInAccount(prefix, getOwner(queue)), queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
|
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
|
||||||
public void testGetQueueAttributes() {
|
public void testGetQueueAttributes() {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
Map<String, String> attributes = api().getQueueApi().getAttributes(queue, ImmutableSet.of("All"));
|
Map<String, String> attributes = api.getQueueApi().getAttributes(queue, ImmutableSet.of("All"));
|
||||||
assertEquals(api().getQueueApi().getAttributes(queue, attributes.keySet()), attributes);
|
assertEquals(api.getQueueApi().getAttributes(queue, attributes.keySet()), attributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testGetQueueAttributes")
|
@Test(dependsOnMethods = "testGetQueueAttributes")
|
||||||
public void testSetQueueAttribute() {
|
public void testSetQueueAttribute() {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
api().getQueueApi().setAttribute(queue, "MaximumMessageSize", "1024");
|
api.getQueueApi().setAttribute(queue, "MaximumMessageSize", "1024");
|
||||||
assertEquals(api().getQueueApi().getAttributes(queue).getMaximumMessageSize(), 1024);
|
assertEquals(api.getQueueApi().getAttributes(queue).getMaximumMessageSize(), 1024);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,8 @@ import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseContextLiveTest;
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.sqs.SQSApi;
|
import org.jclouds.sqs.SQSApi;
|
||||||
import org.jclouds.sqs.SQSApiMetadata;
|
|
||||||
import org.jclouds.sqs.SQSAsyncApi;
|
|
||||||
import org.jclouds.sqs.domain.Message;
|
import org.jclouds.sqs.domain.Message;
|
||||||
import org.jclouds.sqs.features.QueueApi;
|
import org.jclouds.sqs.features.QueueApi;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
|
@ -41,7 +38,6 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
import com.google.common.util.concurrent.Atomics;
|
import com.google.common.util.concurrent.Atomics;
|
||||||
import com.google.common.util.concurrent.Uninterruptibles;
|
import com.google.common.util.concurrent.Uninterruptibles;
|
||||||
|
|
||||||
|
@ -50,7 +46,7 @@ import com.google.common.util.concurrent.Uninterruptibles;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi, SQSAsyncApi>> {
|
public class BaseSQSApiLiveTest extends BaseApiLiveTest<SQSApi> {
|
||||||
|
|
||||||
protected String prefix = System.getProperty("user.name") + "-sqs";
|
protected String prefix = System.getProperty("user.name") + "-sqs";
|
||||||
|
|
||||||
|
@ -65,7 +61,7 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String recreateQueueInRegion(String queueName, String region) {
|
protected String recreateQueueInRegion(String queueName, String region) {
|
||||||
QueueApi api = api().getQueueApiForRegion(region);
|
QueueApi api = this.api.getQueueApiForRegion(region);
|
||||||
URI result = api.get(queueName);
|
URI result = api.get(queueName);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
api.delete(result);
|
api.delete(result);
|
||||||
|
@ -76,16 +72,11 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
|
||||||
return queueName;
|
return queueName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeToken<RestContext<SQSApi, SQSAsyncApi>> contextType() {
|
|
||||||
return SQSApiMetadata.CONTEXT_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String assertPolicyPresent(final URI queue) {
|
protected String assertPolicyPresent(final URI queue) {
|
||||||
final AtomicReference<String> policy = Atomics.newReference();
|
final AtomicReference<String> policy = Atomics.newReference();
|
||||||
assertEventually(new Runnable() {
|
assertEventually(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
String policyForAuthorizationByAccount = api().getQueueApi().getAttribute(queue, "Policy");
|
String policyForAuthorizationByAccount = api.getQueueApi().getAttribute(queue, "Policy");
|
||||||
|
|
||||||
assertNotNull(policyForAuthorizationByAccount);
|
assertNotNull(policyForAuthorizationByAccount);
|
||||||
policy.set(policyForAuthorizationByAccount);
|
policy.set(policyForAuthorizationByAccount);
|
||||||
|
@ -97,7 +88,7 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
|
||||||
protected void assertNoPermissions(final URI queue) {
|
protected void assertNoPermissions(final URI queue) {
|
||||||
assertEventually(new Runnable() {
|
assertEventually(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
String policy = api().getQueueApi().getAttribute(queue, "Policy");
|
String policy = api.getQueueApi().getAttribute(queue, "Policy");
|
||||||
assertTrue(policy == null || policy.indexOf("\"Statement\":[]") != -1, policy);
|
assertTrue(policy == null || policy.indexOf("\"Statement\":[]") != -1, policy);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -106,7 +97,7 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
|
||||||
protected void assertNoMessages(final URI queue) {
|
protected void assertNoMessages(final URI queue) {
|
||||||
assertEventually(new Runnable() {
|
assertEventually(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Message message = api().getMessageApiForQueue(queue).receive();
|
Message message = api.getMessageApiForQueue(queue).receive();
|
||||||
assertNull(message, "message: " + message + " left in queue " + queue);
|
assertNull(message, "message: " + message + " left in queue " + queue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -116,7 +107,7 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
|
||||||
final URI finalQ = queue;
|
final URI finalQ = queue;
|
||||||
assertEventually(new Runnable() {
|
assertEventually(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
FluentIterable<URI> result = api().getQueueApiForRegion(region).list();
|
FluentIterable<URI> result = api.getQueueApiForRegion(region).list();
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assert result.size() >= 1 : result;
|
assert result.size() >= 1 : result;
|
||||||
assertTrue(result.contains(finalQ), finalQ + " not in " + result);
|
assertTrue(result.contains(finalQ), finalQ + " not in " + result);
|
||||||
|
@ -152,15 +143,10 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterClass(groups = "live")
|
@AfterClass(groups = "live")
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
for (URI queue : queues) {
|
for (URI queue : queues) {
|
||||||
api().getQueueApi().delete(queue);
|
api.getQueueApi().delete(queue);
|
||||||
}
|
}
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SQSApi api() {
|
|
||||||
return context.getApi();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class STSApiLiveTest extends BaseSTSApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
protected void testCreateTemporaryCredentials() {
|
protected void testCreateTemporaryCredentials() {
|
||||||
SessionCredentials creds = api().createTemporaryCredentials(
|
SessionCredentials creds = api.createTemporaryCredentials(
|
||||||
new SessionCredentialsOptions().durationSeconds(MINUTES.toSeconds(15)));
|
new SessionCredentialsOptions().durationSeconds(MINUTES.toSeconds(15)));
|
||||||
checkTemporaryCredentials(creds);
|
checkTemporaryCredentials(creds);
|
||||||
// TODO: actually login to some service
|
// TODO: actually login to some service
|
||||||
|
@ -53,7 +53,7 @@ public class STSApiLiveTest extends BaseSTSApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
protected void testCreateFederatedUser() {
|
protected void testCreateFederatedUser() {
|
||||||
UserAndSessionCredentials user = api().createFederatedUser("Bob", new FederatedUserOptions().durationSeconds(MINUTES.toSeconds(15)));
|
UserAndSessionCredentials user = api.createFederatedUser("Bob", new FederatedUserOptions().durationSeconds(MINUTES.toSeconds(15)));
|
||||||
checkTemporaryCredentials(user.getCredentials());
|
checkTemporaryCredentials(user.getCredentials());
|
||||||
assertTrue(user.getUser().getId().contains("Bob"), user + " id incorrect");
|
assertTrue(user.getUser().getId().contains("Bob"), user + " id incorrect");
|
||||||
assertTrue(user.getUser().getArn().contains("Bob"), user + " arn incorrect");
|
assertTrue(user.getUser().getArn().contains("Bob"), user + " arn incorrect");
|
||||||
|
@ -63,7 +63,7 @@ public class STSApiLiveTest extends BaseSTSApiLiveTest {
|
||||||
@Test
|
@Test
|
||||||
protected void testAssumeRole() {
|
protected void testAssumeRole() {
|
||||||
String arnToAssume = getTestArn();
|
String arnToAssume = getTestArn();
|
||||||
UserAndSessionCredentials role = api().assumeRole(arnToAssume, "session",
|
UserAndSessionCredentials role = api.assumeRole(arnToAssume, "session",
|
||||||
new AssumeRoleOptions().durationSeconds(MINUTES.toSeconds(15)));
|
new AssumeRoleOptions().durationSeconds(MINUTES.toSeconds(15)));
|
||||||
checkTemporaryCredentials(role.getCredentials());
|
checkTemporaryCredentials(role.getCredentials());
|
||||||
assertTrue(role.getUser().getId().contains("session"), role + " id incorrect");
|
assertTrue(role.getUser().getId().contains("session"), role + " id incorrect");
|
||||||
|
@ -81,8 +81,4 @@ public class STSApiLiveTest extends BaseSTSApiLiveTest {
|
||||||
checkNotNull(creds.getSessionToken(), "SessionToken cannot be null for TemporaryCredentials.");
|
checkNotNull(creds.getSessionToken(), "SessionToken cannot be null for TemporaryCredentials.");
|
||||||
checkNotNull(creds.getExpiration(), "Expiration cannot be null for TemporaryCredentials.");
|
checkNotNull(creds.getExpiration(), "Expiration cannot be null for TemporaryCredentials.");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected STSApi api() {
|
|
||||||
return context.getApi();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,30 +18,17 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.sts.internal;
|
package org.jclouds.sts.internal;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseContextLiveTest;
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.sts.STSApiMetadata;
|
|
||||||
import org.jclouds.sts.STSAsyncApi;
|
|
||||||
import org.jclouds.sts.STSApi;
|
import org.jclouds.sts.STSApi;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class BaseSTSApiLiveTest extends
|
public class BaseSTSApiLiveTest extends BaseApiLiveTest<STSApi> {
|
||||||
BaseContextLiveTest<RestContext<? extends STSApi, ? extends STSAsyncApi>> {
|
|
||||||
|
|
||||||
public BaseSTSApiLiveTest() {
|
public BaseSTSApiLiveTest() {
|
||||||
provider = "sts";
|
provider = "sts";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeToken<RestContext<? extends STSApi, ? extends STSAsyncApi>> contextType() {
|
|
||||||
return STSApiMetadata.CONTEXT_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,11 @@ import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.blobstore.BlobStore;
|
|
||||||
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
|
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
|
||||||
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
|
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
|
||||||
import org.jclouds.openstack.swift.CommonSwiftAsyncClient;
|
|
||||||
import org.jclouds.openstack.swift.CommonSwiftClient;
|
import org.jclouds.openstack.swift.CommonSwiftClient;
|
||||||
import org.jclouds.openstack.swift.domain.ContainerMetadata;
|
import org.jclouds.openstack.swift.domain.ContainerMetadata;
|
||||||
import org.jclouds.openstack.swift.options.CreateContainerOptions;
|
import org.jclouds.openstack.swift.options.CreateContainerOptions;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -56,19 +53,19 @@ public class SwiftContainerIntegrationLiveTest extends BaseContainerIntegrationT
|
||||||
|
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public void testSetGetContainerMetadata() throws InterruptedException {
|
public void testSetGetContainerMetadata() throws InterruptedException {
|
||||||
BlobStore blobStore = view.getBlobStore();
|
CommonSwiftClient swift = view.utils().injector().getInstance(CommonSwiftClient.class);
|
||||||
RestContext<CommonSwiftClient, CommonSwiftAsyncClient> swift = blobStore.getContext().unwrap();
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
|
|
||||||
assertTrue(swift.getApi().createContainer(containerName));
|
assertTrue(swift.createContainer(containerName));
|
||||||
|
|
||||||
ImmutableMap<String, String> metadata = ImmutableMap.<String, String> of(
|
ImmutableMap<String, String> metadata = ImmutableMap.<String, String> of(
|
||||||
"key1", "value1",
|
"key1", "value1",
|
||||||
"key2", "value2");
|
"key2", "value2");
|
||||||
|
|
||||||
assertTrue(swift.getApi().setContainerMetadata(containerName, metadata));
|
assertTrue(swift.setContainerMetadata(containerName, metadata));
|
||||||
|
|
||||||
ContainerMetadata containerMetadata = swift.getApi().getContainerMetadata(containerName);
|
ContainerMetadata containerMetadata = swift.getContainerMetadata(containerName);
|
||||||
|
|
||||||
assertEquals(containerMetadata.getMetadata().get("key1"), "value1");
|
assertEquals(containerMetadata.getMetadata().get("key1"), "value1");
|
||||||
assertEquals(containerMetadata.getMetadata().get("key2"), "value2");
|
assertEquals(containerMetadata.getMetadata().get("key2"), "value2");
|
||||||
|
@ -76,8 +73,8 @@ public class SwiftContainerIntegrationLiveTest extends BaseContainerIntegrationT
|
||||||
|
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public void testCreateDeleteContainerMetadata() throws InterruptedException {
|
public void testCreateDeleteContainerMetadata() throws InterruptedException {
|
||||||
BlobStore blobStore = view.getBlobStore();
|
CommonSwiftClient swift = view.utils().injector().getInstance(CommonSwiftClient.class);
|
||||||
RestContext<CommonSwiftClient, CommonSwiftAsyncClient> swift = blobStore.getContext().unwrap();
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
CreateContainerOptions options = CreateContainerOptions.Builder
|
CreateContainerOptions options = CreateContainerOptions.Builder
|
||||||
.withPublicAccess()
|
.withPublicAccess()
|
||||||
|
@ -86,18 +83,18 @@ public class SwiftContainerIntegrationLiveTest extends BaseContainerIntegrationT
|
||||||
"key2", "value2",
|
"key2", "value2",
|
||||||
"key3", "value3"));
|
"key3", "value3"));
|
||||||
|
|
||||||
assertTrue(swift.getApi().createContainer(containerName, options));
|
assertTrue(swift.createContainer(containerName, options));
|
||||||
|
|
||||||
ContainerMetadata containerMetadata = swift.getApi().getContainerMetadata(containerName);
|
ContainerMetadata containerMetadata = swift.getContainerMetadata(containerName);
|
||||||
|
|
||||||
assertEquals(containerMetadata.getMetadata().size(), 3);
|
assertEquals(containerMetadata.getMetadata().size(), 3);
|
||||||
assertEquals(containerMetadata.getMetadata().get("key1"), "value1");
|
assertEquals(containerMetadata.getMetadata().get("key1"), "value1");
|
||||||
assertEquals(containerMetadata.getMetadata().get("key2"), "value2");
|
assertEquals(containerMetadata.getMetadata().get("key2"), "value2");
|
||||||
assertEquals(containerMetadata.getMetadata().get("key3"), "value3");
|
assertEquals(containerMetadata.getMetadata().get("key3"), "value3");
|
||||||
|
|
||||||
assertTrue(swift.getApi().deleteContainerMetadata(containerName, ImmutableList.<String> of("key2","key3")));
|
assertTrue(swift.deleteContainerMetadata(containerName, ImmutableList.<String> of("key2","key3")));
|
||||||
|
|
||||||
containerMetadata = swift.getApi().getContainerMetadata(containerName);
|
containerMetadata = swift.getContainerMetadata(containerName);
|
||||||
|
|
||||||
assertEquals(containerMetadata.getMetadata().size(), 1);
|
assertEquals(containerMetadata.getMetadata().size(), 1);
|
||||||
assertEquals(containerMetadata.getMetadata().get("key1"), "value1");
|
assertEquals(containerMetadata.getMetadata().get("key1"), "value1");
|
||||||
|
|
|
@ -22,11 +22,11 @@ import static com.google.common.collect.Iterables.filter;
|
||||||
import static com.google.common.collect.Iterables.find;
|
import static com.google.common.collect.Iterables.find;
|
||||||
import static com.google.common.collect.Iterables.size;
|
import static com.google.common.collect.Iterables.size;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static org.jclouds.util.Predicates2.retry;
|
|
||||||
import static org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration.Builder.changeNameTo;
|
import static org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration.Builder.changeNameTo;
|
||||||
import static org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration.Builder.deleteDiskWithAddressOnParent;
|
import static org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration.Builder.deleteDiskWithAddressOnParent;
|
||||||
import static org.jclouds.trmk.vcloud_0_8.options.CloneVAppOptions.Builder.deploy;
|
import static org.jclouds.trmk.vcloud_0_8.options.CloneVAppOptions.Builder.deploy;
|
||||||
import static org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
import static org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
||||||
|
import static org.jclouds.util.Predicates2.retry;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.fail;
|
import static org.testng.Assert.fail;
|
||||||
|
@ -41,13 +41,12 @@ import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.cim.CIMPredicates;
|
import org.jclouds.cim.CIMPredicates;
|
||||||
import org.jclouds.cim.ResourceAllocationSettingData;
|
import org.jclouds.cim.ResourceAllocationSettingData;
|
||||||
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
|
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshClient.Factory;
|
import org.jclouds.ssh.SshClient.Factory;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
|
@ -74,12 +73,12 @@ import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions;
|
||||||
import org.jclouds.trmk.vcloud_0_8.predicates.TaskSuccess;
|
import org.jclouds.trmk.vcloud_0_8.predicates.TaskSuccess;
|
||||||
import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants;
|
import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants;
|
||||||
import org.testng.annotations.AfterGroups;
|
import org.testng.annotations.AfterGroups;
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.net.HostAndPort;
|
import com.google.common.net.HostAndPort;
|
||||||
|
@ -87,7 +86,7 @@ import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
@Test(groups = "live", singleThreaded = true)
|
@Test(groups = "live", singleThreaded = true)
|
||||||
public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A extends TerremarkVCloudAsyncClient> extends BaseComputeServiceContextLiveTest {
|
public abstract class TerremarkClientLiveTest extends BaseApiLiveTest<TerremarkVCloudClient> {
|
||||||
|
|
||||||
protected String expectedOs = "Ubuntu Linux (64-bit)";
|
protected String expectedOs = "Ubuntu Linux (64-bit)";
|
||||||
protected String itemName = "Ubuntu JeOS 9.10 (64-bit)";
|
protected String itemName = "Ubuntu JeOS 9.10 (64-bit)";
|
||||||
|
@ -105,7 +104,6 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
protected VDC vdc;
|
protected VDC vdc;
|
||||||
protected String serverName;
|
protected String serverName;
|
||||||
protected KeyPair key;
|
protected KeyPair key;
|
||||||
protected S connection;
|
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
||||||
|
|
||||||
|
@ -120,7 +118,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
@Test
|
@Test
|
||||||
public void testKeysList() throws Exception {
|
public void testKeysList() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
TerremarkVCloudClient vCloudExpressClient = TerremarkVCloudClient.class.cast(connection);
|
TerremarkVCloudClient vCloudExpressClient = TerremarkVCloudClient.class.cast(api);
|
||||||
Set<KeyPair> response = vCloudExpressClient.listKeyPairsInOrg(org.getHref());
|
Set<KeyPair> response = vCloudExpressClient.listKeyPairsInOrg(org.getHref());
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
}
|
}
|
||||||
|
@ -130,8 +128,8 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testGetAllInternetServices() throws Exception {
|
public void testGetAllInternetServices() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType vdc : org.getVDCs().values()) {
|
for (ReferenceType vdc : org.getVDCs().values()) {
|
||||||
for (InternetService service : connection.getAllInternetServicesInVDC(vdc.getHref())) {
|
for (InternetService service : api.getAllInternetServicesInVDC(vdc.getHref())) {
|
||||||
assertNotNull(connection.getNodes(service.getId()));
|
assertNotNull(api.getNodes(service.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,11 +139,11 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testCreateInternetServiceMonitorDisabled() throws Exception {
|
public void testCreateInternetServiceMonitorDisabled() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType vdc : org.getVDCs().values()) {
|
for (ReferenceType vdc : org.getVDCs().values()) {
|
||||||
Set<PublicIpAddress> publicIpAddresses = connection.getPublicIpsAssociatedWithVDC(vdc.getHref());
|
Set<PublicIpAddress> publicIpAddresses = api.getPublicIpsAssociatedWithVDC(vdc.getHref());
|
||||||
PublicIpAddress publicIp = publicIpAddresses.iterator().next();
|
PublicIpAddress publicIp = publicIpAddresses.iterator().next();
|
||||||
InternetService service = connection.addInternetServiceToExistingIp(publicIp.getId(), PREFIX
|
InternetService service = api.addInternetServiceToExistingIp(publicIp.getId(), PREFIX
|
||||||
+ "-no-monitoring", Protocol.TCP, 1234, AddInternetServiceOptions.Builder.monitorDisabled());
|
+ "-no-monitoring", Protocol.TCP, 1234, AddInternetServiceOptions.Builder.monitorDisabled());
|
||||||
connection.deleteInternetService(service.getId());
|
api.deleteInternetService(service.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,9 +152,9 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testGetPublicIpsAssociatedWithVDC() throws Exception {
|
public void testGetPublicIpsAssociatedWithVDC() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType vdc : org.getVDCs().values()) {
|
for (ReferenceType vdc : org.getVDCs().values()) {
|
||||||
for (PublicIpAddress ip : connection.getPublicIpsAssociatedWithVDC(vdc.getHref())) {
|
for (PublicIpAddress ip : api.getPublicIpsAssociatedWithVDC(vdc.getHref())) {
|
||||||
assertNotNull(connection.getInternetServicesOnPublicIp(ip.getId()));
|
assertNotNull(api.getInternetServicesOnPublicIp(ip.getId()));
|
||||||
assertNotNull(connection.getPublicIp(ip.getId()));
|
assertNotNull(api.getPublicIp(ip.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,12 +164,12 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testGetConfigCustomizationOptions() throws Exception {
|
public void testGetConfigCustomizationOptions() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType catalog : org.getCatalogs().values()) {
|
for (ReferenceType catalog : org.getCatalogs().values()) {
|
||||||
Catalog response = connection.getCatalog(catalog.getHref());
|
Catalog response = api.getCatalog(catalog.getHref());
|
||||||
for (ReferenceType resource : response.values()) {
|
for (ReferenceType resource : response.values()) {
|
||||||
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
|
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
|
||||||
CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(org.getName(), catalog.getName(),
|
CatalogItem item = api.findCatalogItemInOrgCatalogNamed(org.getName(), catalog.getName(),
|
||||||
resource.getName());
|
resource.getName());
|
||||||
assert connection.getCustomizationOptions(item.getCustomizationOptions().getHref()) != null;
|
assert api.getCustomizationOptions(item.getCustomizationOptions().getHref()) != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,30 +188,30 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
// String expectedOs = "Red Hat Enterprise Linux 5 (64-bit)";
|
// String expectedOs = "Red Hat Enterprise Linux 5 (64-bit)";
|
||||||
|
|
||||||
// lookup the datacenter you are deploying into
|
// lookup the datacenter you are deploying into
|
||||||
vdc = connection.findVDCInOrgNamed(null, null);
|
vdc = api.findVDCInOrgNamed(null, null);
|
||||||
|
|
||||||
// create an options object to collect the configuration we want.
|
// create an options object to collect the configuration we want.
|
||||||
InstantiateVAppTemplateOptions instantiateOptions = createInstantiateOptions().sshKeyFingerprint(
|
InstantiateVAppTemplateOptions instantiateOptions = createInstantiateOptions().sshKeyFingerprint(
|
||||||
key.getFingerPrint());
|
key.getFingerPrint());
|
||||||
|
|
||||||
CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(null, null, itemName);
|
CatalogItem item = api.findCatalogItemInOrgCatalogNamed(null, null, itemName);
|
||||||
|
|
||||||
assert item != null;
|
assert item != null;
|
||||||
|
|
||||||
// if this template supports setting the root password, let's add it to
|
// if this template supports setting the root password, let's add it to
|
||||||
// our options
|
// our options
|
||||||
CustomizationParameters customizationOptions = connection.getCustomizationOptions(item.getCustomizationOptions()
|
CustomizationParameters customizationOptions = api.getCustomizationOptions(item.getCustomizationOptions()
|
||||||
.getHref());
|
.getHref());
|
||||||
|
|
||||||
if (customizationOptions.canCustomizePassword())
|
if (customizationOptions.canCustomizePassword())
|
||||||
instantiateOptions.withPassword("robotsarefun");
|
instantiateOptions.withPassword("robotsarefun");
|
||||||
|
|
||||||
VAppTemplate vAppTemplate = connection.getVAppTemplate(item.getEntity().getHref());
|
VAppTemplate vAppTemplate = api.getVAppTemplate(item.getEntity().getHref());
|
||||||
|
|
||||||
assert vAppTemplate != null;
|
assert vAppTemplate != null;
|
||||||
|
|
||||||
// instantiate, noting vApp returned has minimal details
|
// instantiate, noting vApp returned has minimal details
|
||||||
vApp = connection.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName,
|
vApp = api.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName,
|
||||||
instantiateOptions);
|
instantiateOptions);
|
||||||
|
|
||||||
assertEquals(vApp.getStatus(), Status.RESOLVED);
|
assertEquals(vApp.getStatus(), Status.RESOLVED);
|
||||||
|
@ -221,27 +219,27 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
// in terremark, this should be a no-op, as it should simply return the
|
// in terremark, this should be a no-op, as it should simply return the
|
||||||
// above task, which is
|
// above task, which is
|
||||||
// already deploying
|
// already deploying
|
||||||
Task deployTask = connection.deployVApp(vApp.getHref());
|
Task deployTask = api.deployVApp(vApp.getHref());
|
||||||
|
|
||||||
// check to see the result of calling deploy twice
|
// check to see the result of calling deploy twice
|
||||||
deployTask = connection.deployVApp(vApp.getHref());
|
deployTask = api.deployVApp(vApp.getHref());
|
||||||
assertEquals(deployTask.getHref(), deployTask.getHref());
|
assertEquals(deployTask.getHref(), deployTask.getHref());
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
vApp = api.getVApp(vApp.getHref());
|
||||||
|
|
||||||
assertEquals(vApp.getStatus(), Status.RESOLVED);
|
assertEquals(vApp.getStatus(), Status.RESOLVED);
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
try {// per docs, this is not supported
|
||||||
connection.cancelTask(deployTask.getHref());
|
api.cancelTask(deployTask.getHref());
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert successTester.apply(deployTask.getHref());
|
assert successTester.apply(deployTask.getHref());
|
||||||
System.out.printf("%d: done deploying vApp%n", System.currentTimeMillis());
|
System.out.printf("%d: done deploying vApp%n", System.currentTimeMillis());
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
vApp = api.getVApp(vApp.getHref());
|
||||||
|
|
||||||
ReferenceType vAppResource = connection.findVDCInOrgNamed(null, null).getResourceEntities().get(serverName);
|
ReferenceType vAppResource = api.findVDCInOrgNamed(null, null).getResourceEntities().get(serverName);
|
||||||
assertEquals(vAppResource.getHref(), vApp.getHref());
|
assertEquals(vAppResource.getHref(), vApp.getHref());
|
||||||
|
|
||||||
int processorCount = 1;
|
int processorCount = 1;
|
||||||
|
@ -249,10 +247,10 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
verifyConfigurationOfVApp(vApp, serverName, expectedOs, processorCount, memory, hardDisk);
|
verifyConfigurationOfVApp(vApp, serverName, expectedOs, processorCount, memory, hardDisk);
|
||||||
assertEquals(vApp.getStatus(), Status.OFF);
|
assertEquals(vApp.getStatus(), Status.OFF);
|
||||||
|
|
||||||
assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref());
|
assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
|
||||||
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
|
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
vApp = api.getVApp(vApp.getHref());
|
||||||
assertEquals(vApp.getStatus(), Status.ON);
|
assertEquals(vApp.getStatus(), Status.ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,20 +259,20 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void prepare() {
|
protected void prepare() {
|
||||||
Org org = connection.findOrgNamed(null);
|
Org org = api.findOrgNamed(null);
|
||||||
try {
|
try {
|
||||||
key = connection.generateKeyPairInOrg(org.getHref(), "livetest", false);
|
key = api.generateKeyPairInOrg(org.getHref(), "livetest", false);
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
key = connection.findKeyPairInOrg(org.getHref(), "livetest");
|
key = api.findKeyPairInOrg(org.getHref(), "livetest");
|
||||||
connection.deleteKeyPair(key.getId());
|
api.deleteKeyPair(key.getId());
|
||||||
key = connection.generateKeyPairInOrg(org.getHref(), "livetest", false);
|
key = api.generateKeyPairInOrg(org.getHref(), "livetest", false);
|
||||||
}
|
}
|
||||||
assertNotNull(key);
|
assertNotNull(key);
|
||||||
assertEquals(key.getName(), "livetest");
|
assertEquals(key.getName(), "livetest");
|
||||||
assertNotNull(key.getPrivateKey());
|
assertNotNull(key.getPrivateKey());
|
||||||
assertNotNull(key.getFingerPrint());
|
assertNotNull(key.getFingerPrint());
|
||||||
assertEquals(key.isDefault(), false);
|
assertEquals(key.isDefault(), false);
|
||||||
assertEquals(key.getFingerPrint(), connection.findKeyPairInOrg(org.getHref(), key.getName()).getFingerPrint());
|
assertEquals(key.getFingerPrint(), api.findKeyPairInOrg(org.getHref(), key.getName()).getFingerPrint());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(VApp vApp);
|
protected abstract Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(VApp vApp);
|
||||||
|
@ -288,7 +286,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn")
|
@Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn")
|
||||||
public void testCloneVApp() throws IOException {
|
public void testCloneVApp() throws IOException {
|
||||||
assert successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
|
assert successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
|
||||||
System.out.printf("%d: done powering off vApp%n", System.currentTimeMillis());
|
System.out.printf("%d: done powering off vApp%n", System.currentTimeMillis());
|
||||||
|
|
||||||
StringBuilder name = new StringBuilder();
|
StringBuilder name = new StringBuilder();
|
||||||
|
@ -299,19 +297,19 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
CloneVAppOptions options = deploy().powerOn().withDescription("The description of " + newName);
|
CloneVAppOptions options = deploy().powerOn().withDescription("The description of " + newName);
|
||||||
|
|
||||||
System.out.printf("%d: cloning vApp%n", System.currentTimeMillis());
|
System.out.printf("%d: cloning vApp%n", System.currentTimeMillis());
|
||||||
Task task = connection.cloneVAppInVDC(vdc.getHref(), vApp.getHref(), newName, options);
|
Task task = api.cloneVAppInVDC(vdc.getHref(), vApp.getHref(), newName, options);
|
||||||
|
|
||||||
// wait for the task to complete
|
// wait for the task to complete
|
||||||
assert successTester.apply(task.getHref());
|
assert successTester.apply(task.getHref());
|
||||||
System.out.printf("%d: done cloning vApp%n", System.currentTimeMillis());
|
System.out.printf("%d: done cloning vApp%n", System.currentTimeMillis());
|
||||||
|
|
||||||
assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref());
|
assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
|
||||||
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
|
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
|
||||||
|
|
||||||
// refresh task to get the new vApp location
|
// refresh task to get the new vApp location
|
||||||
task = connection.getTask(task.getHref());
|
task = api.getTask(task.getHref());
|
||||||
|
|
||||||
clone = connection.getVApp(task.getOwner().getHref());
|
clone = api.getVApp(task.getOwner().getHref());
|
||||||
assertEquals(clone.getStatus(), Status.ON);
|
assertEquals(clone.getStatus(), Status.ON);
|
||||||
|
|
||||||
assertEquals(clone.getName(), newName);
|
assertEquals(clone.getName(), newName);
|
||||||
|
@ -320,7 +318,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" })
|
@Test(enabled = true, dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" })
|
||||||
public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
node = connection.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()), vApp.getName()
|
node = api.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()), vApp.getName()
|
||||||
+ "-SSH", 22);
|
+ "-SSH", 22);
|
||||||
loopAndCheckPass();
|
loopAndCheckPass();
|
||||||
}
|
}
|
||||||
|
@ -342,53 +340,53 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testPublicIp")
|
@Test(enabled = true, dependsOnMethods = "testPublicIp")
|
||||||
public void testConfigureNode() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testConfigureNode() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
connection.configureNode(node.getId(), node.getName(), node.isEnabled(), "holy cow");
|
api.configureNode(node.getId(), node.getName(), node.isEnabled(), "holy cow");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testPublicIp")
|
@Test(enabled = true, dependsOnMethods = "testPublicIp")
|
||||||
public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
try {// per docs, this is not supported
|
||||||
connection.undeployVApp(vApp.getHref());
|
api.undeployVApp(vApp.getHref());
|
||||||
fail("Expected UnsupportedOperationException");
|
fail("Expected UnsupportedOperationException");
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {// per docs, this is not supported
|
try {// per docs, this is not supported
|
||||||
connection.suspendVApp(vApp.getHref());
|
api.suspendVApp(vApp.getHref());
|
||||||
fail("Expected UnsupportedOperationException");
|
fail("Expected UnsupportedOperationException");
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert successTester.apply(connection.resetVApp(vApp.getHref()).getHref());
|
assert successTester.apply(api.resetVApp(vApp.getHref()).getHref());
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
vApp = api.getVApp(vApp.getHref());
|
||||||
|
|
||||||
assertEquals(vApp.getStatus(), Status.ON);
|
assertEquals(vApp.getStatus(), Status.ON);
|
||||||
|
|
||||||
// TODO we need to determine whether shutdown is supported before invoking
|
// TODO we need to determine whether shutdown is supported before invoking
|
||||||
// it.
|
// it.
|
||||||
// connection.shutdownVApp(vApp.getId());
|
// api.shutdownVApp(vApp.getId());
|
||||||
// vApp = connection.getVApp(vApp.getId());
|
// vApp = api.getVApp(vApp.getId());
|
||||||
// assertEquals(vApp.getStatus(), VAppStatus.ON);
|
// assertEquals(vApp.getStatus(), VAppStatus.ON);
|
||||||
|
|
||||||
assert successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
|
assert successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
vApp = api.getVApp(vApp.getHref());
|
||||||
assertEquals(vApp.getStatus(), Status.OFF);
|
assertEquals(vApp.getStatus(), Status.OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testLifeCycle")
|
@Test(enabled = true, dependsOnMethods = "testLifeCycle")
|
||||||
public void testConfigure() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testConfigure() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
vApp = api.getVApp(vApp.getHref());
|
||||||
|
|
||||||
Task task = connection.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1)
|
Task task = api.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1)
|
||||||
.addDisk(25 * 1048576).addDisk(25 * 1048576));
|
.addDisk(25 * 1048576).addDisk(25 * 1048576));
|
||||||
|
|
||||||
assert successTester.apply(task.getHref());
|
assert successTester.apply(task.getHref());
|
||||||
|
|
||||||
vApp = connection.getVApp(vApp.getHref());
|
vApp = api.getVApp(vApp.getHref());
|
||||||
assertEquals(vApp.getName(), "eduardo");
|
assertEquals(vApp.getName(), "eduardo");
|
||||||
assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR))
|
assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR))
|
||||||
.getVirtualQuantity().longValue(), 1);
|
.getVirtualQuantity().longValue(), 1);
|
||||||
|
@ -397,23 +395,23 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
assertEquals(size(filter(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))),
|
assertEquals(size(filter(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))),
|
||||||
3);
|
3);
|
||||||
|
|
||||||
assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref());
|
assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
|
||||||
|
|
||||||
loopAndCheckPass();
|
loopAndCheckPass();
|
||||||
|
|
||||||
assert successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
|
assert successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
|
||||||
|
|
||||||
// extract the disks on the vApp sorted by addressOnParent
|
// extract the disks on the vApp sorted by addressOnParent
|
||||||
List<ResourceAllocationSettingData> disks = Lists.newArrayList(filter(vApp.getResourceAllocations(),
|
List<ResourceAllocationSettingData> disks = Lists.newArrayList(filter(vApp.getResourceAllocations(),
|
||||||
CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)));
|
CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)));
|
||||||
|
|
||||||
// delete the second disk
|
// delete the second disk
|
||||||
task = connection.configureVApp(vApp,
|
task = api.configureVApp(vApp,
|
||||||
deleteDiskWithAddressOnParent(Integer.parseInt(disks.get(1).getAddressOnParent())));
|
deleteDiskWithAddressOnParent(Integer.parseInt(disks.get(1).getAddressOnParent())));
|
||||||
|
|
||||||
assert successTester.apply(task.getHref());
|
assert successTester.apply(task.getHref());
|
||||||
|
|
||||||
assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref());
|
assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
|
||||||
loopAndCheckPass();
|
loopAndCheckPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,47 +455,42 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
@AfterGroups(groups = { "live" })
|
@AfterGroups(groups = { "live" })
|
||||||
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
if (node != null)
|
if (node != null)
|
||||||
connection.deleteNode(node.getId());
|
api.deleteNode(node.getId());
|
||||||
if (is != null)
|
if (is != null)
|
||||||
connection.deleteInternetService(is.getId());
|
api.deleteInternetService(is.getId());
|
||||||
if (key != null)
|
if (key != null)
|
||||||
connection.deleteKeyPair(key.getId());
|
api.deleteKeyPair(key.getId());
|
||||||
if (vApp != null) {
|
if (vApp != null) {
|
||||||
try {
|
try {
|
||||||
successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
|
successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
connection.deleteVApp(vApp.getHref());
|
api.deleteVApp(vApp.getHref());
|
||||||
}
|
}
|
||||||
if (clone != null) {
|
if (clone != null) {
|
||||||
try {
|
try {
|
||||||
successTester.apply(connection.powerOffVApp(clone.getHref()).getHref());
|
successTester.apply(api.powerOffVApp(clone.getHref()).getHref());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
connection.deleteVApp(clone.getHref());
|
api.deleteVApp(clone.getHref());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
protected TerremarkVCloudClient create(Properties props, Iterable<Module> modules) {
|
||||||
public void setupContext() {
|
Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
|
||||||
super.setupContext();
|
|
||||||
injector = view.utils().injector();
|
|
||||||
|
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
|
|
||||||
// longer than default internet service timeout
|
// longer than default internet service timeout
|
||||||
socketTester = retry(injector.getInstance(SocketOpen.class), 300, 10, SECONDS);
|
socketTester = retry(injector.getInstance(SocketOpen.class), 300, 10, SECONDS);
|
||||||
successTester = retry(injector.getInstance(TaskSuccess.class), 650, 10, SECONDS);
|
successTester = retry(injector.getInstance(TaskSuccess.class), 650, 10, SECONDS);
|
||||||
connection = (S) RestContext.class.cast(view.unwrap()).getApi();
|
api = injector.getInstance(TerremarkVCloudClient.class);
|
||||||
orgs = listOrgs();
|
orgs = listOrgs();
|
||||||
|
return api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOrg() throws Exception {
|
public void testOrg() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
|
@ -506,21 +499,21 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
assert org.getCatalogs().size() >= 1;
|
assert org.getCatalogs().size() >= 1;
|
||||||
assert org.getTasksLists().size() >= 1;
|
assert org.getTasksLists().size() >= 1;
|
||||||
assert org.getVDCs().size() >= 1;
|
assert org.getVDCs().size() >= 1;
|
||||||
assertEquals(connection.findOrgNamed(org.getName()), org);
|
assertEquals(api.findOrgNamed(org.getName()), org);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertiesCanOverrideDefaultOrg() throws Exception {
|
public void testPropertiesCanOverrideDefaultOrg() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
RestContext<S, A> newContext = null;
|
TerremarkVCloudClient newApi = null;
|
||||||
try {
|
try {
|
||||||
newContext = createView(
|
newApi = create(
|
||||||
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName())),
|
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName())),
|
||||||
setupModules()).unwrap();
|
setupModules());
|
||||||
assertEquals(newContext.getApi().findOrgNamed(null), org);
|
assertEquals(newApi.findOrgNamed(null), org);
|
||||||
} finally {
|
} finally {
|
||||||
newContext.close();
|
newApi.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -535,11 +528,11 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testCatalog() throws Exception {
|
public void testCatalog() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType cat : org.getCatalogs().values()) {
|
for (ReferenceType cat : org.getCatalogs().values()) {
|
||||||
Catalog response = connection.getCatalog(cat.getHref());
|
Catalog response = api.getCatalog(cat.getHref());
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getName());
|
assertNotNull(response.getName());
|
||||||
assertNotNull(response.getHref());
|
assertNotNull(response.getHref());
|
||||||
assertEquals(connection.findCatalogInOrgNamed(org.getName(), response.getName()), response);
|
assertEquals(api.findCatalogInOrgNamed(org.getName(), response.getName()), response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -548,15 +541,14 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testPropertiesCanOverrideDefaultCatalog() throws Exception {
|
public void testPropertiesCanOverrideDefaultCatalog() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType cat : org.getCatalogs().values()) {
|
for (ReferenceType cat : org.getCatalogs().values()) {
|
||||||
RestContext<S, A> newContext = null;
|
TerremarkVCloudClient newApi = null;
|
||||||
try {
|
try {
|
||||||
newContext = createView(
|
newApi = create(
|
||||||
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
||||||
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG, cat.getName())), setupModules())
|
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG, cat.getName())), setupModules());
|
||||||
.unwrap();
|
assertEquals(newApi.findCatalogInOrgNamed(null, null), api.getCatalog(cat.getHref()));
|
||||||
assertEquals(newContext.getApi().findCatalogInOrgNamed(null, null), connection.getCatalog(cat.getHref()));
|
|
||||||
} finally {
|
} finally {
|
||||||
newContext.close();
|
newApi.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,16 +558,16 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testGetVDCNetwork() throws Exception {
|
public void testGetVDCNetwork() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType vdc : org.getVDCs().values()) {
|
for (ReferenceType vdc : org.getVDCs().values()) {
|
||||||
VDC response = connection.getVDC(vdc.getHref());
|
VDC response = api.getVDC(vdc.getHref());
|
||||||
for (ReferenceType resource : response.getAvailableNetworks().values()) {
|
for (ReferenceType resource : response.getAvailableNetworks().values()) {
|
||||||
if (resource.getType().equals(TerremarkVCloudMediaType.NETWORK_XML)) {
|
if (resource.getType().equals(TerremarkVCloudMediaType.NETWORK_XML)) {
|
||||||
try {
|
try {
|
||||||
Network net = connection.getNetwork(resource.getHref());
|
Network net = api.getNetwork(resource.getHref());
|
||||||
assertNotNull(net);
|
assertNotNull(net);
|
||||||
assertNotNull(net.getName());
|
assertNotNull(net.getName());
|
||||||
assertNotNull(net.getHref());
|
assertNotNull(net.getHref());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
connection.findNetworkInOrgVDCNamed(org.getName(), response.getName(), net.getName()), net);
|
api.findNetworkInOrgVDCNamed(org.getName(), response.getName(), net.getName()), net);
|
||||||
} catch (AuthorizationException e) {
|
} catch (AuthorizationException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -589,19 +581,18 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testPropertiesCanOverrideDefaultNetwork() throws Exception {
|
public void testPropertiesCanOverrideDefaultNetwork() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType vdc : org.getVDCs().values()) {
|
for (ReferenceType vdc : org.getVDCs().values()) {
|
||||||
VDC response = connection.getVDC(vdc.getHref());
|
VDC response = api.getVDC(vdc.getHref());
|
||||||
for (ReferenceType net : response.getAvailableNetworks().values()) {
|
for (ReferenceType net : response.getAvailableNetworks().values()) {
|
||||||
RestContext<S, A> newContext = null;
|
TerremarkVCloudClient newApi = null;
|
||||||
try {
|
try {
|
||||||
newContext = createView(
|
newApi = create(
|
||||||
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
||||||
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName(),
|
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName(),
|
||||||
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, net.getName())), setupModules())
|
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, net.getName())), setupModules());
|
||||||
.unwrap();
|
assertEquals(newApi.findNetworkInOrgVDCNamed(null, null, net.getName()),
|
||||||
assertEquals(newContext.getApi().findNetworkInOrgVDCNamed(null, null, net.getName()),
|
api.getNetwork(net.getHref()));
|
||||||
connection.getNetwork(net.getHref()));
|
|
||||||
} finally {
|
} finally {
|
||||||
newContext.close();
|
newApi.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -612,10 +603,10 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testGetCatalogItem() throws Exception {
|
public void testGetCatalogItem() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType cat : org.getCatalogs().values()) {
|
for (ReferenceType cat : org.getCatalogs().values()) {
|
||||||
Catalog response = connection.getCatalog(cat.getHref());
|
Catalog response = api.getCatalog(cat.getHref());
|
||||||
for (ReferenceType resource : response.values()) {
|
for (ReferenceType resource : response.values()) {
|
||||||
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
|
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
|
||||||
CatalogItem item = connection.getCatalogItem(resource.getHref());
|
CatalogItem item = api.getCatalogItem(resource.getHref());
|
||||||
verifyCatalogItem(item);
|
verifyCatalogItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -636,10 +627,10 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testFindCatalogItem() throws Exception {
|
public void testFindCatalogItem() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType cat : org.getCatalogs().values()) {
|
for (ReferenceType cat : org.getCatalogs().values()) {
|
||||||
Catalog response = connection.getCatalog(cat.getHref());
|
Catalog response = api.getCatalog(cat.getHref());
|
||||||
for (ReferenceType resource : response.values()) {
|
for (ReferenceType resource : response.values()) {
|
||||||
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
|
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
|
||||||
CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(org.getName(), response.getName(),
|
CatalogItem item = api.findCatalogItemInOrgCatalogNamed(org.getName(), response.getName(),
|
||||||
resource.getName());
|
resource.getName());
|
||||||
verifyCatalogItem(item);
|
verifyCatalogItem(item);
|
||||||
}
|
}
|
||||||
|
@ -652,7 +643,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testDefaultVDC() throws Exception {
|
public void testDefaultVDC() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType vdc : org.getVDCs().values()) {
|
for (ReferenceType vdc : org.getVDCs().values()) {
|
||||||
VDC response = connection.getVDC(vdc.getHref());
|
VDC response = api.getVDC(vdc.getHref());
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getName());
|
assertNotNull(response.getName());
|
||||||
assertNotNull(response.getHref());
|
assertNotNull(response.getHref());
|
||||||
|
@ -661,7 +652,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
assertNotNull(response.getCatalog());
|
assertNotNull(response.getCatalog());
|
||||||
assertNotNull(response.getInternetServices());
|
assertNotNull(response.getInternetServices());
|
||||||
assertNotNull(response.getPublicIps());
|
assertNotNull(response.getPublicIps());
|
||||||
assertEquals(connection.getVDC(response.getHref()), response);
|
assertEquals(api.getVDC(response.getHref()), response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -670,15 +661,14 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testPropertiesCanOverrideDefaultVDC() throws Exception {
|
public void testPropertiesCanOverrideDefaultVDC() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType vdc : org.getVDCs().values()) {
|
for (ReferenceType vdc : org.getVDCs().values()) {
|
||||||
RestContext<S, A> newContext = null;
|
TerremarkVCloudClient newApi = null;
|
||||||
try {
|
try {
|
||||||
newContext = createView(
|
newApi = create(
|
||||||
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
||||||
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName())), setupModules())
|
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName())), setupModules());
|
||||||
.unwrap();
|
assertEquals(newApi.findVDCInOrgNamed(null, null), api.getVDC(vdc.getHref()));
|
||||||
assertEquals(newContext.getApi().findVDCInOrgNamed(null, null), connection.getVDC(vdc.getHref()));
|
|
||||||
} finally {
|
} finally {
|
||||||
newContext.close();
|
newApi.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -688,12 +678,12 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testDefaultTasksList() throws Exception {
|
public void testDefaultTasksList() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType tasksList : org.getTasksLists().values()) {
|
for (ReferenceType tasksList : org.getTasksLists().values()) {
|
||||||
org.jclouds.trmk.vcloud_0_8.domain.TasksList response = connection.findTasksListInOrgNamed(org.getName(),
|
org.jclouds.trmk.vcloud_0_8.domain.TasksList response = api.findTasksListInOrgNamed(org.getName(),
|
||||||
tasksList.getName());
|
tasksList.getName());
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getLocation());
|
assertNotNull(response.getLocation());
|
||||||
assertNotNull(response.getTasks());
|
assertNotNull(response.getTasks());
|
||||||
assertEquals(connection.getTasksList(response.getLocation()).getLocation(), response.getLocation());
|
assertEquals(api.getTasksList(response.getLocation()).getLocation(), response.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -702,16 +692,15 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testPropertiesCanOverrideDefaultTasksList() throws Exception {
|
public void testPropertiesCanOverrideDefaultTasksList() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType tasksList : org.getTasksLists().values()) {
|
for (ReferenceType tasksList : org.getTasksLists().values()) {
|
||||||
RestContext<S, A> newContext = null;
|
TerremarkVCloudClient newApi = null;
|
||||||
try {
|
try {
|
||||||
newContext = createView(
|
newApi = create(
|
||||||
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
||||||
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_TASKSLIST, tasksList.getName())), setupModules())
|
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_TASKSLIST, tasksList.getName())), setupModules());
|
||||||
.unwrap();
|
assertEquals(newApi.findTasksListInOrgNamed(null, null),
|
||||||
assertEquals(newContext.getApi().findTasksListInOrgNamed(null, null),
|
api.getTasksList(tasksList.getHref()));
|
||||||
connection.getTasksList(tasksList.getHref()));
|
|
||||||
} finally {
|
} finally {
|
||||||
newContext.close();
|
newApi.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -721,14 +710,14 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testGetTask() throws Exception {
|
public void testGetTask() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType tasksList : org.getTasksLists().values()) {
|
for (ReferenceType tasksList : org.getTasksLists().values()) {
|
||||||
org.jclouds.trmk.vcloud_0_8.domain.TasksList response = connection.findTasksListInOrgNamed(org.getName(),
|
org.jclouds.trmk.vcloud_0_8.domain.TasksList response = api.findTasksListInOrgNamed(org.getName(),
|
||||||
tasksList.getName());
|
tasksList.getName());
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getLocation());
|
assertNotNull(response.getLocation());
|
||||||
assertNotNull(response.getTasks());
|
assertNotNull(response.getTasks());
|
||||||
if (response.getTasks().size() > 0) {
|
if (response.getTasks().size() > 0) {
|
||||||
Task task = response.getTasks().last();
|
Task task = response.getTasks().last();
|
||||||
assertEquals(connection.getTask(task.getHref()).getHref(), task.getHref());
|
assertEquals(api.getTask(task.getHref()).getHref(), task.getHref());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -736,17 +725,12 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
|
|
||||||
protected Iterable<Org> orgs;
|
protected Iterable<Org> orgs;
|
||||||
|
|
||||||
@AfterGroups(groups = { "live" })
|
|
||||||
public void teardownClient() {
|
|
||||||
view.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Iterable<Org> listOrgs() {
|
protected Iterable<Org> listOrgs() {
|
||||||
return Iterables.transform(connection.listOrgs().values(), new Function<ReferenceType, Org>() {
|
return Iterables.transform(api.listOrgs().values(), new Function<ReferenceType, Org>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Org apply(ReferenceType arg0) {
|
public Org apply(ReferenceType arg0) {
|
||||||
return connection.getOrg(arg0.getHref());
|
return api.getOrg(arg0.getHref());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -756,12 +740,12 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
public void testGetVAppTemplate() throws Exception {
|
public void testGetVAppTemplate() throws Exception {
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType cat : org.getCatalogs().values()) {
|
for (ReferenceType cat : org.getCatalogs().values()) {
|
||||||
Catalog response = connection.getCatalog(cat.getHref());
|
Catalog response = api.getCatalog(cat.getHref());
|
||||||
for (ReferenceType resource : response.values()) {
|
for (ReferenceType resource : response.values()) {
|
||||||
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
|
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
|
||||||
CatalogItem item = connection.getCatalogItem(resource.getHref());
|
CatalogItem item = api.getCatalogItem(resource.getHref());
|
||||||
if (item.getEntity().getType().equals(TerremarkVCloudMediaType.VAPPTEMPLATE_XML)) {
|
if (item.getEntity().getType().equals(TerremarkVCloudMediaType.VAPPTEMPLATE_XML)) {
|
||||||
assertNotNull(connection.getVAppTemplate(item.getEntity().getHref()));
|
assertNotNull(api.getVAppTemplate(item.getEntity().getHref()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -771,13 +755,13 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetVApp() throws Exception {
|
public void testGetVApp() throws Exception {
|
||||||
for (Org org : listOrgs()) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType vdc : org.getVDCs().values()) {
|
for (ReferenceType vdc : org.getVDCs().values()) {
|
||||||
VDC response = connection.getVDC(vdc.getHref());
|
VDC response = api.getVDC(vdc.getHref());
|
||||||
for (ReferenceType item : response.getResourceEntities().values()) {
|
for (ReferenceType item : response.getResourceEntities().values()) {
|
||||||
if (item.getType().equals(TerremarkVCloudMediaType.VAPP_XML)) {
|
if (item.getType().equals(TerremarkVCloudMediaType.VAPP_XML)) {
|
||||||
try {
|
try {
|
||||||
VApp app = connection.getVApp(item.getHref());
|
VApp app = api.getVApp(item.getHref());
|
||||||
assertNotNull(app);
|
assertNotNull(app);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
||||||
|
@ -790,14 +774,14 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFindVAppTemplate() throws Exception {
|
public void testFindVAppTemplate() throws Exception {
|
||||||
for (Org org : listOrgs()) {
|
for (Org org : orgs) {
|
||||||
for (ReferenceType cat : org.getCatalogs().values()) {
|
for (ReferenceType cat : org.getCatalogs().values()) {
|
||||||
Catalog response = connection.getCatalog(cat.getHref());
|
Catalog response = api.getCatalog(cat.getHref());
|
||||||
for (ReferenceType resource : response.values()) {
|
for (ReferenceType resource : response.values()) {
|
||||||
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
|
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
|
||||||
CatalogItem item = connection.getCatalogItem(resource.getHref());
|
CatalogItem item = api.getCatalogItem(resource.getHref());
|
||||||
if (item.getEntity().getType().equals(TerremarkVCloudMediaType.VAPPTEMPLATE_XML)) {
|
if (item.getEntity().getType().equals(TerremarkVCloudMediaType.VAPPTEMPLATE_XML)) {
|
||||||
assertNotNull(connection.findVAppTemplateInOrgCatalogNamed(org.getName(), response.getName(), item
|
assertNotNull(api.findVAppTemplateInOrgCatalogNamed(org.getName(), response.getName(), item
|
||||||
.getEntity().getName()));
|
.getEntity().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -807,8 +791,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Module getSshModule() {
|
protected Iterable<Module> setupModules() {
|
||||||
return new SshjSshClientModule();
|
return ImmutableSet.<Module> of(getLoggingModule(), new SshjSshClientModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,8 @@ import static org.jclouds.util.Predicates2.retry;
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||||
import org.jclouds.predicates.SocketOpen;
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.ssh.SshClient.Factory;
|
import org.jclouds.ssh.SshClient.Factory;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient;
|
|
||||||
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
|
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -42,7 +40,7 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", enabled = true, singleThreaded = true)
|
@Test(groups = "live", enabled = true, singleThreaded = true)
|
||||||
public abstract class BaseTerremarkClientLiveTest<S extends TerremarkVCloudClient, A extends TerremarkVCloudAsyncClient> extends BaseComputeServiceContextLiveTest {
|
public abstract class BaseTerremarkClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
|
|
||||||
protected String prefix = System.getProperty("user.name");
|
protected String prefix = System.getProperty("user.name");
|
||||||
|
|
||||||
|
@ -54,9 +52,8 @@ public abstract class BaseTerremarkClientLiveTest<S extends TerremarkVCloudClien
|
||||||
|
|
||||||
protected Predicate<HostAndPort> socketTester;
|
protected Predicate<HostAndPort> socketTester;
|
||||||
protected Factory sshFactory;
|
protected Factory sshFactory;
|
||||||
protected S connection;
|
protected TerremarkVCloudClient api;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
|
@ -65,7 +62,7 @@ public abstract class BaseTerremarkClientLiveTest<S extends TerremarkVCloudClien
|
||||||
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
||||||
socketTester = retry(socketOpen, 300, 1, SECONDS);
|
socketTester = retry(socketOpen, 300, 1, SECONDS);
|
||||||
sshFactory = injector.getInstance(Factory.class);
|
sshFactory = injector.getInstance(Factory.class);
|
||||||
connection = (S) RestContext.class.cast(view.unwrap()).getApi();
|
api = injector.getInstance(TerremarkVCloudClient.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Module getSshModule() {
|
protected Module getSshModule() {
|
||||||
|
|
|
@ -0,0 +1,148 @@
|
||||||
|
/**
|
||||||
|
* 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.apis;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.io.Closeables.closeQuietly;
|
||||||
|
import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME;
|
||||||
|
import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.jclouds.ContextBuilder;
|
||||||
|
import org.jclouds.logging.LoggingModules;
|
||||||
|
import org.jclouds.logging.config.LoggingModule;
|
||||||
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
|
import org.jclouds.providers.Providers;
|
||||||
|
import org.testng.annotations.AfterClass;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public abstract class BaseApiLiveTest<A extends Closeable> {
|
||||||
|
protected String prefix = System.getProperty("user.name");
|
||||||
|
protected String provider;
|
||||||
|
|
||||||
|
protected volatile A api;
|
||||||
|
|
||||||
|
protected String identity;
|
||||||
|
protected String credential;
|
||||||
|
protected String endpoint;
|
||||||
|
protected String apiVersion;
|
||||||
|
|
||||||
|
protected Properties setupProperties() {
|
||||||
|
Properties overrides = new Properties();
|
||||||
|
overrides.setProperty(PROPERTY_TRUST_ALL_CERTS, "true");
|
||||||
|
overrides.setProperty(PROPERTY_RELAX_HOSTNAME, "true");
|
||||||
|
identity = setIfTestSystemPropertyPresent(overrides, provider + ".identity");
|
||||||
|
credential = setIfTestSystemPropertyPresent(overrides, provider + ".credential");
|
||||||
|
endpoint = setIfTestSystemPropertyPresent(overrides, provider + ".endpoint");
|
||||||
|
apiVersion = setIfTestSystemPropertyPresent(overrides, provider + ".api-version");
|
||||||
|
setIfTestSystemPropertyPresent(overrides, provider + ".build-version");
|
||||||
|
return overrides;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String setIfTestSystemPropertyPresent(Properties overrides, String key) {
|
||||||
|
if (System.getProperties().containsKey("test." + key)) {
|
||||||
|
String val = System.getProperty("test." + key);
|
||||||
|
overrides.setProperty(key, val);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
|
public void setup() {
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initialize() {
|
||||||
|
closeQuietly(api);
|
||||||
|
api = create(setupProperties(), setupModules());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Iterable<Module> setupModules() {
|
||||||
|
return ImmutableSet.<Module> of(getLoggingModule());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected LoggingModule getLoggingModule() {
|
||||||
|
return LoggingModules.firstOrJDKLoggingModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jclouds.providers.Providers#withId
|
||||||
|
*/
|
||||||
|
protected ProviderMetadata createProviderMetadata() {
|
||||||
|
try {
|
||||||
|
return Providers.withId(provider);
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.jclouds.apis.Apis#withId
|
||||||
|
*/
|
||||||
|
protected ApiMetadata createApiMetadata() {
|
||||||
|
try {
|
||||||
|
return Apis.withId(provider);
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
protected A create(Properties props, Iterable<Module> modules) {
|
||||||
|
return newBuilder().modules(modules).overrides(props).buildApi(new TypeToken<A>(getClass()) {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ContextBuilder newBuilder() {
|
||||||
|
if (provider != null)
|
||||||
|
try {
|
||||||
|
return ContextBuilder.newBuilder(provider);
|
||||||
|
} catch (NoSuchElementException e){
|
||||||
|
Logger.getAnonymousLogger()
|
||||||
|
.warning("provider ["
|
||||||
|
+ provider
|
||||||
|
+ "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata");
|
||||||
|
}
|
||||||
|
|
||||||
|
ProviderMetadata pm = createProviderMetadata();
|
||||||
|
|
||||||
|
ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder
|
||||||
|
.newBuilder(ApiMetadata.class.cast(checkNotNull(createApiMetadata(),
|
||||||
|
"either createApiMetadata or createProviderMetadata must be overridden")));
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass(groups = { "integration", "live" })
|
||||||
|
protected void tearDown() {
|
||||||
|
closeQuietly(api);
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,6 +33,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
@ -140,9 +141,9 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
|
||||||
}.hash(md5()).asBytes()), md5);
|
}.hash(md5()).asBytes()), md5);
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputStream getConsitution() {
|
private InputStream getConsitution() throws MalformedURLException, IOException {
|
||||||
URI constitutionUri = URI.create(format("http://localhost:%d/101constitutions", testPort));
|
URI constitutionUri = URI.create(format("http://localhost:%d/101constitutions", testPort));
|
||||||
return context.utils().http().get(constitutionUri);
|
return constitutionUri.toURL().openStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -61,7 +61,6 @@ import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
|
||||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||||
import org.jclouds.ContextBuilder;
|
import org.jclouds.ContextBuilder;
|
||||||
import org.jclouds.providers.AnonymousProviderMetadata;
|
import org.jclouds.providers.AnonymousProviderMetadata;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Optional;
|
import org.testng.annotations.Optional;
|
||||||
|
@ -87,7 +86,6 @@ public abstract class BaseJettyTest {
|
||||||
protected Injector injector;
|
protected Injector injector;
|
||||||
private AtomicInteger cycle = new AtomicInteger(0);
|
private AtomicInteger cycle = new AtomicInteger(0);
|
||||||
private Server server2;
|
private Server server2;
|
||||||
protected RestContext<IntegrationTestClient, IntegrationTestAsyncClient> context;
|
|
||||||
protected int testPort;
|
protected int testPort;
|
||||||
protected String md5;
|
protected String md5;
|
||||||
static final Pattern actionPattern = Pattern.compile("/objects/(.*)/action/([a-z]*);?(.*)");
|
static final Pattern actionPattern = Pattern.compile("/objects/(.*)/action/([a-z]*);?(.*)");
|
||||||
|
@ -170,8 +168,7 @@ public abstract class BaseJettyTest {
|
||||||
|
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
addConnectionProperties(properties);
|
addConnectionProperties(properties);
|
||||||
context = newBuilder(testPort, properties, createConnectionModule()).build();
|
client = newBuilder(testPort, properties, createConnectionModule()).buildApi(IntegrationTestClient.class);
|
||||||
client = context.getApi();
|
|
||||||
assert client != null;
|
assert client != null;
|
||||||
|
|
||||||
assert client.newStringBuilder() != null;
|
assert client.newStringBuilder() != null;
|
||||||
|
@ -279,7 +276,7 @@ public abstract class BaseJettyTest {
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public void tearDownJetty() throws Exception {
|
public void tearDownJetty() throws Exception {
|
||||||
closeQuietly(context);
|
closeQuietly(client);
|
||||||
if (server2 != null)
|
if (server2 != null)
|
||||||
server2.stop();
|
server2.stop();
|
||||||
server.stop();
|
server.stop();
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.jclouds.aws.ec2.domain.AWSRunningInstance;
|
||||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||||
import org.jclouds.aws.ec2.services.AWSSecurityGroupClient;
|
import org.jclouds.aws.ec2.services.AWSSecurityGroupClient;
|
||||||
import org.jclouds.cloudwatch.CloudWatchApi;
|
import org.jclouds.cloudwatch.CloudWatchApi;
|
||||||
import org.jclouds.cloudwatch.CloudWatchAsyncApi;
|
|
||||||
import org.jclouds.cloudwatch.domain.Dimension;
|
import org.jclouds.cloudwatch.domain.Dimension;
|
||||||
import org.jclouds.cloudwatch.domain.EC2Constants;
|
import org.jclouds.cloudwatch.domain.EC2Constants;
|
||||||
import org.jclouds.cloudwatch.domain.GetMetricStatistics;
|
import org.jclouds.cloudwatch.domain.GetMetricStatistics;
|
||||||
|
@ -56,7 +55,6 @@ import org.jclouds.ec2.domain.KeyPair;
|
||||||
import org.jclouds.ec2.domain.SecurityGroup;
|
import org.jclouds.ec2.domain.SecurityGroup;
|
||||||
import org.jclouds.ec2.services.InstanceClient;
|
import org.jclouds.ec2.services.InstanceClient;
|
||||||
import org.jclouds.ec2.services.KeyPairClient;
|
import org.jclouds.ec2.services.KeyPairClient;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.scriptbuilder.domain.Statements;
|
import org.jclouds.scriptbuilder.domain.Statements;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -157,13 +155,13 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
||||||
// stop the spinner
|
// stop the spinner
|
||||||
future.cancel(true);
|
future.cancel(true);
|
||||||
|
|
||||||
RestContext<CloudWatchApi, CloudWatchAsyncApi> monitoringContext = ContextBuilder
|
CloudWatchApi monitoringApi = ContextBuilder.newBuilder(new AWSCloudWatchProviderMetadata())
|
||||||
.newBuilder(new AWSCloudWatchProviderMetadata())
|
|
||||||
.credentials(identity, credential)
|
.credentials(identity, credential)
|
||||||
.modules(setupModules()).build();
|
.modules(setupModules())
|
||||||
|
.buildApi(CloudWatchApi.class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
GetMetricStatisticsResponse datapoints = monitoringContext.getApi().getMetricApiForRegion(instance.getRegion())
|
GetMetricStatisticsResponse datapoints = monitoringApi.getMetricApiForRegion(instance.getRegion())
|
||||||
.getMetricStatistics(GetMetricStatistics.builder()
|
.getMetricStatistics(GetMetricStatistics.builder()
|
||||||
.dimension(new Dimension(EC2Constants.Dimension.INSTANCE_ID, instance.getId()))
|
.dimension(new Dimension(EC2Constants.Dimension.INSTANCE_ID, instance.getId()))
|
||||||
.unit(Unit.PERCENT)
|
.unit(Unit.PERCENT)
|
||||||
|
@ -176,7 +174,7 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
||||||
.build());
|
.build());
|
||||||
assert (datapoints.size() > 0) : instance;
|
assert (datapoints.size() > 0) : instance;
|
||||||
} finally {
|
} finally {
|
||||||
monitoringContext.close();
|
monitoringApi.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure we made our dummy group and also let in the user's group
|
// make sure we made our dummy group and also let in the user's group
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
package org.jclouds.aws.ec2.compute.extensions;
|
package org.jclouds.aws.ec2.compute.extensions;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.AWSEC2AsyncClient;
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.AWSEC2Client;
|
import org.jclouds.aws.ec2.AWSEC2Client;
|
||||||
import org.jclouds.aws.util.AWSUtils;
|
import org.jclouds.aws.util.AWSUtils;
|
||||||
import org.jclouds.compute.domain.Image;
|
import org.jclouds.compute.domain.Image;
|
||||||
|
@ -27,11 +28,9 @@ import org.jclouds.compute.extensions.ImageExtension;
|
||||||
import org.jclouds.compute.extensions.internal.BaseImageExtensionLiveTest;
|
import org.jclouds.compute.extensions.internal.BaseImageExtensionLiveTest;
|
||||||
import org.jclouds.ec2.compute.functions.EC2ImageParser;
|
import org.jclouds.ec2.compute.functions.EC2ImageParser;
|
||||||
import org.jclouds.ec2.options.DescribeImagesOptions;
|
import org.jclouds.ec2.options.DescribeImagesOptions;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,14 +48,14 @@ public class AWSEC2ImageExtensionLiveTest extends BaseImageExtensionLiveTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Iterable<? extends Image> listImages() {
|
protected Iterable<? extends Image> listImages() {
|
||||||
RestContext<AWSEC2Client, AWSEC2AsyncClient> unwrapped = view.unwrap();
|
AWSEC2Client client = view.utils().getInjector().getInstance(AWSEC2Client.class);
|
||||||
String[] parts = AWSUtils.parseHandle(imageId);
|
String[] parts = AWSUtils.parseHandle(imageId);
|
||||||
String region = parts[0];
|
String region = parts[0];
|
||||||
String imageId = parts[1];
|
String imageId = parts[1];
|
||||||
EC2ImageParser parser = view.utils().getInjector().getInstance(EC2ImageParser.class);
|
EC2ImageParser parser = view.utils().getInjector().getInstance(EC2ImageParser.class);
|
||||||
return Iterables.transform(
|
return transform(
|
||||||
unwrapped.getApi().getAMIServices()
|
client.getAMIServices().describeImagesInRegion(region, new DescribeImagesOptions().imageIds(imageId)),
|
||||||
.describeImagesInRegion(region, new DescribeImagesOptions().imageIds(imageId)), parser);
|
parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -54,6 +54,6 @@ public class TagSecurityGroupLiveTest extends BaseTagApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private AWSSecurityGroupClient securityGroupApi() {
|
private AWSSecurityGroupClient securityGroupApi() {
|
||||||
return AWSEC2Client.class.cast(context.getApi()).getSecurityGroupServices();
|
return AWSEC2Client.class.cast(api).getSecurityGroupServices();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.jclouds.aws.s3.AWSS3Client;
|
||||||
import org.jclouds.aws.s3.predicates.validators.AWSS3BucketNameValidator;
|
import org.jclouds.aws.s3.predicates.validators.AWSS3BucketNameValidator;
|
||||||
import org.jclouds.location.Region;
|
import org.jclouds.location.Region;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.s3.S3AsyncClient;
|
import org.jclouds.s3.S3AsyncClient;
|
||||||
import org.jclouds.s3.S3Client;
|
import org.jclouds.s3.S3Client;
|
||||||
import org.jclouds.s3.config.S3RestClientModule;
|
import org.jclouds.s3.config.S3RestClientModule;
|
||||||
|
@ -72,15 +71,4 @@ public class AWSS3RestClientModule extends S3RestClientModule<AWSS3Client, AWSS3
|
||||||
S3AsyncClient provide(AWSS3AsyncClient in) {
|
S3AsyncClient provide(AWSS3AsyncClient in) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* so that we can inject RestContext<S3Client, S3AsyncClient>
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
||||||
@Singleton
|
|
||||||
@Provides
|
|
||||||
RestContext<S3Client, S3AsyncClient> provideBaseContext(RestContext<AWSS3Client, AWSS3AsyncClient> in) {
|
|
||||||
return (RestContext) in;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.dynect.v3;
|
package org.jclouds.dynect.v3;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
|
|
||||||
import org.jclouds.dynect.v3.domain.Job;
|
import org.jclouds.dynect.v3.domain.Job;
|
||||||
|
@ -36,7 +38,7 @@ import org.jclouds.rest.annotations.Delegate;
|
||||||
* />
|
* />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public interface DynECTApi {
|
public interface DynECTApi extends Closeable {
|
||||||
/**
|
/**
|
||||||
* returns the current status of a job.
|
* returns the current status of a job.
|
||||||
*
|
*
|
||||||
|
|
|
@ -20,6 +20,8 @@ package org.jclouds.dynect.v3;
|
||||||
|
|
||||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
|
@ -48,7 +50,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* @see <a href="https://manage.dynect.net/help/docs/api2/rest/" />
|
* @see <a href="https://manage.dynect.net/help/docs/api2/rest/" />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public interface DynECTAsyncApi {
|
public interface DynECTAsyncApi extends Closeable {
|
||||||
/**
|
/**
|
||||||
* @see DynECTApi#getJob
|
* @see DynECTApi#getJob
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class DynectApiMockTest {
|
||||||
.endpoint(uri)
|
.endpoint(uri)
|
||||||
.overrides(overrides)
|
.overrides(overrides)
|
||||||
.modules(modules)
|
.modules(modules)
|
||||||
.build(DynECTApiMetadata.CONTEXT_TOKEN).getApi();
|
.buildApi(DynECTApi.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
String session = "{\"status\": \"success\", \"data\": {\"token\": \"FFFFFFFFFF\", \"version\": \"3.3.8\"}, \"job_id\": 254417252, \"msgs\": [{\"INFO\": \"login: Login successful\", \"SOURCE\": \"BLL\", \"ERR_CD\": null, \"LVL\": \"INFO\"}]}";
|
String session = "{\"status\": \"success\", \"data\": {\"token\": \"FFFFFFFFFF\", \"version\": \"3.3.8\"}, \"job_id\": 254417252, \"msgs\": [{\"INFO\": \"login: Login successful\", \"SOURCE\": \"BLL\", \"ERR_CD\": null, \"LVL\": \"INFO\"}]}";
|
||||||
|
|
|
@ -199,7 +199,7 @@ public class RecordApiLiveTest extends BaseDynECTApiLiveTest {
|
||||||
checkNotNull(job, "unable to create zone %s", zoneFQDN);
|
checkNotNull(job, "unable to create zone %s", zoneFQDN);
|
||||||
getAnonymousLogger().info("created zone: " + job);
|
getAnonymousLogger().info("created zone: " + job);
|
||||||
assertEquals(job.getStatus(), Status.SUCCESS);
|
assertEquals(job.getStatus(), Status.SUCCESS);
|
||||||
assertEquals(context.getApi().getJob(job.getId()), job);
|
assertEquals(api.getJob(job.getId()), job);
|
||||||
Zone zone = zoneApi().publish(zoneFQDN);
|
Zone zone = zoneApi().publish(zoneFQDN);
|
||||||
checkNotNull(zone, "unable to publish zone %s", zoneFQDN);
|
checkNotNull(zone, "unable to publish zone %s", zoneFQDN);
|
||||||
getAnonymousLogger().info("published zone: " + zone);
|
getAnonymousLogger().info("published zone: " + zone);
|
||||||
|
@ -229,7 +229,7 @@ public class RecordApiLiveTest extends BaseDynECTApiLiveTest {
|
||||||
checkNotNull(job, "unable to create record %s", record);
|
checkNotNull(job, "unable to create record %s", record);
|
||||||
getAnonymousLogger().info("created record: " + job);
|
getAnonymousLogger().info("created record: " + job);
|
||||||
assertEquals(job.getStatus(), Status.SUCCESS);
|
assertEquals(job.getStatus(), Status.SUCCESS);
|
||||||
assertEquals(context.getApi().getJob(job.getId()), job);
|
assertEquals(api.getJob(job.getId()), job);
|
||||||
zoneApi().publish(zoneFQDN);
|
zoneApi().publish(zoneFQDN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,22 +265,22 @@ public class RecordApiLiveTest extends BaseDynECTApiLiveTest {
|
||||||
checkNotNull(job, "unable to delete record %s", id);
|
checkNotNull(job, "unable to delete record %s", id);
|
||||||
getAnonymousLogger().info("deleted record: " + job);
|
getAnonymousLogger().info("deleted record: " + job);
|
||||||
assertEquals(job.getStatus(), Status.SUCCESS);
|
assertEquals(job.getStatus(), Status.SUCCESS);
|
||||||
assertEquals(context.getApi().getJob(job.getId()), job);
|
assertEquals(api.getJob(job.getId()), job);
|
||||||
zoneApi().publish(zoneFQDN);
|
zoneApi().publish(zoneFQDN);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RecordApi api(String zoneFQDN) {
|
protected RecordApi api(String zoneFQDN) {
|
||||||
return context.getApi().getRecordApiForZone(zoneFQDN);
|
return api.getRecordApiForZone(zoneFQDN);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ZoneApi zoneApi() {
|
protected ZoneApi zoneApi() {
|
||||||
return context.getApi().getZoneApi();
|
return api.getZoneApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterClass(groups = "live", alwaysRun = true)
|
@AfterClass(groups = "live", alwaysRun = true)
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
zoneApi().delete(zoneFQDN);
|
zoneApi().delete(zoneFQDN);
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,14 +50,14 @@ public class SessionApiLiveTest extends BaseDynECTApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SessionApi api() {
|
protected SessionApi api() {
|
||||||
return context.getApi().getSessionApi();
|
return api.getSessionApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
if (session != null)
|
if (session != null)
|
||||||
api().logout(session.getToken());
|
api().logout(session.getToken());
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class ZoneApiLiveTest extends BaseDynECTApiLiveTest {
|
||||||
checkNotNull(job, "unable to create zone %s", fqdn);
|
checkNotNull(job, "unable to create zone %s", fqdn);
|
||||||
getAnonymousLogger().info("created zone: " + job);
|
getAnonymousLogger().info("created zone: " + job);
|
||||||
assertEquals(job.getStatus(), Status.SUCCESS);
|
assertEquals(job.getStatus(), Status.SUCCESS);
|
||||||
assertEquals(context.getApi().getJob(job.getId()), job);
|
assertEquals(api.getJob(job.getId()), job);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateZone")
|
@Test(dependsOnMethods = "testCreateZone")
|
||||||
|
@ -90,7 +90,7 @@ public class ZoneApiLiveTest extends BaseDynECTApiLiveTest {
|
||||||
public void testFreezeZone() {
|
public void testFreezeZone() {
|
||||||
Job job = api().freeze(fqdn);
|
Job job = api().freeze(fqdn);
|
||||||
assertEquals(job.getStatus(), Status.SUCCESS);
|
assertEquals(job.getStatus(), Status.SUCCESS);
|
||||||
assertEquals(context.getApi().getJob(job.getId()), job);
|
assertEquals(api.getJob(job.getId()), job);
|
||||||
// TODO: determine how to prove it is frozen
|
// TODO: determine how to prove it is frozen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public class ZoneApiLiveTest extends BaseDynECTApiLiveTest {
|
||||||
public void testThawZone() {
|
public void testThawZone() {
|
||||||
Job job = api().thaw(fqdn);
|
Job job = api().thaw(fqdn);
|
||||||
assertEquals(job.getStatus(), Status.SUCCESS);
|
assertEquals(job.getStatus(), Status.SUCCESS);
|
||||||
assertEquals(context.getApi().getJob(job.getId()), job);
|
assertEquals(api.getJob(job.getId()), job);
|
||||||
// TODO: determine how to prove it is thawed
|
// TODO: determine how to prove it is thawed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,25 +106,25 @@ public class ZoneApiLiveTest extends BaseDynECTApiLiveTest {
|
||||||
public void testDeleteZoneChanges() {
|
public void testDeleteZoneChanges() {
|
||||||
Job job = api().deleteChanges(fqdn);
|
Job job = api().deleteChanges(fqdn);
|
||||||
assertEquals(job.getStatus(), Status.SUCCESS);
|
assertEquals(job.getStatus(), Status.SUCCESS);
|
||||||
assertEquals(context.getApi().getJob(job.getId()), job);
|
assertEquals(api.getJob(job.getId()), job);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testDeleteZoneChanges")
|
@Test(dependsOnMethods = "testDeleteZoneChanges")
|
||||||
public void testDeleteZone() {
|
public void testDeleteZone() {
|
||||||
Job job = api().delete(fqdn);
|
Job job = api().delete(fqdn);
|
||||||
assertEquals(job.getStatus(), Status.SUCCESS);
|
assertEquals(job.getStatus(), Status.SUCCESS);
|
||||||
assertEquals(context.getApi().getJob(job.getId()), job);
|
assertEquals(api.getJob(job.getId()), job);
|
||||||
assertNull(api().get(fqdn), "job " + job + " didn't delete zone" + fqdn);
|
assertNull(api().get(fqdn), "job " + job + " didn't delete zone" + fqdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ZoneApi api() {
|
protected ZoneApi api() {
|
||||||
return context.getApi().getZoneApi();
|
return api.getZoneApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@AfterClass(groups = "live", alwaysRun = true)
|
@AfterClass(groups = "live", alwaysRun = true)
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
api().delete(fqdn);
|
api().delete(fqdn);
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,24 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.dynect.v3.internal;
|
package org.jclouds.dynect.v3.internal;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseContextLiveTest;
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.dynect.v3.DynECTApi;
|
import org.jclouds.dynect.v3.DynECTApi;
|
||||||
import org.jclouds.dynect.v3.DynECTApiMetadata;
|
|
||||||
import org.jclouds.dynect.v3.DynECTAsyncApi;
|
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
|
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class BaseDynECTApiLiveTest extends BaseContextLiveTest<RestContext<DynECTApi, DynECTAsyncApi>> {
|
public class BaseDynECTApiLiveTest extends BaseApiLiveTest<DynECTApi> {
|
||||||
|
|
||||||
public BaseDynECTApiLiveTest() {
|
public BaseDynECTApiLiveTest() {
|
||||||
provider = "dynect";
|
provider = "dynect";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeToken<RestContext<DynECTApi, DynECTAsyncApi>> contextType() {
|
|
||||||
return DynECTApiMetadata.CONTEXT_TOKEN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.glesys;
|
package org.jclouds.glesys;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
import org.jclouds.glesys.features.ArchiveApi;
|
import org.jclouds.glesys.features.ArchiveApi;
|
||||||
import org.jclouds.glesys.features.DomainApi;
|
import org.jclouds.glesys.features.DomainApi;
|
||||||
import org.jclouds.glesys.features.EmailAccountApi;
|
import org.jclouds.glesys.features.EmailAccountApi;
|
||||||
|
@ -33,7 +35,7 @@ import org.jclouds.rest.annotations.Delegate;
|
||||||
* @see <a href="https://customer.glesys.com/api.php" />
|
* @see <a href="https://customer.glesys.com/api.php" />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public interface GleSYSApi {
|
public interface GleSYSApi extends Closeable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Server features.
|
* Provides synchronous access to Server features.
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.glesys;
|
package org.jclouds.glesys;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
import org.jclouds.glesys.features.ArchiveAsyncApi;
|
import org.jclouds.glesys.features.ArchiveAsyncApi;
|
||||||
import org.jclouds.glesys.features.DomainAsyncApi;
|
import org.jclouds.glesys.features.DomainAsyncApi;
|
||||||
import org.jclouds.glesys.features.EmailAccountAsyncApi;
|
import org.jclouds.glesys.features.EmailAccountAsyncApi;
|
||||||
|
@ -33,7 +35,7 @@ import org.jclouds.rest.annotations.Delegate;
|
||||||
* @see <a href="https://customer.glesys.com/api.php" />
|
* @see <a href="https://customer.glesys.com/api.php" />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public interface GleSYSAsyncApi {
|
public interface GleSYSAsyncApi extends Closeable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Server features.
|
* Provides asynchronous access to Server features.
|
||||||
|
|
|
@ -42,34 +42,34 @@ import com.google.common.base.Predicate;
|
||||||
public class ArchiveApiLiveTest extends BaseGleSYSApiLiveTest {
|
public class ArchiveApiLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
|
|
||||||
api = gleContext.getApi().getArchiveApi();
|
archiveApi = api.getArchiveApi();
|
||||||
archiveUser = gleContext.getIdentity().toLowerCase() + "_test9";
|
archiveUser = identity.toLowerCase() + "_test9";
|
||||||
archiveCounter = retry(new Predicate<Integer>() {
|
archiveCounter = retry(new Predicate<Integer>() {
|
||||||
public boolean apply(Integer value) {
|
public boolean apply(Integer value) {
|
||||||
return api.list().size() == value;
|
return archiveApi.list().size() == value;
|
||||||
}
|
}
|
||||||
}, 30, 1, SECONDS);
|
}, 30, 1, SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
protected void tearDownContext() {
|
protected void tearDown() {
|
||||||
int before = api.list().size();
|
int before = archiveApi.list().size();
|
||||||
api.delete(archiveUser);
|
archiveApi.delete(archiveUser);
|
||||||
assertTrue(archiveCounter.apply(before - 1));
|
assertTrue(archiveCounter.apply(before - 1));
|
||||||
|
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArchiveApi api;
|
private ArchiveApi archiveApi;
|
||||||
private String archiveUser;
|
private String archiveUser;
|
||||||
private Predicate<Integer> archiveCounter;
|
private Predicate<Integer> archiveCounter;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllowedArguments() throws Exception {
|
public void testAllowedArguments() throws Exception {
|
||||||
ArchiveAllowedArguments args = api.getAllowedArguments();
|
ArchiveAllowedArguments args = archiveApi.getAllowedArguments();
|
||||||
assertNotNull(args);
|
assertNotNull(args);
|
||||||
assertNotNull(args.getSizes());
|
assertNotNull(args.getSizes());
|
||||||
assertTrue(args.getSizes().size() > 0);
|
assertTrue(args.getSizes().size() > 0);
|
||||||
|
@ -82,36 +82,36 @@ public class ArchiveApiLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCreateArchive() throws Exception {
|
public void testCreateArchive() throws Exception {
|
||||||
try {
|
try {
|
||||||
api.delete(archiveUser);
|
archiveApi.delete(archiveUser);
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int before = api.list().size();
|
int before = archiveApi.list().size();
|
||||||
|
|
||||||
api.createWithCredentialsAndSize(archiveUser, "password", 10);
|
archiveApi.createWithCredentialsAndSize(archiveUser, "password", 10);
|
||||||
|
|
||||||
assertTrue(archiveCounter.apply(before + 1));
|
assertTrue(archiveCounter.apply(before + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateArchive")
|
@Test(dependsOnMethods = "testCreateArchive")
|
||||||
public void testArchiveDetails() throws Exception {
|
public void testArchiveDetails() throws Exception {
|
||||||
Archive details = api.get(archiveUser);
|
Archive details = archiveApi.get(archiveUser);
|
||||||
assertEquals(details.getUsername(), archiveUser);
|
assertEquals(details.getUsername(), archiveUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateArchive")
|
@Test(dependsOnMethods = "testCreateArchive")
|
||||||
public void testChangePassword() throws Exception {
|
public void testChangePassword() throws Exception {
|
||||||
api.changePassword(archiveUser, "newpassword");
|
archiveApi.changePassword(archiveUser, "newpassword");
|
||||||
// TODO assert something useful!
|
// TODO assert something useful!
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateArchive")
|
@Test(dependsOnMethods = "testCreateArchive")
|
||||||
public void testResizeArchive() throws Exception {
|
public void testResizeArchive() throws Exception {
|
||||||
api.resize(archiveUser, 20);
|
archiveApi.resize(archiveUser, 20);
|
||||||
|
|
||||||
assertTrue(retry(new Predicate<String>() {
|
assertTrue(retry(new Predicate<String>() {
|
||||||
public boolean apply(String value) {
|
public boolean apply(String value) {
|
||||||
return api.get(archiveUser) != null && value.equals(api.get(archiveUser).getTotalSize());
|
return archiveApi.get(archiveUser) != null && value.equals(archiveApi.get(archiveUser).getTotalSize());
|
||||||
}
|
}
|
||||||
}, 30, 1, SECONDS).apply("20 GB"));
|
}, 30, 1, SECONDS).apply("20 GB"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,23 +47,23 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
public String testDomain;
|
public String testDomain;
|
||||||
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
testDomain = identity.toLowerCase() + "-domain.jclouds.org";
|
testDomain = identity.toLowerCase() + "-domain.jclouds.org";
|
||||||
api = gleContext.getApi().getDomainApi();
|
domainApi = api.getDomainApi();
|
||||||
domainCounter = retry(new Predicate<Integer>() {
|
domainCounter = retry(new Predicate<Integer>() {
|
||||||
public boolean apply(Integer value) {
|
public boolean apply(Integer value) {
|
||||||
return api.list().size() == value;
|
return domainApi.list().size() == value;
|
||||||
}
|
}
|
||||||
}, 30, 1, SECONDS);
|
}, 30, 1, SECONDS);
|
||||||
recordCounter = retry(new Predicate<Integer>() {
|
recordCounter = retry(new Predicate<Integer>() {
|
||||||
public boolean apply(Integer value) {
|
public boolean apply(Integer value) {
|
||||||
return api.listRecords(testDomain).size() == value;
|
return domainApi.listRecords(testDomain).size() == value;
|
||||||
}
|
}
|
||||||
}, 30, 1, SECONDS);
|
}, 30, 1, SECONDS);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
api.delete(testDomain);
|
domainApi.delete(testDomain);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,21 +71,21 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
public void tearDownContext() {
|
public void tearDown() {
|
||||||
int before = api.list().size();
|
int before = domainApi.list().size();
|
||||||
api.delete(testDomain);
|
domainApi.delete(testDomain);
|
||||||
assertTrue(domainCounter.apply(before - 1));
|
assertTrue(domainCounter.apply(before - 1));
|
||||||
|
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private DomainApi api;
|
private DomainApi domainApi;
|
||||||
private Predicate<Integer> domainCounter;
|
private Predicate<Integer> domainCounter;
|
||||||
private Predicate<Integer> recordCounter;
|
private Predicate<Integer> recordCounter;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDomain() throws Exception {
|
public void testGetDomain() throws Exception {
|
||||||
Domain domain = api.get(testDomain);
|
Domain domain = domainApi.get(testDomain);
|
||||||
assertNotNull(domain);
|
assertNotNull(domain);
|
||||||
assertEquals(domain.getName(), testDomain);
|
assertEquals(domain.getName(), testDomain);
|
||||||
assertNotNull(domain.getCreateTime());
|
assertNotNull(domain.getCreateTime());
|
||||||
|
@ -93,20 +93,20 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateDomain() throws Exception {
|
public void testUpdateDomain() throws Exception {
|
||||||
api.update(testDomain, DomainOptions.Builder.responsiblePerson("another-tester.jclouds.org."));
|
domainApi.update(testDomain, DomainOptions.Builder.responsiblePerson("another-tester.jclouds.org."));
|
||||||
Domain domain = api.get(testDomain);
|
Domain domain = domainApi.get(testDomain);
|
||||||
assertEquals(domain.getResponsiblePerson(), "another-tester.jclouds.org.");
|
assertEquals(domain.getResponsiblePerson(), "another-tester.jclouds.org.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateRecord() throws Exception {
|
public void testCreateRecord() throws Exception {
|
||||||
int before = api.listRecords(testDomain).size();
|
int before = domainApi.listRecords(testDomain).size();
|
||||||
|
|
||||||
api.createRecord(testDomain, "test", "A", "127.0.0.1");
|
domainApi.createRecord(testDomain, "test", "A", "127.0.0.1");
|
||||||
|
|
||||||
assertTrue(recordCounter.apply(before + 1));
|
assertTrue(recordCounter.apply(before + 1));
|
||||||
|
|
||||||
for(DomainRecord record : api.listRecords(testDomain)) {
|
for(DomainRecord record : domainApi.listRecords(testDomain)) {
|
||||||
if ("test".equals(record.getHost())) {
|
if ("test".equals(record.getHost())) {
|
||||||
assertEquals(record.getType(), "A");
|
assertEquals(record.getType(), "A");
|
||||||
assertEquals(record.getData(), "127.0.0.1");
|
assertEquals(record.getData(), "127.0.0.1");
|
||||||
|
@ -116,14 +116,14 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateRecord() throws Exception {
|
public void testUpdateRecord() throws Exception {
|
||||||
int before = api.listRecords(testDomain).size();
|
int before = domainApi.listRecords(testDomain).size();
|
||||||
|
|
||||||
api.createRecord(testDomain, "testeditbefore", "A", "127.0.0.1");
|
domainApi.createRecord(testDomain, "testeditbefore", "A", "127.0.0.1");
|
||||||
|
|
||||||
assertTrue(recordCounter.apply(before + 1));
|
assertTrue(recordCounter.apply(before + 1));
|
||||||
|
|
||||||
String recordId = null;
|
String recordId = null;
|
||||||
for(DomainRecord record : api.listRecords(testDomain)) {
|
for(DomainRecord record : domainApi.listRecords(testDomain)) {
|
||||||
if ("testeditbefore".equals(record.getHost())) {
|
if ("testeditbefore".equals(record.getHost())) {
|
||||||
assertEquals(record.getType(), "A");
|
assertEquals(record.getType(), "A");
|
||||||
assertEquals(record.getData(), "127.0.0.1");
|
assertEquals(record.getData(), "127.0.0.1");
|
||||||
|
@ -133,10 +133,10 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
|
|
||||||
assertNotNull(recordId);
|
assertNotNull(recordId);
|
||||||
|
|
||||||
api.updateRecord(recordId, UpdateRecordOptions.Builder.host("testeditafter"));
|
domainApi.updateRecord(recordId, UpdateRecordOptions.Builder.host("testeditafter"));
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for(DomainRecord record : api.listRecords(testDomain)) {
|
for(DomainRecord record : domainApi.listRecords(testDomain)) {
|
||||||
if (recordId.equals(record.getId())) {
|
if (recordId.equals(record.getId())) {
|
||||||
assertEquals(record.getHost(), "testeditafter");
|
assertEquals(record.getHost(), "testeditafter");
|
||||||
assertEquals(record.getType(), "A");
|
assertEquals(record.getType(), "A");
|
||||||
|
@ -149,11 +149,11 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteRecord() throws Exception {
|
public void testDeleteRecord() throws Exception {
|
||||||
Set<DomainRecord> domainRecords = api.listRecords(testDomain);
|
Set<DomainRecord> domainRecords = domainApi.listRecords(testDomain);
|
||||||
|
|
||||||
int before = domainRecords.size();
|
int before = domainRecords.size();
|
||||||
|
|
||||||
api.deleteRecord(domainRecords.iterator().next().getId());
|
domainApi.deleteRecord(domainRecords.iterator().next().getId());
|
||||||
|
|
||||||
assertTrue(recordCounter.apply(before - 1));
|
assertTrue(recordCounter.apply(before - 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,17 +53,17 @@ public class EmailAccountApiLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
testDomain = hostName + ".test.jclouds.org";
|
testDomain = hostName + ".test.jclouds.org";
|
||||||
api = gleContext.getApi().getEmailAccountApi();
|
emailAccountApi = api.getEmailAccountApi();
|
||||||
deleteAll();
|
deleteAll();
|
||||||
|
|
||||||
createDomain(testDomain);
|
createDomain(testDomain);
|
||||||
|
|
||||||
emailAccountCounter = retry(new Predicate<Integer>() {
|
emailAccountCounter = retry(new Predicate<Integer>() {
|
||||||
public boolean apply(Integer value) {
|
public boolean apply(Integer value) {
|
||||||
return api.listDomain(testDomain).size() == value;
|
return emailAccountApi.listDomain(testDomain).size() == value;
|
||||||
}
|
}
|
||||||
}, 180, 5, SECONDS);
|
}, 180, 5, SECONDS);
|
||||||
|
|
||||||
|
@ -73,61 +73,61 @@ public class EmailAccountApiLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void tearDownContext() {
|
public void tearDown() {
|
||||||
deleteAll();
|
deleteAll();
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteAll() {
|
private void deleteAll() {
|
||||||
api.delete("test@" + testDomain);
|
emailAccountApi.delete("test@" + testDomain);
|
||||||
api.delete("test1@" + testDomain);
|
emailAccountApi.delete("test1@" + testDomain);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EmailAccountApi api;
|
private EmailAccountApi emailAccountApi;
|
||||||
private String testDomain;
|
private String testDomain;
|
||||||
private Predicate<Integer> emailAccountCounter;
|
private Predicate<Integer> emailAccountCounter;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateEmail() {
|
public void testCreateEmail() {
|
||||||
api.createWithPassword("test@" + testDomain, "password", CreateAccountOptions.Builder.antiVirus(true)
|
emailAccountApi.createWithPassword("test@" + testDomain, "password", CreateAccountOptions.Builder.antiVirus(true)
|
||||||
.autorespond(true).autorespondMessage("out of office"));
|
.autorespond(true).autorespondMessage("out of office"));
|
||||||
|
|
||||||
assertTrue(emailAccountCounter.apply(1));
|
assertTrue(emailAccountCounter.apply(1));
|
||||||
|
|
||||||
api.createWithPassword("test1@" + testDomain, "password");
|
emailAccountApi.createWithPassword("test1@" + testDomain, "password");
|
||||||
|
|
||||||
assertTrue(emailAccountCounter.apply(2));
|
assertTrue(emailAccountCounter.apply(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateEmail")
|
@Test(dependsOnMethods = "testCreateEmail")
|
||||||
public void testAliases() {
|
public void testAliases() {
|
||||||
assertTrue(api.listAliasesInDomain(testDomain).isEmpty());
|
assertTrue(emailAccountApi.listAliasesInDomain(testDomain).isEmpty());
|
||||||
|
|
||||||
EmailAlias alias = api.createAlias("test2@" + testDomain, "test@" + testDomain);
|
EmailAlias alias = emailAccountApi.createAlias("test2@" + testDomain, "test@" + testDomain);
|
||||||
assertEquals(alias.getAlias(), "test2@" + testDomain);
|
assertEquals(alias.getAlias(), "test2@" + testDomain);
|
||||||
assertEquals(alias.getForwardTo(), "test@" + testDomain);
|
assertEquals(alias.getForwardTo(), "test@" + testDomain);
|
||||||
|
|
||||||
EmailAlias aliasFromList = Iterables.getOnlyElement(api.listAliasesInDomain(testDomain));
|
EmailAlias aliasFromList = Iterables.getOnlyElement(emailAccountApi.listAliasesInDomain(testDomain));
|
||||||
assertEquals(aliasFromList, alias);
|
assertEquals(aliasFromList, alias);
|
||||||
|
|
||||||
EmailOverview overview = api.getOverview();
|
EmailOverview overview = emailAccountApi.getOverview();
|
||||||
assertEquals(1, overview.getSummary().getAliases());
|
assertEquals(1, overview.getSummary().getAliases());
|
||||||
|
|
||||||
alias = api.updateAlias("test2@" + testDomain, "test1@" + testDomain);
|
alias = emailAccountApi.updateAlias("test2@" + testDomain, "test1@" + testDomain);
|
||||||
overview = api.getOverview();
|
overview = emailAccountApi.getOverview();
|
||||||
assertEquals(1, overview.getSummary().getAliases());
|
assertEquals(1, overview.getSummary().getAliases());
|
||||||
|
|
||||||
aliasFromList = Iterables.getOnlyElement(api.listAliasesInDomain(testDomain));
|
aliasFromList = Iterables.getOnlyElement(emailAccountApi.listAliasesInDomain(testDomain));
|
||||||
assertEquals(aliasFromList, alias);
|
assertEquals(aliasFromList, alias);
|
||||||
|
|
||||||
api.delete("test2@" + testDomain);
|
emailAccountApi.delete("test2@" + testDomain);
|
||||||
overview = api.getOverview();
|
overview = emailAccountApi.getOverview();
|
||||||
assertEquals(0, overview.getSummary().getAliases());
|
assertEquals(0, overview.getSummary().getAliases());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateEmail")
|
@Test(dependsOnMethods = "testCreateEmail")
|
||||||
public void testOverview() throws Exception {
|
public void testOverview() throws Exception {
|
||||||
EmailOverview overview = api.getOverview();
|
EmailOverview overview = emailAccountApi.getOverview();
|
||||||
assertNotNull(overview.getSummary());
|
assertNotNull(overview.getSummary());
|
||||||
assertTrue(overview.getSummary().getAccounts() > 0);
|
assertTrue(overview.getSummary().getAccounts() > 0);
|
||||||
assertTrue(overview.getSummary().getAliases() > -1);
|
assertTrue(overview.getSummary().getAliases() > -1);
|
||||||
|
@ -142,22 +142,22 @@ public class EmailAccountApiLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateEmail")
|
@Test(dependsOnMethods = "testCreateEmail")
|
||||||
public void testListAccounts() throws Exception {
|
public void testListAccounts() throws Exception {
|
||||||
FluentIterable<EmailAccount> accounts = api.listDomain(testDomain);
|
FluentIterable<EmailAccount> accounts = emailAccountApi.listDomain(testDomain);
|
||||||
assertTrue(accounts.size() >= 1);
|
assertTrue(accounts.size() >= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testCreateEmail")
|
@Test(dependsOnMethods = "testCreateEmail")
|
||||||
public void testUpdateAccount() throws Exception {
|
public void testUpdateAccount() throws Exception {
|
||||||
FluentIterable<EmailAccount> accounts = api.listDomain(testDomain);
|
FluentIterable<EmailAccount> accounts = emailAccountApi.listDomain(testDomain);
|
||||||
for (EmailAccount account : accounts) {
|
for (EmailAccount account : accounts) {
|
||||||
if (account.getAccount().equals("test@" + testDomain)) {
|
if (account.getAccount().equals("test@" + testDomain)) {
|
||||||
assertTrue(account.isAntiVirus());
|
assertTrue(account.isAntiVirus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
api.update("test@" + testDomain, UpdateAccountOptions.Builder.antiVirus(false));
|
emailAccountApi.update("test@" + testDomain, UpdateAccountOptions.Builder.antiVirus(false));
|
||||||
|
|
||||||
accounts = api.listDomain(testDomain);
|
accounts = emailAccountApi.listDomain(testDomain);
|
||||||
for (EmailAccount account : accounts) {
|
for (EmailAccount account : accounts) {
|
||||||
if (account.getAccount().equals("test@" + testDomain)) {
|
if (account.getAccount().equals("test@" + testDomain)) {
|
||||||
assertFalse(account.isAntiVirus());
|
assertFalse(account.isAntiVirus());
|
||||||
|
|
|
@ -50,41 +50,41 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
super.setupContext();
|
super.setup();
|
||||||
api = gleContext.getApi().getIpApi();
|
ipApi = api.getIpApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void tearDownContext() {
|
public void tearDown() {
|
||||||
if (reservedIp != null) {
|
if (reservedIp != null) {
|
||||||
api.release(reservedIp.getAddress());
|
ipApi.release(reservedIp.getAddress());
|
||||||
}
|
}
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IpApi api;
|
private IpApi ipApi;
|
||||||
private IpDetails reservedIp;
|
private IpDetails reservedIp;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListFree() throws Exception {
|
public void testListFree() throws Exception {
|
||||||
FluentIterable<String> freeIps = api.listFree(4, "Falkenberg", "Xen");
|
FluentIterable<String> freeIps = ipApi.listFree(4, "Falkenberg", "Xen");
|
||||||
assertFalse(freeIps.isEmpty());
|
assertFalse(freeIps.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void reserveIp() throws Exception {
|
public void reserveIp() throws Exception {
|
||||||
FluentIterable<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ");
|
FluentIterable<String> openVzIps = ipApi.listFree(4, "Falkenberg", "OpenVZ");
|
||||||
assertFalse(openVzIps.isEmpty());
|
assertFalse(openVzIps.isEmpty());
|
||||||
reservedIp = api.take(Iterables.get(openVzIps, 0));
|
reservedIp = ipApi.take(Iterables.get(openVzIps, 0));
|
||||||
assertTrue(reservedIp.isReserved());
|
assertTrue(reservedIp.isReserved());
|
||||||
checkOpenVZDefailsInFalkenberg(reservedIp);
|
checkOpenVZDefailsInFalkenberg(reservedIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "reserveIp")
|
@Test(dependsOnMethods = "reserveIp")
|
||||||
public void reserveAndReleaseIp() throws Exception {
|
public void reserveAndReleaseIp() throws Exception {
|
||||||
IpDetails details = api.release(reservedIp.getAddress());
|
IpDetails details = ipApi.release(reservedIp.getAddress());
|
||||||
assertEquals(details.getAddress(), reservedIp.getAddress());
|
assertEquals(details.getAddress(), reservedIp.getAddress());
|
||||||
assertFalse(details.isReserved());
|
assertFalse(details.isReserved());
|
||||||
|
|
||||||
|
@ -94,21 +94,21 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
|
|
||||||
@Test(dependsOnMethods = "reserveIp")
|
@Test(dependsOnMethods = "reserveIp")
|
||||||
public void testList() throws Exception {
|
public void testList() throws Exception {
|
||||||
FluentIterable<IpDetails> ownIps = api.list();
|
FluentIterable<IpDetails> ownIps = ipApi.list();
|
||||||
assertTrue(ownIps.contains(reservedIp));
|
assertTrue(ownIps.contains(reservedIp));
|
||||||
ownIps = api.list(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()));
|
ownIps = ipApi.list(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()));
|
||||||
assertTrue(ownIps.contains(reservedIp));
|
assertTrue(ownIps.contains(reservedIp));
|
||||||
ownIps = api.list(ListIpOptions.Builder.platform(reservedIp.getPlatform()));
|
ownIps = ipApi.list(ListIpOptions.Builder.platform(reservedIp.getPlatform()));
|
||||||
assertTrue(ownIps.contains(reservedIp));
|
assertTrue(ownIps.contains(reservedIp));
|
||||||
ownIps = api.list(ListIpOptions.Builder.ipVersion(reservedIp.getVersion()));
|
ownIps = ipApi.list(ListIpOptions.Builder.ipVersion(reservedIp.getVersion()));
|
||||||
assertTrue(ownIps.contains(reservedIp));
|
assertTrue(ownIps.contains(reservedIp));
|
||||||
|
|
||||||
ownIps = api.list(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()),
|
ownIps = ipApi.list(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()),
|
||||||
ListIpOptions.Builder.platform(reservedIp.getPlatform()),
|
ListIpOptions.Builder.platform(reservedIp.getPlatform()),
|
||||||
ListIpOptions.Builder.ipVersion(reservedIp.getVersion()));
|
ListIpOptions.Builder.ipVersion(reservedIp.getVersion()));
|
||||||
assertTrue(ownIps.contains(reservedIp));
|
assertTrue(ownIps.contains(reservedIp));
|
||||||
|
|
||||||
ownIps = api.list(ListIpOptions.Builder.serverId("xmthisisnotaserverid"));
|
ownIps = ipApi.list(ListIpOptions.Builder.serverId("xmthisisnotaserverid"));
|
||||||
assertTrue(ownIps.isEmpty());
|
assertTrue(ownIps.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,20 +123,20 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetOpenVZDetails() throws Exception {
|
public void testGetOpenVZDetails() throws Exception {
|
||||||
FluentIterable<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ");
|
FluentIterable<String> openVzIps = ipApi.listFree(4, "Falkenberg", "OpenVZ");
|
||||||
assertFalse(openVzIps.isEmpty());
|
assertFalse(openVzIps.isEmpty());
|
||||||
String openVzIp = openVzIps.iterator().next();
|
String openVzIp = openVzIps.iterator().next();
|
||||||
IpDetails ipDetails = api.get(openVzIp);
|
IpDetails ipDetails = ipApi.get(openVzIp);
|
||||||
checkOpenVZDefailsInFalkenberg(ipDetails);
|
checkOpenVZDefailsInFalkenberg(ipDetails);
|
||||||
assertEquals(ipDetails.getAddress(), openVzIp);
|
assertEquals(ipDetails.getAddress(), openVzIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetXenDetails() throws Exception {
|
public void testGetXenDetails() throws Exception {
|
||||||
FluentIterable<String> xenVzIps = api.listFree(4, "Falkenberg", "Xen");
|
FluentIterable<String> xenVzIps = ipApi.listFree(4, "Falkenberg", "Xen");
|
||||||
assertFalse(xenVzIps.isEmpty());
|
assertFalse(xenVzIps.isEmpty());
|
||||||
String xenIp = xenVzIps.iterator().next();
|
String xenIp = xenVzIps.iterator().next();
|
||||||
IpDetails ipDetails = api.get(xenIp);
|
IpDetails ipDetails = ipApi.get(xenIp);
|
||||||
assertEquals(ipDetails.getDatacenter(), "Falkenberg");
|
assertEquals(ipDetails.getDatacenter(), "Falkenberg");
|
||||||
assertEquals(ipDetails.getPlatform(), "Xen");
|
assertEquals(ipDetails.getPlatform(), "Xen");
|
||||||
assertEquals(ipDetails.getVersion(), 4);
|
assertEquals(ipDetails.getVersion(), 4);
|
||||||
|
@ -152,42 +152,42 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
public void testPtrSetReset() throws Exception {
|
public void testPtrSetReset() throws Exception {
|
||||||
IpDetails original = reservedIp;
|
IpDetails original = reservedIp;
|
||||||
|
|
||||||
IpDetails modified = api.setPtr(reservedIp.getAddress(), "wibble.");
|
IpDetails modified = ipApi.setPtr(reservedIp.getAddress(), "wibble.");
|
||||||
IpDetails modified2 = api.get(reservedIp.getAddress());
|
IpDetails modified2 = ipApi.get(reservedIp.getAddress());
|
||||||
|
|
||||||
assertEquals(modified.getPtr(), "wibble.");
|
assertEquals(modified.getPtr(), "wibble.");
|
||||||
assertEquals(modified2, modified);
|
assertEquals(modified2, modified);
|
||||||
|
|
||||||
reservedIp = api.resetPtr(reservedIp.getAddress());
|
reservedIp = ipApi.resetPtr(reservedIp.getAddress());
|
||||||
|
|
||||||
assertEquals(reservedIp, original);
|
assertEquals(reservedIp, original);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "reserveIp")
|
@Test(dependsOnMethods = "reserveIp")
|
||||||
public void testAddRemove() throws Exception {
|
public void testAddRemove() throws Exception {
|
||||||
IpDetails added = api.addToServer(reservedIp.getAddress(), serverId);
|
IpDetails added = ipApi.addToServer(reservedIp.getAddress(), serverId);
|
||||||
|
|
||||||
assertEquals(added.getAddress(), reservedIp.getAddress());
|
assertEquals(added.getAddress(), reservedIp.getAddress());
|
||||||
assertEquals(added.getPtr(), reservedIp.getPtr());
|
assertEquals(added.getPtr(), reservedIp.getPtr());
|
||||||
assertEquals(added.getServerId(), serverId);
|
assertEquals(added.getServerId(), serverId);
|
||||||
|
|
||||||
IpDetails again = api.get(reservedIp.getAddress());
|
IpDetails again = ipApi.get(reservedIp.getAddress());
|
||||||
assertEquals(again, added);
|
assertEquals(again, added);
|
||||||
|
|
||||||
IpDetails removed = api.removeFromServer(reservedIp.getAddress(), serverId);
|
IpDetails removed = ipApi.removeFromServer(reservedIp.getAddress(), serverId);
|
||||||
assertEquals(removed, added.toBuilder().serverId(null).build());
|
assertEquals(removed, added.toBuilder().serverId(null).build());
|
||||||
|
|
||||||
assertEquals(removed, reservedIp);
|
assertEquals(removed, reservedIp);
|
||||||
|
|
||||||
Set<String> openVzIps = Sets.newHashSet(api.listFree(4, "Falkenberg", "OpenVZ"));
|
Set<String> openVzIps = Sets.newHashSet(ipApi.listFree(4, "Falkenberg", "OpenVZ"));
|
||||||
openVzIps.remove(reservedIp.getAddress());
|
openVzIps.remove(reservedIp.getAddress());
|
||||||
assertFalse(openVzIps.isEmpty());
|
assertFalse(openVzIps.isEmpty());
|
||||||
|
|
||||||
added = api.addToServer(reservedIp.getAddress(), serverId);
|
added = ipApi.addToServer(reservedIp.getAddress(), serverId);
|
||||||
|
|
||||||
assertEquals(added.getServerId(), serverId);
|
assertEquals(added.getServerId(), serverId);
|
||||||
|
|
||||||
removed = api.removeFromServerAndRelease(reservedIp.getAddress(), serverId);
|
removed = ipApi.removeFromServerAndRelease(reservedIp.getAddress(), serverId);
|
||||||
|
|
||||||
assertNull(removed.getServerId());
|
assertNull(removed.getServerId());
|
||||||
assertFalse(removed.isReserved());
|
assertFalse(removed.isReserved());
|
||||||
|
|
|
@ -61,22 +61,22 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
hostName = hostName + "-server";
|
hostName = hostName + "-server";
|
||||||
super.setupContext();
|
super.setup();
|
||||||
api = gleContext.getApi().getServerApi();
|
serverApi = api.getServerApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void tearDownContext() {
|
public void tearDown() {
|
||||||
if (testServerId2 != null) {
|
if (testServerId2 != null) {
|
||||||
api.destroy(testServerId2, DestroyServerOptions.Builder.discardIp());
|
serverApi.destroy(testServerId2, DestroyServerOptions.Builder.discardIp());
|
||||||
}
|
}
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServerApi api;
|
private ServerApi serverApi;
|
||||||
private String testServerId2;
|
private String testServerId2;
|
||||||
|
|
||||||
@BeforeMethod
|
@BeforeMethod
|
||||||
|
@ -86,7 +86,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAllowedArguments() throws Exception {
|
public void testAllowedArguments() throws Exception {
|
||||||
Map<String,AllowedArgumentsForCreateServer> templates = api.getAllowedArgumentsForCreateByPlatform();
|
Map<String,AllowedArgumentsForCreateServer> templates = serverApi.getAllowedArgumentsForCreateByPlatform();
|
||||||
|
|
||||||
assertTrue(templates.containsKey("OpenVZ"));
|
assertTrue(templates.containsKey("OpenVZ"));
|
||||||
assertTrue(templates.containsKey("Xen"));
|
assertTrue(templates.containsKey("Xen"));
|
||||||
|
@ -108,7 +108,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListTemplates() throws Exception {
|
public void testListTemplates() throws Exception {
|
||||||
FluentIterable<OSTemplate> oSTemplates = api.listTemplates();
|
FluentIterable<OSTemplate> oSTemplates = serverApi.listTemplates();
|
||||||
|
|
||||||
for(OSTemplate oSTemplate : oSTemplates) {
|
for(OSTemplate oSTemplate : oSTemplates) {
|
||||||
checkTemplate(oSTemplate);
|
checkTemplate(oSTemplate);
|
||||||
|
@ -126,12 +126,12 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testListServers() throws Exception {
|
public void testListServers() throws Exception {
|
||||||
FluentIterable<Server> response = api.list();
|
FluentIterable<Server> response = serverApi.list();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertTrue(response.size() > 0);
|
assertTrue(response.size() > 0);
|
||||||
|
|
||||||
for (Server server : response) {
|
for (Server server : response) {
|
||||||
ServerDetails newDetails = api.get(server.getId());
|
ServerDetails newDetails = serverApi.get(server.getId());
|
||||||
assertEquals(newDetails.getId(), server.getId());
|
assertEquals(newDetails.getId(), server.getId());
|
||||||
assertEquals(newDetails.getHostname(), server.getHostname());
|
assertEquals(newDetails.getHostname(), server.getHostname());
|
||||||
assertEquals(newDetails.getPlatform(), server.getPlatform());
|
assertEquals(newDetails.getPlatform(), server.getPlatform());
|
||||||
|
@ -141,7 +141,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testServerDetails() throws Exception {
|
public void testServerDetails() throws Exception {
|
||||||
ServerDetails details = api.get(serverId);
|
ServerDetails details = serverApi.get(serverId);
|
||||||
checkServer(details);
|
checkServer(details);
|
||||||
assertEquals("Ubuntu 10.04 LTS 32-bit", details.getTemplateName());
|
assertEquals("Ubuntu 10.04 LTS 32-bit", details.getTemplateName());
|
||||||
assertEquals("Falkenberg", details.getDatacenter());
|
assertEquals("Falkenberg", details.getDatacenter());
|
||||||
|
@ -153,22 +153,22 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testServerStatus() throws Exception {
|
public void testServerStatus() throws Exception {
|
||||||
ServerStatus newStatus = api.getStatus(serverId);
|
ServerStatus newStatus = serverApi.getStatus(serverId);
|
||||||
checkStatus(newStatus);
|
checkStatus(newStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateServer() throws Exception {
|
public void testUpdateServer() throws Exception {
|
||||||
ServerDetails edited = api.update(serverId, UpdateServerOptions.Builder.description("this is a different description!"));
|
ServerDetails edited = serverApi.update(serverId, UpdateServerOptions.Builder.description("this is a different description!"));
|
||||||
assertEquals(edited.getDescription(), "this is a different description!");
|
assertEquals(edited.getDescription(), "this is a different description!");
|
||||||
|
|
||||||
edited = api.update(serverId, UpdateServerOptions.Builder.description("another description!").hostname("host-name1"));
|
edited = serverApi.update(serverId, UpdateServerOptions.Builder.description("another description!").hostname("host-name1"));
|
||||||
assertEquals(edited.getDescription(), "another description!");
|
assertEquals(edited.getDescription(), "another description!");
|
||||||
assertEquals(edited.getHostname(), "host-name1");
|
assertEquals(edited.getHostname(), "host-name1");
|
||||||
|
|
||||||
edited = api.resetPassword(serverId, "anotherpass");
|
edited = serverApi.resetPassword(serverId, "anotherpass");
|
||||||
assertEquals(edited.getHostname(), "host-name1");
|
assertEquals(edited.getHostname(), "host-name1");
|
||||||
|
|
||||||
edited = api.update(serverId, UpdateServerOptions.Builder.hostname(hostName));
|
edited = serverApi.update(serverId, UpdateServerOptions.Builder.hostname(hostName));
|
||||||
assertEquals(edited.getHostname(), hostName);
|
assertEquals(edited.getHostname(), hostName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
public void testRebootServer() throws Exception {
|
public void testRebootServer() throws Exception {
|
||||||
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
||||||
|
|
||||||
api.reboot(serverId);
|
serverApi.reboot(serverId);
|
||||||
|
|
||||||
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
||||||
}
|
}
|
||||||
|
@ -185,17 +185,17 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
public void testStopAndStartServer() throws Exception {
|
public void testStopAndStartServer() throws Exception {
|
||||||
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
||||||
|
|
||||||
api.stop(serverId);
|
serverApi.stop(serverId);
|
||||||
|
|
||||||
assertTrue(serverStatusChecker.apply(Server.State.STOPPED));
|
assertTrue(serverStatusChecker.apply(Server.State.STOPPED));
|
||||||
|
|
||||||
api.start(serverId);
|
serverApi.start(serverId);
|
||||||
|
|
||||||
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testServerLimits() throws Exception {
|
public void testServerLimits() throws Exception {
|
||||||
Map<String, ServerLimit> limits = api.getLimits(serverId);
|
Map<String, ServerLimit> limits = serverApi.getLimits(serverId);
|
||||||
assertNotNull(limits);
|
assertNotNull(limits);
|
||||||
for (Map.Entry<String, ServerLimit> entry : limits.entrySet()) {
|
for (Map.Entry<String, ServerLimit> entry : limits.entrySet()) {
|
||||||
assertNotNull(entry.getKey());
|
assertNotNull(entry.getKey());
|
||||||
|
@ -211,16 +211,16 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
|
|
||||||
public void testResourceUsage() throws Exception {
|
public void testResourceUsage() throws Exception {
|
||||||
// test server has only been in existence for less than a minute - check all servers
|
// test server has only been in existence for less than a minute - check all servers
|
||||||
for (Server server : api.list()) {
|
for (Server server : serverApi.list()) {
|
||||||
try {
|
try {
|
||||||
ResourceUsage usage = api.getResourceUsage(server.getId(), "diskioread", "minute");
|
ResourceUsage usage = serverApi.getResourceUsage(server.getId(), "diskioread", "minute");
|
||||||
assertEquals(usage.getInfo().getResource(), "diskioread");
|
assertEquals(usage.getInfo().getResource(), "diskioread");
|
||||||
assertEquals(usage.getInfo().getResolution(), "minute");
|
assertEquals(usage.getInfo().getResolution(), "minute");
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ResourceUsage usage = api.getResourceUsage(server.getId(), "cpuusage", "minute");
|
ResourceUsage usage = serverApi.getResourceUsage(server.getId(), "cpuusage", "minute");
|
||||||
assertEquals(usage.getInfo().getResource(), "cpuusage");
|
assertEquals(usage.getInfo().getResource(), "cpuusage");
|
||||||
assertEquals(usage.getInfo().getResolution(), "minute");
|
assertEquals(usage.getInfo().getResolution(), "minute");
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
|
@ -230,7 +230,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testConsole() throws Exception {
|
public void testConsole() throws Exception {
|
||||||
Console console = api.getConsole(serverId);
|
Console console = serverApi.getConsole(serverId);
|
||||||
assertNotNull(console);
|
assertNotNull(console);
|
||||||
assertNotNull(console.getHost());
|
assertNotNull(console.getHost());
|
||||||
assertTrue(console.getPort() > 0 && console.getPort() < 65537);
|
assertTrue(console.getPort() > 0 && console.getPort() < 65537);
|
||||||
|
@ -240,7 +240,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
// takes a few minutes and requires an extra server (used 1 already)
|
// takes a few minutes and requires an extra server (used 1 already)
|
||||||
@Test(enabled=false)
|
@Test(enabled=false)
|
||||||
public void testCloneServer() throws Exception {
|
public void testCloneServer() throws Exception {
|
||||||
ServerDetails testServer2 = api.clone(serverId, testHostName2, CloneServerOptions.Builder.cpucores(1));
|
ServerDetails testServer2 = serverApi.clone(serverId, testHostName2, CloneServerOptions.Builder.cpucores(1));
|
||||||
|
|
||||||
assertNotNull(testServer2.getId());
|
assertNotNull(testServer2.getId());
|
||||||
assertEquals(testServer2.getHostname(), "jclouds-test2");
|
assertEquals(testServer2.getHostname(), "jclouds-test2");
|
||||||
|
@ -248,19 +248,19 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
|
||||||
|
|
||||||
testServerId2 = testServer2.getId();
|
testServerId2 = testServer2.getId();
|
||||||
|
|
||||||
Predicate<State> cloneChecker = statusChecker(api, testServerId2);
|
Predicate<State> cloneChecker = statusChecker(serverApi, testServerId2);
|
||||||
assertTrue(cloneChecker.apply(Server.State.STOPPED));
|
assertTrue(cloneChecker.apply(Server.State.STOPPED));
|
||||||
|
|
||||||
api.start(testServer2.getId());
|
serverApi.start(testServer2.getId());
|
||||||
|
|
||||||
// TODO ServerStatus==STOPPED suggests the previous call to start should have worked
|
// TODO ServerStatus==STOPPED suggests the previous call to start should have worked
|
||||||
cloneChecker = retry(new Predicate<Server.State>() {
|
cloneChecker = retry(new Predicate<Server.State>() {
|
||||||
public boolean apply(Server.State value) {
|
public boolean apply(Server.State value) {
|
||||||
ServerStatus status = api.getStatus(testServerId2, ServerStatusOptions.Builder.state());
|
ServerStatus status = serverApi.getStatus(testServerId2, ServerStatusOptions.Builder.state());
|
||||||
if (status.getState() == value) {
|
if (status.getState() == value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
api.start(testServerId2);
|
serverApi.start(testServerId2);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, 600, 30, SECONDS);
|
}, 600, 30, SECONDS);
|
||||||
|
|
|
@ -22,12 +22,9 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static org.jclouds.util.Predicates2.retry;
|
import static org.jclouds.util.Predicates2.retry;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
import org.jclouds.apis.BaseApiLiveTest;
|
||||||
import org.jclouds.glesys.GleSYSApi;
|
import org.jclouds.glesys.GleSYSApi;
|
||||||
import org.jclouds.glesys.GleSYSAsyncApi;
|
|
||||||
import org.jclouds.glesys.features.DomainApi;
|
import org.jclouds.glesys.features.DomainApi;
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
@ -38,24 +35,15 @@ import com.google.common.base.Predicate;
|
||||||
* @author Adrian Cole, Adam Lowe
|
* @author Adrian Cole, Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class BaseGleSYSApiLiveTest extends BaseComputeServiceContextLiveTest {
|
public class BaseGleSYSApiLiveTest extends BaseApiLiveTest<GleSYSApi> {
|
||||||
protected String hostName = System.getProperty("user.name").replace('.','-').toLowerCase();
|
protected String hostName = System.getProperty("user.name").replace('.','-').toLowerCase();
|
||||||
|
|
||||||
protected RestContext<GleSYSApi, GleSYSAsyncApi> gleContext;
|
|
||||||
|
|
||||||
public BaseGleSYSApiLiveTest() {
|
public BaseGleSYSApiLiveTest() {
|
||||||
provider = "glesys";
|
provider = "glesys";
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
|
||||||
@Override
|
|
||||||
public void setupContext() {
|
|
||||||
super.setupContext();
|
|
||||||
gleContext = view.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createDomain(String domain) {
|
protected void createDomain(String domain) {
|
||||||
final DomainApi api = gleContext.getApi().getDomainApi();
|
final DomainApi api = this.api.getDomainApi();
|
||||||
int before = api.list().size();
|
int before = api.list().size();
|
||||||
api.create(domain);
|
api.create(domain);
|
||||||
|
|
||||||
|
|
|
@ -60,21 +60,21 @@ public class BaseGleSYSApiWithAServerLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
|
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setup() {
|
||||||
assertNull(serverId, "This method should be called EXACTLY once per run");
|
assertNull(serverId, "This method should be called EXACTLY once per run");
|
||||||
super.setupContext();
|
super.setup();
|
||||||
serverStatusChecker = createServer(hostName);
|
serverStatusChecker = createServer(hostName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "integration", "live" })
|
@AfterClass(groups = { "integration", "live" })
|
||||||
@Override
|
@Override
|
||||||
public void tearDownContext() {
|
public void tearDown() {
|
||||||
gleContext.getApi().getServerApi().destroy(serverId, DestroyServerOptions.Builder.discardIp());
|
api.getServerApi().destroy(serverId, DestroyServerOptions.Builder.discardIp());
|
||||||
super.tearDownContext();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createDomain(String domain) {
|
protected void createDomain(String domain) {
|
||||||
final DomainApi api = gleContext.getApi().getDomainApi();
|
final DomainApi api = this.api.getDomainApi();
|
||||||
int before = api.list().size();
|
int before = api.list().size();
|
||||||
api.create(domain);
|
api.create(domain);
|
||||||
Predicate<Integer> result = retry(new Predicate<Integer>() {
|
Predicate<Integer> result = retry(new Predicate<Integer>() {
|
||||||
|
@ -86,7 +86,7 @@ public class BaseGleSYSApiWithAServerLiveTest extends BaseGleSYSApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Predicate<State> createServer(String hostName) {
|
protected Predicate<State> createServer(String hostName) {
|
||||||
final ServerApi api = gleContext.getApi().getServerApi();
|
final ServerApi api = this.api.getServerApi();
|
||||||
|
|
||||||
ServerDetails testServer = api.createWithHostnameAndRootPassword(
|
ServerDetails testServer = api.createWithHostnameAndRootPassword(
|
||||||
ServerSpec.builder().datacenter("Falkenberg").platform("OpenVZ").templateName("Ubuntu 10.04 LTS 32-bit")
|
ServerSpec.builder().datacenter("Falkenberg").platform("OpenVZ").templateName("Ubuntu 10.04 LTS 32-bit")
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid;
|
package org.jclouds.gogrid;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
import org.jclouds.gogrid.services.GridImageAsyncClient;
|
import org.jclouds.gogrid.services.GridImageAsyncClient;
|
||||||
import org.jclouds.gogrid.services.GridIpAsyncClient;
|
import org.jclouds.gogrid.services.GridIpAsyncClient;
|
||||||
import org.jclouds.gogrid.services.GridJobAsyncClient;
|
import org.jclouds.gogrid.services.GridJobAsyncClient;
|
||||||
|
@ -28,7 +30,7 @@ import org.jclouds.rest.annotations.Delegate;
|
||||||
/**
|
/**
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public interface GoGridAsyncClient {
|
public interface GoGridAsyncClient extends Closeable {
|
||||||
public static final String VERSION = "1.5";
|
public static final String VERSION = "1.5";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid;
|
package org.jclouds.gogrid;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
import org.jclouds.gogrid.services.GridImageClient;
|
import org.jclouds.gogrid.services.GridImageClient;
|
||||||
import org.jclouds.gogrid.services.GridIpClient;
|
import org.jclouds.gogrid.services.GridIpClient;
|
||||||
import org.jclouds.gogrid.services.GridJobClient;
|
import org.jclouds.gogrid.services.GridJobClient;
|
||||||
|
@ -28,7 +30,7 @@ import org.jclouds.rest.annotations.Delegate;
|
||||||
/**
|
/**
|
||||||
* @author Oleksiy Yarmula
|
* @author Oleksiy Yarmula
|
||||||
*/
|
*/
|
||||||
public interface GoGridClient {
|
public interface GoGridClient extends Closeable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Services with methods, related to managing servers
|
* Services with methods, related to managing servers
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue