cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# -*- coding: utf-8 -*-
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox Validation Kit - Storage snapshotting and merging testcase.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCopyright (C) 2013 Oracle Corporation
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.
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.
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# Standard Python imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Only the main script needs to modify the path.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncg_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Validation Kit imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Translate a controller type to a name. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if eControllerType == vboxcon.StorageControllerType_PIIX3 or eControllerType == vboxcon.StorageControllerType_PIIX4:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif eControllerType == vboxcon.StorageControllerType_IntelAhci:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif eControllerType == vboxcon.StorageControllerType_LsiLogicSas:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif eControllerType == vboxcon.StorageControllerType_LsiLogic or eControllerType == vboxcon.StorageControllerType_BusLogic:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass tdStorageSnapshot(vbox.TestDriver): # pylint: disable=R0902
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Storage benchmark.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asTestVMsDef = ['tst-win7-vhd', 'tst-debian-vhd', 'tst-debian-vdi'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asStorageCtrlsDef = ['AHCI', 'IDE', 'LsiLogicSAS', 'LsiLogic', 'BusLogic'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asDiskFormatsDef = ['VDI', 'VMDK', 'VHD', 'QED', 'Parallels', 'QCOW', 'iSCSI'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Overridden methods.
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 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 the specified VMs when testing.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def parseOption(self, asArgs, iArg): # pylint: disable=R0912,R0915
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--storage-ctrls" takes a colon separated list of Storage controller types');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs): raise base.InvalidOption('The "--disk-formats" takes a colon separated list of disk formats');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs): raise base.InvalidOption('The "--test-vms" takes colon separated list');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--test-vms" value "%s" is not valid; valid values are: %s' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs): raise base.InvalidOption('The "--skip-vms" takes colon separated list');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return vbox.TestDriver.parseOption(self, asArgs, iArg);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Remove skipped VMs from the test list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Construct the resource list the first time it's queried.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Make sure vboxapi has been imported so we can use the constants.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Configure the VMs we're going to use.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Windows VMs
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.createTestVM('tst-win7-vhd', 1, '4.2/storage/win7.vhd', sKind = 'Windows7', fIoApic = True, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Linux VMs
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.createTestVM('tst-debian-vhd', 1, '4.2/storage/debian.vhd', sKind = 'Debian_64', fIoApic = True, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.createTestVM('tst-debian-vdi', 1, '4.2/storage/debian.vdi', sKind = 'Debian_64', fIoApic = True, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eNic0AttachType = vboxcon.NetworkAttachmentType_NAT, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Execute the testcase.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Test execution helpers.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Uploads a test file to the test machine.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = self.txsUploadString(oSession, oTxsSession, self.sRndData, '${SCRATCH}/' + str(uuid.uuid4()), \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def test1OneCfg(self, sVmName, eStorageController, sDiskFormat):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Runs the specified VM thru test #1.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns a success indicator on the general test execution. This is not
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync the actual test result.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # @ŧodo: Implement support for different formats.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Reconfigure the VM
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 = oSession.close() and fRc and True; # pychecker hack.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Start up.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(sVmName, fCdWait = False, fNatForwardingForTxs = True);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oSession is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Fudge factor - Allow the guest to finish starting up.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Do a snapshot first.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSnapshot = oSession.findSnapshot('Snapshot ' + str(i));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.deleteSnapshot(oSnapshot.id, cMsTimeout = 60 * 1000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Deleting snapshot %d took %d ms' % (i, msElapsed));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Runs one VM thru the various configurations.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eStorageCtrl = vboxcon.StorageControllerType_IntelAhci;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eStorageCtrl = vboxcon.StorageControllerType_PIIX4;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eStorageCtrl = vboxcon.StorageControllerType_LsiLogicSas;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eStorageCtrl = vboxcon.StorageControllerType_LsiLogic;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eStorageCtrl = vboxcon.StorageControllerType_BusLogic;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.test1OneCfg(sVmName, eStorageCtrl, sDiskFormat);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Executes test #1.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Loop thru the test VMs.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # run test on the VM.