Changeset 65051 in vbox for trunk/src/VBox/ValidationKit/testmanager/core
- Timestamp:
- Jan 2, 2017 11:55:03 AM (8 years ago)
- Location:
- trunk/src/VBox/ValidationKit/testmanager/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/core/base.py
r65039 r65051 1186 1186 ## @} 1187 1187 1188 def __init__(self, sName, sVarNm = None, sTypeNm = ksType_UInt, sState = ksState_NotSelected, sKind = ksKind_AnyOf): 1188 def __init__(self, sName, sVarNm = None, sType = ksType_UInt, sState = ksState_NotSelected, sKind = ksKind_AnyOf): 1189 assert len(sVarNm) in (2,3); # required by wuimain.py 1189 1190 self.sName = sName; 1190 1191 self.sState = sState; 1191 1192 self.sVarNm = sVarNm if sVarNm is not None else sName; 1192 self.sType Nm = sTypeNm;1193 self.sType = sType; 1193 1194 self.sKind = sKind; 1194 1195 self.aoSelected = []; # Single value, any type. … … 1201 1202 1202 1203 Filters are used to narrow down data that is displayed in a list or 1203 report. It differs a little from ModelDataBase in that it's not tied to a1204 database table, but one or more database queries that are typically very1205 complicated.1204 report. This class differs a little from ModelDataBase in that it is not 1205 tied to a database table, but one or more database queries that are 1206 typically rather complicated. 1206 1207 1207 1208 The filter object has two roles: … … 1234 1235 if oCriterion.sType == FilterCriterion.ksType_UInt: 1235 1236 oCriterion.aoSelected = oDisp.getListOfIntParams(oCriterion.sVarNm, iMin = 0, aiDefaults = []); 1237 elif oCriterion.sType == FilterCriterion.ksType_String: 1238 oCriterion.aoSelected = oDisp.getListOfStrParams(oCriterion.sVarNm, asDefaults = []); 1236 1239 else: 1237 oCriterion.aoSelected = oDisp.getListOfStrParams(oCriterion.sVarNm, asDefaults = []);1238 if len(oCriterion.aoSelected) :1239 oCriterion.sState = FilterCriterion.ksState_Selected;1240 assert False; 1241 if len(oCriterion.aoSelected) > 0: 1242 oCriterion.sState = FilterCriterion.ksState_Selected; 1240 1243 else: 1241 oCriterion.sState = FilterCriterion.ksState_NotSelected;1244 oCriterion.sState = FilterCriterion.ksState_NotSelected; 1242 1245 return self; 1243 1244 1246 1245 1247 -
trunk/src/VBox/ValidationKit/testmanager/core/testresults.py
r64951 r65051 37 37 from common import constants; 38 38 from testmanager import config; 39 from testmanager.core.base import ModelDataBase, ModelLogicBase, ModelDataBaseTestCase, TMExceptionBase, \ 40 TMTooManyRows, TMRowNotFound; 39 from testmanager.core.base import ModelDataBase, ModelLogicBase, ModelDataBaseTestCase, ModelFilterBase, \ 40 FilterCriterion, FilterCriterionValueAndDescription, \ 41 TMExceptionBase, TMTooManyRows, TMRowNotFound; 41 42 from testmanager.core.testgroup import TestGroupData; 42 43 from testmanager.core.build import BuildDataEx, BuildCategoryData; … … 638 639 """Hanging offence committed by test case.""" 639 640 pass; 641 642 643 class TestResultFilter(ModelFilterBase): 644 """ 645 Test result filter. 646 """ 647 648 kiTestStatus = 0; 649 kiSchedGroups = 1; 650 kiTestBoxes = 2; 651 652 def __init__(self): 653 ModelFilterBase.__init__(self); 654 oCrit = FilterCriterion('Test status', sVarNm = 'ts', sType = FilterCriterion.ksType_String); 655 oCrit.aoPossible = ( 656 FilterCriterionValueAndDescription(TestResultData.ksTestStatus_Success, 'Success'), 657 FilterCriterionValueAndDescription(TestResultData.ksTestStatus_Running, 'Running'), 658 FilterCriterionValueAndDescription(TestResultData.ksTestStatus_Skipped, 'Skipped'), 659 FilterCriterionValueAndDescription(TestResultData.ksTestStatus_Aborted, 'Aborted'), 660 FilterCriterionValueAndDescription(TestResultData.ksTestStatus_Failure, 'Failure'), 661 FilterCriterionValueAndDescription(TestResultData.ksTestStatus_TimedOut, 'Timed out'), 662 FilterCriterionValueAndDescription(TestResultData.ksTestStatus_Rebooted, 'Rebooted'), 663 ); 664 self.aCriteria.append(oCrit); 665 assert self.aCriteria[self.kiTestStatus] is oCrit; 666 667 oCrit = FilterCriterion('Sched groups', sVarNm = 'sg'); 668 self.aCriteria.append(oCrit); 669 assert self.aCriteria[self.kiSchedGroups] is oCrit; 670 671 oCrit = FilterCriterion('Testboxes', sVarNm = 'tb'); 672 self.aCriteria.append(oCrit); 673 assert self.aCriteria[self.kiTestBoxes] is oCrit; 640 674 641 675 … … 849 883 return sRet 850 884 851 def fetchResultsForListing(self, iStart, cMaxRows, tsNow, sInterval, enmResultSortBy, # pylint: disable=R0913885 def fetchResultsForListing(self, iStart, cMaxRows, tsNow, sInterval, oFilter, enmResultSortBy, # pylint: disable=R0913 852 886 enmResultsGroupingType, iResultsGroupingValue, fOnlyFailures, fOnlyNeedingReason): 853 887 """ … … 864 898 Raises exception on error. 865 899 """ 900 901 _ = oFilter; 866 902 867 903 # … … 939 975 sQuery += ' AND TestSets.enmStatus != \'success\'::TestStatus_T\n' \ 940 976 ' AND TestSets.enmStatus != \'running\'::TestStatus_T\n'; 977 if oFilter.aCriteria[oFilter.kiTestStatus].sState == FilterCriterion.ksState_Selected: 978 sQuery += ' AND TestSets.enmStatus IN (' \ 979 + ', '.join('\'%s\'' % sValue for sValue in oFilter.aCriteria[oFilter.kiTestStatus].aoSelected) + ')\n'; 980 if oFilter.aCriteria[oFilter.kiSchedGroups].sState == FilterCriterion.ksState_Selected: 981 sQuery += ' AND TestSets.idSchedGroup IN (' \ 982 + ', '.join(str(iVal) for iVal in oFilter.aCriteria[oFilter.kiSchedGroups].aoSelected) + ')\n'; 983 if oFilter.aCriteria[oFilter.kiTestBoxes].sState == FilterCriterion.ksState_Selected: 984 sQuery += ' AND TestSets.idTestBox IN (' \ 985 + ', '.join(str(iVal) for iVal in oFilter.aCriteria[oFilter.kiTestBoxes].aoSelected) + ')\n'; 941 986 if fOnlyNeedingReason: 942 987 sQuery += ' AND TestResultFailures.idTestSet IS NULL\n'; … … 1070 1115 1071 1116 1072 def getEntriesCount(self, tsNow, sInterval, enmResultsGroupingType, iResultsGroupingValue, fOnlyFailures, fOnlyNeedingReason): 1117 def getEntriesCount(self, tsNow, sInterval, oFilter, enmResultsGroupingType, iResultsGroupingValue, 1118 fOnlyFailures, fOnlyNeedingReason): 1073 1119 """ 1074 1120 Get number of table records. … … 1081 1127 @param iResultsGroupingValue is ignored. 1082 1128 """ 1129 _ = oFilter; 1083 1130 1084 1131 # … … 1108 1155 sQuery += ' AND TestSets.enmStatus != \'success\'::TestStatus_T\n' \ 1109 1156 ' AND TestSets.enmStatus != \'running\'::TestStatus_T\n'; 1157 if oFilter.aCriteria[oFilter.kiTestStatus].sState == FilterCriterion.ksState_Selected: 1158 sQuery += ' AND TestSets.enmStatus IN (' \ 1159 + ', '.join('\'%s\'' % sValue for sValue in oFilter.aCriteria[oFilter.kiTestStatus].aoSelected) + ')\n'; 1160 if oFilter.aCriteria[oFilter.kiSchedGroups].sState == FilterCriterion.ksState_Selected: 1161 sQuery += ' AND TestSets.idSchedGroup IN (' \ 1162 + ', '.join(str(iVal) for iVal in oFilter.aCriteria[oFilter.kiSchedGroups].aoSelected) + ')\n'; 1163 if oFilter.aCriteria[oFilter.kiTestBoxes].sState == FilterCriterion.ksState_Selected: 1164 sQuery += ' AND TestSets.idTestBox IN (' \ 1165 + ', '.join(str(iVal) for iVal in oFilter.aCriteria[oFilter.kiTestBoxes].aoSelected) + ')\n'; 1110 1166 if fOnlyNeedingReason: 1111 1167 sQuery += ' AND TestResultFailures.idTestSet IS NULL\n'; … … 1298 1354 except IndexError: 1299 1355 return None 1356 1357 1358 def fetchPossibleFilterOptions(self, oFilter, tsNow, sPeriod): 1359 """ 1360 Fetches the available filter criteria. 1361 Returns oFilter. 1362 """ 1363 assert isinstance(oFilter, TestResultFilter); 1364 1365 # Scheduling groups (see getSchedGroups). 1366 oCrit = oFilter.aCriteria[TestResultFilter.kiSchedGroups]; 1367 self._oDb.execute('SELECT SchedGroups.idSchedGroup, SchedGroups.sName\n' 1368 'FROM ( SELECT idSchedGroup,\n' 1369 ' MAX(TestSets.tsCreated) AS tsNow\n' 1370 ' FROM TestSets\n' 1371 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1372 ' GROUP BY idSchedGroup\n' 1373 ' ) AS SchedGroupIDs\n' 1374 ' INNER JOIN SchedGroups\n' 1375 ' ON SchedGroups.idSchedGroup = SchedGroupIDs.idSchedGroup\n' 1376 ' AND SchedGroups.tsExpire > SchedGroupIDs.tsNow\n' 1377 ' AND SchedGroups.tsEffective <= SchedGroupIDs.tsNow\n' 1378 'ORDER BY SchedGroups.sName\n' ); 1379 for aoRow in self._oDb.fetchAll(): 1380 oCrit.aoPossible.append(FilterCriterionValueAndDescription(aoRow[0], aoRow[1])); 1381 1382 # Scheduling groups (see getTestBoxes). 1383 oCrit = oFilter.aCriteria[TestResultFilter.kiTestBoxes]; 1384 self._oDb.execute('SELECT TestBoxesWithStrings.idTestBox, TestBoxesWithStrings.sName\n' 1385 'FROM ( SELECT idTestBox AS idTestBox,\n' 1386 ' MAX(idGenTestBox) AS idGenTestBox\n' 1387 ' FROM TestSets\n' 1388 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1389 ' GROUP BY idTestBox\n' 1390 ' ) AS TestBoxIDs\n' 1391 ' LEFT OUTER JOIN TestBoxesWithStrings\n' 1392 ' ON TestBoxesWithStrings.idGenTestBox = TestBoxIDs.idGenTestBox\n' 1393 'ORDER BY TestBoxesWithStrings.sName\n' ); 1394 for aoRow in self._oDb.fetchAll(): 1395 oCrit.aoPossible.append(FilterCriterionValueAndDescription(aoRow[0], aoRow[1])); 1396 1397 return oFilter; 1300 1398 1301 1399
Note:
See TracChangeset
for help on using the changeset viewer.