cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#!/usr/bin/env python
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# -*- coding: utf-8 -*-
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# $Id$
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox Validation Kit - Storage snapshotting and merging testcase.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__copyright__ = \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCopyright (C) 2013 Oracle Corporation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThis file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncavailable from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncyou can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncGeneral Public License (GPL) as published by the Free Software
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncFoundation, in version 2 as it comes in the "COPYING" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution. VirtualBox OSE is distributed in the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynchope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThe contents of this file may alternatively be used under the terms
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncof the Common Development and Distribution License Version 1.0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync(CDDL) only, as it comes in the "COPYING.CDDL" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution, in which case the provisions of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCDDL are applicable instead of those of the GPL.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncYou may elect to license modified versions of this file under the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncterms and conditions of either the GPL or the CDDL or both.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__version__ = "$Id$"
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Standard Python imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport os;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport sys;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport uuid;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Only the main script needs to modify the path.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctry: __file__
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncexcept: __file__ = sys.argv[0];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncg_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncsys.path.append(g_ksValidationKitDir);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Validation Kit imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testdriver import reporter;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testdriver import base;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testdriver import vbox;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testdriver import vboxcon;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef _ControllerTypeToName(eControllerType):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Translate a controller type to a name. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if eControllerType == vboxcon.StorageControllerType_PIIX3 or eControllerType == vboxcon.StorageControllerType_PIIX4:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sType = "IDE Controller";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif eControllerType == vboxcon.StorageControllerType_IntelAhci:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sType = "SATA Controller";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif eControllerType == vboxcon.StorageControllerType_LsiLogicSas:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sType = "SAS Controller";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif eControllerType == vboxcon.StorageControllerType_LsiLogic or eControllerType == vboxcon.StorageControllerType_BusLogic:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sType = "SCSI Controller";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sType = "Storage Controller";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return sType;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass tdStorageSnapshot(vbox.TestDriver): # pylint: disable=R0902
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Storage benchmark.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync vbox.TestDriver.__init__(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asRsrcs = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oGuestToGuestVM = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oGuestToGuestSess = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oGuestToGuestTxs = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asTestVMsDef = ['tst-win7-vhd', 'tst-debian-vhd', 'tst-debian-vdi'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asTestVMs = self.asTestVMsDef;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asSkipVMs = [];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asStorageCtrlsDef = ['AHCI', 'IDE', 'LsiLogicSAS', 'LsiLogic', 'BusLogic'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asStorageCtrls = self.asStorageCtrlsDef;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asDiskFormatsDef = ['VDI', 'VMDK', 'VHD', 'QED', 'Parallels', 'QCOW', 'iSCSI'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asDiskFormats = self.asDiskFormatsDef;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sRndData = os.urandom(100*1024*1024);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Overridden methods.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def showUsage(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync rc = vbox.TestDriver.showUsage(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('tdStorageSnapshot1 Options:');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --storage-ctrls <type1[:type2[:...]]>');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Default: %s' % (':'.join(self.asStorageCtrls)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --disk-formats <type1[:type2[:...]]>');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Default: %s' % (':'.join(self.asDiskFormats)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --test-vms <vm1[:vm2[:...]]>');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Test the specified VMs in the given order. Use this to change');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' the execution order or limit the choice of VMs');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Default: %s (all)' % (':'.join(self.asTestVMsDef)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --skip-vms <vm1[:vm2[:...]]>');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Skip the specified VMs when testing.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return rc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def parseOption(self, asArgs, iArg): # pylint: disable=R0912,R0915
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if asArgs[iArg] == '--storage-ctrls':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--storage-ctrls" takes a colon separated list of Storage controller types');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asStorageCtrls = asArgs[iArg].split(':');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--disk-formats':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs): raise base.InvalidOption('The "--disk-formats" takes a colon separated list of disk formats');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asDiskFormats = asArgs[iArg].split(':');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--test-vms':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs): raise base.InvalidOption('The "--test-vms" takes colon separated list');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asTestVMs = asArgs[iArg].split(':');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for s in self.asTestVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if s not in self.asTestVMsDef:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--test-vms" value "%s" is not valid; valid values are: %s' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (s, ' '.join(self.asTestVMsDef)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--skip-vms':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs): raise base.InvalidOption('The "--skip-vms" takes colon separated list');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asSkipVMs = asArgs[iArg].split(':');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for s in self.asSkipVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if s not in self.asTestVMsDef:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return vbox.TestDriver.parseOption(self, asArgs, iArg);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return iArg + 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def completeOptions(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Remove skipped VMs from the test list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for sVM in self.asSkipVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: self.asTestVMs.remove(sVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return vbox.TestDriver.completeOptions(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def getResourceSet(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Construct the resource list the first time it's queried.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.asRsrcs is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asRsrcs = [];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if 'tst-win7-vhd' in self.asTestVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asRsrcs.append('4.2/storage/win7.vhd');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if 'tst-debian-vhd' in self.asTestVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asRsrcs.append('4.2/storage/debian.vhd');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if 'tst-debian-vdi' in self.asTestVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asRsrcs.append('4.2/storage/debian.vdi');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.asRsrcs;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def actionConfig(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Make sure vboxapi has been imported so we can use the constants.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.importVBoxApi():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Configure the VMs we're going to use.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Windows VMs
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if 'tst-win7-vhd' in self.asTestVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.createTestVM('tst-win7-vhd', 1, '4.2/storage/win7.vhd', sKind = 'Windows7', fIoApic = True, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eNic0Type = vboxcon.NetworkAdapterType_Am79C973);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Linux VMs
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if 'tst-debian-vhd' in self.asTestVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.createTestVM('tst-debian-vhd', 1, '4.2/storage/debian.vhd', sKind = 'Debian_64', fIoApic = True, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eNic0Type = vboxcon.NetworkAdapterType_Am79C973);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if 'tst-debian-vdi' in self.asTestVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.createTestVM('tst-debian-vdi', 1, '4.2/storage/debian.vdi', sKind = 'Debian_64', fIoApic = True, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eNic0Type = vboxcon.NetworkAdapterType_Am79C973);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def actionExecute(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Execute the testcase.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = self.test1();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Test execution helpers.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def test1UploadFile(self, oSession, oTxsSession):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Uploads a test file to the test machine.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('Upload file');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = self.txsUploadString(oSession, oTxsSession, self.sRndData, '${SCRATCH}/' + str(uuid.uuid4()), \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout = 3600 * 1000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone(not fRc);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def test1OneCfg(self, sVmName, eStorageController, sDiskFormat):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Runs the specified VM thru test #1.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns a success indicator on the general test execution. This is not
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync the actual test result.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.getVmByName(sVmName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # @ŧodo: Implement support for different formats.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync _ = sDiskFormat;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Reconfigure the VM
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession = self.openSession(oVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oSession is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Attach HD
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.ensureControllerAttached(_ControllerTypeToName(eStorageController));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = fRc and oSession.setStorageControllerType(eStorageController, _ControllerTypeToName(eStorageController));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = fRc and oSession.saveSettings();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.close() and fRc and True; # pychecker hack.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Start up.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.logVmInfo(oVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(sVmName, fCdWait = False, fNatForwardingForTxs = True);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oSession is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.addTask(oSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Fudge factor - Allow the guest to finish starting up.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sleep(5);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Do a snapshot first.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.takeSnapshot('Base snapshot');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(0, 10):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.takeSnapshot('Snapshot ' + str(i));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.test1UploadFile(oSession, oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync msNow = base.timestampMilli();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSnapshot = oSession.findSnapshot('Snapshot ' + str(i));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.deleteSnapshot(oSnapshot.id, cMsTimeout = 60 * 1000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync msElapsed = base.timestampMilli() - msNow;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Deleting snapshot %d took %d ms' % (i, msElapsed));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # cleanup.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.terminateVmBySession(oSession)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def test1OneVM(self, sVmName):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Runs one VM thru the various configurations.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart(sVmName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for sStorageCtrl in self.asStorageCtrls:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart(sStorageCtrl);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sStorageCtrl == 'AHCI':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eStorageCtrl = vboxcon.StorageControllerType_IntelAhci;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sStorageCtrl == 'IDE':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eStorageCtrl = vboxcon.StorageControllerType_PIIX4;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sStorageCtrl == 'LsiLogicSAS':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eStorageCtrl = vboxcon.StorageControllerType_LsiLogicSas;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sStorageCtrl == 'LsiLogic':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eStorageCtrl = vboxcon.StorageControllerType_LsiLogic;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sStorageCtrl == 'BusLogic':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eStorageCtrl = vboxcon.StorageControllerType_BusLogic;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eStorageCtrl = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for sDiskFormat in self.asDiskFormats:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('%s' % (sDiskFormat));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.test1OneCfg(sVmName, eStorageCtrl, sDiskFormat);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def test1(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Executes test #1.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Loop thru the test VMs.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for sVM in self.asTestVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # run test on the VM.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.test1OneVM(sVM):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncif __name__ == '__main__':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sys.exit(tdStorageSnapshot().main(sys.argv));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync