VirtualBox

Ignore:
Timestamp:
Jul 8, 2019 12:25:46 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131889
Message:

ValidationKit/tests/storage/tdStorageBenchmark1: Allow static configurations where we are just given a directory for testing and have no control over the disk devices

Location:
trunk/src/VBox/ValidationKit/tests/storage
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/storage/remoteexecutor.py

    r79092 r79591  
    276276        return fRc;
    277277
     278    def rmTree(self, sDir, cMsTimeout = 30000):
     279        """
     280        Recursively removes all files and sub directories including the given directory.
     281        """
     282        fRc = True;
     283        if self.oTxsSession is not None:
     284            fRc = self.oTxsSession.syncRmTree(sDir, cMsTimeout);
     285        else:
     286            fRc = self.execBinaryNoStdOut('rm', ('-rf', sDir));
     287
     288        return fRc;
  • trunk/src/VBox/ValidationKit/tests/storage/storagecfg.py

    r79092 r79591  
    409409        return oExec.execBinaryNoStdOut('zramctl', ('-r', oDisk.getPath()));
    410410
     411## @name Host disk config types.
     412## @{
     413g_ksDiskCfgStatic = 'StaticDir';
     414g_ksDiskCfgRegExp = 'RegExp';
     415g_ksDiskCfgList   = 'DiskList';
     416## @}
     417
     418class DiskCfg(object):
     419    """
     420    Host disk configuration.
     421    """
     422
     423    def __init__(self, sTargetOs, sCfgType, oDisks):
     424        self.sTargetOs = sTargetOs;
     425        self.sCfgType  = sCfgType;
     426        self.oDisks    = oDisks;
     427
     428    def getTargetOs(self):
     429        return self.sTargetOs;
     430
     431    def getCfgType(self):
     432        return self.sCfgType;
     433
     434    def isCfgStaticDir(self):
     435        return self.sCfgType == g_ksDiskCfgStatic;
     436
     437    def isCfgRegExp(self):
     438        return self.sCfgType == g_ksDiskCfgRegExp;
     439
     440    def isCfgList(self):
     441        return self.sCfgType == g_ksDiskCfgList;
     442
     443    def getDisks(self):
     444        return self.oDisks;
     445
    411446class StorageCfg(object):
    412447    """
     
    414449    """
    415450
    416     def __init__(self, oExec, sTargetOs, oDiskCfg):
     451    def __init__(self, oExec, oDiskCfg):
    417452        self.oExec    = oExec;
    418453        self.lstDisks = [ ]; # List of disks present in the system.
     
    421456        self.iPoolId  = 0;
    422457        self.iVolId   = 0;
     458        self.oDiskCfg = oDiskCfg;
    423459
    424460        fRc = True;
    425461        oStorOs = None;
    426         if sTargetOs == 'solaris':
     462        if oDiskCfg.getTargetOs() == 'solaris':
    427463            oStorOs = StorageConfigOsSolaris();
    428         elif sTargetOs == 'linux':
     464        elif oDiskCfg.getTargetOs() == 'linux':
    429465            oStorOs = StorageConfigOsLinux(); # pylint: disable=redefined-variable-type
    430         else:
     466        elif not oDiskCfg.isCfgStaticDir(): # For unknown hosts we only a static testing directory we don't care about setting up.
    431467            fRc = False;
    432468
    433469        if fRc:
    434470            self.oStorOs = oStorOs;
    435             if utils.isString(oDiskCfg):
    436                 self.lstDisks = oStorOs.getDisksMatchingRegExp(oDiskCfg);
    437             else:
     471            if oDiskCfg.isCfgRegExp():
     472                self.lstDisks = oStorOs.getDisksMatchingRegExp(oDiskCfg.getDisks());
     473            elif oDiskCfg.isCfgList():
    438474                # Assume a list of of disks and add.
    439                 for sDisk in oDiskCfg:
     475                for sDisk in oDiskCfg.getDisks():
    440476                    self.lstDisks.append(StorageDisk(sDisk));
    441477
     
    448484        """
    449485
    450         # Destroy all volumes first.
    451         for sMountPoint in self.dVols.keys(): # pylint: disable=consider-iterating-dictionary
    452             self.destroyVolume(sMountPoint);
    453 
    454         # Destroy all pools.
    455         for sPool in self.dPools.keys(): # pylint: disable=consider-iterating-dictionary
    456             self.destroyStoragePool(sPool);
     486        if not self.oDiskCfg.isCfgStaticDir():
     487            # Destroy all volumes first.
     488            for sMountPoint in self.dVols.keys(): # pylint: disable=consider-iterating-dictionary
     489                self.destroyVolume(sMountPoint);
     490
     491            # Destroy all pools.
     492            for sPool in self.dPools.keys(): # pylint: disable=consider-iterating-dictionary
     493                self.destroyStoragePool(sPool);
    457494
    458495        self.dVols.clear();
    459496        self.dPools.clear();
    460         self.iPoolId = 0;
    461         self.iVolId  = 0;
     497        self.oDiskCfg = None;
     498        self.iPoolId  = 0;
     499        self.iVolId   = 0;
    462500
    463501    def getRawDisk(self):
     
    465503        Returns a raw disk device from the list of free devices for use.
    466504        """
     505
    467506        for oDisk in self.lstDisks:
    468507            if oDisk.isUsed() is False:
     
    493532        sPool = None;
    494533
    495         if fRamDisk:
    496             oDisk = self.oStorOs.createRamDisk(self.oExec, cbPool);
    497             if oDisk is not None:
    498                 lstDisks.append(oDisk);
    499                 cDisks = 1;
    500         else:
    501             if cDisks == 0:
    502                 cDisks = self.getUnusedDiskCount();
    503 
    504             for oDisk in self.lstDisks:
    505                 if not oDisk.isUsed():
    506                     oDisk.setUsed(True);
     534        if not self.oDiskCfg.isCfgStaticDir():
     535            if fRamDisk:
     536                oDisk = self.oStorOs.createRamDisk(self.oExec, cbPool);
     537                if oDisk is not None:
    507538                    lstDisks.append(oDisk);
    508                     if len(lstDisks) == cDisks:
    509                         break;
    510 
    511         # Enough drives to satisfy the request?
    512         if len(lstDisks) == cDisks:
    513             # Create a list of all device paths
    514             lstDiskPaths = [ ];
    515             for oDisk in lstDisks:
    516                 lstDiskPaths.append(oDisk.getPath());
    517 
    518             # Find a name for the pool
    519             sPool = 'pool' + str(self.iPoolId);
    520             self.iPoolId += 1;
    521 
    522             fRc = self.oStorOs.createStoragePool(self.oExec, sPool, lstDiskPaths, sRaidLvl);
    523             if fRc:
    524                 self.dPools[sPool] = lstDisks;
     539                    cDisks = 1;
    525540            else:
    526                 self.iPoolId -= 1;
    527         else:
    528             fRc = False;
    529 
    530         # Cleanup in case of error.
    531         if not fRc:
    532             for oDisk in lstDisks:
    533                 oDisk.setUsed(False);
    534                 if oDisk.isRamDisk():
    535                     self.oStorOs.destroyRamDisk(self.oExec, oDisk);
    536 
    537         return fRc, sPool;
    538 
    539     def destroyStoragePool(self, sPool):
    540         """
    541         Destroys the storage pool with the given ID.
    542         """
    543 
    544         lstDisks = self.dPools.get(sPool);
    545         if lstDisks is not None:
    546             fRc = self.oStorOs.destroyPool(self.oExec, sPool);
    547             if fRc:
    548                 # Mark disks as unused
    549                 self.dPools.pop(sPool);
     541                if cDisks == 0:
     542                    cDisks = self.getUnusedDiskCount();
     543
     544                for oDisk in self.lstDisks:
     545                    if not oDisk.isUsed():
     546                        oDisk.setUsed(True);
     547                        lstDisks.append(oDisk);
     548                        if len(lstDisks) == cDisks:
     549                            break;
     550
     551            # Enough drives to satisfy the request?
     552            if len(lstDisks) == cDisks:
     553                # Create a list of all device paths
     554                lstDiskPaths = [ ];
     555                for oDisk in lstDisks:
     556                    lstDiskPaths.append(oDisk.getPath());
     557
     558                # Find a name for the pool
     559                sPool = 'pool' + str(self.iPoolId);
     560                self.iPoolId += 1;
     561
     562                fRc = self.oStorOs.createStoragePool(self.oExec, sPool, lstDiskPaths, sRaidLvl);
     563                if fRc:
     564                    self.dPools[sPool] = lstDisks;
     565                else:
     566                    self.iPoolId -= 1;
     567            else:
     568                fRc = False;
     569
     570            # Cleanup in case of error.
     571            if not fRc:
    550572                for oDisk in lstDisks:
    551573                    oDisk.setUsed(False);
     
    553575                        self.oStorOs.destroyRamDisk(self.oExec, oDisk);
    554576        else:
    555             fRc = False;
     577            sPool = 'StaticDummy';
     578
     579        return fRc, sPool;
     580
     581    def destroyStoragePool(self, sPool):
     582        """
     583        Destroys the storage pool with the given ID.
     584        """
     585
     586        fRc = True;
     587
     588        if not self.oDiskCfg.isCfgStaticDir():
     589            lstDisks = self.dPools.get(sPool);
     590            if lstDisks is not None:
     591                fRc = self.oStorOs.destroyPool(self.oExec, sPool);
     592                if fRc:
     593                    # Mark disks as unused
     594                    self.dPools.pop(sPool);
     595                    for oDisk in lstDisks:
     596                        oDisk.setUsed(False);
     597                        if oDisk.isRamDisk():
     598                            self.oStorOs.destroyRamDisk(self.oExec, oDisk);
     599            else:
     600                fRc = False;
    556601
    557602        return fRc;
     
    564609        fRc = True;
    565610        sMountPoint = None;
    566         if sPool in self.dPools:
    567             sVol = 'vol' + str(self.iVolId);
    568             sMountPoint = self.oStorOs.getMntBase() + '/' + sVol;
    569             self.iVolId += 1;
    570             fRc = self.oStorOs.createVolume(self.oExec, sPool, sVol, sMountPoint, cbVol);
    571             if fRc:
    572                 self.dVols[sMountPoint] = (sVol, sPool);
     611        if not self.oDiskCfg.isCfgStaticDir():
     612            if sPool in self.dPools:
     613                sVol = 'vol' + str(self.iVolId);
     614                sMountPoint = self.oStorOs.getMntBase() + '/' + sVol;
     615                self.iVolId += 1;
     616                fRc = self.oStorOs.createVolume(self.oExec, sPool, sVol, sMountPoint, cbVol);
     617                if fRc:
     618                    self.dVols[sMountPoint] = (sVol, sPool);
     619                else:
     620                    self.iVolId -= 1;
    573621            else:
    574                 self.iVolId -= 1;
    575         else:
    576             fRc = False;
     622                fRc = False;
     623        else:
     624            sMountPoint = self.oDiskCfg.getDisks();
    577625
    578626        return fRc, sMountPoint;
     
    583631        """
    584632
    585         sVol, sPool = self.dVols.get(sMountPoint);
    586         fRc = True;
    587         if sVol is not None:
    588             fRc = self.oStorOs.destroyVolume(self.oExec, sPool, sVol);
    589             if fRc:
    590                 self.dVols.pop(sMountPoint);
    591         else:
    592             fRc = False;
     633        fRc = True;
     634        if not self.oDiskCfg.isCfgStaticDir():
     635            sVol, sPool = self.dVols.get(sMountPoint);
     636            if sVol is not None:
     637                fRc = self.oStorOs.destroyVolume(self.oExec, sPool, sVol);
     638                if fRc:
     639                    self.dVols.pop(sMountPoint);
     640            else:
     641                fRc = False;
    593642
    594643        return fRc;
     
    604653        Tries to cleanup any leftover pools and volumes from a failed previous run.
    605654        """
    606         return self.oStorOs.cleanupPoolsAndVolumes(self.oExec, 'pool', 'vol');
    607 
     655        if not self.oDiskCfg.isCfgStaticDir():
     656            return self.oStorOs.cleanupPoolsAndVolumes(self.oExec, 'pool', 'vol');
     657        else:
     658            fRc = True;
     659            for sEntry in os.listdir(self.oDiskCfg.getDisks()):
     660                fRc = fRc and self.oExec.rmTree(os.path.join(self.oDiskCfg.getDisks(), sEntry));
     661
     662            return fRc;
  • trunk/src/VBox/ValidationKit/tests/storage/tdStorageBenchmark1.py

    r79092 r79591  
    395395    # Global storage configs for the testbox
    396396    kdStorageCfgs = {
    397         'testboxstor1.de.oracle.com': r'c[3-9]t\dd0\Z',
    398         'adaris': [ '/dev/sda' ]
     397        'testboxstor1.de.oracle.com': storagecfg.DiskCfg('solaris', storagecfg.g_ksDiskCfgRegExp, r'c[3-9]t\dd0\Z'),
     398        'testboxstor2.de.oracle.com': storagecfg.DiskCfg('win',     storagecfg.g_ksDiskCfgStatic, 'D:'),
     399        'adaris':                     storagecfg.DiskCfg('linux',   storagecfg.g_ksDiskCfgList,   [ '/dev/sda' ]),
     400        'daedalus':                   storagecfg.DiskCfg('darwin',  storagecfg.g_ksDiskCfgStatic, '/Volumes/VirtualBox/Testsuite/StorageScratch'),
    399401    };
    400402
     
    11621164                    lstBinaryPaths = ['/bin', '/sbin', '/usr/bin', '/usr/sbin' ];
    11631165                    oExecVm = remoteexecutor.RemoteExecutor(oTxsSession, lstBinaryPaths, '${SCRATCH}');
    1164                     oStorCfgVm = storagecfg.StorageCfg(oExecVm, 'linux', self.getGuestDisk(oSession, oTxsSession, \
    1165                                                                                            eStorageController));
     1166                    oGstDiskCfg = storagecfg.DiskCfg('linux', storagecfg.g_ksDiskCfgList, self.getGuestDisk(oSession, oTxsSession, eStorageController));
     1167                    oStorCfgVm = storagecfg.StorageCfg(oExecVm, oGstDiskCfg);
    11661168
    11671169                    iTry = 0;
     
    12741276            oExecutor = remoteexecutor.RemoteExecutor(None, lstBinaryPaths, self.sScratchPath);
    12751277            if not self.fUseScratch:
    1276                 self.oStorCfg = storagecfg.StorageCfg(oExecutor, utils.getHostOs(), oDiskCfg);
     1278                self.oStorCfg = storagecfg.StorageCfg(oExecutor, oDiskCfg);
    12771279
    12781280                # Try to cleanup any leftovers from a previous run first.
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette