1 | # -*- coding: utf-8 -*-
|
---|
2 | # $Id: schedulerbeci.py 98103 2023-01-17 14:15:46Z vboxsync $
|
---|
3 |
|
---|
4 | """
|
---|
5 | Test Manager - Best-Effort-Continuous-Integration (BECI) scheduler.
|
---|
6 | """
|
---|
7 |
|
---|
8 | __copyright__ = \
|
---|
9 | """
|
---|
10 | Copyright (C) 2012-2023 Oracle and/or its affiliates.
|
---|
11 |
|
---|
12 | This file is part of VirtualBox base platform packages, as
|
---|
13 | available from https://www.virtualbox.org.
|
---|
14 |
|
---|
15 | This program is free software; you can redistribute it and/or
|
---|
16 | modify it under the terms of the GNU General Public License
|
---|
17 | as published by the Free Software Foundation, in version 3 of the
|
---|
18 | License.
|
---|
19 |
|
---|
20 | This program is distributed in the hope that it will be useful, but
|
---|
21 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
23 | General Public License for more details.
|
---|
24 |
|
---|
25 | You should have received a copy of the GNU General Public License
|
---|
26 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
27 |
|
---|
28 | The contents of this file may alternatively be used under the terms
|
---|
29 | of the Common Development and Distribution License Version 1.0
|
---|
30 | (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
31 | in the VirtualBox distribution, in which case the provisions of the
|
---|
32 | CDDL are applicable instead of those of the GPL.
|
---|
33 |
|
---|
34 | You may elect to license modified versions of this file under the
|
---|
35 | terms and conditions of either the GPL or the CDDL or both.
|
---|
36 |
|
---|
37 | SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
38 | """
|
---|
39 | __version__ = "$Revision: 98103 $"
|
---|
40 |
|
---|
41 |
|
---|
42 | # Validation Kit imports.
|
---|
43 | from testmanager.core.schedulerbase import SchedulerBase, SchedQueueData;
|
---|
44 |
|
---|
45 |
|
---|
46 | class SchdulerBeci(SchedulerBase): # pylint: disable=too-few-public-methods
|
---|
47 | """
|
---|
48 | The best-effort-continuous-integration scheduler, BECI for short.
|
---|
49 | """
|
---|
50 |
|
---|
51 | def __init__(self, oDb, oSchedGrpData, iVerbosity, tsSecStart):
|
---|
52 | SchedulerBase.__init__(self, oDb, oSchedGrpData, iVerbosity, tsSecStart);
|
---|
53 |
|
---|
54 | def _recreateQueueItems(self, oData):
|
---|
55 | #
|
---|
56 | # Prepare the input data for the loop below. We compress the priority
|
---|
57 | # to reduce the number of loops we need to executes below.
|
---|
58 | #
|
---|
59 | # Note! For BECI test group priority only applies to the ordering of
|
---|
60 | # test groups, which has been resolved by the done sorting in the
|
---|
61 | # base class.
|
---|
62 | #
|
---|
63 | iMinPriority = 0x7fff;
|
---|
64 | iMaxPriority = 0;
|
---|
65 | for oTestGroup in oData.aoTestGroups:
|
---|
66 | for oTestCase in oTestGroup.aoTestCases:
|
---|
67 | iPrio = oTestCase.iSchedPriority;
|
---|
68 | assert iPrio in range(32);
|
---|
69 | iPrio = iPrio // 4;
|
---|
70 | assert iPrio in range(8);
|
---|
71 | if iPrio > iMaxPriority:
|
---|
72 | iMaxPriority = iPrio;
|
---|
73 | if iPrio < iMinPriority:
|
---|
74 | iMinPriority = iPrio;
|
---|
75 |
|
---|
76 | oTestCase.iBeciPrio = iPrio;
|
---|
77 | oTestCase.iNextVariation = -1;
|
---|
78 |
|
---|
79 | assert iMinPriority in range(8);
|
---|
80 | assert iMaxPriority in range(8);
|
---|
81 | assert iMinPriority <= iMaxPriority;
|
---|
82 |
|
---|
83 | #
|
---|
84 | # Generate the
|
---|
85 | #
|
---|
86 | cMaxItems = len(oData.aoArgsVariations) * 64;
|
---|
87 | cMaxItems = min(cMaxItems, 1048576);
|
---|
88 |
|
---|
89 | aoItems = [];
|
---|
90 | cNotAtEnd = len(oData.aoTestCases);
|
---|
91 | while len(aoItems) < cMaxItems:
|
---|
92 | self.msgDebug('outer loop: %s items' % (len(aoItems),));
|
---|
93 | for iPrio in range(iMaxPriority, iMinPriority - 1, -1):
|
---|
94 | #self.msgDebug('prio loop: %s' % (iPrio,));
|
---|
95 | for oTestGroup in oData.aoTestGroups:
|
---|
96 | #self.msgDebug('testgroup loop: %s' % (oTestGroup,));
|
---|
97 | for oTestCase in oTestGroup.aoTestCases:
|
---|
98 | #self.msgDebug('testcase loop: idTestCase=%s' % (oTestCase.idTestCase,));
|
---|
99 | if iPrio <= oTestCase.iBeciPrio and oTestCase.aoArgsVariations:
|
---|
100 | # Get variation.
|
---|
101 | iNext = oTestCase.iNextVariation;
|
---|
102 | if iNext != 0:
|
---|
103 | if iNext == -1: iNext = 0;
|
---|
104 | cNotAtEnd -= 1;
|
---|
105 | oArgsVariation = oTestCase.aoArgsVariations[iNext];
|
---|
106 |
|
---|
107 | # Update next variation.
|
---|
108 | iNext = (iNext + 1) % len(oTestCase.aoArgsVariations);
|
---|
109 | cNotAtEnd += iNext != 0;
|
---|
110 | oTestCase.iNextVariation = iNext;
|
---|
111 |
|
---|
112 | # Create queue item and append it.
|
---|
113 | oItem = SchedQueueData();
|
---|
114 | oItem.initFromValues(idSchedGroup = self._oSchedGrpData.idSchedGroup,
|
---|
115 | idGenTestCaseArgs = oArgsVariation.idGenTestCaseArgs,
|
---|
116 | idTestGroup = oTestGroup.idTestGroup,
|
---|
117 | aidTestGroupPreReqs = oTestGroup.aidTestGroupPreReqs,
|
---|
118 | bmHourlySchedule = oTestGroup.bmHourlySchedule,
|
---|
119 | cMissingGangMembers = oArgsVariation.cGangMembers,
|
---|
120 | offQueue = len(aoItems));
|
---|
121 | aoItems.append(oItem);
|
---|
122 |
|
---|
123 | # Done?
|
---|
124 | if cNotAtEnd == 0:
|
---|
125 | self.msgDebug('returns %s items' % (len(aoItems),));
|
---|
126 | return aoItems;
|
---|
127 | return aoItems;
|
---|
128 |
|
---|