mirror of https://github.com/apache/jclouds.git
fixed terremark tests
This commit is contained in:
parent
302321ce18
commit
bb7dbf3a8e
|
@ -24,6 +24,7 @@ import static com.google.common.collect.Iterables.size;
|
||||||
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.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
@ -31,9 +32,9 @@ import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ExecutionException;
|
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;
|
||||||
|
@ -51,8 +52,8 @@ import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshClient.Factory;
|
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
|
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.domain.Catalog;
|
import org.jclouds.trmk.vcloud_0_8.domain.Catalog;
|
||||||
import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem;
|
import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem;
|
||||||
|
@ -76,7 +77,6 @@ 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.AfterTest;
|
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -105,10 +105,17 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe
|
||||||
|
|
||||||
protected VApp clone;
|
protected VApp clone;
|
||||||
protected VDC vdc;
|
protected VDC vdc;
|
||||||
|
protected String serverName;
|
||||||
|
protected KeyPair key;
|
||||||
|
|
||||||
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
|
||||||
|
|
||||||
public TerremarkClientLiveTest() {
|
public TerremarkClientLiveTest() {
|
||||||
this.provider = "trmk-vcloudexpress";
|
this.provider = "trmk-vcloudexpress";
|
||||||
|
StringBuffer name = new StringBuffer();
|
||||||
|
for (int i = 0; i < 15; i++)
|
||||||
|
name.append("d");
|
||||||
|
serverName = name.toString();// "adriantest";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -176,10 +183,6 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe
|
||||||
public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException, TimeoutException,
|
public void testInstantiateAndPowerOn() throws InterruptedException, ExecutionException, TimeoutException,
|
||||||
IOException {
|
IOException {
|
||||||
prepare();
|
prepare();
|
||||||
StringBuffer name = new StringBuffer();
|
|
||||||
for (int i = 0; i < 15; i++)
|
|
||||||
name.append("c");
|
|
||||||
String serverName = name.toString();// "adriantest";
|
|
||||||
|
|
||||||
long hardDisk = 4194304;
|
long hardDisk = 4194304;
|
||||||
|
|
||||||
|
@ -189,9 +192,9 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe
|
||||||
|
|
||||||
// lookup the datacenter you are deploying into
|
// lookup the datacenter you are deploying into
|
||||||
vdc = connection.findVDCInOrgNamed(null, null);
|
vdc = connection.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();
|
InstantiateVAppTemplateOptions instantiateOptions = createInstantiateOptions().sshKeyFingerprint(key.getFingerPrint());
|
||||||
|
|
||||||
CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(null, null, itemName);
|
CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(null, null, itemName);
|
||||||
|
|
||||||
|
@ -201,6 +204,8 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe
|
||||||
// our options
|
// our options
|
||||||
CustomizationParameters customizationOptions = connection.getCustomizationOptions(item.getCustomizationOptions()
|
CustomizationParameters customizationOptions = connection.getCustomizationOptions(item.getCustomizationOptions()
|
||||||
.getHref());
|
.getHref());
|
||||||
|
|
||||||
|
|
||||||
if (customizationOptions.canCustomizePassword())
|
if (customizationOptions.canCustomizePassword())
|
||||||
instantiateOptions.withPassword("robotsarefun");
|
instantiateOptions.withPassword("robotsarefun");
|
||||||
|
|
||||||
|
@ -252,10 +257,26 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe
|
||||||
assertEquals(vApp.getStatus(), Status.ON);
|
assertEquals(vApp.getStatus(), Status.ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract InstantiateVAppTemplateOptions createInstantiateOptions();
|
protected InstantiateVAppTemplateOptions createInstantiateOptions() {
|
||||||
|
return processorCount(1).memory(512).sshKeyFingerprint(key.getFingerPrint());
|
||||||
|
}
|
||||||
|
|
||||||
protected void prepare() {
|
protected void prepare() {
|
||||||
|
Org org = connection.findOrgNamed(null);
|
||||||
|
try {
|
||||||
|
key = connection.generateKeyPairInOrg(org.getHref(), "livetest", false);
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
key = connection.findKeyPairInOrg(org.getHref(), "livetest");
|
||||||
|
connection.deleteKeyPair(key.getId());
|
||||||
|
key = connection.generateKeyPairInOrg(org.getHref(), "livetest", false);
|
||||||
|
}
|
||||||
|
assertNotNull(key);
|
||||||
|
assertEquals(key.getName(), "livetest");
|
||||||
|
assertNotNull(key.getPrivateKey());
|
||||||
|
assertNotNull(key.getFingerPrint());
|
||||||
|
assertEquals(key.isDefault(), false);
|
||||||
|
assertEquals(key.getFingerPrint(), connection.findKeyPairInOrg(org.getHref(), key.getName())
|
||||||
|
.getFingerPrint());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(VApp vApp);
|
protected abstract Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(VApp vApp);
|
||||||
|
@ -435,12 +456,14 @@ public abstract class TerremarkClientLiveTest extends BaseVersionedServiceLiveTe
|
||||||
|
|
||||||
protected abstract SshClient getConnectionFor(IPSocket socket);
|
protected abstract SshClient getConnectionFor(IPSocket socket);
|
||||||
|
|
||||||
@AfterTest
|
@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());
|
connection.deleteNode(node.getId());
|
||||||
if (is != null)
|
if (is != null)
|
||||||
connection.deleteInternetService(is.getId());
|
connection.deleteInternetService(is.getId());
|
||||||
|
if (key != null)
|
||||||
|
connection.deleteKeyPair(key.getId());
|
||||||
if (vApp != null) {
|
if (vApp != null) {
|
||||||
try {
|
try {
|
||||||
successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
|
successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.trmk.ecloud;
|
package org.jclouds.trmk.ecloud;
|
||||||
|
|
||||||
import static org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
@ -32,7 +30,6 @@ import org.jclouds.trmk.vcloud_0_8.domain.InternetService;
|
||||||
import org.jclouds.trmk.vcloud_0_8.domain.Protocol;
|
import org.jclouds.trmk.vcloud_0_8.domain.Protocol;
|
||||||
import org.jclouds.trmk.vcloud_0_8.domain.PublicIpAddress;
|
import org.jclouds.trmk.vcloud_0_8.domain.PublicIpAddress;
|
||||||
import org.jclouds.trmk.vcloud_0_8.domain.VApp;
|
import org.jclouds.trmk.vcloud_0_8.domain.VApp;
|
||||||
import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions;
|
|
||||||
import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants;
|
import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -58,14 +55,10 @@ public class TerremarkECloudClientLiveTest extends TerremarkClientLiveTest {
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected InstantiateVAppTemplateOptions createInstantiateOptions() {
|
|
||||||
return processorCount(1).memory(512);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SshClient getConnectionFor(IPSocket socket) {
|
protected SshClient getConnectionFor(IPSocket socket) {
|
||||||
return sshFactory.create(socket, LoginCredentials.builder().user("ecloud").password("TmrkCl0ud1s#1!").build());
|
return sshFactory.create(socket, LoginCredentials.builder().user("ecloud").password("TmrkCl0ud1s#1!").privateKey(
|
||||||
|
key.getPrivateKey()).authenticateSudo(true).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,27 +18,17 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.trmk.vcloudexpress;
|
package org.jclouds.trmk.vcloudexpress;
|
||||||
|
|
||||||
import static org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions.Builder.processorCount;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
import static org.testng.Assert.assertNotNull;
|
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.trmk.vcloud_0_8.TerremarkClientLiveTest;
|
import org.jclouds.trmk.vcloud_0_8.TerremarkClientLiveTest;
|
||||||
import org.jclouds.trmk.vcloud_0_8.domain.InternetService;
|
import org.jclouds.trmk.vcloud_0_8.domain.InternetService;
|
||||||
import org.jclouds.trmk.vcloud_0_8.domain.KeyPair;
|
|
||||||
import org.jclouds.trmk.vcloud_0_8.domain.Protocol;
|
import org.jclouds.trmk.vcloud_0_8.domain.Protocol;
|
||||||
import org.jclouds.trmk.vcloud_0_8.domain.PublicIpAddress;
|
import org.jclouds.trmk.vcloud_0_8.domain.PublicIpAddress;
|
||||||
import org.jclouds.trmk.vcloud_0_8.domain.Org;
|
|
||||||
import org.jclouds.trmk.vcloud_0_8.domain.VApp;
|
import org.jclouds.trmk.vcloud_0_8.domain.VApp;
|
||||||
import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions;
|
|
||||||
import org.jclouds.trmk.vcloudexpress.suppliers.TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier;
|
import org.jclouds.trmk.vcloudexpress.suppliers.TerremarkVCloudExpressInternetServiceAndPublicIpAddressSupplier;
|
||||||
import org.testng.annotations.AfterTest;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,45 +39,10 @@ import org.testng.annotations.Test;
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "TerremarkVCloudExpressClientLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "TerremarkVCloudExpressClientLiveTest")
|
||||||
public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTest {
|
public class TerremarkVCloudExpressClientLiveTest extends TerremarkClientLiveTest {
|
||||||
|
|
||||||
KeyPair key;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void prepare() {
|
|
||||||
TerremarkVCloudExpressClient vCloudExpressClient = TerremarkVCloudExpressClient.class.cast(connection);
|
|
||||||
|
|
||||||
Org org = vCloudExpressClient.findOrgNamed(null);
|
|
||||||
try {
|
|
||||||
key = vCloudExpressClient.generateKeyPairInOrg(org.getHref(), "livetest", false);
|
|
||||||
} catch (IllegalStateException e) {
|
|
||||||
key = vCloudExpressClient.findKeyPairInOrg(org.getHref(), "livetest");
|
|
||||||
vCloudExpressClient.deleteKeyPair(key.getId());
|
|
||||||
key = vCloudExpressClient.generateKeyPairInOrg(org.getHref(), "livetest", false);
|
|
||||||
}
|
|
||||||
assertNotNull(key);
|
|
||||||
assertEquals(key.getName(), "livetest");
|
|
||||||
assertNotNull(key.getPrivateKey());
|
|
||||||
assertNotNull(key.getFingerPrint());
|
|
||||||
assertEquals(key.isDefault(), false);
|
|
||||||
assertEquals(key.getFingerPrint(), vCloudExpressClient.findKeyPairInOrg(org.getHref(), key.getName())
|
|
||||||
.getFingerPrint());
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterTest
|
|
||||||
void cleanup1() throws InterruptedException, ExecutionException, TimeoutException {
|
|
||||||
if (key != null) {
|
|
||||||
TerremarkVCloudExpressClient vCloudExpressClient = TerremarkVCloudExpressClient.class.cast(connection);
|
|
||||||
vCloudExpressClient.deleteKeyPair(key.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SshClient getConnectionFor(IPSocket socket) {
|
protected SshClient getConnectionFor(IPSocket socket) {
|
||||||
return sshFactory.create(socket, new Credentials("vcloud", key.getPrivateKey()));
|
return sshFactory.create(socket, LoginCredentials.builder().user("vcloud").password("TmrkCl0ud1s#1!").privateKey(
|
||||||
}
|
key.getPrivateKey()).authenticateSudo(true).build());
|
||||||
|
|
||||||
@Override
|
|
||||||
protected InstantiateVAppTemplateOptions createInstantiateOptions() {
|
|
||||||
return processorCount(1).memory(512).sshKeyFingerprint(key.getFingerPrint());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue