VirtualBox

Changeset 61283 in vbox for trunk/src


Ignore:
Timestamp:
May 29, 2016 9:06:04 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
107575
Message:

virtual test sheriff: fixes to bad-testbox management. now partially tested.

Location:
trunk/src/VBox/ValidationKit/testmanager
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/batch/virtual_test_sheriff.py

    r61282 r61283  
    7373        self.oLogin = None;
    7474        self.uidSelf = -1;
     75        self.oLogFile = None;
    7576
    7677        oParser = OptionParser();
    77         oParser.add_option('--start-hours-ago', dest = 'cStartHoursAgo', metavar = '<hours>', default = 0,
     78        oParser.add_option('--start-hours-ago', dest = 'cStartHoursAgo', metavar = '<hours>', default = 0, type = 'int',
    7879                           help = 'When to start specified as hours relative to current time.  Defauls is right now.', );
    79         oParser.add_option('--hours-period', dest = 'cPeriodInHours', metavar = '<period-in-hours>', default = 2,
     80        oParser.add_option('--hours-period', dest = 'cHoursBack', metavar = '<period-in-hours>', default = 2, type = 'int',
    8081                           help = 'Work period specified in hours.  Defauls is 2 hours.');
    8182        oParser.add_option('--real-run-back', dest = 'fRealRun', action = 'store_true', default = False,
     
    8384        oParser.add_option('-q', '--quiet', dest = 'fQuiet', action = 'store_true', default = False,
    8485                           help = 'Quiet execution');
    85         oParser.add_option('-l', '--log', dest = 'sBuildLogPath', metavar = '<url>',
     86        oParser.add_option('-l', '--log', dest = 'sBuildLogPath', metavar = '<url>', default = None,
    8687                           help = 'URL to the build logs (optional).');
    8788        oParser.add_option('--debug', dest = 'fDebug', action = 'store_true', default = False,
     
    9091        (self.oConfig, _) = oParser.parse_args();
    9192
     93        if self.oConfig.sBuildLogPath is not None and len(self.oConfig.sBuildLogPath) > 0:
     94            self.oLogFile = open(self.oConfig.sBuildLogPath, "a");
     95            self.oLogFile.write('VirtualTestSheriff: $Revision$ \n');
     96
     97
    9298    def eprint(self, sText):
    9399        """
     
    96102        """
    97103        print 'error: %s' % (sText,);
     104        if self.oLogFile is not None:
     105            self.oLogFile.write('error: %s\n' % (sText,));
    98106        return 1;
    99107
     
    102110        Prints debug info.
    103111        """
    104         if not self.oConfig.fDebug:
    105             print 'debug: %s' % (sText, );
     112        if self.oConfig.fDebug:
     113            if not self.oConfig.fQuiet:
     114                print 'debug: %s' % (sText, );
     115            if self.oLogFile is not None:
     116                self.oLogFile.write('debug: %s\n' % (sText,));
    106117        return 0;
    107118
     
    112123        if not self.oConfig.fQuiet:
    113124            print 'info: %s' % (sText,);
     125        if self.oLogFile is not None:
     126            self.oLogFile.write('info: %s\n' % (sText,));
    114127        return 0;
    115128
     
    127140          and (not self.oConfig.fDebug or self.oConfig.fRealRun):
    128141            return rcExit;
    129         tsNow = self.oConfig.tsNow if self.oConfig.fDebug else None;
     142        tsNow      = self.tsNow              if self.oConfig.fDebug else None;
     143        cHoursBack = self.oConfig.cHoursBack if self.oConfig.fDebug else 2;
    130144        oTestBoxLogic = TestBoxLogic(self.oDb);
    131145
     
    133147        # Get list of bad test boxes for given period and check them out individually.
    134148        #
    135         aidBadTestBoxes = self.oTestSetLogic.fetchBadTestBoxIds();
     149        aidBadTestBoxes = self.oTestSetLogic.fetchBadTestBoxIds(cHoursBack = cHoursBack, tsNow = tsNow);
    136150        for idTestBox in aidBadTestBoxes:
    137151            # Skip if the testbox is already disabled or has a pending reboot command.
     
    151165
    152166            # Get the most recent testsets for this box (descending on tsDone) and see how bad it is.
    153             aoSets  = self.oTestSetLogic.fetchResultForTestBox(idTestBox, cHoursBack = 2, tsNow = tsNow);
     167            aoSets  = self.oTestSetLogic.fetchResultForTestBox(idTestBox, cHoursBack = cHoursBack, tsNow = tsNow);
    154168            cOkay      = 0;
    155169            cBad       = 0;
     
    160174                else:
    161175                    ## @todo maybe check the elapsed time here, it could still be a bad run.
    162                     iFirstOkay = iSet;
    163176                    cOkay += 1;
     177                    if iFirstOkay > iSet:
     178                        iFirstOkay = iSet;
    164179                if iSet > 10:
    165180                    break;
     
    168183            # history and at least three in the last 10 results.
    169184            if iFirstOkay >= 2 and cBad > 2:
    170                 if oTestBoxLogic.hasTestBoxRecentlyBeenRebooted(idTestBox, cHoursBack = 2, tsNow = tsNow):
     185                if oTestBoxLogic.hasTestBoxRecentlyBeenRebooted(idTestBox, cHoursBack = cHoursBack, tsNow = tsNow):
    171186                    self.vprint('Disabling testbox #%u (%s) - iFirstOkay=%u cBad=%u cOkay=%u'
    172187                                % ( idTestBox, oTestBox.sName, iFirstOkay, cBad, cOkay));
    173                     if self.oConfig.fRealRun:
     188                    if self.oConfig.fRealRun is True:
    174189                        try:
    175190                            oTestBoxLogic.disableTestBox(idTestBox, self.uidSelf, fCommit = True,
     
    181196                    self.vprint('Rebooting testbox #%u (%s) - iFirstOkay=%u cBad=%u cOkay=%u'
    182197                                % ( idTestBox, oTestBox.sName, iFirstOkay, cBad, cOkay));
    183                     if self.oConfig.fRealRun:
     198                    if self.oConfig.fRealRun is True:
    184199                        try:
    185200                            oTestBoxLogic.rebootTestBox(idTestBox, self.uidSelf, fCommit = True,
     
    188203                        except Exception as oXcpt:
    189204                            rcExit = self.eprint('Error rebooting testbox #%u (%u): %s\n' % (idTestBox, oTestBox.sName, oXcpt,));
     205            else:
     206                self.dprint('badTestBoxManagement: #%u (%s) looks ok:  iFirstOkay=%u cBad=%u cOkay=%u'
     207                            % ( idTestBox, oTestBox.sName, iFirstOkay, cBad, cOkay));
    190208        return rcExit;
    191209
     
    234252        self.oDb.close();
    235253        self.oDb = None;
     254        if self.oLogFile is not None:
     255            self.oLogFile.close();
     256            self.oLogFile = None;
    236257        return rcExit;
    237258
  • trunk/src/VBox/ValidationKit/testmanager/core/testbox.py

    r61282 r61283  
    908908                          'WHERE  idTestBox      = %s\n'
    909909                          '   AND tsExpire       < %s\n'
    910                           '   AND tsExpire      >= %s - interval \'%u hours\'\n'
     910                          '   AND tsExpire      >= %s - interval \'%s hours\'\n'
    911911                          '   AND enmPendingCmd IN (%s, %s)\n'
    912912                          , ( idTestBox, tsNow, tsNow, cHoursBack,
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