VirtualBox

Ignore:
Timestamp:
Mar 19, 2020 8:40:17 PM (5 years ago)
Author:
vboxsync
Message:

TestManager: Don't generate scheduling entries for disabled scheduling groups. Remove items from SchedQueues belonging to deleted scheduling groups when regenerating all queues.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/core/schedulerbase.py

    r82968 r83341  
    6969        # Load data from the database.
    7070        #
     71        oSchedGroupLogic = SchedGroupLogic(oDb);
     72        self.oSchedGroup = oSchedGroupLogic.cachedLookup(idSchedGroup);
    7173
    7274        # Will extend the entries with aoTestCases and dTestCases members
    73         # further down.  checkForGroupDepCycles will add aidTestGroupPreReqs.
    74         self.aoTestGroups       = SchedGroupLogic(oDb).getMembers(idSchedGroup);
     75        # further down (SchedGroupMemberDataEx).  checkForGroupDepCycles
     76        # will add aidTestGroupPreReqs.
     77        self.aoTestGroups       = oSchedGroupLogic.getMembers(idSchedGroup);
    7578
    7679        # aoTestCases entries are TestCaseData instance with iSchedPriority
    7780        # and idTestGroup added for our purposes.
    7881        # We will add oTestGroup and aoArgsVariations members to each further down.
    79         self.aoTestCases        = SchedGroupLogic(oDb).getTestCasesForGroup(idSchedGroup, cMax = 4096);
     82        self.aoTestCases        = oSchedGroupLogic.getTestCasesForGroup(idSchedGroup, cMax = 4096);
    8083
    8184        # Load dependencies.
     
    8790        # and idTestGroup added for our purposes.
    8891        # We will add oTestGroup and oTestCase members to each further down.
    89         self.aoArgsVariations   = SchedGroupLogic(oDb).getTestCaseArgsForGroup(idSchedGroup, cMax = 65536);
     92        self.aoArgsVariations   = oSchedGroupLogic.getTestCaseArgsForGroup(idSchedGroup, cMax = 65536);
    9093
    9194        #
     
    262265
    263266            if oTestGroup.aoTestCases:
    264                 iTstPrio = oTestGroup.aoTestCases[0];
     267                iTstPrio = oTestGroup.aoTestCases[0].iSchedPriority;
    265268                for iTestCase, oTestCase in enumerate(oTestGroup.aoTestCases):
    266269                    if oTestCase.iSchedPriority > iTstPrio:
     
    622625            #
    623626            aoItems = list();
    624             if oData.aoArgsVariations:
     627            if not oData.oSchedGroup.fEnabled:
     628                self.msgInfo('Disabled.');
     629            elif not oData.aoArgsVariations:
     630                self.msgInfo('Found no test case argument variations.');
     631            else:
    625632                aoItems = self._recreateQueueItems(oData);
    626633                self.msgDebug('len(aoItems)=%s' % (len(aoItems),));
     
    635642                                      , (self._oSchedGrpData.idSchedGroup,));
    636643                    cItems  = self._oDb.fetchOne()[0];
    637                     offQueueNew = (offQueue * cItems) / len(aoItems);
     644                    offQueueNew = (offQueue * cItems) // len(aoItems);
    638645                    if offQueueNew != 0:
    639646                        aoItems = aoItems[offQueueNew:] + aoItems[:offQueueNew];
     
    646653            self._recreateQueueCancelGatherings();
    647654            self._oDb.execute('DELETE FROM SchedQueues WHERE idSchedGroup = %s\n', (self._oSchedGrpData.idSchedGroup,));
    648             self._oDb.insertList('INSERT INTO SchedQueues (\n'
    649                                   '         idSchedGroup,\n'
    650                                   '         offQueue,\n'
    651                                   '         idGenTestCaseArgs,\n'
    652                                   '         idTestGroup,\n'
    653                                   '         aidTestGroupPreReqs,\n'
    654                                   '         bmHourlySchedule,\n'
    655                                   '         cMissingGangMembers )\n',
    656                                  aoItems, self._formatItemForInsert);
     655            if aoItems:
     656                self._oDb.insertList('INSERT INTO SchedQueues (\n'
     657                                      '         idSchedGroup,\n'
     658                                      '         offQueue,\n'
     659                                      '         idGenTestCaseArgs,\n'
     660                                      '         idTestGroup,\n'
     661                                      '         aidTestGroupPreReqs,\n'
     662                                      '         bmHourlySchedule,\n'
     663                                      '         cMissingGangMembers )\n',
     664                                     aoItems, self._formatItemForInsert);
    657665        return (aoErrors, self._asMessages);
    658666
     
    723731
    724732
     733    @staticmethod
     734    def cleanUpOrphanedQueues(oDb):
     735        """
     736        Removes orphan scheduling queues from the SchedQueues table.
     737
     738        Queues becomes orphaned when the scheduling group they belongs to has been deleted.
     739
     740        Returns number of orphaned queues.
     741        Raises exception database error.
     742        """
     743        cRet = 0;
     744        try:
     745            oDb.rollback();
     746            oDb.begin();
     747            oDb.execute('''
     748SELECT  SchedQueues.idSchedGroup
     749FROM    SchedQueues
     750        LEFT OUTER JOIN SchedGroups
     751                     ON SchedGroups.idSchedGroup = SchedQueues.idSchedGroup
     752                    AND SchedGroups.tsExpire     = 'infinity'::TIMESTAMP
     753WHERE   SchedGroups.idSchedGroup is NULL
     754GROUP BY SchedQueues.idSchedGroup''');
     755            aaoOrphanRows = oDb.fetchAll();
     756            cRet = len(aaoOrphanRows);
     757            if cRet > 0:
     758                oDb.execute('DELETE FROM SchedQueues WHERE idSchedGroup IN (%s)'
     759                            % (','.join([str(aoRow[0]) for aoRow in aaoOrphanRows]),));
     760                oDb.commit();
     761        except:
     762            oDb.rollback();
     763            raise;
     764        return cRet;
     765
    725766
    726767    #
     
    764805
    765806        cSecTimeout = oTestEx.cSecTimeout if oTestEx.cSecTimeout is not None else oTestEx.oTestCase.cSecTimeout;
    766         cSecTimeout = cSecTimeout * oTestBox.pctScaleTimeout / 100;
     807        cSecTimeout = cSecTimeout * oTestBox.pctScaleTimeout // 100;
    767808
    768809        dResponse   = \
     
    871912
    872913        sBaseFilename = '%04d/%02d/%02d/%02d/TestSet-%s' \
    873                       % (tsNow.year, tsNow.month, tsNow.day, (tsNow.hour / 6) * 6, idTestSet);
     914                      % (tsNow.year, tsNow.month, tsNow.day, (tsNow.hour // 6) * 6, idTestSet);
    874915
    875916        #
  • trunk/src/VBox/ValidationKit/testmanager/core/schedulerbeci.py

    r82968 r83341  
    5757                iPrio = oTestCase.iSchedPriority;
    5858                assert iPrio in range(32);
    59                 iPrio = iPrio / 4;
     59                iPrio = iPrio // 4;
    6060                assert iPrio in range(8);
    6161                if iPrio > iMaxPriority:
  • trunk/src/VBox/ValidationKit/testmanager/webui/wuiadmin.py

    r83338 r83341  
    685685                            else:
    686686                                self._sPageBody += '<p>%s. [Cannot link to %s]</p>' \
    687                                                  % (webutils.escapeElem(oError[0]), webutils.escapeElem(str(oError[1])));
     687                                                 % (webutils.escapeElem(oError[0]), webutils.escapeElem(str(oError[1])),);
    688688                    for sMsg in asMessages:
    689689                        self._sPageBody += '<p>%s<p>\n' % (webutils.escapeElem(sMsg),);
     690
     691            # Remove leftovers from deleted scheduling groups.
     692            self._sPageBody += '<h3>Cleanups</h3>\n';
     693            cOrphans = SchedulerBase.cleanUpOrphanedQueues(self._oDb);
     694            self._sPageBody += '<p>Removed %s orphaned (deleted) queue%s.<p>\n' % (cOrphans, '' if cOrphans == 1 else 's', );
    690695        else:
    691696            self._sPageBody = webutils.escapeElem('%s is a read only user and may not regenerate the scheduling queues!'
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