refactored configuration and setup to test with build 4.1.8

This commit is contained in:
Adrian Cole 2012-01-05 18:57:15 -08:00
parent af598ffeb0
commit 013c0eaf83
12 changed files with 84 additions and 68 deletions

View File

@ -14,7 +14,7 @@ The "VirtualboxAdministrationTest" helper will run these preliminary steps:
(this value can be overwritten directly on the commandline using -Dtest.virtualbox.workingDir)
2. Install Virtualbox from the internet (mac os x lion and ubuntu host are supported at the moment)
3. Download by default an ubuntu 11.04 server i386 ISO into "jclouds-virtualbox-test" from http://releases.ubuntu.com/11.04/ubuntu-11.04-server-i386.iso.
4. Download VirtualBox Guest Additions ISO (tested with VBoxGuestAdditions_4.0.2-update-69551.iso) into "jclouds-virtualbox-test"
4. Download VirtualBox Guest Additions ISO into "jclouds-virtualbox-test" from http://download.virtualbox.org/virtualbox/4.1.8/VBoxGuestAdditions_4.1.8.iso
5. Disable login credential: $ VBoxManage setproperty websrvauthlibrary null
6. Start an embedded jetty server that serves a preseed file specifically written for ubuntu 11.04
7. Start webservice with increasead timeout: $ /usr/bin/vboxwebsrv --timeout 10000 and then will:

View File

@ -39,7 +39,7 @@
<test.virtualbox.build-version>4.1.8r75467</test.virtualbox.build-version>
<test.virtualbox.identity>administrator</test.virtualbox.identity>
<test.virtualbox.credential>12345</test.virtualbox.credential>
<test.virtualbox.image-id></test.virtualbox.image-id>
<test.virtualbox.image-id>ubuntu-11.04-server-i386</test.virtualbox.image-id>
<test.virtualbox.image.login-user></test.virtualbox.image.login-user>
<test.virtualbox.image.authenticate-sudo></test.virtualbox.image.authenticate-sudo>
</properties>

View File

