Changeset 65053 in vbox for trunk/src/VBox/ValidationKit/testmanager/core
- Timestamp:
- Jan 2, 2017 4:43:09 PM (8 years ago)
- Location:
- trunk/src/VBox/ValidationKit/testmanager/core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/core/base.py
r65051 r65053 1158 1158 """ 1159 1159 1160 def __init__(self, oValue, sDesc): 1161 self.oValue = oValue; ##< Typically the ID of something in the database. 1162 self.sDesc = sDesc; ##< What to display. 1160 def __init__(self, oValue, sDesc, fIrrelevant = False): 1161 self.oValue = oValue; ##< Typically the ID of something in the database. 1162 self.sDesc = sDesc; ##< What to display. 1163 self.fIrrelevant = fIrrelevant; ##< Irrelevant filter option, only present because it's selected 1163 1164 1164 1165 … … 1186 1187 ## @} 1187 1188 1188 def __init__(self, sName, sVarNm = None, sType = ksType_UInt, sState = ksState_NotSelected, sKind = ksKind_AnyOf): 1189 def __init__(self, sName, sVarNm = None, sType = ksType_UInt, sState = ksState_NotSelected, sKind = ksKind_AnyOf, 1190 sTable = None, sColumn = None): 1189 1191 assert len(sVarNm) in (2,3); # required by wuimain.py 1190 1192 self.sName = sName; … … 1195 1197 self.aoSelected = []; # Single value, any type. 1196 1198 self.aoPossible = []; # type: list[FilterCriterionValueAndDescription] 1199 self.sTable = sTable; 1200 self.sColumn = sColumn; 1197 1201 1198 1202 -
trunk/src/VBox/ValidationKit/testmanager/core/build.py
r65040 r65053 148 148 """ 149 149 150 def __init__(self, oDb): 151 ModelLogicBase.__init__(self, oDb) 152 self.dCache = None; 153 150 154 def fetchForListing(self, iStart, cMaxRows, tsNow): 151 155 """ … … 235 239 _ = uidAuthor; _ = fCascade; 236 240 return True; 241 242 def cachedLookup(self, idBuildCategory): 243 """ 244 Looks up the most recent BuildCategoryData object for idBuildCategory 245 via an object cache. 246 247 Returns a shared BuildCategoryData object. None if not found. 248 Raises exception on DB error. 249 """ 250 if self.dCache is None: 251 self.dCache = self._oDb.getCache('BuildCategoryData'); 252 oEntry = self.dCache.get(idBuildCategory, None); 253 if oEntry is None: 254 self._oDb.execute('SELECT *\n' 255 'FROM BuildCategories\n' 256 'WHERE idBuildCategory = %s\n' 257 , (idBuildCategory, )); 258 if self._oDb.getRowCount() == 1: 259 aaoRow = self._oDb.fetchOne(); 260 oEntry = BuildCategoryData(); 261 oEntry.initFromDbRow(aaoRow); 262 self.dCache[idBuildCategory] = oEntry; 263 return oEntry; 237 264 238 265 # -
trunk/src/VBox/ValidationKit/testmanager/core/testresults.py
r65051 r65053 41 41 TMExceptionBase, TMTooManyRows, TMRowNotFound; 42 42 from testmanager.core.testgroup import TestGroupData; 43 from testmanager.core.build import BuildDataEx, BuildCategoryData ;43 from testmanager.core.build import BuildDataEx, BuildCategoryData, BuildLogic, BuildCategoryLogic; 44 44 from testmanager.core.failurereason import FailureReasonLogic; 45 from testmanager.core.testbox import TestBoxData ;46 from testmanager.core.testcase import TestCaseData ;47 from testmanager.core.schedgroup import SchedGroupData ;45 from testmanager.core.testbox import TestBoxData, TestBoxLogic; 46 from testmanager.core.testcase import TestCaseData, TestCaseLogic; 47 from testmanager.core.schedgroup import SchedGroupData, SchedGroupLogic; 48 48 from testmanager.core.systemlog import SystemLogData, SystemLogLogic; 49 49 from testmanager.core.testresultfailures import TestResultFailureDataEx; … … 647 647 648 648 kiTestStatus = 0; 649 kiSchedGroups = 1; 650 kiTestBoxes = 2; 649 kiBranches = 1; 650 kiSchedGroups = 2; 651 kiTestBoxes = 3; 652 kiTestCases = 4; 653 kiRevisions = 5; 654 kiCpuArches = 6; 655 kiCpuVendors = 7; 656 kiOses = 8; 657 kiOsVersions = 9; 658 kiFailReasons = 10; 651 659 652 660 def __init__(self): 653 661 ModelFilterBase.__init__(self); 654 oCrit = FilterCriterion('Test status', sVarNm = 'ts', sType = FilterCriterion.ksType_String); 662 oCrit = FilterCriterion('Test status', sVarNm = 'ts', sType = FilterCriterion.ksType_String, 663 sTable = 'TestSets', sColumn = 'enmStatus'); 655 664 oCrit.aoPossible = ( 656 665 FilterCriterionValueAndDescription(TestResultData.ksTestStatus_Success, 'Success'), … … 665 674 assert self.aCriteria[self.kiTestStatus] is oCrit; 666 675 667 oCrit = FilterCriterion('Sched groups', sVarNm = 'sg'); 676 oCrit = FilterCriterion('Branches', sVarNm = 'br', sType = FilterCriterion.ksType_String, 677 sTable = 'BuildCategories', sColumn = 'sBranch'); 678 self.aCriteria.append(oCrit); 679 assert self.aCriteria[self.kiBranches] is oCrit; 680 681 oCrit = FilterCriterion('Sched groups', sVarNm = 'sg', sTable = 'TestSets', sColumn = 'idSchedGroup'); 668 682 self.aCriteria.append(oCrit); 669 683 assert self.aCriteria[self.kiSchedGroups] is oCrit; 670 684 671 oCrit = FilterCriterion('Testboxes', sVarNm = 'tb' );685 oCrit = FilterCriterion('Testboxes', sVarNm = 'tb', sTable = 'TestSets', sColumn = 'idTestBox'); 672 686 self.aCriteria.append(oCrit); 673 687 assert self.aCriteria[self.kiTestBoxes] is oCrit; 688 689 oCrit = FilterCriterion('Test cases', sVarNm = 'tc', sTable = 'TestSets', sColumn = 'idTestCase'); 690 self.aCriteria.append(oCrit); 691 assert self.aCriteria[self.kiTestCases] is oCrit; 692 693 oCrit = FilterCriterion('Revisions', sVarNm = 'rv', sTable = 'Builds', sColumn = 'iRevision'); 694 self.aCriteria.append(oCrit); 695 assert self.aCriteria[self.kiRevisions] is oCrit; 696 697 oCrit = FilterCriterion('CPU Arches', sVarNm = 'ca', sTable = 'TestBoxesWithStrings', sColumn = 'idStrCpuArch'); 698 self.aCriteria.append(oCrit); 699 assert self.aCriteria[self.kiCpuArches] is oCrit; 700 701 oCrit = FilterCriterion('CPU Vendor', sVarNm = 'cv', sTable = 'TestBoxesWithStrings', sColumn = 'idStrCpuVendor'); 702 self.aCriteria.append(oCrit); 703 assert self.aCriteria[self.kiCpuVendors] is oCrit; 704 705 oCrit = FilterCriterion('OSes', sVarNm = 'os', sTable = 'TestBoxesWithStrings', sColumn = 'idStrOs'); 706 self.aCriteria.append(oCrit); 707 assert self.aCriteria[self.kiOses] is oCrit; 708 709 oCrit = FilterCriterion('OS Versions', sVarNm = 'ov', sTable = 'TestBoxesWithStrings', sColumn = 'idStrOsVersion'); 710 self.aCriteria.append(oCrit); 711 assert self.aCriteria[self.kiOsVersions] is oCrit; 712 713 oCrit = FilterCriterion('Failure Reasons', sVarNm = 'fr', sTable = 'TestResultFailures', sColumn = 'idFailureReason'); 714 self.aCriteria.append(oCrit); 715 assert self.aCriteria[self.kiFailReasons] is oCrit; 716 717 718 def getWhereConditions(self, sExtraIndent = '', iOmit = -1): 719 """ 720 Construct the WHERE conditions for the filter, optionally omitting one 721 criterion. 722 """ 723 sQuery = ''; 724 for iCrit, oCrit in enumerate(self.aCriteria): 725 if oCrit.sState == FilterCriterion.ksState_Selected and iCrit != iOmit: 726 sQuery += '%s AND %s.%s IN (' % (sExtraIndent, oCrit.sTable, oCrit.sColumn,); 727 if oCrit.sType == FilterCriterion.ksType_String: 728 sQuery += ', '.join('\'%s\'' % (sValue,) for sValue in oCrit.aoSelected) + ')\n'; 729 else: 730 sQuery += ', '.join(str(iValue) for iValue in oCrit.aoSelected) + ')\n'; 731 return sQuery; 732 733 def getTableJoins(self, sExtraIndent = '', iOmit = -1): 734 """ 735 Construct the WHERE conditions for the filter, optionally omitting one 736 criterion. 737 """ 738 sQuery = ''; 739 afDone = { 'TestSets': True, }; 740 for iCrit, oCrit in enumerate(self.aCriteria): 741 if oCrit.sState == FilterCriterion.ksState_Selected \ 742 and oCrit.sTable not in afDone \ 743 and iCrit != iOmit: 744 afDone[oCrit.sTable] = True; 745 if oCrit.sTable == 'Builds': 746 sQuery += '%sINNER JOIN Builds\n' \ 747 '%s ON Builds.idBuild = TestSets.idBuild\n' \ 748 '%s AND Builds.tsExpire > TestSets.tsCreated\n' \ 749 '%s AND Builds.tsEffective <= TestSets.tsCreated\n' \ 750 % ( sExtraIndent, sExtraIndent, sExtraIndent, sExtraIndent, ); 751 elif oCrit.sTable == 'TestResultFailures': 752 sQuery += '%sLEFT OUTER JOIN TestResultFailures\n' \ 753 '%s ON TestResultFailures.idTestSet = TestSets.idTestSet\n' \ 754 '%s AND TestResultFailures.tsExpire = \'infinity\'::TIMESTAMP\n' \ 755 % ( sExtraIndent, sExtraIndent, sExtraIndent, ); 756 elif oCrit.sTable == 'TestBoxesWithStrings': 757 sQuery += '%sLEFT OUTER JOIN TestBoxesWithStrings\n' \ 758 '%s ON TestBoxesWithStrings.idGenTestBox = TestSets.idGenTestBox\n' \ 759 % ( sExtraIndent, sExtraIndent, ); 760 elif oCrit.sTable == 'BuildCategories': 761 sQuery += '%sINNER JOIN BuildCategories\n' \ 762 '%s ON BuildCategories.idBuildCategory = TestSets.idBuildCategory\n' \ 763 % ( sExtraIndent, sExtraIndent, ); 764 else: 765 assert False, oCrit.sTable; 766 return sQuery; 767 768 def isJoiningWithTable(self, sTable): 769 """ Checks whether getTableJoins already joins with TestResultFailures. """ 770 for oCrit in self.aCriteria: 771 if oCrit.sTable == sTable and oCrit.sState == FilterCriterion.ksState_Selected: 772 return True; 773 return False 774 674 775 675 776 … … 743 844 ## Default sort by map. 744 845 kdResultSortByMap = { 745 ksResultsSortByRunningAndStart: ( '', None, None, '', '' ),846 ksResultsSortByRunningAndStart: ( (), None, None, '', '' ), 746 847 ksResultsSortByBuildRevision: ( 747 848 # Sorting tables. 748 ', Builds',849 ('Builds',), 749 850 # Sorting table join(s). 750 851 ' AND TestSets.idBuild = Builds.idBuild' … … 758 859 ''), 759 860 ksResultsSortByTestBoxName: ( 760 ', TestBoxes',861 ('TestBoxes',), 761 862 ' AND TestSets.idGenTestBox = TestBoxes.idGenTestBox', 762 863 ' TestBoxes.sName DESC', 763 864 '', '' ), 764 865 ksResultsSortByTestBoxOsArch: ( 765 ', TestBoxesWithStrings',866 ('TestBoxesWithStrings',), 766 867 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 767 868 ' TestBoxesWithStrings.sOs, TestBoxesWithStrings.sCpuArch', 768 869 '', '' ), 769 870 ksResultsSortByTestBoxOs: ( 770 ', TestBoxesWithStrings',871 ('TestBoxesWithStrings',), 771 872 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 772 873 ' TestBoxesWithStrings.sOs', 773 874 '', '' ), 774 875 ksResultsSortByTestBoxOsVersion: ( 775 ', TestBoxesWithStrings',876 ('TestBoxesWithStrings',), 776 877 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 777 878 ' TestBoxesWithStrings.sOs, TestBoxesWithStrings.sOsVersion DESC', 778 879 '', '' ), 779 880 ksResultsSortByTestBoxArch: ( 780 ', TestBoxesWithStrings',881 ('TestBoxesWithStrings',), 781 882 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 782 883 ' TestBoxesWithStrings.sCpuArch', 783 884 '', '' ), 784 885 ksResultsSortByTestBoxCpuVendor: ( 785 ', TestBoxesWithStrings',886 ('TestBoxesWithStrings',), 786 887 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 787 888 ' TestBoxesWithStrings.sCpuVendor', 788 889 '', '' ), 789 890 ksResultsSortByTestBoxCpuName: ( 790 ', TestBoxesWithStrings',891 ('TestBoxesWithStrings',), 791 892 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 792 893 ' TestBoxesWithStrings.sCpuVendor, TestBoxesWithStrings.sCpuName', 793 894 '', '' ), 794 895 ksResultsSortByTestBoxCpuRev: ( 795 ', TestBoxesWithStrings',896 ('TestBoxesWithStrings',), 796 897 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 797 898 ' TestBoxesWithStrings.sCpuVendor, TestBoxesWithStrings.lCpuRevision DESC', … … 799 900 ', TestBoxesWithStrings.lCpuRevision' ), 800 901 ksResultsSortByTestBoxCpuFeatures: ( 801 ', TestBoxes',902 ('TestBoxes',), 802 903 ' AND TestSets.idGenTestBox = TestBoxes.idGenTestBox', 803 904 ' TestBoxes.fCpuHwVirt DESC, TestBoxes.fCpuNestedPaging DESC, TestBoxes.fCpu64BitGuest DESC, TestBoxes.cCpus DESC', … … 805 906 '' ), 806 907 ksResultsSortByTestCaseName: ( 807 ', TestCases',908 ('TestCases',), 808 909 ' AND TestSets.idGenTestCase = TestCases.idGenTestCase', 809 910 ' TestCases.sName', 810 911 '', '' ), 811 912 ksResultsSortByFailureReason: ( 812 '', '',913 (), '', 813 914 'asSortByFailureReason ASC', 814 915 ', array_agg(FailureReasons.sShort ORDER BY TestResultFailures.idTestResult) AS asSortByFailureReason', … … 819 920 ksResultsGroupingTypeNone: ( 820 921 # Grouping tables; 821 '',922 (), 822 923 # Grouping field; 823 924 None, … … 831 932 ksResultsGroupingTypeTestCase: ('', 'TestSets.idTestCase', None, {},), 832 933 ksResultsGroupingTypeOS: ( 833 ', TestBoxes',934 ('TestBoxes',), 834 935 'TestBoxes.idStrOs', 835 936 ' AND TestBoxes.idGenTestBox = TestSets.idGenTestBox', … … 837 938 ), 838 939 ksResultsGroupingTypeArch: ( 839 ', TestBoxes',940 ('TestBoxes',), 840 941 'TestBoxes.idStrCpuArch', 841 942 ' AND TestBoxes.idGenTestBox = TestSets.idGenTestBox', … … 844 945 ksResultsGroupingTypeBuildCat: ('', 'TestSets.idBuildCategory', None, {},), 845 946 ksResultsGroupingTypeBuildRev: ( 846 ', Builds',947 ('Builds',), 847 948 'Builds.iRevision', 848 949 ' AND Builds.idBuild = TestSets.idBuild' 849 950 ' AND Builds.tsExpire > TestSets.tsCreated' 850 951 ' AND Builds.tsEffective <= TestSets.tsCreated', 851 { ksResultsSortByBuildRevision: ( '', None, ' Builds.iRevision DESC' ), }952 { ksResultsSortByBuildRevision: ( (), None, ' Builds.iRevision DESC' ), } 852 953 ), 853 954 ksResultsGroupingTypeSchedGroup: ( '', 'TestSets.idSchedGroup', None, {},), … … 908 1009 if enmResultSortBy is None or enmResultSortBy not in self.kasResultsSortBy: 909 1010 raise TMExceptionBase('Unknown sorting'); 910 sGroupingTables, sGroupingField, sGroupingCondition, dSortingOverrides = self.kdResultGroupingMap[enmResultsGroupingType];911 if enmResultSortBy in dSort ingOverrides:912 sSortTables, sSortWhere, sSortOrderBy, sSortColumns, sSortGroupBy = dSortingOverrides[enmResultSortBy];1011 asGroupingTables, sGroupingField, sGroupingCondition, dSortOverrides = self.kdResultGroupingMap[enmResultsGroupingType]; 1012 if enmResultSortBy in dSortOverrides: 1013 asSortTables, sSortWhere, sSortOrderBy, sSortColumns, sSortGroupBy = dSortOverrides[enmResultSortBy]; 913 1014 else: 914 sSortTables, sSortWhere, sSortOrderBy, sSortColumns, sSortGroupBy = self.kdResultSortByMap[enmResultSortBy];1015 asSortTables, sSortWhere, sSortOrderBy, sSortColumns, sSortGroupBy = self.kdResultSortByMap[enmResultSortBy]; 915 1016 916 1017 # … … 962 1063 ' TestSets.idGenTestCase AS idGenTestCase,\n' \ 963 1064 ' TestSets.idGenTestCaseArgs AS idGenTestCaseArgs\n' \ 964 ' FROM TestSets'; 965 if fOnlyNeedingReason: 1065 ' FROM TestSets\n'; 1066 sQuery += oFilter.getTableJoins(' '); 1067 if fOnlyNeedingReason and not oFilter.isJoiningWithTable('TestResultFailures'): 966 1068 sQuery += '\n' \ 967 1069 ' LEFT OUTER JOIN TestResultFailures\n' \ 968 1070 ' ON TestSets.idTestSet = TestResultFailures.idTestSet\n' \ 969 1071 ' AND TestResultFailures.tsExpire = \'infinity\'::TIMESTAMP'; 970 sQuery += sGroupingTables.replace(',', ',\n '); 971 sQuery += sSortTables.replace( ',', ',\n '); 972 sQuery += '\n' \ 973 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sInterval, ' '); 1072 for asTables in [asGroupingTables, asSortTables]: 1073 for sTable in asTables: 1074 if not oFilter.isJoiningWithTable(sTable): 1075 sQuery = sQuery[:-1] + ',\n ' + sTable + '\n'; 1076 1077 sQuery += ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sInterval, ' ') + \ 1078 oFilter.getWhereConditions(' '); 974 1079 if fOnlyFailures or fOnlyNeedingReason: 975 1080 sQuery += ' AND TestSets.enmStatus != \'success\'::TestStatus_T\n' \ 976 1081 ' 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';986 1082 if fOnlyNeedingReason: 987 1083 sQuery += ' AND TestResultFailures.idTestSet IS NULL\n'; … … 1137 1233 if enmResultsGroupingType not in self.kdResultGroupingMap: 1138 1234 raise TMExceptionBase('Unknown grouping type') 1139 sGroupingTables, sGroupingField, sGroupingCondition, _ = self.kdResultGroupingMap[enmResultsGroupingType];1235 asGroupingTables, sGroupingField, sGroupingCondition, _ = self.kdResultGroupingMap[enmResultsGroupingType]; 1140 1236 1141 1237 # … … 1143 1239 # 1144 1240 sQuery = 'SELECT COUNT(TestSets.idTestSet)\n' \ 1145 'FROM TestSets ';1146 if fOnlyNeedingReason:1147 sQuery += '\n' \1148 1241 'FROM TestSets\n'; 1242 sQuery += oFilter.getTableJoins(); 1243 if fOnlyNeedingReason and not oFilter.isJoiningWithTable('TestResultFailures'): 1244 sQuery += ' LEFT OUTER JOIN TestResultFailures\n' \ 1149 1245 ' ON TestSets.idTestSet = TestResultFailures.idTestSet\n' \ 1150 ' AND TestResultFailures.tsExpire = \'infinity\'::TIMESTAMP'; 1151 sQuery += sGroupingTables.replace(',', ',\n '); 1152 sQuery += '\n' \ 1153 'WHERE ' + self._getTimePeriodQueryPart(tsNow, sInterval); 1246 ' AND TestResultFailures.tsExpire = \'infinity\'::TIMESTAMP\n'; 1247 for sTable in asGroupingTables: 1248 if not oFilter.isJoiningWithTable(sTable): 1249 sQuery = sQuery[:-1] + ',\n ' + sTable + '\n'; 1250 sQuery += 'WHERE ' + self._getTimePeriodQueryPart(tsNow, sInterval) + \ 1251 oFilter.getWhereConditions(); 1154 1252 if fOnlyFailures or fOnlyNeedingReason: 1155 1253 sQuery += ' AND TestSets.enmStatus != \'success\'::TestStatus_T\n' \ 1156 1254 ' 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';1166 1255 if fOnlyNeedingReason: 1167 1256 sQuery += ' AND TestResultFailures.idTestSet IS NULL\n'; … … 1355 1444 return None 1356 1445 1357 1358 1446 def fetchPossibleFilterOptions(self, oFilter, tsNow, sPeriod): 1359 1447 """ 1360 Fetches the available filter criteria. 1448 Fetches the available filter criteria, given the current filtering. 1449 1361 1450 Returns oFilter. 1362 1451 """ 1363 1452 assert isinstance(oFilter, TestResultFilter); 1453 1454 def workerDoFetch(oMissingLogicType, sNameAttr = 'sName', fIdIsName = False): 1455 """ Does the tedious result fetching and handling of missing bits. """ 1456 dLeft = { oValue: 1 for oValue in oCrit.aoSelected }; 1457 for aoRow in self._oDb.fetchAll(): 1458 oCrit.aoPossible.append(FilterCriterionValueAndDescription(aoRow[0], aoRow[1])); 1459 if aoRow[0] in dLeft: 1460 del dLeft[aoRow[0]]; 1461 if len(dLeft) > 0: 1462 if fIdIsName: 1463 for idMissing in dLeft: 1464 oCrit.aoPossible.append(FilterCriterionValueAndDescription(idMissing, idMissing, fIrrelevant = True)); 1465 else: 1466 oMissingLogic = oMissingLogicType(self._oDb); 1467 for idMissing in dLeft: 1468 oMissing = oMissingLogic.cachedLookup(idMissing); 1469 if oMissing is not None: 1470 oCrit.aoPossible.append(FilterCriterionValueAndDescription(idMissing, 1471 getattr(oMissing, sNameAttr), 1472 fIrrelevant = True)); 1364 1473 1365 1474 # Scheduling groups (see getSchedGroups). 1366 1475 oCrit = oFilter.aCriteria[TestResultFilter.kiSchedGroups]; 1367 1476 self._oDb.execute('SELECT SchedGroups.idSchedGroup, SchedGroups.sName\n' 1368 'FROM ( SELECT idSchedGroup,\n'1477 'FROM ( SELECT TestSets.idSchedGroup,\n' 1369 1478 ' MAX(TestSets.tsCreated) AS tsNow\n' 1370 ' FROM TestSets\n' 1479 ' FROM TestSets\n' + oFilter.getTableJoins(iOmit = TestResultFilter.kiSchedGroups) + 1371 1480 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1372 ' GROUP BY idSchedGroup\n' 1481 oFilter.getWhereConditions(iOmit = TestResultFilter.kiSchedGroups) + 1482 ' GROUP BY TestSets.idSchedGroup\n' 1373 1483 ' ) AS SchedGroupIDs\n' 1374 1484 ' INNER JOIN SchedGroups\n' … … 1377 1487 ' AND SchedGroups.tsEffective <= SchedGroupIDs.tsNow\n' 1378 1488 '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). 1489 workerDoFetch(SchedGroupLogic); 1490 1491 # Testboxes (see getTestBoxes). 1383 1492 oCrit = oFilter.aCriteria[TestResultFilter.kiTestBoxes]; 1384 1493 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' 1494 'FROM ( SELECT TestSets.idTestBox AS idTestBox,\n' 1495 ' MAX(TestSets.idGenTestBox) AS idGenTestBox\n' 1496 ' FROM TestSets\n' + oFilter.getTableJoins(iOmit = TestResultFilter.kiTestBoxes) + 1388 1497 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1389 ' GROUP BY idTestBox\n' 1498 oFilter.getWhereConditions(iOmit = TestResultFilter.kiTestBoxes) + 1499 ' GROUP BY TestSets.idTestBox\n' 1390 1500 ' ) AS TestBoxIDs\n' 1391 1501 ' LEFT OUTER JOIN TestBoxesWithStrings\n' 1392 1502 ' ON TestBoxesWithStrings.idGenTestBox = TestBoxIDs.idGenTestBox\n' 1393 1503 'ORDER BY TestBoxesWithStrings.sName\n' ); 1394 for aoRow in self._oDb.fetchAll(): 1395 oCrit.aoPossible.append(FilterCriterionValueAndDescription(aoRow[0], aoRow[1])); 1504 workerDoFetch(TestBoxLogic); 1505 1506 # Testbox OSes. 1507 oCrit = oFilter.aCriteria[TestResultFilter.kiOses]; 1508 self._oDb.execute('SELECT DISTINCT TestBoxesWithStrings.idStrOs, TestBoxesWithStrings.sOs\n' 1509 'FROM ( SELECT DISTINCT TestSets.idGenTestBox\n' 1510 ' FROM TestSets\n' + oFilter.getTableJoins(iOmit = TestResultFilter.kiOses) + 1511 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1512 oFilter.getWhereConditions(iOmit = TestResultFilter.kiOses) + 1513 ' ) AS TestBoxGenIDs\n' 1514 ' LEFT OUTER JOIN TestBoxesWithStrings\n' 1515 ' ON TestBoxesWithStrings.idGenTestBox = TestBoxGenIDs.idGenTestBox\n' 1516 'ORDER BY TestBoxesWithStrings.sOs\n' ); 1517 workerDoFetch(TestBoxLogic, 'sOs'); 1518 1519 # Testbox OS versions . 1520 oCrit = oFilter.aCriteria[TestResultFilter.kiOsVersions]; 1521 self._oDb.execute('SELECT DISTINCT TestBoxesWithStrings.idStrOsVersion, TestBoxesWithStrings.sOsVersion\n' 1522 'FROM ( SELECT DISTINCT TestSets.idGenTestBox AS idGenTestBox\n' 1523 ' FROM TestSets\n' + oFilter.getTableJoins(iOmit = TestResultFilter.kiOsVersions) + 1524 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1525 oFilter.getWhereConditions(iOmit = TestResultFilter.kiOsVersions) + 1526 ' ) AS TestBoxGenIDs\n' 1527 ' LEFT OUTER JOIN TestBoxesWithStrings\n' 1528 ' ON TestBoxesWithStrings.idGenTestBox = TestBoxGenIDs.idGenTestBox\n' 1529 'ORDER BY TestBoxesWithStrings.sOsVersion\n' ); 1530 workerDoFetch(TestBoxLogic, 'sOsVersion'); 1531 1532 # Testbox CPU/OS architectures. 1533 oCrit = oFilter.aCriteria[TestResultFilter.kiCpuArches]; 1534 self._oDb.execute('SELECT DISTINCT TestBoxesWithStrings.idStrCpuArch, TestBoxesWithStrings.sCpuArch\n' 1535 'FROM ( SELECT DISTINCT TestSets.idGenTestBox\n' 1536 ' FROM TestSets\n' + oFilter.getTableJoins(iOmit = TestResultFilter.kiCpuArches) + 1537 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1538 oFilter.getWhereConditions(iOmit = TestResultFilter.kiCpuArches) + 1539 ' ) AS TestBoxGenIDs\n' 1540 ' LEFT OUTER JOIN TestBoxesWithStrings\n' 1541 ' ON TestBoxesWithStrings.idGenTestBox = TestBoxGenIDs.idGenTestBox\n' 1542 'ORDER BY TestBoxesWithStrings.sCpuArch\n' ); 1543 workerDoFetch(TestBoxLogic, 'sCpuArch'); 1544 1545 # Testbox CPU vendors. 1546 oCrit = oFilter.aCriteria[TestResultFilter.kiCpuVendors]; 1547 self._oDb.execute('SELECT DISTINCT TestBoxesWithStrings.idStrCpuVendor, TestBoxesWithStrings.sCpuVendor\n' 1548 'FROM ( SELECT DISTINCT TestSets.idGenTestBox\n' 1549 ' FROM TestSets\n' + oFilter.getTableJoins(iOmit = TestResultFilter.kiCpuVendors) + 1550 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1551 oFilter.getWhereConditions(iOmit = TestResultFilter.kiCpuVendors) + 1552 ' ) AS TestBoxGenIDs\n' 1553 ' LEFT OUTER JOIN TestBoxesWithStrings\n' 1554 ' ON TestBoxesWithStrings.idGenTestBox = TestBoxGenIDs.idGenTestBox\n' 1555 'ORDER BY TestBoxesWithStrings.sCpuVendor\n' ); 1556 workerDoFetch(TestBoxLogic, 'sCpuVendor'); 1557 1558 # Testcases (see getTestCases). 1559 oCrit = oFilter.aCriteria[TestResultFilter.kiTestCases]; 1560 self._oDb.execute('SELECT TestCases.idTestCase, TestCases.sName\n' 1561 'FROM ( SELECT TestSets.idTestCase AS idTestCase,\n' 1562 ' MAX(TestSets.idGenTestCase) AS idGenTestCase\n' 1563 ' FROM TestSets\n' + oFilter.getTableJoins(iOmit = TestResultFilter.kiTestCases) + 1564 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1565 oFilter.getWhereConditions(iOmit = TestResultFilter.kiTestCases) + 1566 ' GROUP BY TestSets.idTestCase\n' 1567 ' ) AS TestCasesIDs\n' 1568 ' LEFT OUTER JOIN TestCases ON TestCases.idGenTestCase = TestCasesIDs.idGenTestCase\n' 1569 'ORDER BY TestCases.sName\n' ); 1570 workerDoFetch(TestCaseLogic); 1571 1572 # Build revisions. 1573 oCrit = oFilter.aCriteria[TestResultFilter.kiRevisions]; 1574 self._oDb.execute('SELECT Builds.iRevision, CONCAT(\'r\', Builds.iRevision)\n' 1575 'FROM ( SELECT TestSets.idBuild AS idBuild,\n' 1576 ' MAX(TestSets.tsCreated) AS tsNow\n' 1577 ' FROM TestSets\n' + oFilter.getTableJoins(iOmit = TestResultFilter.kiRevisions) + 1578 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1579 oFilter.getWhereConditions(iOmit = TestResultFilter.kiRevisions) + 1580 ' GROUP BY TestSets.idBuild\n' 1581 ' ) AS BuildIDs\n' 1582 ' INNER JOIN Builds\n' 1583 ' ON Builds.idBuild = BuildIDs.idBuild\n' 1584 ' AND Builds.tsExpire > BuildIDs.tsNow\n' 1585 ' AND Builds.tsEffective <= BuildIDs.tsNow\n' 1586 'GROUP BY Builds.iRevision\n' 1587 'ORDER BY Builds.iRevision DESC\n' ); 1588 workerDoFetch(BuildLogic); 1589 1590 # Build branches. 1591 oCrit = oFilter.aCriteria[TestResultFilter.kiBranches]; 1592 self._oDb.execute('SELECT DISTINCT BuildCategories.sBranch, BuildCategories.sBranch\n' 1593 'FROM ( SELECT DISTINCT TestSets.idBuildCategory\n' 1594 ' FROM TestSets\n' + oFilter.getTableJoins(iOmit = TestResultFilter.kiBranches) + 1595 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1596 oFilter.getWhereConditions(iOmit = TestResultFilter.kiBranches) + 1597 ' ) AS BuildCategoryIDs\n' 1598 ' INNER JOIN BuildCategories\n' 1599 ' ON BuildCategories.idBuildCategory = BuildCategoryIDs.idBuildCategory\n' 1600 'ORDER BY BuildCategories.sBranch DESC\n' ); 1601 workerDoFetch(BuildCategoryLogic, fIdIsName = True); 1602 1603 # Failure reasons. 1604 oCrit = oFilter.aCriteria[TestResultFilter.kiFailReasons]; 1605 self._oDb.execute('SELECT FailureReasons.idFailureReason, FailureReasons.sShort\n' 1606 'FROM ( SELECT TestResultFailures.idFailureReason\n' 1607 ' FROM TestSets\n' 1608 ' INNER JOIN TestResultFailures\n' 1609 ' ON TestResultFailures.idTestSet = TestSets.idTestSet\n' 1610 ' AND TestResultFailures.tsExpire = \'infinity\'::TIMESTAMP\n' + 1611 oFilter.getTableJoins(iOmit = TestResultFilter.kiFailReasons) + 1612 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1613 oFilter.getWhereConditions(iOmit = TestResultFilter.kiFailReasons) + 1614 ' GROUP BY TestResultFailures.idFailureReason\n' 1615 ' ) AS FailureReasonIDs\n' 1616 ' INNER JOIN FailureReasons\n' 1617 ' ON FailureReasons.idFailureReason = FailureReasonIDs.idFailureReason\n' 1618 ' AND FailureReasons.tsExpire = \'infinity\'::TIMESTAMP\n' 1619 'ORDER BY FailureReasons.sShort\n' ); 1620 workerDoFetch(FailureReasonLogic, 'sShort'); 1396 1621 1397 1622 return oFilter;
Note:
See TracChangeset
for help on using the changeset viewer.