issue 384: some fixing to AdminLiveTest for cloning vms from admin node - unstable

This commit is contained in:
andreaturli 2011-09-11 21:52:38 +01:00
parent fc52cdbaf8
commit 435253dcb5
2 changed files with 248 additions and 259 deletions

View File

@ -175,8 +175,8 @@ public class VirtualboxAdministrationKickstartLiveTest {
adminDisk = workingDir
+ File.separator
+ System.getProperty("test." + provider + ".clonedDisk",
"disk.vdi");
+ System.getProperty("test." + provider + ".adminDisk",
"admin.vdi");
guestAdditionsDvd = workingDir
+ File.separator
+ System.getProperty("test." + provider + ".guestAdditionsDvd",
@ -457,8 +457,10 @@ public class VirtualboxAdministrationKickstartLiveTest {
runScriptOnNode(guestId,
"mount -o loop /dev/dvd /media/cdrom");
runScriptOnNode(guestId, "sh /media/cdrom/VBoxLinuxAdditions.run");
// for Debian based OS
runScriptOnNode(guestId, "rm /etc/udev/rules.d/70-persistent-net.rules");
//runScriptOnNode(guestId, "apt-get --yes install virtualbox-ose-guest-utils");
//}
}

View File

@ -30,26 +30,26 @@ import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URI;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.options.RunScriptOptions;
import org.jclouds.domain.Credentials;
import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule;
import org.jclouds.logging.Logger;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.ssh.SshClient;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.virtualbox_4_1.AccessMode;
import org.virtualbox_4_1.CloneMode;
import org.virtualbox_4_1.CloneOptions;
import org.virtualbox_4_1.DeviceType;
import org.virtualbox_4_1.IMachine;
import org.virtualbox_4_1.IMedium;
@ -63,13 +63,11 @@ import org.virtualbox_4_1.NetworkAttachmentType;
import org.virtualbox_4_1.SessionState;
import org.virtualbox_4_1.StorageBus;
import org.virtualbox_4_1.VirtualBoxManager;
import org.virtualbox_4_1.jaxws.MediumState;
import org.virtualbox_4_1.jaxws.MediumVariant;
import com.google.common.base.Predicate;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.inject.Guice;
import com.google.inject.Injector;
@Test(groups = "live", testName = "virtualbox.VirtualboxLiveTest")
@ -112,22 +110,23 @@ public class VirtualboxLiveTest {
protected int numberOfVirtualMachine;
protected String originalDisk;
private String originalDiskPath;
private String clonedDisk;
private IMedium clonedHd;
private ComputeServiceContext context;
private String originalDiskPath;
private String clonedDisk;
private IMedium clonedHd;
private ComputeServiceContext context;
private String hostId = "host";
private String guestId = "guest";
private String majorVersion;
private String minorVersion;
private String apiVersion;
private String hostId = "host";
private String guestId = "guest";
private String majorVersion;
private String minorVersion;
private String apiVersion;
private String adminNodeName;
protected Logger logger() {
protected Logger logger() {
return context.utils().loggerFactory().getLogger("jclouds.compute");
}
}
protected void setupCredentials() {
protected void setupCredentials() {
identity = System.getProperty("test." + provider + ".identity",
"administrator");
credential = System.getProperty("test." + provider + ".credential",
@ -138,25 +137,16 @@ protected void setupCredentials() {
"4.1.2r73507");
majorVersion = Iterables.get(Splitter.on('r').split(apiVersion), 0);
minorVersion = Iterables.get(Splitter.on('r').split(apiVersion), 1);
}
}
protected void setupConfigurationProperties() {
// VBOX
settingsFile = null; // Fully qualified path where the settings file
// should be created, or NULL for a default
// folder and file based on the name argument (see
// composeMachineFilename()).
osTypeId = System.getProperty("test." + provider + ".osTypeId", ""); // Guest
// OS
// Type
// ID.
vmId = System.getProperty("test." + provider + ".vmId", null); // Machine
// UUID
// (optional).
forceOverwrite = true; // If true, an existing machine settings file will
// be overwritten.
settingsFile = null;
osTypeId = System.getProperty("test." + provider + ".osTypeId", "");
vmId = System.getProperty("test." + provider + ".vmId", null);
forceOverwrite = true;
// OS specific information
adminNodeName = System.getProperty("test." + provider + ".adminnodename", "jclouds-virtualbox-kickstart-admin");
vmName = checkNotNull(System.getProperty("test." + provider + ".vmname", "jclouds-virtualbox-node"));
osUsername = System.getProperty("test." + provider + ".osusername", "toor");
osPassword = System.getProperty("test." + provider + ".ospassword", "password");
@ -169,17 +159,15 @@ protected void setupCredentials() {
"jclouds-virtualbox-test");
originalDisk = System.getProperty("test." + provider + ".originalDisk", "admin.vdi");
originalDiskPath = workingDir
+ File.separator + originalDisk;
originalDiskPath = workingDir + File.separator + originalDisk;
clonedDisk = System.getProperty("test." + provider + ".clonedDisk", "clone.vdi");
clonedDiskPath = workingDir + File.separator + clonedDisk;
numberOfVirtualMachine = Integer.parseInt(checkNotNull(System.getProperty("test." + provider
+ ".numberOfVirtualMachine", "2")));
+ ".numberOfVirtualMachine", "1")));
}
@BeforeGroups(groups = "live")
protected void setupClient() throws Exception {
context = TestUtils.computeServiceForLocalhost();
@ -214,12 +202,16 @@ protected void setupCredentials() {
} else
clonedHd = manager.getVBox().openMedium(clonedDiskPath, DeviceType.HardDisk, AccessMode.ReadWrite, forceOverwrite);
clonedHd.setType(MediumType.MultiAttach);
assertEquals(clonedHd.getId().equals(""), false);
}
@Test(dependsOnMethods = "testCloneHardDisk")
public void testStartVirtualMachines() {
public void testStartVirtualMachines() throws InterruptedException {
//IMedium clonedHd = cloneDisk(MediumType.MultiAttach);
List<CloneOptions> options = new ArrayList<CloneOptions>();
options.add(CloneOptions.KeepDiskNames);
for (int i = 1; i < numberOfVirtualMachine + 1; i++) {
createVirtualMachine(i);
}
@ -234,6 +226,8 @@ protected void setupCredentials() {
ISession session = manager.getSessionObject();
IMachine machine = manager.getVBox().findMachine(instanceName);
machine.lockMachine(session, LockType.Write);
IMachine mutable = session.getMachine();
// network
@ -246,7 +240,6 @@ protected void setupCredentials() {
boolean found = false;
while ((line = bufferedReader.readLine()) != null && !found) {
if (line.split(":")[0].contains("Name")) {
hostInterface = line.split(":")[1];
}
@ -260,17 +253,14 @@ protected void setupCredentials() {
// TODO Auto-generated catch block
e.printStackTrace();
}
// TODO: lookup translations for 4.1 for the below
// mutable.getNetworkAdapter(new Long(0)).attachToBridgedInterface();
// mutable.getNetworkAdapter(new
// Long(0)).setHostInterface(hostInterface.trim());
mutable.getNetworkAdapter(new Long(0)).setAttachmentType(
NetworkAttachmentType.Bridged);
mutable.getNetworkAdapter(new Long(0)).setAdapterType(NetworkAdapterType.Am79C973);
mutable.getNetworkAdapter(new Long(0)).setBridgedInterface(hostInterface.trim());
mutable.getNetworkAdapter(new Long(0)).setEnabled(true);
mutable.saveSettings();
// disk
// disk
mutable.addStorageController(controller, StorageBus.IDE);
mutable.saveSettings();
IMedium distroMedium = manager.getVBox().openMedium(
@ -281,9 +271,6 @@ protected void setupCredentials() {
session.unlockMachine();
}
private void launchVMProcess(IMachine machine, ISession session) {
IProgress prog = machine.launchVMProcess(session, "gui", "");
prog.waitForCompletion(-1);