mirror of
https://github.com/apache/jclouds.git
synced 2025-02-16 15:08:28 +00:00
issue 384: tests passed but still connection problem to guest with bridged NIC
This commit is contained in:
parent
4b62c4a022
commit
716ae1ad54
@ -25,10 +25,12 @@ import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScr
|
|||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
@ -66,6 +68,7 @@ import org.virtualbox_4_1.IStorageController;
|
|||||||
import org.virtualbox_4_1.LockType;
|
import org.virtualbox_4_1.LockType;
|
||||||
import org.virtualbox_4_1.MachineState;
|
import org.virtualbox_4_1.MachineState;
|
||||||
import org.virtualbox_4_1.NATProtocol;
|
import org.virtualbox_4_1.NATProtocol;
|
||||||
|
import org.virtualbox_4_1.NetworkAdapterType;
|
||||||
import org.virtualbox_4_1.NetworkAttachmentType;
|
import org.virtualbox_4_1.NetworkAttachmentType;
|
||||||
import org.virtualbox_4_1.SessionState;
|
import org.virtualbox_4_1.SessionState;
|
||||||
import org.virtualbox_4_1.StorageBus;
|
import org.virtualbox_4_1.StorageBus;
|
||||||
@ -119,6 +122,7 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
|||||||
private String minorVersion;
|
private String minorVersion;
|
||||||
private URI vboxDmg;
|
private URI vboxDmg;
|
||||||
private String vboxVersionName;
|
private String vboxVersionName;
|
||||||
|
private String snapshotDescription;
|
||||||
|
|
||||||
protected void setupCredentials() {
|
protected void setupCredentials() {
|
||||||
identity = System.getProperty("test." + provider + ".identity",
|
identity = System.getProperty("test." + provider + ".identity",
|
||||||
@ -185,6 +189,8 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
|||||||
preseedUrl = System.getProperty("test." + provider + ".preseedurl",
|
preseedUrl = System.getProperty("test." + provider + ".preseedurl",
|
||||||
"http://dl.dropbox.com/u/693111/preseed.cfg");
|
"http://dl.dropbox.com/u/693111/preseed.cfg");
|
||||||
|
|
||||||
|
snapshotDescription = System.getProperty("test." + provider + "snapshotdescription", "jclouds-virtualbox-snaphot");
|
||||||
|
|
||||||
keyboardSequence = System
|
keyboardSequence = System
|
||||||
.getProperty(
|
.getProperty(
|
||||||
"test." + provider + ".keyboardSequence",
|
"test." + provider + ".keyboardSequence",
|
||||||
@ -198,6 +204,7 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
|||||||
+ "keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false "
|
+ "keyboard-configuration/layout=USA keyboard-configuration/variant=USA console-setup/ask_detect=false "
|
||||||
+ "initrd=/install/initrd.gz -- <Enter>");
|
+ "initrd=/install/initrd.gz -- <Enter>");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeGroups(groups = "live")
|
@BeforeGroups(groups = "live")
|
||||||
@ -294,7 +301,7 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
|||||||
|
|
||||||
protected boolean isUbuntu(String id) {
|
protected boolean isUbuntu(String id) {
|
||||||
return context.getComputeService().getNodeMetadata(id)
|
return context.getComputeService().getNodeMetadata(id)
|
||||||
.getOperatingSystem().getDescription().equals("ubuntu/11.04");
|
.getOperatingSystem().getDescription().contains("ubuntu");
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeMethod
|
@BeforeMethod
|
||||||
@ -446,20 +453,18 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
|||||||
|
|
||||||
@Test(dependsOnMethods = "testStartVirtualMachine")
|
@Test(dependsOnMethods = "testStartVirtualMachine")
|
||||||
public void testConfigureGuestAdditions() {
|
public void testConfigureGuestAdditions() {
|
||||||
// TODO generalize: at the moment we are usign apt-get not the guestadditions.iso attached
|
// TODO generalize
|
||||||
//if(isUbuntu(guestId)) {
|
if(isUbuntu(guestId)) {
|
||||||
// Configure your system for building kernel modules by running
|
runScriptOnNode(guestId, "m-a prepare -i", wrapInInitScript(true));
|
||||||
runScriptOnNode(guestId, "m-a prepare -i", wrapInInitScript(true));
|
runScriptOnNode(guestId,
|
||||||
|
|
||||||
runScriptOnNode(guestId,
|
|
||||||
"mount -o loop /dev/dvd /media/cdrom");
|
"mount -o loop /dev/dvd /media/cdrom");
|
||||||
ExecResponse response = runScriptOnNode(guestId, "sh /media/cdrom/VBoxLinuxAdditions.run");
|
runScriptOnNode(guestId,
|
||||||
response.getExitCode();
|
"sh /media/cdrom/VBoxLinuxAdditions.run");
|
||||||
// for Debian based OS
|
runScriptOnNode(guestId, "rm /etc/udev/rules.d/70-persistent-net.rules");
|
||||||
runScriptOnNode(guestId, "rm /etc/udev/rules.d/70-persistent-net.rules");
|
runScriptOnNode(guestId, "mkdir /etc/udev/rules.d/70-persistent-net.rules");
|
||||||
|
runScriptOnNode(guestId, "rm -rf /dev/.udev/");
|
||||||
|
runScriptOnNode(guestId, "rm /lib/udev/rules.d/75-persistent-net-generator.rules");
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testConfigureGuestAdditions")
|
@Test(dependsOnMethods = "testConfigureGuestAdditions")
|
||||||
@ -469,156 +474,179 @@ public class VirtualboxAdministrationKickstartLiveTest {
|
|||||||
assertEquals(machine.getState(), MachineState.PoweredOff);
|
assertEquals(machine.getState(), MachineState.PoweredOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test(dependsOnMethods = "testStopVirtualMachine")
|
||||||
* @param machine
|
public void testChangeNICtoBridged() {
|
||||||
*/
|
ISession session = manager.getSessionObject();
|
||||||
private void powerDownMachine(IMachine machine) {
|
IMachine adminNode = manager.getVBox().findMachine(vmName);
|
||||||
|
adminNode.lockMachine(session, LockType.Write);
|
||||||
|
IMachine mutable = session.getMachine();
|
||||||
|
// network
|
||||||
|
String hostInterface = null;
|
||||||
|
String command = "vboxmanage list bridgedifs";
|
||||||
try {
|
try {
|
||||||
ISession machineSession = manager.openMachineSession(machine);
|
Process child = Runtime.getRuntime().exec(command);
|
||||||
IProgress progress = machineSession.getConsole().powerDown();
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
||||||
progress.waitForCompletion(-1);
|
String line = "";
|
||||||
machineSession.unlockMachine();
|
boolean found = false;
|
||||||
|
|
||||||
while (!machine.getSessionState().equals(SessionState.Unlocked)) {
|
while ((line = bufferedReader.readLine()) != null && !found) {
|
||||||
try {
|
if (line.split(":")[0].contains("Name")) {
|
||||||
System.out
|
hostInterface = line.split(":")[1];
|
||||||
.println("waiting for unlocking session - session state: "
|
}
|
||||||
+ machine.getSessionState());
|
if (line.split(":")[0].contains("Status") && line.split(":")[1].contains("Up")) {
|
||||||
Thread.sleep(1000);
|
System.out.println("bridge: " + hostInterface.trim());
|
||||||
} catch (InterruptedException e) {
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
} catch (Exception e) {
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testStopVirtualMachine")
|
mutable.getNetworkAdapter(new Long(0)).setAttachmentType(NetworkAttachmentType.Bridged);
|
||||||
public void cleanUp() throws IOException {
|
mutable.getNetworkAdapter(new Long(0)).setAdapterType(NetworkAdapterType.Am79C973);
|
||||||
ISession session = manager.getSessionObject();
|
mutable.getNetworkAdapter(new Long(0)).setMACAddress(manager.getVBox().getHost().generateMACAddress());
|
||||||
IMachine machine = manager.getVBox().findMachine(vmName);
|
mutable.getNetworkAdapter(new Long(0)).setBridgedInterface(hostInterface.trim());
|
||||||
machine.lockMachine(session, LockType.Write);
|
mutable.getNetworkAdapter(new Long(0)).setEnabled(true);
|
||||||
IMachine mutable = session.getMachine();
|
|
||||||
mutable.getNetworkAdapter(new Long(0)).getNatDriver()
|
|
||||||
.removeRedirect("guestssh");
|
|
||||||
// detach disk from controller
|
|
||||||
mutable.detachDevice(controllerIDE, 0, 0);
|
|
||||||
mutable.saveSettings();
|
mutable.saveSettings();
|
||||||
session.unlockMachine();
|
session.unlockMachine();
|
||||||
|
}
|
||||||
|
|
||||||
for (IStorageController storageController : machine
|
@Test(dependsOnMethods = "testChangeNICtoBridged")
|
||||||
.getStorageControllers()) {
|
public void testTakeAdminNodeSnapshot() {
|
||||||
if (storageController.getName().equals(controllerSATA)) {
|
ISession session = manager.getSessionObject();
|
||||||
session = manager.getSessionObject();
|
IMachine adminNode = manager.getVBox().findMachine(vmName);
|
||||||
machine.lockMachine(session, LockType.Write);
|
adminNode.lockMachine(session, LockType.Write);
|
||||||
|
if(adminNode.getCurrentSnapshot() == null || !adminNode.getCurrentSnapshot().getDescription().equals(snapshotDescription)) {
|
||||||
mutable = session.getMachine();
|
manager.getSessionObject().getConsole().takeSnapshot(adminNode.getId(), snapshotDescription);
|
||||||
mutable.detachDevice(storageController.getName(), 1, 1);
|
|
||||||
mutable.saveSettings();
|
|
||||||
session.unlockMachine();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
session.unlockMachine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
void stopVboxWebServer() throws IOException {
|
void stopVboxWebServer() throws IOException {
|
||||||
runScriptOnNode(guestId, "pidof vboxwebsrv | xargs kill");
|
runScriptOnNode(guestId, "pidof vboxwebsrv | xargs kill");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ExecResponse runScriptOnNode(String nodeId, String command,
|
protected ExecResponse runScriptOnNode(String nodeId, String command,
|
||||||
RunScriptOptions options) {
|
RunScriptOptions options) {
|
||||||
ExecResponse toReturn = context.getComputeService().runScriptOnNode(
|
ExecResponse toReturn = context.getComputeService().runScriptOnNode(
|
||||||
nodeId, command, options);
|
nodeId, command, options);
|
||||||
assert toReturn.getExitCode() == 0 : toReturn;
|
assert toReturn.getExitCode() == 0 : toReturn;
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ExecResponse runScriptOnNode(String nodeId, String command) {
|
protected ExecResponse runScriptOnNode(String nodeId, String command) {
|
||||||
return runScriptOnNode(nodeId, command, wrapInInitScript(false));
|
return runScriptOnNode(nodeId, command, wrapInInitScript(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private File downloadFileUnlessPresent(URI sourceURL,
|
private File downloadFileUnlessPresent(URI sourceURL,
|
||||||
String destinationDir, String filename) throws Exception {
|
String destinationDir, String filename) throws Exception {
|
||||||
|
|
||||||
File iso = new File(destinationDir, filename);
|
File iso = new File(destinationDir, filename);
|
||||||
|
|
||||||
if (!iso.exists()) {
|
if (!iso.exists()) {
|
||||||
InputStream is = context.utils().http().get(sourceURL);
|
InputStream is = context.utils().http().get(sourceURL);
|
||||||
checkNotNull(is, "%s not found", sourceURL);
|
checkNotNull(is, "%s not found", sourceURL);
|
||||||
try {
|
try {
|
||||||
ByteStreams.copy(is, new FileOutputStream(iso));
|
ByteStreams.copy(is, new FileOutputStream(iso));
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(is);
|
Closeables.closeQuietly(is);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return iso;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendKeyboardSequence(String keyboardSequence)
|
||||||
|
throws InterruptedException {
|
||||||
|
String[] sequenceSplited = keyboardSequence.split(" ");
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String line : sequenceSplited) {
|
||||||
|
String converted = stringToKeycode(line);
|
||||||
|
for (String word : converted.split(" ")) {
|
||||||
|
sb.append("vboxmanage controlvm " + vmName
|
||||||
|
+ " keyboardputscancode " + word + "; ");
|
||||||
|
|
||||||
|
if (word.endsWith(KeyboardScancodes.SPECIAL_KEYBOARD_BUTTON_MAP.get("<Enter>"))) {
|
||||||
|
runScriptOnNode(hostId, sb.toString(), runAsRoot(false)
|
||||||
|
.wrapInInitScript(false));
|
||||||
|
sb.delete(0, sb.length()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (word.endsWith(KeyboardScancodes.SPECIAL_KEYBOARD_BUTTON_MAP.get("<Return>"))) {
|
||||||
|
runScriptOnNode(hostId, sb.toString(), runAsRoot(false)
|
||||||
|
.wrapInInitScript(false));
|
||||||
|
sb.delete(0, sb.length()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return iso;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendKeyboardSequence(String keyboardSequence)
|
private String stringToKeycode(String s) {
|
||||||
throws InterruptedException {
|
StringBuilder keycodes = new StringBuilder();
|
||||||
String[] sequenceSplited = keyboardSequence.split(" ");
|
if (s.startsWith("<")) {
|
||||||
StringBuilder sb = new StringBuilder();
|
String[] specials = s.split("<");
|
||||||
for (String line : sequenceSplited) {
|
for (int i = 1; i < specials.length; i++) {
|
||||||
String converted = stringToKeycode(line);
|
keycodes.append(KeyboardScancodes.SPECIAL_KEYBOARD_BUTTON_MAP
|
||||||
for (String word : converted.split(" ")) {
|
.get("<" + specials[i]) + " ");
|
||||||
sb.append("vboxmanage controlvm " + vmName
|
|
||||||
+ " keyboardputscancode " + word + "; ");
|
|
||||||
|
|
||||||
if (word.endsWith(KeyboardScancodes.SPECIAL_KEYBOARD_BUTTON_MAP.get("<Enter>"))) {
|
|
||||||
runScriptOnNode(hostId, sb.toString(), runAsRoot(false)
|
|
||||||
.wrapInInitScript(false));
|
|
||||||
sb.delete(0, sb.length()-1);
|
|
||||||
}
|
}
|
||||||
|
return keycodes.toString();
|
||||||
|
|
||||||
if (word.endsWith(KeyboardScancodes.SPECIAL_KEYBOARD_BUTTON_MAP.get("<Return>"))) {
|
|
||||||
runScriptOnNode(hostId, sb.toString(), runAsRoot(false)
|
|
||||||
.wrapInInitScript(false));
|
|
||||||
sb.delete(0, sb.length()-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String stringToKeycode(String s) {
|
|
||||||
StringBuilder keycodes = new StringBuilder();
|
int i = 0;
|
||||||
if (s.startsWith("<")) {
|
while (i < s.length()) {
|
||||||
String[] specials = s.split("<");
|
String digit = s.substring(i, i + 1);
|
||||||
for (int i = 1; i < specials.length; i++) {
|
String hex = KeyboardScancodes.NORMAL_KEYBOARD_BUTTON_MAP
|
||||||
keycodes.append(KeyboardScancodes.SPECIAL_KEYBOARD_BUTTON_MAP
|
.get(digit);
|
||||||
.get("<" + specials[i]) + " ");
|
keycodes.append(hex + " ");
|
||||||
|
if (i != 0 && i % 14 == 0)
|
||||||
|
keycodes.append(" ");
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
keycodes.append(KeyboardScancodes.SPECIAL_KEYBOARD_BUTTON_MAP
|
||||||
|
.get("<Spacebar>") + " ");
|
||||||
|
|
||||||
return keycodes.toString();
|
return keycodes.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
int i = 0;
|
*
|
||||||
while (i < s.length()) {
|
* @param machine
|
||||||
String digit = s.substring(i, i + 1);
|
* @param session
|
||||||
String hex = KeyboardScancodes.NORMAL_KEYBOARD_BUTTON_MAP
|
*/
|
||||||
.get(digit);
|
private void launchVMProcess(IMachine machine, ISession session) {
|
||||||
keycodes.append(hex + " ");
|
IProgress prog = machine.launchVMProcess(session, "gui", "");
|
||||||
if (i != 0 && i % 14 == 0)
|
prog.waitForCompletion(-1);
|
||||||
keycodes.append(" ");
|
session.unlockMachine();
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
keycodes.append(KeyboardScancodes.SPECIAL_KEYBOARD_BUTTON_MAP
|
|
||||||
.get("<Spacebar>") + " ");
|
|
||||||
|
|
||||||
return keycodes.toString();
|
/**
|
||||||
}
|
* @param machine
|
||||||
|
*/
|
||||||
|
private void powerDownMachine(IMachine machine) {
|
||||||
|
try {
|
||||||
|
ISession machineSession = manager.openMachineSession(machine);
|
||||||
|
IProgress progress = machineSession.getConsole().powerDown();
|
||||||
|
progress.waitForCompletion(-1);
|
||||||
|
machineSession.unlockMachine();
|
||||||
|
|
||||||
/**
|
while (!machine.getSessionState().equals(SessionState.Unlocked)) {
|
||||||
*
|
try {
|
||||||
* @param machine
|
System.out
|
||||||
* @param session
|
.println("waiting for unlocking session - session state: "
|
||||||
*/
|
+ machine.getSessionState());
|
||||||
private void launchVMProcess(IMachine machine, ISession session) {
|
Thread.sleep(1000);
|
||||||
IProgress prog = machine.launchVMProcess(session, "gui", "");
|
} catch (InterruptedException e) {
|
||||||
prog.waitForCompletion(-1);
|
}
|
||||||
session.unlockMachine();
|
}
|
||||||
}
|
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,7 +23,10 @@ import static org.jclouds.compute.options.RunScriptOptions.Builder.runAsRoot;
|
|||||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript;
|
import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
@ -47,11 +50,12 @@ import org.testng.annotations.Test;
|
|||||||
import org.virtualbox_4_1.CloneMode;
|
import org.virtualbox_4_1.CloneMode;
|
||||||
import org.virtualbox_4_1.CloneOptions;
|
import org.virtualbox_4_1.CloneOptions;
|
||||||
import org.virtualbox_4_1.IMachine;
|
import org.virtualbox_4_1.IMachine;
|
||||||
import org.virtualbox_4_1.IMedium;
|
|
||||||
import org.virtualbox_4_1.IProgress;
|
import org.virtualbox_4_1.IProgress;
|
||||||
import org.virtualbox_4_1.ISession;
|
import org.virtualbox_4_1.ISession;
|
||||||
import org.virtualbox_4_1.LockType;
|
import org.virtualbox_4_1.LockType;
|
||||||
import org.virtualbox_4_1.MachineState;
|
import org.virtualbox_4_1.MachineState;
|
||||||
|
import org.virtualbox_4_1.NetworkAdapterType;
|
||||||
|
import org.virtualbox_4_1.NetworkAttachmentType;
|
||||||
import org.virtualbox_4_1.SessionState;
|
import org.virtualbox_4_1.SessionState;
|
||||||
import org.virtualbox_4_1.VirtualBoxManager;
|
import org.virtualbox_4_1.VirtualBoxManager;
|
||||||
|
|
||||||
@ -143,7 +147,6 @@ public class VirtualboxLiveTest {
|
|||||||
|
|
||||||
clonedDisk = System.getProperty("test." + provider + ".clonedDisk", "clone.vdi");
|
clonedDisk = System.getProperty("test." + provider + ".clonedDisk", "clone.vdi");
|
||||||
clonedDiskPath = workingDir + File.separator + clonedDisk;
|
clonedDiskPath = workingDir + File.separator + clonedDisk;
|
||||||
snapshotDescription = System.getProperty("test." + provider + "snapshotdescription", "jclouds-virtualbox-snaphot");
|
|
||||||
numberOfVirtualMachine = Integer.parseInt(checkNotNull(System.getProperty("test." + provider
|
numberOfVirtualMachine = Integer.parseInt(checkNotNull(System.getProperty("test." + provider
|
||||||
+ ".numberOfVirtualMachine", "3")));
|
+ ".numberOfVirtualMachine", "3")));
|
||||||
}
|
}
|
||||||
@ -172,16 +175,6 @@ public class VirtualboxLiveTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTakeAdminNodeSnapshot() {
|
|
||||||
ISession session = manager.getSessionObject();
|
|
||||||
IMachine adminNode = manager.getVBox().findMachine(adminNodeName);
|
|
||||||
adminNode.lockMachine(session, LockType.Write);
|
|
||||||
if(adminNode.getCurrentSnapshot() == null || !adminNode.getCurrentSnapshot().getDescription().equals(snapshotDescription)) {
|
|
||||||
manager.getSessionObject().getConsole().takeSnapshot(adminNode.getId(), snapshotDescription);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testTakeAdminNodeSnapshot")
|
|
||||||
public void testStartAndValidateVirtualMachines() throws InterruptedException {
|
public void testStartAndValidateVirtualMachines() throws InterruptedException {
|
||||||
for (int i = 1; i < numberOfVirtualMachine + 1; i++) {
|
for (int i = 1; i < numberOfVirtualMachine + 1; i++) {
|
||||||
createAndLaunchVirtualMachine(i);
|
createAndLaunchVirtualMachine(i);
|
||||||
@ -189,9 +182,9 @@ public class VirtualboxLiveTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createAndLaunchVirtualMachine(int i) throws InterruptedException {
|
private void createAndLaunchVirtualMachine(int i) throws InterruptedException {
|
||||||
|
|
||||||
String instanceName = vmName + "_" + i;
|
String instanceName = vmName + "_" + i;
|
||||||
IMachine adminNode = manager.getVBox().findMachine(adminNodeName);
|
IMachine adminNode = manager.getVBox().findMachine(adminNodeName);
|
||||||
|
|
||||||
IMachine clonedVM = manager.getVBox().createMachine(settingsFile, instanceName, osTypeId, vmId, forceOverwrite);
|
IMachine clonedVM = manager.getVBox().createMachine(settingsFile, instanceName, osTypeId, vmId, forceOverwrite);
|
||||||
List<CloneOptions> options = new ArrayList<CloneOptions>();
|
List<CloneOptions> options = new ArrayList<CloneOptions>();
|
||||||
options.add(CloneOptions.Link);
|
options.add(CloneOptions.Link);
|
||||||
@ -201,6 +194,7 @@ public class VirtualboxLiveTest {
|
|||||||
|
|
||||||
manager.getVBox().registerMachine(clonedVM);
|
manager.getVBox().registerMachine(clonedVM);
|
||||||
|
|
||||||
|
|
||||||
System.out.println("\nLaunching VM named " + clonedVM.getName() + " ...");
|
System.out.println("\nLaunching VM named " + clonedVM.getName() + " ...");
|
||||||
launchVMProcess(clonedVM, manager.getSessionObject());
|
launchVMProcess(clonedVM, manager.getSessionObject());
|
||||||
String ipAddress = null;
|
String ipAddress = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user