mirror of https://github.com/apache/jclouds.git
Merge pull request #127 from jsonking/master
Issue 695: Updated test url and refactored credentials code into singe location.
This commit is contained in:
commit
1cf2be9b09
|
@ -25,6 +25,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.compute.BaseVersionedServiceLiveTest;
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
@ -44,43 +45,19 @@ 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 BaseVCloudClientLiveTest {
|
public abstract class BaseVCloudClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
protected String prefix = System.getProperty("user.name");
|
protected String prefix = System.getProperty("user.name");
|
||||||
|
|
||||||
protected ComputeService client;
|
protected ComputeService client;
|
||||||
|
|
||||||
protected String provider = "vcloud";
|
public BaseVCloudClientLiveTest() {
|
||||||
protected String identity;
|
provider = "vcloud";
|
||||||
protected String credential;
|
}
|
||||||
protected String endpoint;
|
|
||||||
protected String apiversion;
|
|
||||||
|
|
||||||
protected VCloudClient getVCloudApi() {
|
protected VCloudClient getVCloudApi() {
|
||||||
return VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi());
|
return VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi());
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
protected void setupCredentials() {
|
|
||||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
|
||||||
credential = System.getProperty("test." + provider + ".credential");
|
|
||||||
endpoint = System.getProperty("test." + provider + ".endpoint");
|
|
||||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Properties setupProperties() {
|
|
||||||
Properties overrides = new Properties();
|
|
||||||
overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
|
|
||||||
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
|
||||||
overrides.setProperty(provider + ".identity", identity);
|
|
||||||
if (credential != null)
|
|
||||||
overrides.setProperty(provider + ".credential", credential);
|
|
||||||
if (endpoint != null)
|
|
||||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
|
||||||
if (apiversion != null)
|
|
||||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
|
||||||
return overrides;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.compute.BaseVersionedServiceLiveTest;
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
@ -37,7 +37,6 @@ 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.TerremarkVCloudClient;
|
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
|
||||||
import org.testng.annotations.AfterGroups;
|
import org.testng.annotations.AfterGroups;
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -50,16 +49,14 @@ 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 <T extends TerremarkVCloudClient>{
|
public abstract class BaseTerremarkClientLiveTest <T extends TerremarkVCloudClient> extends BaseVersionedServiceLiveTest {
|
||||||
protected String prefix = System.getProperty("user.name");
|
protected String prefix = System.getProperty("user.name");
|
||||||
|
|
||||||
protected ComputeService client;
|
protected ComputeService client;
|
||||||
|
|
||||||
protected String provider = "trmk-ecloud";
|
public BaseTerremarkClientLiveTest() {
|
||||||
protected String identity;
|
provider = "trmk-ecloud";
|
||||||
protected String credential;
|
}
|
||||||
protected String endpoint;
|
|
||||||
protected String apiversion;
|
|
||||||
|
|
||||||
protected RetryablePredicate<IPSocket> socketTester;
|
protected RetryablePredicate<IPSocket> socketTester;
|
||||||
protected Factory sshFactory;
|
protected Factory sshFactory;
|
||||||
|
@ -69,28 +66,6 @@ public abstract class BaseTerremarkClientLiveTest <T extends TerremarkVCloudClie
|
||||||
return (T) client.getContext().getProviderSpecificContext().getApi();
|
return (T) client.getContext().getProviderSpecificContext().getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
protected void setupCredentials() {
|
|
||||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
|
||||||
credential = System.getProperty("test." + provider + ".credential");
|
|
||||||
endpoint = System.getProperty("test." + provider + ".endpoint");
|
|
||||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Properties setupProperties() {
|
|
||||||
Properties overrides = new Properties();
|
|
||||||
overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
|
|
||||||
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
|
||||||
overrides.setProperty(provider + ".identity", identity);
|
|
||||||
if (credential != null)
|
|
||||||
overrides.setProperty(provider + ".credential", credential);
|
|
||||||
if (endpoint != null)
|
|
||||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
|
||||||
if (apiversion != null)
|
|
||||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
|
||||||
return overrides;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
|
|
|
@ -120,7 +120,7 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "integration", "live" }, singleThreaded = true)
|
@Test(groups = { "integration", "live" }, singleThreaded = true)
|
||||||
public abstract class BaseComputeServiceLiveTest {
|
public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
|
|
||||||
protected String group;
|
protected String group;
|
||||||
|
|
||||||
|
@ -133,26 +133,6 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
protected Template template;
|
protected Template template;
|
||||||
protected Map<String, String> keyPair;
|
protected Map<String, String> keyPair;
|
||||||
|
|
||||||
protected String provider;
|
|
||||||
protected String identity;
|
|
||||||
protected String credential;
|
|
||||||
protected String endpoint;
|
|
||||||
protected String apiversion;
|
|
||||||
|
|
||||||
protected Properties setupProperties() {
|
|
||||||
Properties overrides = new Properties();
|
|
||||||
overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
|
|
||||||
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
|
||||||
overrides.setProperty(provider + ".identity", identity);
|
|
||||||
if (credential != null)
|
|
||||||
overrides.setProperty(provider + ".credential", credential);
|
|
||||||
if (endpoint != null)
|
|
||||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
|
||||||
if (apiversion != null)
|
|
||||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
|
||||||
return overrides;
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeGroups(groups = { "integration", "live" })
|
@BeforeGroups(groups = { "integration", "live" })
|
||||||
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
setServiceDefaults();
|
setServiceDefaults();
|
||||||
|
@ -172,13 +152,6 @@ public abstract class BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupCredentials() {
|
|
||||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
|
||||||
credential = System.getProperty("test." + provider + ".credential");
|
|
||||||
endpoint = System.getProperty("test." + provider + ".endpoint");
|
|
||||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setupKeyPairForTest() throws FileNotFoundException, IOException {
|
protected void setupKeyPairForTest() throws FileNotFoundException, IOException {
|
||||||
keyPair = ComputeTestUtils.setupKeyPair();
|
keyPair = ComputeTestUtils.setupKeyPair();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
/**
|
||||||
|
* 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.compute;
|
||||||
|
|
||||||
|
import org.jclouds.Constants;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.base.Strings.emptyToNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Jason King
|
||||||
|
*/
|
||||||
|
public abstract class BaseVersionedServiceLiveTest {
|
||||||
|
|
||||||
|
protected String provider;
|
||||||
|
protected String identity;
|
||||||
|
protected String credential;
|
||||||
|
protected String endpoint;
|
||||||
|
protected String apiversion;
|
||||||
|
|
||||||
|
protected Properties setupProperties() {
|
||||||
|
|
||||||
|
if (emptyToNull(provider) == null) throw new NullPointerException("provider must not be null or empty:"+provider);
|
||||||
|
if (emptyToNull(identity) == null) throw new NullPointerException("identity must not be null or empty:"+provider);
|
||||||
|
|
||||||
|
Properties overrides = new Properties();
|
||||||
|
overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
|
||||||
|
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
||||||
|
|
||||||
|
overrides.setProperty(provider + ".identity", identity);
|
||||||
|
|
||||||
|
if (credential != null)
|
||||||
|
overrides.setProperty(provider + ".credential", credential);
|
||||||
|
if (endpoint != null)
|
||||||
|
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||||
|
if (apiversion != null)
|
||||||
|
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||||
|
|
||||||
|
return overrides;
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
protected void setupCredentials() {
|
||||||
|
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||||
|
credential = System.getProperty("test." + provider + ".credential");
|
||||||
|
endpoint = System.getProperty("test." + provider + ".endpoint");
|
||||||
|
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -48,10 +48,10 @@
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<test.trmk-enterprisecloud.endpoint>http://209.251.187.125/livespec</test.trmk-enterprisecloud.endpoint>
|
<test.trmk-enterprisecloud.endpoint>https://services-beta.enterprisecloud.terremark.com/cloudapi</test.trmk-enterprisecloud.endpoint>
|
||||||
<test.trmk-enterprisecloud.apiversion>2011-07-01</test.trmk-enterprisecloud.apiversion>
|
<test.trmk-enterprisecloud.apiversion>2011-07-01</test.trmk-enterprisecloud.apiversion>
|
||||||
<test.trmk-enterprisecloud.identity>readonly@terremark.com</test.trmk-enterprisecloud.identity>
|
<test.trmk-enterprisecloud.identity>FIXME</test.trmk-enterprisecloud.identity>
|
||||||
<test.trmk-enterprisecloud.credential>T3rr3m@rk</test.trmk-enterprisecloud.credential>
|
<test.trmk-enterprisecloud.credential>FIXME</test.trmk-enterprisecloud.credential>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -34,8 +34,7 @@ public class TerremarkEnterpriseCloudPropertiesBuilder extends PropertiesBuilder
|
||||||
@Override
|
@Override
|
||||||
protected Properties defaultProperties() {
|
protected Properties defaultProperties() {
|
||||||
Properties properties = super.defaultProperties();
|
Properties properties = super.defaultProperties();
|
||||||
// TODO replace with the actual rest url
|
properties.setProperty(PROPERTY_ENDPOINT, "https://services-beta.enterprisecloud.terremark.com/cloudapi");
|
||||||
properties.setProperty(PROPERTY_ENDPOINT, "http://209.251.187.125/livespec");
|
|
||||||
properties.setProperty(PROPERTY_API_VERSION, "2011-07-01");
|
properties.setProperty(PROPERTY_API_VERSION, "2011-07-01");
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.trmk.enterprisecloud.features;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.compute.BaseVersionedServiceLiveTest;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
|
@ -39,21 +40,22 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public class BaseTerremarkEnterpriseCloudClientLiveTest {
|
public class BaseTerremarkEnterpriseCloudClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
|
|
||||||
protected RestContext<TerremarkEnterpriseCloudClient, TerremarkEnterpriseCloudAsyncClient> context;
|
protected RestContext<TerremarkEnterpriseCloudClient, TerremarkEnterpriseCloudAsyncClient> context;
|
||||||
protected Module module;
|
protected Module module;
|
||||||
|
|
||||||
|
public BaseTerremarkEnterpriseCloudClientLiveTest() {
|
||||||
|
provider = "trmk-enterprisecloud";
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
// TODO organize this like other compute tests
|
setupCredentials();
|
||||||
String identity = System.getProperty("test.trmk-enterprisecloud.identity", "readonly@terremark.com");
|
Properties overrides = setupProperties();
|
||||||
String credential = System.getProperty("test.trmk-enterprisecloud.credential", "T3rr3m@rk");
|
|
||||||
|
|
||||||
Properties props = new Properties();
|
context = new RestContextFactory().createContext(provider, identity, credential,
|
||||||
|
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides);
|
||||||
context = new RestContextFactory().createContext("trmk-enterprisecloud", identity, credential,
|
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class TaskClientLiveTest extends BaseTerremarkEnterpriseCloudClientLiveTe
|
||||||
// TODO: don't hard-code id
|
// TODO: don't hard-code id
|
||||||
// TODO: docs say don't parse the href, yet no xml includes "identifier",
|
// TODO: docs say don't parse the href, yet no xml includes "identifier",
|
||||||
// I suspect we may need to change to URI args as opposed to long
|
// I suspect we may need to change to URI args as opposed to long
|
||||||
Set<Task> response = client.getTasksInEnvironment(1);
|
Set<Task> response = client.getTasksInEnvironment(77);
|
||||||
assert null != response;
|
assert null != response;
|
||||||
|
|
||||||
assertTrue(response.size() >= 0);
|
assertTrue(response.size() >= 0);
|
||||||
|
|
Loading…
Reference in New Issue