@ -19,6 +19,8 @@
package org.jclouds.virtualbox;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_BUILD_VERSION;
import static org.jclouds.Constants.PROPERTY_CREDENTIAL;
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.Constants.PROPERTY_IDENTITY;
@ -47,9 +49,12 @@ public class VirtualBoxPropertiesBuilder extends PropertiesBuilder {
@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.put(PROPERTY_ENDPOINT, "http://localhost:18083/");
// later version not in maven, yet
properties.put(PROPERTY_API_VERSION, "4.1.4");
properties.put(PROPERTY_BUILD_VERSION, "4.1.8r75467");
properties.put(PROPERTY_IDENTITY, "administrator");
properties.put(PROPERTY_CREDENTIAL, "12345");
properties.put(PROPERTY_ENDPOINT, "http://localhost:18083/");
properties.put(VirtualBoxConstants.VIRTUALBOX_PRESEED_URL, "http://dl.dropbox.com/u/693111/preseed.cfg");
properties.put(VirtualBoxConstants.VIRTUALBOX_SNAPSHOT_DESCRIPTION, "jclouds-virtualbox-snaphot");
properties.put(VirtualBoxConstants.VIRTUALBOX_HOSTNAME, "jclouds-virtualbox-kickstart-admin");
@ -68,9 +73,6 @@ public class VirtualBoxPropertiesBuilder extends PropertiesBuilder {
properties.put(VirtualBoxConstants.VIRTUALBOX_WORKINGDIR, System.getProperty("user.home") + File.separator
+ System.getProperty("test.virtualbox.workingDir", "jclouds-virtualbox-test"));
// TODO: Add more properties and use the wired properties from test code.
properties.put(VirtualBoxConstants.VIRTUALBOX_DISTRO_ISO_NAME, "ubuntu-11.04-server-i386.iso");
properties.put(VirtualBoxConstants.VIRTUALBOX_JETTY_PORT, "8080");
return properties;

View File

@ -51,8 +51,6 @@ public interface VirtualBoxConstants {
public static final String VIRTUALBOX_HOST_ID = "jclouds.virtualbox.hostid";
public static final String VIRTUALBOX_DISTRO_ISO_NAME = "jclouds.virtualbox.distroisoname";
public static final String VIRTUALBOX_JETTY_PORT = "jclouds.virtualbox.jetty.port";
public static final String VIRTUALBOX_JETTY_BASE_RESOURCE = "jclouds.virtualbox.jetty.baseresource";

View File

@ -22,8 +22,10 @@ package org.jclouds.virtualbox;
import static org.jclouds.virtualbox.experiment.TestUtils.computeServiceForLocalhostAndGuest;
import java.net.URI;
import java.util.Properties;
import org.eclipse.jetty.server.Server;
import org.jclouds.Constants;
import org.jclouds.compute.BaseVersionedServiceLiveTest;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
@ -34,13 +36,16 @@ import org.jclouds.sshj.config.SshjSshClientModule;
import org.jclouds.virtualbox.config.VirtualBoxConstants;
import org.jclouds.virtualbox.functions.admin.StartJettyIfNotAlreadyRunning;
import org.jclouds.virtualbox.functions.admin.StartVBoxIfNotAlreadyRunning;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.jclouds.virtualbox.util.PropertyUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.virtualbox_4_1.SessionState;
import org.virtualbox_4_1.VirtualBoxManager;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.inject.Module;
/**
@ -57,16 +62,42 @@ public class BaseVirtualBoxClientLiveTest extends BaseVersionedServiceLiveTest {
protected ComputeServiceContext context;
protected VirtualBoxManager manager;
protected Server jetty;
protected String hostVersion;
protected String operatingSystemIso;
protected String guestAdditionsIso;
protected String adminDisk;
@BeforeGroups(groups = { "live" })
public void setupClient() {
context = new ComputeServiceContextFactory().createContext(provider, identity, credential,
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), setupProperties());
jetty = new StartJettyIfNotAlreadyRunning(port).apply(basebaseResource);
startVboxIfNotAlreadyRunning();
@Override
protected void setupCredentials() {
// default behavior is to bomb when no user is configured, but we know the default user of vbox
Properties defaultVBoxProperties = new VirtualBoxPropertiesBuilder().build();
if (!System.getProperties().containsKey("test." + provider + ".identity"))
System.setProperty("test." + provider + ".identity", defaultVBoxProperties
.getProperty(Constants.PROPERTY_IDENTITY));
super.setupCredentials();
// add in other properties we may need that are in defaults.
if (endpoint == null)
endpoint = defaultVBoxProperties.getProperty(Constants.PROPERTY_ENDPOINT);
if (buildVersion == null)
buildVersion = defaultVBoxProperties.getProperty(Constants.PROPERTY_BUILD_VERSION);
}
@AfterGroups(groups = "live")
@BeforeClass(groups = "live")
public void setupClient() {
setupCredentials();
Properties overrides = setupProperties();
context = new ComputeServiceContextFactory().createContext(provider, identity, credential,
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides);
jetty = new StartJettyIfNotAlreadyRunning(port).apply(basebaseResource);
startVboxIfNotAlreadyRunning();
hostVersion = Iterables.get(Splitter.on('r').split(buildVersion), 0);
String workingDir = PropertyUtils.getWorkingDirFromProperty();
adminDisk = workingDir + "/testadmin.vdi";
operatingSystemIso = String.format("%s/%s.iso", workingDir, imageId);
guestAdditionsIso = String.format("%s/VBoxGuestAdditions_%s.iso", workingDir, hostVersion);
}
@AfterClass(groups = "live")
protected void tearDown() throws Exception {
if (context != null)
context.close();

View File

@ -42,8 +42,6 @@ import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient;
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
import org.jclouds.virtualbox.functions.IMachineToImage;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
import org.virtualbox_4_1.IMachine;
import org.virtualbox_4_1.VirtualBoxManager;
@ -62,7 +60,7 @@ public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClien
}.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule())
.getInstance(Json.class));
@BeforeGroups(groups = { "live" })
@Override
public void setupClient() {
super.setupClient();
final VirtualBoxManager manager = getManager();
@ -133,7 +131,7 @@ public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClien
// check state;
}
@AfterGroups(groups = "live")
@Override
protected void tearDown() throws Exception {
if (machine != null)
adapter.destroyNode(machine.getNodeId() + "");

View File

@ -29,7 +29,6 @@ import org.jclouds.virtualbox.domain.HardDisk;
import org.jclouds.virtualbox.domain.StorageController;
import org.jclouds.virtualbox.domain.VmSpec;
import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndDeleteItsMedia;
import org.jclouds.virtualbox.util.PropertyUtils;
import org.testng.annotations.Test;
import org.virtualbox_4_1.CleanupMode;
import org.virtualbox_4_1.IMachine;
@ -87,16 +86,15 @@ public class CloneAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends
private IMachine getMasterNode(VirtualBoxManager manager,
ComputeServiceContext localHostContext) {
try {
String workingDir = PropertyUtils.getWorkingDirFromProperty();
StorageController ideController = StorageController
.builder()
.name(ideControllerName)
.bus(StorageBus.IDE)
.attachISO(0, 0, workingDir + "/ubuntu-11.04-server-i386.iso")
.attachISO(0, 0, operatingSystemIso)
.attachHardDisk(
HardDisk.builder().diskpath(workingDir + "/testadmin.vdi")
HardDisk.builder().diskpath(adminDisk)
.controllerPort(0).deviceSlot(1).build())
.attachISO(1, 1, workingDir + "/VBoxGuestAdditions_4.1.2.iso")
.attachISO(1, 1, guestAdditionsIso)
.build();
VmSpec vmSpec = VmSpec.builder().id(vmId).name(vmName)
.osTypeId(osTypeId).memoryMB(512).cleanUpMode(CleanupMode.Full)

View File

@ -49,8 +49,7 @@ import org.jclouds.virtualbox.domain.NatAdapter;
import org.jclouds.virtualbox.domain.StorageController;
import org.jclouds.virtualbox.domain.VmSpec;
import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndDeleteItsMedia;
import org.jclouds.virtualbox.util.PropertyUtils;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.virtualbox_4_1.CleanupMode;
import org.virtualbox_4_1.IMachine;
@ -80,18 +79,16 @@ public class CreateAndInstallVmLiveTest extends BaseVirtualBoxClientLiveTest {
private StorageController ideController;
private VmSpec vmSpecification;
@BeforeGroups(groups = {"live"})
public void setUp() throws Exception {
identity = "toor";
credential = "password";
String workingDir = PropertyUtils.getWorkingDirFromProperty();
HardDisk hardDisk = HardDisk.builder().diskpath(workingDir + "/testadmin.vdi").autoDelete(true)
@Override
@BeforeClass(groups = "live")
public void setupClient() {
super.setupClient();
HardDisk hardDisk = HardDisk.builder().diskpath(adminDisk).autoDelete(true)
.controllerPort(0).deviceSlot(1).build();
ideController = StorageController.builder().name(ideControllerName).bus(StorageBus.IDE)
.attachISO(0, 0, workingDir + "/ubuntu-11.04-server-i386.iso")
.attachISO(0, 0, operatingSystemIso)
.attachHardDisk(hardDisk)
.attachISO(1, 1, workingDir + "/VBoxGuestAdditions_4.1.2.iso").build();
.attachISO(1, 1, guestAdditionsIso).build();
vmSpecification = VmSpec.builder().id(vmId).name(vmName).memoryMB(512).osTypeId(osTypeId)
.controller(ideController)
.forceOverwrite(true)

View File

@ -28,8 +28,6 @@ import org.jclouds.virtualbox.domain.HardDisk;
import org.jclouds.virtualbox.domain.StorageController;
import org.jclouds.virtualbox.domain.VmSpec;
import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndDeleteItsMedia;
import org.jclouds.virtualbox.util.PropertyUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.virtualbox_4_1.CleanupMode;
import org.virtualbox_4_1.IMachine;
@ -47,20 +45,20 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends
private CleanupMode mode;
private StorageController ideController;
@BeforeMethod
public void setUp() {
@Override
public void setupClient() {
super.setupClient();
ideControllerName = "IDE Controller";
mode = CleanupMode.Full;
String workingDir = PropertyUtils.getWorkingDirFromProperty();
ideController = StorageController
.builder()
.name(ideControllerName)
.bus(StorageBus.IDE)
.attachISO(0, 0, workingDir + "/ubuntu-11.04-server-i386.iso")
.attachISO(0, 0, operatingSystemIso)
.attachHardDisk(
HardDisk.builder().diskpath(workingDir + "/testadmin.vdi")
HardDisk.builder().diskpath(adminDisk)
.controllerPort(0).deviceSlot(1).build())
.attachISO(1, 1, workingDir + "/VBoxGuestAdditions_4.1.2.iso")
.attachISO(1, 1, guestAdditionsIso)
.build();
}

View File

@ -33,7 +33,6 @@ import org.jclouds.virtualbox.domain.HardDisk;
import org.jclouds.virtualbox.domain.NatAdapter;
import org.jclouds.virtualbox.domain.StorageController;
import org.jclouds.virtualbox.domain.VmSpec;
import org.jclouds.virtualbox.util.PropertyUtils;
import org.testng.annotations.Test;
import org.virtualbox_4_1.CleanupMode;
import org.virtualbox_4_1.IMachine;
@ -61,11 +60,10 @@ public class UnregisterMachineIfExistsAndDeleteItsMediaTest {
List<IMedium> media = new ArrayList<IMedium>();
List<IMedium> mediums = Collections.unmodifiableList(media);
String workingDir = PropertyUtils.getWorkingDirFromProperty();
StorageController ideController = StorageController.builder().name(ideControllerName).bus(StorageBus.IDE)
.attachISO(0, 0, workingDir + "/ubuntu-11.04-server-i386.iso")
.attachHardDisk(HardDisk.builder().diskpath(workingDir + "/testadmin.vdi").controllerPort(0).deviceSlot(1).build())
.attachISO(1, 1, workingDir + "/VBoxGuestAdditions_4.1.2.iso").build();
.attachISO(0, 0, "/tmp/ubuntu-11.04-server-i386.iso")
.attachHardDisk(HardDisk.builder().diskpath("/tmp/testadmin.vdi").controllerPort(0).deviceSlot(1).build())
.attachISO(1, 1, "/tmp/VBoxGuestAdditions_4.1.2.iso").build();
VmSpec vmSpecification = VmSpec.builder().id(vmId).name(vmName).memoryMB(512).osTypeId(osTypeId)
.controller(ideController)
.forceOverwrite(true)

View File

@ -30,8 +30,7 @@ import org.jclouds.virtualbox.functions.CloneAndRegisterMachineFromIMachineIfNot
import org.jclouds.virtualbox.functions.CreateAndRegisterMachineFromIsoIfNotAlreadyExists;
import org.jclouds.virtualbox.functions.IMachineToVmSpec;
import org.jclouds.virtualbox.functions.admin.UnregisterMachineIfExistsAndDeleteItsMedia;
import org.jclouds.virtualbox.util.PropertyUtils;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.virtualbox_4_1.CleanupMode;
import org.virtualbox_4_1.IMachine;
@ -56,20 +55,19 @@ public class IsLinkedClonesLiveTest extends BaseVirtualBoxClientLiveTest {
private VmSpec masterSpec;
private VmSpec cloneSpec;
@BeforeGroups(groups = { "live" })
public void setUp() throws Exception {
identity = "toor";
credential = "password";
@Override
@BeforeClass(groups = "live")
public void setupClient() {
super.setupClient();
String workingDir = PropertyUtils.getWorkingDirFromProperty();
HardDisk hardDisk = HardDisk.builder()
.diskpath(workingDir + "/testadmin.vdi").autoDelete(true)
.diskpath(adminDisk).autoDelete(true)
.controllerPort(0).deviceSlot(1).build();
masterStorageController = StorageController.builder()
.name(ideControllerName).bus(StorageBus.IDE)
.attachISO(0, 0, workingDir + "/ubuntu-11.04-server-i386.iso")
.attachISO(0, 0, operatingSystemIso)
.attachHardDisk(hardDisk)
.attachISO(1, 1, workingDir + "/VBoxGuestAdditions_4.1.2.iso")
.attachISO(1, 1, guestAdditionsIso)
.build();
masterSpec = VmSpec.builder().id(vmId).name(vmName).memoryMB(512)
.osTypeId(osTypeId).controller(masterStorageController)

View File

@ -21,7 +21,6 @@ import org.jclouds.virtualbox.domain.StorageController;
import org.jclouds.virtualbox.domain.VmSpec;
import org.jclouds.virtualbox.functions.CreateAndInstallVm;
import org.jclouds.virtualbox.functions.LaunchMachineIfNotAlreadyRunning;
import org.jclouds.virtualbox.util.PropertyUtils;
import org.testng.annotations.Test;
import org.virtualbox_4_1.IMachine;
import org.virtualbox_4_1.IProgress;
@ -71,10 +70,9 @@ public class SshAvailableLiveTest extends BaseVirtualBoxClientLiveTest {
new InetSocketAddressConnect(), 10, 1, TimeUnit.SECONDS);
String vmId = "jclouds-image-iso-2";
String workingDir = PropertyUtils.getWorkingDirFromProperty();
StorageController ideController = StorageController.builder().name("IDE Controller").bus(StorageBus.IDE)
.attachISO(0, 0, workingDir + "/ubuntu-11.04-server-i386.iso")
.attachHardDisk(HardDisk.builder().diskpath(workingDir + "/testadmin.vdi").controllerPort(0).deviceSlot(1).build()).build();
.attachISO(0, 0, operatingSystemIso)
.attachHardDisk(HardDisk.builder().diskpath(adminDisk).controllerPort(0).deviceSlot(1).build()).build();
VmSpec vmSpecification = VmSpec.builder().id(vmId).name(vmName).osTypeId("")
.memoryMB(512)
.controller(ideController)