# -*- coding: utf-8 -*-
# $Id$
"""
VirtualBox Validation Kit - Local teleportation testdriver.
"""
__copyright__ = \
"""
Copyright (C) 2010-2014 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
"""
# Standard Python imports.
import os;
import sys;
# Only the main script needs to modify the path.
try: __file__
g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
# Validation Kit imports.
"""
Local Teleportation Test #1.
"""
self.asSkipTests = [];
#
# Overridden methods.
#
return rc;
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--virt-modes" takes a colon separated list of modes');
for s in self.asVirtModes:
if s not in self.asVirtModesDef:
iArg += 1;
if iArg >= len(asArgs): raise base.InvalidOption('The "--cpu-counts" takes a colon separated list of cpu counts');
try: c = int(s);
iArg += 1;
if s not in self.asTestVMsDef:
else:
iArg += 1;
if s not in self.asTestVMsDef:
iArg += 1;
if s not in self.asTestsDef:
iArg += 1;
for s in self.asSkipTests:
if s not in self.asTestsDef:
#self.asTestVMs = ['tst-rhel5', 'tst-win2k3ent', 'tst-sol10',];
else:
return iArg + 1;
# Remove skipped VMs from the test VM list.
except: pass;
# Remove skipped tests from the test list.
except: pass;
# If no test2, then no test VMs.
# Construct the resource list the first time it's queried.
## @todo actionConfig() and getResourceSet() are working on the same
# set of VMs as tdNetBenchmark1, creating common base class would be
# a good idea.
# Some stupid trickery to guess the location of the iso. ## fixme - testsuite unzip ++
sVBoxValidationKit_iso = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxValidationKit.iso'));
sVBoxValidationKit_iso = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxTestSuite.iso'));
break;
break;
# Make sure vboxapi has been imported so we can use the constants.
if not self.importVBoxApi():
return False;
#
# Configure the empty VMs we're going to use for the first tests.
#
#oVM = self.createTestVMs('tst-empty-hwvirt', 0, sKind = 'Other', fVirtEx = True);
#if oVM is None:
# return False;
if oVM is None:
return False;
#
# Configure the VMs we're going to use for the last test.
#
# Linux VMs
if oVM is None:
return False;
if oVM is None:
return False;
oVM = self.createTestVMs('tst-sles11', 1, '3.0/tcp/sles11.vdi', sKind = 'OpenSUSE', fIoApic = True, \
if oVM is None:
return False;
if oVM is None:
return False;
if oVM is None:
return False;
if oVM is None:
return False;
# Windows VMs
if oVM is None:
return False;
oVM = self.createTestVMs('tst-win2k3ent-64', 1, '3.0/tcp/win2k3ent-64.vdi', sKind = 'Windows2003_64', \
if oVM is None:
return False;
if oVM is None:
return False;
# Solaris VMs
if oVM is None:
return False;
if oVM is None:
return False;
return True;
"""
Execute the testcase.
"""
return fRc;
#
# Test config helpers.
#
"""
Wrapper around vbox.createTestVM for creating two VMs, the source
(sName-1) and target (sName-2).
Returns the 2nd VM object on success, None on failure.
"""
if oVM is not None:
return oVM;
#
# Test execution helpers.
#
"""
Attempts a teleportation.
Returns the input parameters for the next test2Teleport call (source
and destiation are switched around). The input session is closed and
removed from the task list, while the return session is in the list.
"""
# Enable the teleporter of the VM.
if fRc:
if fRc:
# Start the destination VM.
if oSessionDst is not None:
# Do the teleportation.
try:
except:
uDstPort = 6502;
if oProgressSrc is not None:
oProgressSrc.wait();
if oProgressSrc.isSuccess():
oProgressDst.wait();
# Terminate the source VM.
# Return with the source and destination swapped.
# Failure / bail out.
"""
Runs the specified VM thru test #1.
"""
# Reconfigure the source VM.
if oSession is not None:
oSession = None;
else:
# Reconfigure the destination VM.
if oSession is not None:
oSession = None;
else:
# Simple test.
# Start the source VM.
if oSessionSrc is not None:
# Simple back and forth to test the ice...
cTeleportations = 0;
cTeleportations += 1;
# Teleport back and forth for a while.
cTeleportations += 1;
break;
break;
# Clean up the source VM.
return None;
"""
Runs one VM (a pair really) thru the various configurations.
"""
if asSupVirtModes is None:
continue;
continue;
if sVirtMode not in asSupVirtModes:
continue;
hsVirtModeDesc = {};
"""
Executes test #2.
"""
# Loop thru the test VMs.
# figure args.
asSupVirtModes = None;
# run test on the VM.
return fRc;
#
# Test #1
#
"""
Resets the teleportation config for the specified VM.
Returns True on success, False on failure.
"""
if oSession is not None:
oSession = None;
else:
return fRc;
"""
Test the password check.
"""
# Start the target VM.
if oSessionDst is not None:
# Start the source VM.
if oSessionSrc is not None:
for sPassword in tsPasswords:
if oProgressSrc:
oProgressSrc.wait();
if oProgressSrc.isSuccess():
% (oProgressSrc.getErrInfoText(),));
elif oProgressDst.isCompleted():
% sPassword);
else:
break;
else:
"""
Misconfigure the target VM and check that teleportation fails with the
same status and message on both ends.
xTracker: #4813
"""
# Give the source a bit more RAM.
if oSession is not None:
oSession = None;
else:
if fRc:
# Start the target VM.
if oSessionDst is not None:
# Start the source VM.
if oSessionSrc is not None:
# Try teleport.
if oProgressSrc:
oProgressSrc.wait();
oProgressDst.wait();
# Make sure it failed.
# Compare the results.
else:
else:
"""
Test that basic teleporting works.
xTracker: #4749
"""
# Start the target VM.
if oSessionDst is not None:
# Start the source VM.
if oSessionSrc is not None:
# Try teleport.
if oProgressSrc:
oProgressSrc.wait();
oProgressDst.wait();
else:
"""
Test that we can start and cancel a teleportation target.
(No source VM trying to connect here.)
xTracker: #4965
"""
if oSession is not None:
else:
"""
Test that starting a teleportation target VM will fail if we give it
a bad address to bind to.
"""
# re-configure it with a bad bind-to address.
if oSession is not None:
fRc = oSession.setupTeleporter(True, uPort=6502, sAddress='no.such.hostname.should.ever.exist.duh');
oSession = None;
if fRc:
# Try start it.
if oSession is not None:
## TODO: exact error code and look for the IPRT right string.
# put back the old teleporter setup.
else:
# test1Sub2 - start
""" This should never fail."""
try:
except:
return False;
try:
except:
return False;
reporter.testFailure('machine.teleporterEnabled=%s but afterwards it is actually %s' % (fEnabled, fNew));
return False;
return True;
""" This should never fail."""
try:
except:
return False;
try:
except:
return False;
reporter.testFailure('machine.teleporterPassword="%s" but afterwards it is actually "%s"' % (sPassword, sNew));
return False;
return True;
""" This can fail, thus fInvalid."""
if not fInvalid:
else:
except: return reporter.testFailureXcpt();
try:
else:
if fInvalid:
except: return reporter.testFailureXcpt();
if not fInvalid:
else:
return False;
return True;
""" This should never fail."""
try:
except:
return False;
try:
except:
return False;
reporter.testFailure('machine.teleporterAddress="%s" but afterwards it is actually "%s"' % (sAddress, sNew));
return False;
return True;
"""
Test the attributes, making sure that we get exceptions on bad values.
"""
# Save the original teleporter attributes for the discard test.
try:
except:
else:
# Open a session and start messing with the properties.
if oSession is not None:
# Anything goes for the address.
# The port is restricted to {0..65535}.
break;
# Anything goes for the password.
# Just test that it works.
# Finally, discard the changes, close the session and check
# that we're back to the originals.
else:
try:
if oVM.teleporterAddress != sOrgAddress: reporter.testFailure('Rollback failed for teleporterAddress');
if oVM.teleporterPassword != sOrgPassword: reporter.testFailure('Rollback failed for teleporterPassword');
if oVM.teleporterEnabled != fOrgEnabled: reporter.testFailure('Rollback failed for teleporterEnabled');
except:
# test1Sub1 - start
def test1Sub1DoTeleport(self, oSession, sHostname, uPort, sPassword, cMsMaxDowntime, hrcExpected, sTestName):
""" Do a bad IConsole::teleport call and check the result."""
try:
else:
else:
return fRc;
""" Test simple IConsole::teleport() failure paths. """
if oSession:
else:
"""
Executes test #1 - Negative API testing.
ASSUMES that the VMs are
"""
# Get the VMs.
#oVmHwVirt1 = self.getVmByName('tst-empty-hwvirt-1');
#oVmHwVirt2 = self.getVmByName('tst-empty-hwvirt-2');
# Reset their teleportation related configuration.
#for oVM in (oVmHwVirt1, oVmHwVirt2, oVmRaw1, oVmRaw2):
# Do the testing (don't both with fRc on the subtests).
if fRc:
else:
if __name__ == '__main__':