VirtualBox

Changeset 100078 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Jun 6, 2023 5:15:22 AM (21 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
157767
Message:

Main/src-server and Storage: Immutable media handling flexibility added bugref:5995

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/api/tdCloneMedium1.py

    r99235 r100078  
    246246        return True
    247247
     248    def testCloneToBase(self):
     249        """
     250        Tests cloning diff to base
     251        """
     252
     253        reporter.testStart("testCloneToBase")
     254
     255        try:
     256            oVBox = self.oTstDrv.oVBoxMgr.getVirtualBox()
     257            oVM = self.oTstDrv.createTestVM('test-medium-clone-base', 1, None, 4)
     258            assert oVM is not None
     259
     260            fRc = True
     261            oSession = self.oTstDrv.openSession(oVM)
     262            cImages = 10
     263            reporter.log('Creating chain with %d disk images' % (cImages))
     264            sHddPath = os.path.join(self.oTstDrv.sScratchPath, 'CloneTest1.vdi')
     265            hd1 = oSession.createBaseHd(sHddPath, cb=1024*1024)
     266            if hd1 is None:
     267                    fRc = False
     268            for i in range(2, cImages + 1):
     269                sHddPath = os.path.join(self.oTstDrv.sScratchPath, 'CloneTest' + str(i) + '.vdi')
     270                if i == 2:
     271                    oHd = oSession.createDiffHd(hd1, sHddPath)
     272                    hd2 = oHd
     273                else:
     274                    oHd = oSession.createDiffHd(oHd, sHddPath)
     275                if oHd is None:
     276                    fRc = False
     277                    break
     278
     279
     280            # modify the VM config, attach HDD
     281            sController='SATA Controller'
     282            fRc = fRc and oSession.attachHd(sHddPath, sController, fImmutable=False, fForceResource=False)
     283            fRc = fRc and oSession.saveSettings()
     284
     285            try:
     286                oProgressCom = oHd.cloneTo(hd1, (vboxcon.MediumVariant_Standard, ), None);
     287            except:
     288                reporter.errorXcpt('failed to clone medium %s to %s' % (oHd.name, hd1.name));
     289                return False;
     290            oProgress = vboxwrappers.ProgressWrapper(oProgressCom, self.oTstDrv.oVBoxMgr, self.oTstDrv,
     291                                                     'clone disk %s to base disk %s' % (oHd.name, hd1.name));
     292            oProgress.wait(cMsTimeout = 15*60*1000); # 15 min
     293            oProgress.logResult();
     294
     295            fRc = oSession.close() and fRc
     296            self.deleteVM(oVM)
     297
     298        except:
     299            reporter.errorXcpt()
     300
     301        return reporter.testDone()[1] == 0
     302
    248303    def testAll(self):
    249         return self.testCloneOnly() & self.testResizeAndClone()
     304        return self.testCloneOnly() & self.testResizeAndClone() & self.testCloneToBase()
    250305
    251306if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.

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