Changeset 61267 in vbox for trunk/src/VBox/ValidationKit/testmanager/core
- Timestamp:
- May 28, 2016 8:36:17 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 107559
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/core/testresults.py
r61258 r61267 445 445 ksParam_sComment = 'TestResultFailure_sComment'; 446 446 447 kasAllowNullAttributes = ['tsEffective', 'tsExpire', 'uidAuthor', 'sComment' ];447 kasAllowNullAttributes = ['tsEffective', 'tsExpire', 'uidAuthor', 'sComment', 'idTestSet' ]; 448 448 449 449 kcDbColumns = 7; … … 618 618 self.oFailureReason = None; 619 619 if aoRow[31] is not None: 620 self.oFailureReason = oFailureReasonLogic.cachedLookup(aoRow[3 0]);620 self.oFailureReason = oFailureReasonLogic.cachedLookup(aoRow[31]); 621 621 self.oFailureReasonAssigner = None; 622 622 if aoRow[32] is not None: 623 self.oFailureReasonAssigner = oUserAccountLogic.cachedLookup(aoRow[3 1]);623 self.oFailureReasonAssigner = oUserAccountLogic.cachedLookup(aoRow[32]); 624 624 self.tsFailureReasonAssigned = aoRow[33]; 625 625 self.sFailureReasonComment = aoRow[34]; … … 769 769 kdResultGroupingMap = { 770 770 ksResultsGroupingTypeNone: ( 771 # Grouping tables; # Grouping field; # Grouping where addition. # Sort by overrides.772 ' TestSets',None, None, {}771 # Grouping tables; # Grouping field; # Grouping where addition. # Sort by overrides. 772 '', None, None, {} 773 773 ), 774 ksResultsGroupingTypeTestGroup: (' TestSets', 'TestSets.idTestGroup', None,{}),775 ksResultsGroupingTypeTestBox: (' TestSets', 'TestSets.idTestBox', None,{}),776 ksResultsGroupingTypeTestCase: (' TestSets', 'TestSets.idTestCase', None,{}),774 ksResultsGroupingTypeTestGroup: ('', 'TestSets.idTestGroup', None, {}), 775 ksResultsGroupingTypeTestBox: ('', 'TestSets.idTestBox', None, {}), 776 ksResultsGroupingTypeTestCase: ('', 'TestSets.idTestCase', None, {}), 777 777 ksResultsGroupingTypeBuildRev: ( 778 ' TestSets, Builds',778 ', Builds', 779 779 'Builds.iRevision', 780 780 ' AND Builds.idBuild = TestSets.idBuild' … … 784 784 ), 785 785 ksResultsGroupingTypeSchedGroup: ( 786 ' TestSets, TestBoxes',786 ', TestBoxes', 787 787 'TestBoxes.idSchedGroup', 788 788 ' AND TestSets.idGenTestBox = TestBoxes.idGenTestBox', … … 809 809 self.oUserAccountLogic = None; 810 810 811 def _getTimePeriodQueryPart(self, tsNow, sInterval ):811 def _getTimePeriodQueryPart(self, tsNow, sInterval, sExtraIndent = ''): 812 812 """ 813 813 Get part of SQL query responsible for SELECT data within … … 819 819 if tsNow is None: 820 820 sRet = '(TestSets.tsDone IS NULL OR TestSets.tsDone >= (CURRENT_TIMESTAMP - \'%s\'::interval))\n' \ 821 ' AND TestSets.tsCreated >= (CURRENT_TIMESTAMP - \'%s\'::interval - \'%u months\'::interval)\n' \ 822 % (sInterval, sInterval, cMonthsMourningPeriod); 821 '%s AND TestSets.tsCreated >= (CURRENT_TIMESTAMP - \'%s\'::interval - \'%u months\'::interval)\n' \ 822 % ( sInterval, 823 sExtraIndent, sInterval, cMonthsMourningPeriod); 823 824 else: 824 825 sTsNow = '\'%s\'::TIMESTAMP' % (tsNow,); # It's actually a string already. duh. 825 826 sRet = 'TestSets.tsCreated <= %s\n' \ 826 ' AND TestSets.tsCreated >= (%s - \'%s\'::interval - \'%u months\'::interval)\n' \827 ' AND (TestSets.tsDone IS NULL OR TestSets.tsDone >= (%s - \'%s\'::interval))\n' \827 '% AND TestSets.tsCreated >= (%s - \'%s\'::interval - \'%u months\'::interval)\n' \ 828 '% AND (TestSets.tsDone IS NULL OR TestSets.tsDone >= (%s - \'%s\'::interval))\n' \ 828 829 % ( sTsNow, 829 s TsNow, sInterval, cMonthsMourningPeriod,830 s TsNow, sInterval );830 sExtraIndent, sTsNow, sInterval, cMonthsMourningPeriod, 831 sExtraIndent, sTsNow, sInterval ); 831 832 return sRet 832 833 833 def fetchResultsForListing(self, iStart, cMaxRows, tsNow, sInterval, enmResultSortBy, 834 enmResultsGroupingType, iResultsGroupingValue, fOnlyFailures ):834 def fetchResultsForListing(self, iStart, cMaxRows, tsNow, sInterval, enmResultSortBy, # pylint: disable=R0913 835 enmResultsGroupingType, iResultsGroupingValue, fOnlyFailures, fOnlyNeedingReason): 835 836 """ 836 837 Fetches TestResults table content. … … 902 903 ' Builds,\n' \ 903 904 ' TestBoxes,\n' \ 904 ' TestResults LEFT OUTER JOIN TestResultFailures\n' \ 905 ' ON TestResults.idTestResult = TestResultFailures.idTestResult\n' \ 906 ' AND TestResultFailures.tsExpire = \'infinity\'::TIMESTAMP'; 905 ' TestResults\n' \ 906 ' LEFT OUTER JOIN TestResultFailures\n' \ 907 ' ON TestResults.idTestResult = TestResultFailures.idTestResult\n' \ 908 ' AND TestResultFailures.tsExpire = \'infinity\'::TIMESTAMP'; 907 909 if sSortingOrderBy is not None and sSortingOrderBy.find('FailureReason') >= 0: 908 910 sQuery += '\n' \ 909 911 ' LEFT OUTER JOIN FailureReasons\n' \ 910 ' ONTestResultFailures.idFailureReason = FailureReasons.idFailureReason\n' \911 ' AND FailureReasons.tsExpire = \'infinity\'::TIMESTAMP';912 ' ON TestResultFailures.idFailureReason = FailureReasons.idFailureReason\n' \ 913 ' AND FailureReasons.tsExpire = \'infinity\'::TIMESTAMP'; 912 914 sQuery += ',\n'\ 913 915 ' TestCases,\n' \ … … 922 924 ' TestSets.idGenTestCase AS idGenTestCase,\n' \ 923 925 ' TestSets.idGenTestCaseArgs AS idGenTestCaseArgs\n' \ 924 ' FROM ' + sGroupingTables + sSortingTables + '\n' \ 925 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sInterval); 926 if fOnlyFailures: 927 sQuery += ' AND TestSets.enmStatus != \'success\'::TestStatus_T' \ 928 ' AND TestSets.enmStatus != \'running\'::TestStatus_T'; 926 ' FROM TestSets'; 927 if fOnlyNeedingReason: 928 sQuery += '\n' \ 929 ' LEFT OUTER JOIN TestResultFailures\n' \ 930 ' ON TestSets.idTestSet = TestResultFailures.idTestSet\n' \ 931 ' AND TestResultFailures.tsExpire = \'infinity\'::TIMESTAMP'; 932 sQuery += sGroupingTables.replace(',', ',\n '); 933 sQuery += sSortingTables.replace( ',', ',\n '); 934 sQuery += '\n' \ 935 ' WHERE ' + self._getTimePeriodQueryPart(tsNow, sInterval, ' '); 936 if fOnlyFailures or fOnlyNeedingReason: 937 sQuery += ' AND TestSets.enmStatus != \'success\'::TestStatus_T\n' \ 938 ' AND TestSets.enmStatus != \'running\'::TestStatus_T\n'; 939 if fOnlyNeedingReason: 940 sQuery += ' AND TestResultFailures.idTestSet IS NULL\n'; 929 941 if sGroupingField is not None: 930 942 sQuery += ' AND %s = %d\n' % (sGroupingField, iResultsGroupingValue,); … … 972 984 return aoRows 973 985 974 def getEntriesCount(self, tsNow, sInterval, enmResultsGroupingType, iResultsGroupingValue, fOnlyFailures ):986 def getEntriesCount(self, tsNow, sInterval, enmResultsGroupingType, iResultsGroupingValue, fOnlyFailures, fOnlyNeedingReason): 975 987 """ 976 988 Get number of table records. … … 997 1009 # Construct the query. 998 1010 # 999 sQuery = 'SELECT COUNT(idTestSet)\n' \ 1000 'FROM ' + sGroupingTables + '\n' \ 1001 'WHERE ' + self._getTimePeriodQueryPart(tsNow, sInterval); 1002 if fOnlyFailures: 1003 sQuery += ' AND TestSets.enmStatus != \'success\'::TestStatus_T' \ 1004 ' AND TestSets.enmStatus != \'running\'::TestStatus_T'; 1011 sQuery = 'SELECT COUNT(TestSets.idTestSet)\n' \ 1012 'FROM TestSets'; 1013 if fOnlyNeedingReason: 1014 sQuery += '\n' \ 1015 ' LEFT OUTER JOIN TestResultFailures\n' \ 1016 ' ON TestSets.idTestSet = TestResultFailures.idTestSet\n' \ 1017 ' AND TestResultFailures.tsExpire = \'infinity\'::TIMESTAMP'; 1018 sQuery += sGroupingTables.replace(',', ',\n '); 1019 sQuery += '\n' \ 1020 'WHERE ' + self._getTimePeriodQueryPart(tsNow, sInterval); 1021 if fOnlyFailures or fOnlyNeedingReason: 1022 sQuery += ' AND TestSets.enmStatus != \'success\'::TestStatus_T\n' \ 1023 ' AND TestSets.enmStatus != \'running\'::TestStatus_T\n'; 1024 if fOnlyNeedingReason: 1025 sQuery += ' AND TestResultFailures.idTestSet IS NULL\n'; 1005 1026 if sGroupingField is not None: 1006 1027 sQuery += ' AND %s = %d\n' % (sGroupingField, iResultsGroupingValue,); … … 1062 1083 """ 1063 1084 1064 ## @todo do all in one query. 1065 self._oDb.execute('SELECT DISTINCT TestBoxes.idTestBox, TestBoxes.idGenTestBox\n' 1066 'FROM TestBoxes, TestSets\n' 1067 'WHERE TestSets.idGenTestBox = TestBoxes.idGenTestBox\n' 1068 ' AND ' + self._getTimePeriodQueryPart(tsNow, sPeriod) + 1069 'ORDER BY TestBoxes.idTestBox, TestBoxes.idGenTestBox DESC' ); 1070 idPrevTestBox = -1; 1071 asIdGenTestBoxes = []; 1085 self._oDb.execute('SELECT TestBoxes.*\n' 1086 'FROM TestBoxes,\n' 1087 ' ( SELECT TestBoxes.idTestBox AS idTestBox,\n' 1088 ' MAX(TestBoxes.idGenTestBox) AS idGenTestBox\n' 1089 ' FROM TestBoxes, TestSets\n' 1090 ' WHERE TestSets.idGenTestBox = TestBoxes.idGenTestBox\n' 1091 ' AND ' + self._getTimePeriodQueryPart(tsNow, sPeriod, ' ') + 1092 ' GROUP BY TestBoxes.idTestBox\n' 1093 ' ORDER BY TestBoxes.idTestBox\n' 1094 ' ) AS TestBoxIDs\n' 1095 'WHERE TestBoxes.idGenTestBox = TestBoxIDs.idGenTestBox\n' 1096 'ORDER BY TestBoxes.sName\n' ); 1097 aoRet = [] 1072 1098 for aoRow in self._oDb.fetchAll(): 1073 if aoRow[0] != idPrevTestBox: 1074 idPrevTestBox = aoRow[0]; 1075 asIdGenTestBoxes.append(str(aoRow[1])); 1076 1077 aoRet = [] 1078 if len(asIdGenTestBoxes) > 0: 1079 self._oDb.execute('SELECT *\n' 1080 'FROM TestBoxes\n' 1081 'WHERE idGenTestBox IN (' + ','.join(asIdGenTestBoxes) + ')\n' 1082 'ORDER BY sName'); 1083 for aoRow in self._oDb.fetchAll(): 1084 aoRet.append(TestBoxData().initFromDbRow(aoRow)); 1099 aoRet.append(TestBoxData().initFromDbRow(aoRow)); 1085 1100 return aoRet 1086 1101 … … 2182 2197 def _resolveSetTestIdIfMissing(self, oData): 2183 2198 """ Resolve any missing idTestSet reference (it's a duplicate for speed efficiency). """ 2184 if oData.idTestSet is None and oData.idTestResult is not None 2199 if oData.idTestSet is None and oData.idTestResult is not None: 2185 2200 self._oDb.execute('SELECT idTestSet FROM TestResults WHERE idTestResult = %s', (oData.idTestResult,)); 2186 oData.idTest Result = self._oDb.fetchOne()[0];2201 oData.idTestSet = self._oDb.fetchOne()[0]; 2187 2202 return oData; 2188 2203
Note:
See TracChangeset
for help on using the changeset viewer.