Merge pull request #127 from jsonking/master

Issue 695: Updated test url and refactored credentials code into singe location.
This commit is contained in:
Adrian Cole 2011-11-10 00:52:53 -08:00
commit 1cf2be9b09
8 changed files with 97 additions and 100 deletions

View File

@ -25,6 +25,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import org.jclouds.Constants;
import org.jclouds.compute.BaseVersionedServiceLiveTest;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
@ -44,43 +45,19 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@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 ComputeService client;
protected String provider = "vcloud";
protected String identity;
protected String credential;
protected String endpoint;
protected String apiversion;
public BaseVCloudClientLiveTest() {
provider = "vcloud";
}
protected VCloudClient getVCloudApi() {
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" })
public void setupClient() {
setupCredentials();

View File

@ -25,7 +25,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.jclouds.Constants;
import org.jclouds.compute.BaseVersionedServiceLiveTest;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContextFactory;
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.trmk.vcloud_0_8.TerremarkVCloudClient;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
@ -50,16 +49,14 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@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 ComputeService client;
protected String provider = "trmk-ecloud";
protected String identity;
protected String credential;
protected String endpoint;
protected String apiversion;
public BaseTerremarkClientLiveTest() {
provider = "trmk-ecloud";
}
protected RetryablePredicate<IPSocket> socketTester;
protected Factory sshFactory;
@ -69,28 +66,6 @@ public abstract class BaseTerremarkClientLiveTest <T extends TerremarkVCloudClie
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" })
public void setupClient() {
setupCredentials();

View File

@ -120,7 +120,7 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@Test(groups = { "integration", "live" }, singleThreaded = true)
public abstract class BaseComputeServiceLiveTest {
public abstract class BaseComputeServiceLiveTest extends BaseVersionedServiceLiveTest {
protected String group;
@ -133,26 +133,6 @@ public abstract class BaseComputeServiceLiveTest {
protected Template template;
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" })
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException {
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 {
keyPair = ComputeTestUtils.setupKeyPair();
}

View File

@ -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");
}
}

View File

@ -48,10 +48,10 @@
</repositories>
<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.identity>readonly@terremark.com</test.trmk-enterprisecloud.identity>
<test.trmk-enterprisecloud.credential>T3rr3m@rk</test.trmk-enterprisecloud.credential>
<test.trmk-enterprisecloud.identity>FIXME</test.trmk-enterprisecloud.identity>
<test.trmk-enterprisecloud.credential>FIXME</test.trmk-enterprisecloud.credential>
</properties>
<dependencies>
<dependency>

View File

@ -34,8 +34,7 @@ public class TerremarkEnterpriseCloudPropertiesBuilder extends PropertiesBuilder
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
// TODO replace with the actual rest url
properties.setProperty(PROPERTY_ENDPOINT, "http://209.251.187.125/livespec");
properties.setProperty(PROPERTY_ENDPOINT, "https://services-beta.enterprisecloud.terremark.com/cloudapi");
properties.setProperty(PROPERTY_API_VERSION, "2011-07-01");
return properties;
}

View File

@ -20,6 +20,7 @@ package org.jclouds.trmk.enterprisecloud.features;
import java.util.Properties;
import org.jclouds.compute.BaseVersionedServiceLiveTest;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextFactory;
@ -39,21 +40,22 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@Test(groups = "live")
public class BaseTerremarkEnterpriseCloudClientLiveTest {
public class BaseTerremarkEnterpriseCloudClientLiveTest extends BaseVersionedServiceLiveTest {
protected RestContext<TerremarkEnterpriseCloudClient, TerremarkEnterpriseCloudAsyncClient> context;
protected Module module;
public BaseTerremarkEnterpriseCloudClientLiveTest() {
provider = "trmk-enterprisecloud";
}
@BeforeGroups(groups = { "live" })
public void setupClient() {
// TODO organize this like other compute tests
String identity = System.getProperty("test.trmk-enterprisecloud.identity", "readonly@terremark.com");
String credential = System.getProperty("test.trmk-enterprisecloud.credential", "T3rr3m@rk");
setupCredentials();
Properties overrides = setupProperties();
Properties props = new Properties();
context = new RestContextFactory().createContext("trmk-enterprisecloud", identity, credential,
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), props);
context = new RestContextFactory().createContext(provider, identity, credential,
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides);
}
@AfterGroups(groups = "live")

View File

@ -47,7 +47,7 @@ public class TaskClientLiveTest extends BaseTerremarkEnterpriseCloudClientLiveTe
// TODO: don't hard-code id
// 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
Set<Task> response = client.getTasksInEnvironment(1);
Set<Task> response = client.getTasksInEnvironment(77);
assert null != response;
assertTrue(response.size() >= 0);