VirtualBox

Ignore:
Timestamp:
Jun 9, 2019 8:55:56 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131214
Message:

ValKit/tdGuestOsUnattendedInst1: Added option for installing guest additions and implemented waiting for them to come online. bugref:9151

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/installation/tdGuestOsUnattendedInst1.py

    r79046 r79056  
    7777        self.fOptIoApic     = None;
    7878        self.fOptPae        = None;
     79        self.fOptInstallGAs = False;
    7980        self.asOptExtraData = [];
    8081        if fFlags & self.kfIdeIrqDelay:
    8182            self.asOptExtraData = self.kasIdeIrqDelay;
     83
     84    def _unattendedConfigure(self, oIUnattended, oTestDrv): # type: (Any, vbox.TestDriver) -> bool
     85        """
     86        Configures the unattended install object.
     87
     88        The ISO attribute has been set and detectIsoOS has been done, the rest of the
     89        setup is done here.
     90
     91        Returns True on success, False w/ errors logged on failure.
     92        """
     93
     94        #
     95        # Make it install the TXS.
     96        #
     97        try:    oIUnattended.installTestExecService = True;
     98        except: return reporter.errorXcpt();
     99        try:    oIUnattended.validationKitIsoPath   = oTestDrv.sVBoxValidationKitIso;
     100        except: return reporter.errorXcpt();
     101        oTestDrv.processPendingEvents();
     102
     103        #
     104        # Install GAs?
     105        #
     106        if self.fOptInstallGAs:
     107            try:    oIUnattended.installGuestAdditions = True;
     108            except: return reporter.errorXcpt();
     109            try:    oIUnattended.additionsIsoPath      = oTestDrv.getGuestAdditionsIso();
     110            except: return reporter.errorXcpt();
     111            oTestDrv.processPendingEvents();
     112
     113        return True;
     114
     115    def _unattendedDoIt(self, oIUnattended, oVM, oTestDrv): # type: (Any, Any, vbox.TestDriver) -> bool
     116        """
     117        Does the unattended installation preparing, media construction and VM reconfiguration.
     118
     119        Returns True on success, False w/ errors logged on failure.
     120        """
     121
     122        # Associate oVM with the installer:
     123        try:
     124            oIUnattended.machine = oVM;
     125        except:
     126            return reporter.errorXcpt();
     127        oTestDrv.processPendingEvents();
     128
     129        # Prepare and log it:
     130        try:
     131            oIUnattended.prepare();
     132        except:
     133            return reporter.errorXcpt("IUnattended.prepare failed");
     134        oTestDrv.processPendingEvents();
     135
     136        reporter.log('IUnattended attributes after prepare():');
     137        self._unattendedLogIt(oIUnattended, oTestDrv);
     138
     139        # Create media:
     140        try:
     141            oIUnattended.constructMedia();
     142        except:
     143            return reporter.errorXcpt("IUnattended.constructMedia failed");
     144        oTestDrv.processPendingEvents();
     145
     146        # Reconfigure the VM:
     147        try:
     148            oIUnattended.reconfigureVM();
     149        except:
     150            return reporter.errorXcpt("IUnattended.reconfigureVM failed");
     151        oTestDrv.processPendingEvents();
     152
     153        return True;
     154
     155    def _unattendedLogIt(self, oIUnattended, oTestDrv):
     156        """
     157        Logs the attributes of the unattended installation object.
     158        """
     159        fRc = True;
     160        asAttribs = ( 'isoPath', 'user', 'password', 'fullUserName', 'productKey', 'additionsIsoPath', 'installGuestAdditions',
     161                      'validationKitIsoPath', 'installTestExecService', 'timeZone', 'locale', 'language', 'country', 'proxy',
     162                      'packageSelectionAdjustments', 'hostname', 'auxiliaryBasePath', 'imageIndex', 'machine',
     163                      'scriptTemplatePath', 'postInstallScriptTemplatePath', 'postInstallCommand',
     164                      'extraInstallKernelParameters', 'detectedOSTypeId', 'detectedOSVersion', 'detectedOSLanguages',
     165                      'detectedOSFlavor', 'detectedOSHints', );
     166        for sAttrib in asAttribs:
     167            try:
     168                oValue = getattr(oIUnattended, sAttrib);
     169            except:
     170                fRc = reporter.errorXcpt('sAttrib=%s' % sAttrib);
     171            else:
     172                reporter.log('%s: %s' % (sAttrib.rjust(32), oValue,));
     173                oTestDrv.processPendingEvents();
     174        return fRc;
    82175
    83176
     
    172265        return (fRc, oVM)
    173266
     267    def isLoggedOntoDesktop(self):
     268        #
     269        # Normally all unattended installations should end up on the desktop.
     270        # An exception is a minimal install, but we currently don't support that.
     271        #
     272        return True;
     273
    174274    #
    175275    # Our methods.
     
    226326
    227327        return True;
    228 
    229     def _unattendedConfigure(self, oIUnattended, oTestDrv): # type: (Any, vbox.TestDriver) -> bool
    230         """
    231         Configures the unattended install object.
    232 
    233         The ISO attribute has been set and detectIsoOS has been done, the rest of the
    234         setup is done here.
    235 
    236         Returns True on success, False w/ errors logged on failure.
    237         """
    238 
    239         #
    240         # Make it install the TXS.
    241         #
    242         try:    oIUnattended.installTestExecService = True;
    243         except: return reporter.errorXcpt();
    244         try:    oIUnattended.validationKitIsoPath = oTestDrv.sVBoxValidationKitIso;
    245         except: return reporter.errorXcpt();
    246 
    247         return True;
    248 
    249     def _unattendedDoIt(self, oIUnattended, oVM, oTestDrv): # type: (Any, Any, vbox.TestDriver) -> bool
    250         """
    251         Does the unattended installation preparing, media construction and VM reconfiguration.
    252 
    253         Returns True on success, False w/ errors logged on failure.
    254         """
    255 
    256         # Associate oVM with the installer:
    257         try:
    258             oIUnattended.machine = oVM;
    259         except:
    260             return reporter.errorXcpt();
    261         oTestDrv.processPendingEvents();
    262 
    263         # Prepare:
    264         try:
    265             oIUnattended.prepare();
    266         except:
    267             return reporter.errorXcpt("IUnattended.prepare failed");
    268         oTestDrv.processPendingEvents();
    269 
    270         # Create media:
    271         try:
    272             oIUnattended.constructMedia();
    273         except:
    274             return reporter.errorXcpt("IUnattended.constructMedia failed");
    275         oTestDrv.processPendingEvents();
    276 
    277         # Reconfigure the VM:
    278         try:
    279             oIUnattended.reconfigureVM();
    280         except:
    281             return reporter.errorXcpt("IUnattended.reconfigureVM failed");
    282         oTestDrv.processPendingEvents();
    283 
    284         return True;
    285 
    286     def _unattendedLogIt(self, oIUnattended):
    287         """
    288         Logs the attributes of the unattended installation object.
    289         """
    290         fRc = True;
    291         asAttribs = ( 'isoPath', 'user', 'password ', 'fullUserName', 'productKey', 'additionsIsoPath', 'installGuestAdditions',
    292                       'validationKitIsoPath', 'installTestExecService', 'timeZone', 'locale', 'language', 'country', 'proxy',
    293                       'packageSelectionAdjustments', 'hostname', 'auxiliaryBasePath', 'imageIndex', 'machine',
    294                       'scriptTemplatePath', 'postInstallScriptTemplatePath', 'postInstallCommand',
    295                       'extraInstallKernelParameters', 'detectedOSTypeId', 'detectedOSVersion', 'detectedOSLanguages',
    296                       'detectedOSFlavor', 'detectedOSHints', );
    297         for sAttrib in asAttribs:
    298             try:
    299                 oValue = getattr(oIUnattended, sAttrib);
    300             except:
    301                 fRc = reporter.errorXcpt('sAttrib=%s' % sAttrib);
    302             else:
    303                 reporter.log('%s: %s' % (sAttrib.rjust(32), oValue,));
    304         return fRc;
    305328
    306329
     
    441464            for oTestVm in self.aoSelectedVms:
    442465                oTestVm.fOptPae = False;
     466        elif asArgs[iArg] == '--install-additions':
     467            for oTestVm in self.aoSelectedVms:
     468                oTestVm.fOptInstallGAs = True;
     469        elif asArgs[iArg] == '--no-install-additions':
     470            for oTestVm in self.aoSelectedVms:
     471                oTestVm.fOptInstallGAs = False;
    443472        else:
    444473            return vbox.TestDriver.parseOption(self, asArgs, iArg);
     
    456485        return self.oTestVmSet.actionExecute(self, self.testOneVmConfig)
    457486
    458     def testOneVmConfig(self, oVM, oTestVm):
     487    def testOneVmConfig(self, oVM, oTestVm): # type: (Any, UnattendedVm) -> bool
    459488        """
    460489        Install guest OS and wait for result
     
    462491
    463492        self.logVmInfo(oVM)
    464         reporter.testStart('Installing %s' % (oTestVm.sVmName,))
     493        reporter.testStart('Installing %s%s' % (oTestVm.sVmName, ' with GAs' if oTestVm.fOptInstallGAs else ''))
    465494
    466495        cMsTimeout = 40*60000;
     
    469498
    470499        oSession, _ = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = False, cMsTimeout = cMsTimeout);
     500        #oSession = self.startVmByName(oTestVm.sVmName); # (for quickly testing waitForGAs)
    471501        if oSession is not None:
    472             # The guest has connected to TXS, so we're done (for now anyways).
    473             reporter.log('Guest reported success')
    474             ## @todo Do save + restore.
     502            # The guest has connected to TXS.
     503            reporter.log('Guest reported success via TXS.');
     504            #reporter.log('VM started...');              # (for quickly testing waitForGAs)
     505
     506            # If we're installing GAs, wait for them to come online:
     507            fRc = True;
     508            if oTestVm.fOptInstallGAs:
     509                aenmRunLevels = [vboxcon.AdditionsRunLevelType_Userland,];
     510                if oTestVm.isLoggedOntoDesktop():
     511                    aenmRunLevels.append(vboxcon.AdditionsRunLevelType_Desktop);
     512                fRc = self.waitForGAs(oSession, cMsTimeout = cMsTimeout / 2, aenmWaitForRunLevels = aenmRunLevels);
     513
     514            # Now do a save & restore test:
     515            if fRc is True:
     516                pass; ## @todo Do save + restore.
     517
     518            # Test GAs if requested:
     519            if oTestVm.fOptInstallGAs and fRc is True:
     520                pass;
    475521
    476522            reporter.testDone()
    477             fRc = self.terminateVmBySession(oSession)
     523            fRc = self.terminateVmBySession(oSession) and fRc;
    478524            return fRc is True
    479525
    480526        reporter.error('Installation of %s has failed' % (oTestVm.sVmName,))
    481         oTestVm.detatchAndDeleteHd(self); # Save space.
     527        #oTestVm.detatchAndDeleteHd(self); # Save space.
    482528        reporter.testDone()
    483529        return False
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