def test1(self): """ Executes test #1. """ fRc = True oDiskCfg = self.kdStorageCfgs.get(socket.gethostname().lower()) # Test the host first if requested if oDiskCfg is not None or self.fUseScratch: lstBinaryPaths = ['/bin', '/sbin', '/usr/bin', '/usr/sbin', \ '/opt/csw/bin', '/usr/ccs/bin', '/usr/sfw/bin'] oExecutor = remoteexecutor.RemoteExecutor(None, lstBinaryPaths, self.sScratchPath) if not self.fUseScratch: self.oStorCfg = storagecfg.StorageCfg(oExecutor, utils.getHostOs(), oDiskCfg) # Try to cleanup any leftovers from a previous run first. fRc = self.oStorCfg.cleanupLeftovers() if not fRc: reporter.error( 'Failed to cleanup any leftovers from a previous run') if self.fTestHost: reporter.testStart('Host') if self.fUseScratch: sMountPoint = self.sScratchPath else: sMountPoint = self.prepareStorage(self.oStorCfg) if sMountPoint is not None: for sIoTest in self.asTests: reporter.testStart(sIoTest) for sTestSet in self.asTestSets: reporter.testStart(sTestSet) dTestSet = self.kdTestSets.get(sTestSet) self.testBenchmark(utils.getHostOs(), sIoTest, sMountPoint, oExecutor, dTestSet) reporter.testDone() reporter.testDone() self.cleanupStorage(self.oStorCfg) else: reporter.testFailure('Failed to prepare host storage') fRc = False reporter.testDone() else: # Create the storage space first if it is not done before every test. sMountPoint = None if self.fUseScratch: sMountPoint = self.sScratchPath elif not self.fRecreateStorCfg: reporter.testStart('Create host storage') sMountPoint = self.prepareStorage(self.oStorCfg) if sMountPoint is None: reporter.testFailure('Failed to prepare host storage') fRc = False self.oStorCfg.mkDirOnVolume(sMountPoint, 'test', 0777) sMountPoint = sMountPoint + '/test' reporter.testDone() if fRc: # Run the storage tests. if not self.testStorage(sMountPoint): fRc = False if not self.fRecreateStorCfg: self.cleanupStorage(self.oStorCfg) else: fRc = False return fRc
def testOneCfg( self, sVmName, eStorageController, sHostIoCache, sDiskFormat, # pylint: disable=R0913,R0915 sDiskVariant, sDiskPath, cCpus, sIoTest, sVirtMode, sTestSet): """ Runs the specified VM thru test #1. Returns a success indicator on the general test execution. This is not the actual test result. """ oVM = self.getVmByName(sVmName) dTestSet = self.kdTestSets.get(sTestSet) cbDisk = dTestSet.get('DiskSizeGb') * 1024 * 1024 * 1024 fHwVirt = sVirtMode != 'raw' fNestedPaging = sVirtMode == 'hwvirt-np' fRc = True if sDiskFormat == 'iSCSI': sDiskPath = self.asIscsiTargets[0] elif self.fUseScratch: sDiskPath = self.sScratchPath else: # If requested recreate the storage space to start with a clean config # for benchmarks if self.fRecreateStorCfg: sMountPoint = self.prepareStorage(self.oStorCfg) if sMountPoint is not None: # Create a directory where every normal user can write to. self.oStorCfg.mkDirOnVolume(sMountPoint, 'test', 0777) sDiskPath = sMountPoint + '/test' else: fRc = False reporter.testFailure('Failed to prepare storage for VM') if not fRc: return fRc lstDisks = [] # List of disks we have to delete afterwards. for iDiffLvl in range(self.cDiffLvls + 1): if iDiffLvl == 0: reporter.testStart('Base') else: reporter.testStart('Diff %u' % (iDiffLvl)) # Reconfigure the VM oSession = self.openSession(oVM) if oSession is not None: # Attach HD fRc = oSession.ensureControllerAttached( _ControllerTypeToName(eStorageController)) fRc = fRc and oSession.setStorageControllerType( eStorageController, _ControllerTypeToName(eStorageController)) if sHostIoCache == 'hostiocache': fRc = fRc and oSession.setStorageControllerHostIoCache( _ControllerTypeToName(eStorageController), True) elif sHostIoCache == 'no-hostiocache': fRc = fRc and oSession.setStorageControllerHostIoCache( _ControllerTypeToName(eStorageController), False) iDevice = 0 if eStorageController == vboxcon.StorageControllerType_PIIX3 or \ eStorageController == vboxcon.StorageControllerType_PIIX4: iDevice = 1 # Master is for the OS. oHdParent = None if iDiffLvl > 0: oHdParent = lstDisks[0] oHd = self.createHd(oSession, sDiskFormat, sDiskVariant, iDiffLvl, oHdParent, sDiskPath, cbDisk) if oHd is not None: lstDisks.insert(0, oHd) try: if oSession.fpApiVer >= 4.0: oSession.o.machine.attachDevice(_ControllerTypeToName(eStorageController), \ 0, iDevice, vboxcon.DeviceType_HardDisk, oHd) else: oSession.o.machine.attachDevice(_ControllerTypeToName(eStorageController), \ 0, iDevice, vboxcon.DeviceType_HardDisk, oHd.id) except: reporter.errorXcpt('attachDevice("%s",%s,%s,HardDisk,"%s") failed on "%s"' \ % (_ControllerTypeToName(eStorageController), 1, 0, oHd.id, oSession.sName) ) fRc = False else: reporter.log('attached "%s" to %s' % (sDiskPath, oSession.sName)) else: fRc = False fRc = fRc and oSession.enableVirtEx(fHwVirt) fRc = fRc and oSession.enableNestedPaging(fNestedPaging) fRc = fRc and oSession.setCpuCount(cCpus) fRc = fRc and oSession.saveSettings() fRc = oSession.close() and fRc and True # pychecker hack. oSession = None else: fRc = False # Start up. if fRc is True: self.logVmInfo(oVM) oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp( sVmName, fCdWait=False, fNatForwardingForTxs=True) if oSession is not None: self.addTask(oSession) # Fudge factor - Allow the guest to finish starting up. self.sleep(5) # Prepare the storage on the guest lstBinaryPaths = [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ] oExecVm = remoteexecutor.RemoteExecutor( oTxsSession, lstBinaryPaths, '${SCRATCH}') oStorCfgVm = storagecfg.StorageCfg(oExecVm, 'linux', self.getGuestDisk(oSession, oTxsSession, \ eStorageController)) sMountPoint = self.prepareStorage(oStorCfgVm) if sMountPoint is not None: self.testBenchmark('linux', sIoTest, sMountPoint, oExecVm, dTestSet) self.cleanupStorage(oStorCfgVm) else: reporter.testFailure( 'Failed to prepare storage for the guest benchmark' ) # cleanup. self.removeTask(oTxsSession) self.terminateVmBySession(oSession) else: fRc = False # Remove disk oSession = self.openSession(oVM) if oSession is not None: try: oSession.o.machine.detachDevice( _ControllerTypeToName(eStorageController), 0, iDevice) # Remove storage controller if it is not an IDE controller. if eStorageController is not vboxcon.StorageControllerType_PIIX3 \ and eStorageController is not vboxcon.StorageControllerType_PIIX4: oSession.o.machine.removeStorageController( _ControllerTypeToName(eStorageController)) oSession.saveSettings() oSession.saveSettings() oSession.close() oSession = None except: reporter.errorXcpt( 'failed to detach/delete disk %s from storage controller' % (sDiskPath)) else: fRc = False reporter.testDone() # Delete all disks for oHd in lstDisks: self.oVBox.deleteHdByMedium(oHd) # Cleanup storage area if sDiskFormat != 'iSCSI' and not self.fUseScratch and self.fRecreateStorCfg: self.cleanupStorage(self.oStorCfg) return fRc
def testOneCfg(self, sVmName, eStorageController, sDiskFormat, sDiskVariant, # pylint: disable=R0913 sDiskPath, cCpus, sIoTest, sVirtMode, sTestSet): """ Runs the specified VM thru test #1. Returns a success indicator on the general test execution. This is not the actual test result. """ oVM = self.getVmByName(sVmName); dTestSet = self.kdTestSets.get(sTestSet); cbDisk = dTestSet.get('DiskSizeGb') * 1024*1024*1024; fHwVirt = sVirtMode != 'raw'; fNestedPaging = sVirtMode == 'hwvirt-np'; fRc = True; if sDiskFormat == 'iSCSI': sDiskPath = self.asIscsiTargets[0]; elif self.fUseScratch: sDiskPath = self.sScratchPath; else: # If requested recreate the storage space to start with a clean config # for benchmarks if self.fRecreateStorCfg: sMountPoint = self.prepareStorage(self.oStorCfg); if sMountPoint is not None: # Create a directory where every normal user can write to. self.oStorCfg.mkDirOnVolume(sMountPoint, 'test', 0777); sDiskPath = sMountPoint + '/test'; else: fRc = False; reporter.testFailure('Failed to prepare storage for VM'); if not fRc: return fRc; # Reconfigure the VM oSession = self.openSession(oVM); if oSession is not None: # Attach HD fRc = oSession.ensureControllerAttached(_ControllerTypeToName(eStorageController)); fRc = fRc and oSession.setStorageControllerType(eStorageController, _ControllerTypeToName(eStorageController)); iDevice = 0; if eStorageController == vboxcon.StorageControllerType_PIIX3 or \ eStorageController == vboxcon.StorageControllerType_PIIX4: iDevice = 1; # Master is for the OS. if sDiskFormat == "iSCSI": listNames = []; listValues = []; listValues = self.asIscsiTargets[0].split('|'); listNames.append('TargetAddress'); listNames.append('TargetName'); listNames.append('LUN'); if self.fpApiVer >= 5.0: oHd = oSession.oVBox.createMedium(sDiskFormat, sDiskPath, vboxcon.AccessMode_ReadWrite, \ vboxcon.DeviceType_HardDisk); else: oHd = oSession.oVBox.createHardDisk(sDiskFormat, sDiskPath); oHd.type = vboxcon.MediumType_Normal; oHd.setProperties(listNames, listValues); # Attach it. if fRc is True: try: if oSession.fpApiVer >= 4.0: oSession.o.machine.attachDevice(_ControllerTypeToName(eStorageController), \ 0, iDevice, vboxcon.DeviceType_HardDisk, oHd); else: oSession.o.machine.attachDevice(_ControllerTypeToName(eStorageController), \ 0, iDevice, vboxcon.DeviceType_HardDisk, oHd.id); except: reporter.errorXcpt('attachDevice("%s",%s,%s,HardDisk,"%s") failed on "%s"' \ % (_ControllerTypeToName(eStorageController), 1, 0, oHd.id, oSession.sName) ); fRc = False; else: reporter.log('attached "%s" to %s' % (sDiskPath, oSession.sName)); else: tMediumVariant = self.convDiskToMediumVariant(sDiskVariant); fRc = fRc and oSession.createAndAttachHd(sDiskPath + '/test.disk', sDiskFormat, \ _ControllerTypeToName(eStorageController), \ cb = cbDisk, iPort = 0, iDevice = iDevice, \ fImmutable = False, cMsTimeout = 3600 * 1000, \ tMediumVariant = tMediumVariant); fRc = fRc and oSession.enableVirtEx(fHwVirt); fRc = fRc and oSession.enableNestedPaging(fNestedPaging); fRc = fRc and oSession.setCpuCount(cCpus); fRc = fRc and oSession.saveSettings(); fRc = oSession.close() and fRc and True; # pychecker hack. oSession = None; else: fRc = False; # Start up. if fRc is True: self.logVmInfo(oVM); oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(sVmName, fCdWait = False, fNatForwardingForTxs = True); if oSession is not None: self.addTask(oSession); # Fudge factor - Allow the guest to finish starting up. self.sleep(5); # Prepare the storage on the guest lstBinaryPaths = ['/bin', '/sbin', '/usr/bin', '/usr/sbin' ]; oExecVm = remoteexecutor.RemoteExecutor(oTxsSession, lstBinaryPaths, '${SCRATCH}'); oStorCfgVm = storagecfg.StorageCfg(oExecVm, 'linux', self.getGuestDisk(oSession, oTxsSession, \ eStorageController)); sMountPoint = self.prepareStorage(oStorCfgVm); if sMountPoint is not None: self.testBenchmark('linux', sIoTest, sMountPoint, oExecVm, dTestSet); self.cleanupStorage(oStorCfgVm); else: reporter.testFailure('Failed to prepare storage for the guest benchmark'); # cleanup. self.removeTask(oTxsSession); self.terminateVmBySession(oSession) else: fRc = False; # Remove disk oSession = self.openSession(oVM); if oSession is not None: try: oSession.o.machine.detachDevice(_ControllerTypeToName(eStorageController), 0, iDevice); # Remove storage controller if it is not an IDE controller. if eStorageController is not vboxcon.StorageControllerType_PIIX3 \ and eStorageController is not vboxcon.StorageControllerType_PIIX4: oSession.o.machine.removeStorageController(_ControllerTypeToName(eStorageController)); oSession.saveSettings(); self.oVBox.deleteHdByLocation(sDiskPath + '/test.disk'); oSession.saveSettings(); oSession.close(); oSession = None; except: reporter.errorXcpt('failed to detach/delete disk %s from storage controller' % (sDiskPath)); else: fRc = False; # Cleanup storage area if sDiskFormat != 'iSCSI' and not self.fUseScratch and self.fRecreateStorCfg: self.cleanupStorage(self.oStorCfg); return fRc;