mirror of https://github.com/apache/jclouds.git
Merge pull request #329 from andreaturli/develop
issue 384: fixed Clone and CreateAndRegister tests
This commit is contained in:
commit
5d9d03ed7e
|
@ -82,7 +82,8 @@ public class CloneAndRegisterMachineFromIMachineIfNotAlreadyExists implements Fu
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean machineNotFoundException(VBoxException e) {
|
private boolean machineNotFoundException(VBoxException e) {
|
||||||
return e.getMessage().contains("VirtualBox error: Could not find a registered machine named ");
|
return e.getMessage().contains("VirtualBox error: Could not find a registered machine named ") ||
|
||||||
|
e.getMessage().contains("Could not find a registered machine with UUID {");
|
||||||
}
|
}
|
||||||
|
|
||||||
private IMachine cloneMachine(VmSpec vmSpec, IMachine master) {
|
private IMachine cloneMachine(VmSpec vmSpec, IMachine master) {
|
||||||
|
|
|
@ -81,8 +81,10 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExists implements Functi
|
||||||
public IMachine apply(@Nullable IMachineSpec launchSpecification) {
|
public IMachine apply(@Nullable IMachineSpec launchSpecification) {
|
||||||
final IVirtualBox vBox = manager.get().getVBox();
|
final IVirtualBox vBox = manager.get().getVBox();
|
||||||
String vmName = launchSpecification.getVmSpec().getVmName();
|
String vmName = launchSpecification.getVmSpec().getVmName();
|
||||||
|
String vmId = launchSpecification.getVmSpec().getVmId();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
vBox.findMachine(vmName);
|
vBox.findMachine(vmId);
|
||||||
throw new IllegalStateException("Machine " + vmName + " is already registered.");
|
throw new IllegalStateException("Machine " + vmName + " is already registered.");
|
||||||
} catch (VBoxException e) {
|
} catch (VBoxException e) {
|
||||||
if (machineNotFoundException(e))
|
if (machineNotFoundException(e))
|
||||||
|
@ -93,7 +95,8 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExists implements Functi
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean machineNotFoundException(VBoxException e) {
|
private boolean machineNotFoundException(VBoxException e) {
|
||||||
return e.getMessage().contains("VirtualBox error: Could not find a registered machine named ");
|
return e.getMessage().contains("VirtualBox error: Could not find a registered machine named ") ||
|
||||||
|
e.getMessage().contains("Could not find a registered machine with UUID {");
|
||||||
}
|
}
|
||||||
|
|
||||||
private IMachine createMachine(IVirtualBox vBox, IMachineSpec machineSpec) {
|
private IMachine createMachine(IVirtualBox vBox, IMachineSpec machineSpec) {
|
||||||
|
|
|
@ -20,9 +20,12 @@
|
||||||
package org.jclouds.virtualbox.functions;
|
package org.jclouds.virtualbox.functions;
|
||||||
|
|
||||||
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_IMAGE_PREFIX;
|
||||||
|
import static org.jclouds.virtualbox.config.VirtualBoxConstants.VIRTUALBOX_INSTALLATION_KEY_SEQUENCE;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
|
|
||||||
|
import org.jclouds.config.ValueOfConfigurationKeyOrNull;
|
||||||
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
|
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
|
||||||
import org.jclouds.virtualbox.domain.*;
|
import org.jclouds.virtualbox.domain.*;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
@ -33,20 +36,21 @@ import org.virtualbox_4_1.ISession;
|
||||||
import org.virtualbox_4_1.StorageBus;
|
import org.virtualbox_4_1.StorageBus;
|
||||||
|
|
||||||
import com.google.common.base.CaseFormat;
|
import com.google.common.base.CaseFormat;
|
||||||
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrea Turli
|
* @author Andrea Turli
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", singleThreaded = true, testName = "CloneAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest")
|
@Test(groups = "live", singleThreaded = true, testName = "CloneAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest")
|
||||||
public class CloneAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends BaseVirtualBoxClientLiveTest {
|
public class CloneAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends
|
||||||
|
BaseVirtualBoxClientLiveTest {
|
||||||
|
|
||||||
private static final boolean IS_LINKED_CLONE = true;
|
private static final boolean IS_LINKED_CLONE = true;
|
||||||
|
|
||||||
private VmSpec clonedVmSpec;
|
private VmSpec clonedVmSpec;
|
||||||
private IMachineSpec sourceMachineSpec;
|
private IMachineSpec sourceMachineSpec;
|
||||||
|
|
||||||
|
|
||||||
private CleanupMode mode = CleanupMode.Full;
|
private CleanupMode mode = CleanupMode.Full;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,24 +58,44 @@ public class CloneAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends Ba
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
super.setupClient();
|
super.setupClient();
|
||||||
String sourceName = VIRTUALBOX_IMAGE_PREFIX
|
String sourceName = VIRTUALBOX_IMAGE_PREFIX
|
||||||
+ CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName());
|
+ CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass()
|
||||||
|
.getSimpleName());
|
||||||
String cloneName = VIRTUALBOX_IMAGE_PREFIX
|
String cloneName = VIRTUALBOX_IMAGE_PREFIX
|
||||||
+ "Clone#" + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName()
|
+ "Clone#"
|
||||||
);
|
+ CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass()
|
||||||
|
.getSimpleName());
|
||||||
|
|
||||||
StorageController ideController = StorageController.builder().name("IDE Controller").bus(StorageBus.IDE)
|
StorageController ideController = StorageController
|
||||||
.attachISO(0, 0, operatingSystemIso).attachHardDisk(
|
.builder()
|
||||||
HardDisk.builder().diskpath(adminDisk).controllerPort(0).deviceSlot(1).autoDelete(true).build()).attachISO(1, 1,
|
.name("IDE Controller")
|
||||||
guestAdditionsIso).build();
|
.bus(StorageBus.IDE)
|
||||||
|
.attachISO(0, 0, operatingSystemIso)
|
||||||
|
.attachHardDisk(
|
||||||
|
HardDisk.builder().diskpath(adminDisk).controllerPort(0)
|
||||||
|
.deviceSlot(1).autoDelete(true).build())
|
||||||
|
.attachISO(1, 1, guestAdditionsIso).build();
|
||||||
|
|
||||||
|
VmSpec sourceVmSpec = VmSpec.builder().id(sourceName).name(sourceName)
|
||||||
|
.osTypeId("").memoryMB(512).cleanUpMode(CleanupMode.Full)
|
||||||
|
.controller(ideController).forceOverwrite(true).build();
|
||||||
|
|
||||||
|
Injector injector = context.utils().injector();
|
||||||
|
Function<String, String> configProperties = injector
|
||||||
|
.getInstance(ValueOfConfigurationKeyOrNull.class);
|
||||||
|
IsoSpec isoSpec = IsoSpec
|
||||||
|
.builder()
|
||||||
|
.sourcePath(operatingSystemIso)
|
||||||
|
.installationScript(
|
||||||
|
configProperties.apply(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE)
|
||||||
|
.replace("HOSTNAME", sourceVmSpec.getVmName()))
|
||||||
|
.preConfiguration(preconfigurationUri).build();
|
||||||
|
|
||||||
VmSpec sourceVmSpec = VmSpec.builder().id(sourceName).name(sourceName).osTypeId("").memoryMB(512).cleanUpMode(
|
|
||||||
CleanupMode.Full).controller(ideController).forceOverwrite(true).build();
|
|
||||||
IsoSpec isoSpec = IsoSpec.builder().build();
|
|
||||||
NetworkSpec networkSpec = NetworkSpec.builder().build();
|
NetworkSpec networkSpec = NetworkSpec.builder().build();
|
||||||
sourceMachineSpec = IMachineSpec.builder().iso(isoSpec).vm(sourceVmSpec).network(networkSpec).build();
|
sourceMachineSpec = IMachineSpec.builder().iso(isoSpec).vm(sourceVmSpec)
|
||||||
|
.network(networkSpec).build();
|
||||||
|
|
||||||
clonedVmSpec = VmSpec.builder().id(cloneName).name(cloneName).memoryMB(512).cleanUpMode(mode)
|
clonedVmSpec = VmSpec.builder().id(cloneName).name(cloneName)
|
||||||
.forceOverwrite(true).build();
|
.memoryMB(512).cleanUpMode(mode).forceOverwrite(true).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -81,15 +105,18 @@ public class CloneAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends Ba
|
||||||
|
|
||||||
if (source.getCurrentSnapshot() != null) {
|
if (source.getCurrentSnapshot() != null) {
|
||||||
ISession session = manager.get().openMachineSession(source);
|
ISession session = manager.get().openMachineSession(source);
|
||||||
session.getConsole().deleteSnapshot(source.getCurrentSnapshot().getId());
|
session.getConsole().deleteSnapshot(
|
||||||
|
source.getCurrentSnapshot().getId());
|
||||||
session.unlockMachine();
|
session.unlockMachine();
|
||||||
}
|
}
|
||||||
|
|
||||||
IMachine clone = new CloneAndRegisterMachineFromIMachineIfNotAlreadyExists(manager, workingDir, clonedVmSpec,
|
IMachine clone = new CloneAndRegisterMachineFromIMachineIfNotAlreadyExists(
|
||||||
IS_LINKED_CLONE).apply(source);
|
manager, workingDir, clonedVmSpec, IS_LINKED_CLONE)
|
||||||
|
.apply(source);
|
||||||
assertEquals(clone.getName(), clonedVmSpec.getVmName());
|
assertEquals(clone.getName(), clonedVmSpec.getVmName());
|
||||||
} finally {
|
} finally {
|
||||||
for (VmSpec spec : ImmutableSet.of(clonedVmSpec, sourceMachineSpec.getVmSpec()))
|
for (VmSpec spec : ImmutableSet.of(clonedVmSpec,
|
||||||
|
sourceMachineSpec.getVmSpec()))
|
||||||
undoVm(spec);
|
undoVm(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,11 +125,13 @@ public class CloneAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends Ba
|
||||||
private IMachine getSourceNode() {
|
private IMachine getSourceNode() {
|
||||||
try {
|
try {
|
||||||
Injector injector = context.utils().injector();
|
Injector injector = context.utils().injector();
|
||||||
return injector.getInstance(CreateAndRegisterMachineFromIsoIfNotAlreadyExists.class).apply(
|
return injector.getInstance(
|
||||||
sourceMachineSpec);
|
CreateAndRegisterMachineFromIsoIfNotAlreadyExists.class).apply(
|
||||||
|
sourceMachineSpec);
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
// already created
|
// already created
|
||||||
return manager.get().getVBox().findMachine(sourceMachineSpec.getVmSpec().getVmId());
|
return manager.get().getVBox()
|
||||||
|
.findMachine(sourceMachineSpec.getVmSpec().getVmId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -57,8 +57,8 @@ import static org.testng.Assert.assertTrue;
|
||||||
public class CreateAndInstallVmLiveTest extends BaseVirtualBoxClientLiveTest {
|
public class CreateAndInstallVmLiveTest extends BaseVirtualBoxClientLiveTest {
|
||||||
|
|
||||||
Map<OsFamily, Map<String, String>> map = new BaseComputeServiceContextModule() {
|
Map<OsFamily, Map<String, String>> map = new BaseComputeServiceContextModule() {
|
||||||
}.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(new GsonModule())
|
}.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice
|
||||||
.getInstance(Json.class));
|
.createInjector(new GsonModule()).getInstance(Json.class));
|
||||||
|
|
||||||
private VmSpec vmSpecification;
|
private VmSpec vmSpecification;
|
||||||
|
|
||||||
|
@ -67,37 +67,47 @@ public class CreateAndInstallVmLiveTest extends BaseVirtualBoxClientLiveTest {
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
super.setupClient();
|
super.setupClient();
|
||||||
String vmName = VIRTUALBOX_IMAGE_PREFIX
|
String vmName = VIRTUALBOX_IMAGE_PREFIX
|
||||||
+ CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName());
|
+ CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass()
|
||||||
|
.getSimpleName());
|
||||||
|
|
||||||
HardDisk hardDisk = HardDisk.builder().diskpath(adminDisk).autoDelete(true)
|
HardDisk hardDisk = HardDisk.builder().diskpath(adminDisk)
|
||||||
.controllerPort(0).deviceSlot(1).build();
|
.autoDelete(true).controllerPort(0).deviceSlot(1).build();
|
||||||
StorageController ideController = StorageController.builder().name("IDE Controller").bus(StorageBus.IDE)
|
StorageController ideController = StorageController.builder()
|
||||||
.attachISO(0, 0, operatingSystemIso)
|
.name("IDE Controller").bus(StorageBus.IDE)
|
||||||
.attachHardDisk(hardDisk)
|
.attachISO(0, 0, operatingSystemIso).attachHardDisk(hardDisk)
|
||||||
.attachISO(1, 1, guestAdditionsIso).build();
|
.attachISO(1, 1, guestAdditionsIso).build();
|
||||||
vmSpecification = VmSpec.builder().id("jclouds-image-iso-1").name(vmName).memoryMB(512).osTypeId("")
|
vmSpecification = VmSpec.builder().id(vmName).name(vmName).memoryMB(512)
|
||||||
.controller(ideController)
|
.osTypeId("").controller(ideController).forceOverwrite(true)
|
||||||
.forceOverwrite(true)
|
.cleanUpMode(CleanupMode.Full).build();
|
||||||
.cleanUpMode(CleanupMode.Full).build();
|
|
||||||
undoVm(vmSpecification);
|
undoVm(vmSpecification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateImageMachineFromIso() throws Exception {
|
public void testCreateImageMachineFromIso() throws Exception {
|
||||||
Injector injector = context.utils().injector();
|
Injector injector = context.utils().injector();
|
||||||
Function<String, String> configProperties = injector.getInstance(ValueOfConfigurationKeyOrNull.class);
|
Function<String, String> configProperties = injector
|
||||||
|
.getInstance(ValueOfConfigurationKeyOrNull.class);
|
||||||
|
|
||||||
IMachineSpec machineSpec = IMachineSpec.builder().vm(vmSpecification)
|
IMachineSpec machineSpec = IMachineSpec
|
||||||
.iso(IsoSpec.builder()
|
.builder()
|
||||||
.sourcePath(operatingSystemIso)
|
.vm(vmSpecification)
|
||||||
.installationScript(configProperties
|
.iso(IsoSpec
|
||||||
.apply(VIRTUALBOX_INSTALLATION_KEY_SEQUENCE)
|
.builder()
|
||||||
.replace("HOSTNAME", vmSpecification.getVmName()))
|
.sourcePath(operatingSystemIso)
|
||||||
.preConfiguration(preconfigurationUri)
|
.installationScript(
|
||||||
.build())
|
configProperties.apply(
|
||||||
.network(NetworkSpec.builder()
|
VIRTUALBOX_INSTALLATION_KEY_SEQUENCE).replace(
|
||||||
.natNetworkAdapter(0, NatAdapter.builder().tcpRedirectRule("127.0.0.1", 2222, "", 22).build())
|
"HOSTNAME", vmSpecification.getVmName()))
|
||||||
.build()).build();
|
.preConfiguration(preconfigurationUri).build())
|
||||||
IMachine imageMachine = injector.getInstance(CreateAndInstallVm.class).apply(machineSpec);
|
.network(
|
||||||
|
NetworkSpec
|
||||||
|
.builder()
|
||||||
|
.natNetworkAdapter(
|
||||||
|
0,
|
||||||
|
NatAdapter.builder()
|
||||||
|
.tcpRedirectRule("127.0.0.1", 2222, "", 22)
|
||||||
|
.build()).build()).build();
|
||||||
|
IMachine imageMachine = injector.getInstance(CreateAndInstallVm.class)
|
||||||
|
.apply(machineSpec);
|
||||||
|
|
||||||
IMachineToImage iMachineToImage = new IMachineToImage(manager, map);
|
IMachineToImage iMachineToImage = new IMachineToImage(manager, map);
|
||||||
Image newImage = iMachineToImage.apply(imageMachine);
|
Image newImage = iMachineToImage.apply(imageMachine);
|
||||||
|
|
|
@ -21,6 +21,8 @@ package org.jclouds.virtualbox.functions;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.fail;
|
import static org.testng.Assert.fail;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
|
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest;
|
||||||
import org.jclouds.virtualbox.domain.*;
|
import org.jclouds.virtualbox.domain.*;
|
||||||
|
@ -54,8 +56,10 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends B
|
||||||
@Test
|
@Test
|
||||||
public void testCreateNewMachine() throws Exception {
|
public void testCreateNewMachine() throws Exception {
|
||||||
String vmName = "jclouds-test-create-1-node";
|
String vmName = "jclouds-test-create-1-node";
|
||||||
|
String vmId = UUID.randomUUID().toString();
|
||||||
|
|
||||||
VmSpec vmSpec = VmSpec.builder()
|
VmSpec vmSpec = VmSpec.builder()
|
||||||
.id(vmName)
|
.id(vmId)
|
||||||
.name(vmName)
|
.name(vmName)
|
||||||
.memoryMB(512)
|
.memoryMB(512)
|
||||||
.controller(ideController)
|
.controller(ideController)
|
||||||
|
@ -84,7 +88,11 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends B
|
||||||
@Test
|
@Test
|
||||||
public void testCreateNewMachineWithBadOsType() throws Exception {
|
public void testCreateNewMachineWithBadOsType() throws Exception {
|
||||||
String vmName = "jclouds-test-create-2-node";
|
String vmName = "jclouds-test-create-2-node";
|
||||||
VmSpec vmSpec = VmSpec.builder().id(vmName).name(vmName).memoryMB(512).controller(ideController)
|
String vmId = UUID.randomUUID().toString();
|
||||||
|
|
||||||
|
VmSpec vmSpec = VmSpec.builder()
|
||||||
|
.id(vmId)
|
||||||
|
.name(vmName).memoryMB(512).controller(ideController)
|
||||||
.cleanUpMode(mode).osTypeId("SomeWeirdUnknownOs").forceOverwrite(true).build();
|
.cleanUpMode(mode).osTypeId("SomeWeirdUnknownOs").forceOverwrite(true).build();
|
||||||
IsoSpec isoSpec = IsoSpec.builder()
|
IsoSpec isoSpec = IsoSpec.builder()
|
||||||
.sourcePath(operatingSystemIso)
|
.sourcePath(operatingSystemIso)
|
||||||
|
|
|
@ -30,9 +30,11 @@ import static org.easymock.classextension.EasyMock.verify;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.easymock.EasyMock;
|
import org.easymock.EasyMock;
|
||||||
|
import org.jclouds.virtualbox.domain.HardDisk;
|
||||||
import org.jclouds.virtualbox.domain.IMachineSpec;
|
import org.jclouds.virtualbox.domain.IMachineSpec;
|
||||||
import org.jclouds.virtualbox.domain.IsoSpec;
|
import org.jclouds.virtualbox.domain.IsoSpec;
|
||||||
import org.jclouds.virtualbox.domain.NetworkSpec;
|
import org.jclouds.virtualbox.domain.NetworkSpec;
|
||||||
|
import org.jclouds.virtualbox.domain.StorageController;
|
||||||
import org.jclouds.virtualbox.domain.VmSpec;
|
import org.jclouds.virtualbox.domain.VmSpec;
|
||||||
import org.jclouds.virtualbox.util.MachineUtils;
|
import org.jclouds.virtualbox.util.MachineUtils;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -41,6 +43,7 @@ import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.ISession;
|
import org.virtualbox_4_1.ISession;
|
||||||
import org.virtualbox_4_1.IVirtualBox;
|
import org.virtualbox_4_1.IVirtualBox;
|
||||||
import org.virtualbox_4_1.LockType;
|
import org.virtualbox_4_1.LockType;
|
||||||
|
import org.virtualbox_4_1.StorageBus;
|
||||||
import org.virtualbox_4_1.VBoxException;
|
import org.virtualbox_4_1.VBoxException;
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
|
@ -53,7 +56,7 @@ import com.google.common.base.Suppliers;
|
||||||
@Test(groups = "unit", testName = "CreateAndRegisterMachineFromIsoIfNotAlreadyExistsTest")
|
@Test(groups = "unit", testName = "CreateAndRegisterMachineFromIsoIfNotAlreadyExistsTest")
|
||||||
public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsTest {
|
public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsTest {
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled=false)
|
||||||
public void testCreateAndSetMemoryWhenNotAlreadyExists() throws Exception {
|
public void testCreateAndSetMemoryWhenNotAlreadyExists() throws Exception {
|
||||||
|
|
||||||
MachineUtils machineUtils = createMock(MachineUtils.class);
|
MachineUtils machineUtils = createMock(MachineUtils.class);
|
||||||
|
@ -61,7 +64,8 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsTest {
|
||||||
IVirtualBox vBox = createMock(IVirtualBox.class);
|
IVirtualBox vBox = createMock(IVirtualBox.class);
|
||||||
Supplier<URI> preconfiguration = createNiceMock(Supplier.class);
|
Supplier<URI> preconfiguration = createNiceMock(Supplier.class);
|
||||||
String vmName = "jclouds-image-my-ubuntu-image";
|
String vmName = "jclouds-image-my-ubuntu-image";
|
||||||
VmSpec vmSpec = VmSpec.builder().id(vmName).name(vmName).osTypeId("").memoryMB(1024).cleanUpMode(
|
StorageController ideController = StorageController.builder().name("IDE Controller").bus(StorageBus.IDE).build();
|
||||||
|
VmSpec vmSpec = VmSpec.builder().id(vmName).name(vmName).osTypeId("").memoryMB(1024).controller(ideController).cleanUpMode(
|
||||||
CleanupMode.Full).build();
|
CleanupMode.Full).build();
|
||||||
IMachineSpec machineSpec = IMachineSpec.builder()
|
IMachineSpec machineSpec = IMachineSpec.builder()
|
||||||
.iso(IsoSpec.builder().sourcePath("some.iso").installationScript("").preConfiguration(preconfiguration).build())
|
.iso(IsoSpec.builder().sourcePath("some.iso").installationScript("").preConfiguration(preconfiguration).build())
|
||||||
|
@ -74,8 +78,8 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsTest {
|
||||||
expect(vBox.composeMachineFilename(vmName, "/tmp/workingDir")).andReturn("settingsFile");
|
expect(vBox.composeMachineFilename(vmName, "/tmp/workingDir")).andReturn("settingsFile");
|
||||||
|
|
||||||
StringBuilder errorMessageBuilder = new StringBuilder();
|
StringBuilder errorMessageBuilder = new StringBuilder();
|
||||||
errorMessageBuilder.append("VirtualBox error: Could not find a registered machine named ");
|
errorMessageBuilder.append("VirtualBox error: Could not find a registered machine with UUID {");
|
||||||
errorMessageBuilder.append("'jclouds-image-virtualbox-iso-to-machine-test' (0x80BB0001)");
|
errorMessageBuilder.append("'jclouds-image-virtualbox-iso-to-machine-test'} (0x80BB0001)");
|
||||||
String errorMessage = errorMessageBuilder.toString();
|
String errorMessage = errorMessageBuilder.toString();
|
||||||
VBoxException vBoxException = new VBoxException(createNiceMock(Throwable.class), errorMessage);
|
VBoxException vBoxException = new VBoxException(createNiceMock(Throwable.class), errorMessage);
|
||||||
|
|
||||||
|
@ -102,7 +106,7 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsTest {
|
||||||
verify(manager, createdMachine, vBox, session);
|
verify(manager, createdMachine, vBox, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = IllegalStateException.class, enabled=false)
|
@Test(expectedExceptions = IllegalStateException.class)
|
||||||
public void testFailIfMachineIsAlreadyRegistered() throws Exception {
|
public void testFailIfMachineIsAlreadyRegistered() throws Exception {
|
||||||
|
|
||||||
MachineUtils machineUtils = createMock(MachineUtils.class);
|
MachineUtils machineUtils = createMock(MachineUtils.class);
|
||||||
|
@ -119,7 +123,7 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsTest {
|
||||||
|
|
||||||
replay(manager, vBox, machineUtils);
|
replay(manager, vBox, machineUtils);
|
||||||
|
|
||||||
VmSpec launchSpecification = VmSpec.builder().id("").name(vmName).osTypeId("").memoryMB(1024).cleanUpMode(
|
VmSpec launchSpecification = VmSpec.builder().id(vmName).name(vmName).osTypeId("").memoryMB(1024).cleanUpMode(
|
||||||
CleanupMode.Full).build();
|
CleanupMode.Full).build();
|
||||||
|
|
||||||
IMachineSpec machineSpec = IMachineSpec.builder()
|
IMachineSpec machineSpec = IMachineSpec.builder()
|
||||||
|
@ -152,7 +156,7 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsTest {
|
||||||
|
|
||||||
replay(manager, vBox, machineUtils);
|
replay(manager, vBox, machineUtils);
|
||||||
|
|
||||||
VmSpec launchSpecification = VmSpec.builder().id("").name(vmName).osTypeId("").cleanUpMode(CleanupMode.Full)
|
VmSpec launchSpecification = VmSpec.builder().id(vmName).name(vmName).osTypeId("").cleanUpMode(CleanupMode.Full)
|
||||||
.memoryMB(1024).build();
|
.memoryMB(1024).build();
|
||||||
IMachineSpec machineSpec = IMachineSpec.builder()
|
IMachineSpec machineSpec = IMachineSpec.builder()
|
||||||
.iso(IsoSpec.builder()
|
.iso(IsoSpec.builder()
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class IsLinkedClonesLiveTest extends BaseVirtualBoxClientLiveTest {
|
||||||
.build();
|
.build();
|
||||||
masterStorageController = StorageController.builder().name(ideControllerName).bus(StorageBus.IDE).attachISO(0, 0,
|
masterStorageController = StorageController.builder().name(ideControllerName).bus(StorageBus.IDE).attachISO(0, 0,
|
||||||
operatingSystemIso).attachHardDisk(hardDisk).attachISO(1, 1, guestAdditionsIso).build();
|
operatingSystemIso).attachHardDisk(hardDisk).attachISO(1, 1, guestAdditionsIso).build();
|
||||||
VmSpec masterSpec = VmSpec.builder().id(vmId).name(vmName).memoryMB(512).osTypeId(osTypeId).controller(
|
VmSpec masterSpec = VmSpec.builder().id(vmName).name(vmName).memoryMB(512).osTypeId(osTypeId).controller(
|
||||||
masterStorageController).forceOverwrite(true).cleanUpMode(CleanupMode.Full).build();
|
masterStorageController).forceOverwrite(true).cleanUpMode(CleanupMode.Full).build();
|
||||||
masterMachineSpec = IMachineSpec.builder()
|
masterMachineSpec = IMachineSpec.builder()
|
||||||
.iso(IsoSpec.builder()
|
.iso(IsoSpec.builder()
|
||||||
|
|
Loading…
Reference in New Issue