Changeset 61286 in vbox for trunk/src/VBox/ValidationKit/testmanager/core/report.py
- Timestamp:
- May 30, 2016 12:22:41 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/core/report.py
r61278 r61286 35 35 from testmanager.core.dbobjcache import DatabaseObjCache; 36 36 from testmanager.core.failurereason import FailureReasonLogic; 37 from testmanager.core.testbox import TestBox Data;37 from testmanager.core.testbox import TestBoxLogic, TestBoxData; 38 38 from testmanager.core.testcase import TestCaseLogic; 39 from testmanager.core.testcaseargs import TestCaseArgsLogic; 39 40 from common import constants; 40 41 … … 198 199 class ReportTransientBase(object): 199 200 """ Details on the test where a problem was first/last seen. """ 200 def __init__(self, idBuild, iRevision, sRepository, idTestSet, idTestResult, tsDone, iPeriod, fEnter): 201 def __init__(self, idBuild, iRevision, sRepository, idTestSet, idTestResult, tsDone, # pylint: disable=too-many-arguments 202 iPeriod, fEnter, idSubject, oSubject): 201 203 self.idBuild = idBuild; # Build ID. 202 204 self.iRevision = iRevision; # SVN revision for build. … … 207 209 self.iPeriod = iPeriod; # Data set period. 208 210 self.fEnter = fEnter; # True if enter event, False if leave event. 211 self.idSubject = idSubject; 212 self.oSubject = oSubject; 209 213 210 214 class ReportFailureReasonTransient(ReportTransientBase): … … 212 216 def __init__(self, idBuild, iRevision, sRepository, idTestSet, idTestResult, tsDone, # pylint: disable=R0913 213 217 iPeriod, fEnter, oReason): 214 ReportTransientBase.__init__(self, idBuild, iRevision, sRepository, idTestSet, idTestResult, tsDone, iPeriod, fEnter); 218 ReportTransientBase.__init__(self, idBuild, iRevision, sRepository, idTestSet, idTestResult, tsDone, iPeriod, fEnter, 219 oReason.idFailureReason, oReason); 215 220 self.oReason = oReason; # FailureReasonDataEx 216 217 class ReportTestCaseFailureTransient(ReportTransientBase):218 """ Details on the test where a test case was first/last seen. """219 def __init__(self, idBuild, iRevision, sRepository, idTestSet, idTestResult, tsDone, # pylint: disable=R0913220 iPeriod, fEnter, oTestCase):221 ReportTransientBase.__init__(self, idBuild, iRevision, sRepository, idTestSet, idTestResult, tsDone, iPeriod, fEnter);222 self.oTestCase = oTestCase; # TestCaseDataEx223 224 221 225 222 … … 246 243 self.idFailureReason = aoRow[0]; 247 244 self.oReason = oReason; # FailureReasonDataEx 248 249 class ReportTestCaseFailureRow(ReportHitRowWithTotalBase):250 """ The account of one test case for a period. """251 def __init__(self, aoRow, oTestCase):252 ReportHitRowWithTotalBase.__init__(self, aoRow[0], oTestCase, aoRow[1], aoRow[4], aoRow[2], aoRow[3]);253 245 254 246 … … 369 361 ReportPeriodBase.__init__(self, oSet, iPeriod, sDesc, tsFrom, tsTo); 370 362 self.cWithoutReason = 0; # Number of failed test sets without any assigned reason. 371 372 class ReportTestCaseFailurePeriod(ReportPeriodWithTotalBase):373 """ A period in ReportTestCaseFailureSet. """374 def __init__(self, oSet, iPeriod, sDesc, tsFrom, tsTo):375 ReportPeriodWithTotalBase.__init__(self, oSet, iPeriod, sDesc, tsFrom, tsTo);376 363 377 364 … … 513 500 ReportPeriodSetBase.__init__(self, 'idFailureReason'); 514 501 515 class ReportTestCaseFailureSet(ReportPeriodSetWithTotalBase):516 """ What ReportLazyModel.getTestCaseFailures returns. """517 def __init__(self):518 ReportPeriodSetWithTotalBase.__init__(self, 'idTestCase');519 502 520 503 … … 720 703 Gets the test case failures of the subject in the specified period. 721 704 722 Returns a ReportTestCaseFailureSet instance. 723 724 """ 725 726 oTestCaseLogic = TestCaseLogic(self._oDb); 705 Returns a ReportPeriodSetWithTotalBase instance. 706 707 """ 708 return self._getSimpleFailures('idTestCase', TestCaseLogic); 709 710 711 def getTestCaseVariationFailures(self): 712 """ 713 Gets the test case failures of the subject in the specified period. 714 715 Returns a ReportPeriodSetWithTotalBase instance. 716 717 """ 718 return self._getSimpleFailures('idTestCaseArgs', TestCaseArgsLogic); 719 720 721 def getTestBoxFailures(self): 722 """ 723 Gets the test box failures of the subject in the specified period. 724 725 Returns a ReportPeriodSetWithTotalBase instance. 726 727 """ 728 return self._getSimpleFailures('idTestBox', TestBoxLogic); 729 730 731 def _getSimpleFailures(self, sIdColumn, oCacheLogicType, sIdAttr = None): 732 """ 733 Gets the test box failures of the subject in the specified period. 734 735 Returns a ReportPeriodSetWithTotalBase instance. 736 737 """ 738 739 oLogic = oCacheLogicType(self._oDb); 740 oSet = ReportPeriodSetWithTotalBase(sIdColumn if sIdAttr is None else sIdAttr); 727 741 728 742 # Retrieve the period results. 729 oSet = ReportTestCaseFailureSet();730 743 for iPeriod in xrange(self.cPeriods): 731 self._oDb.execute('SELECT idTestCase,\n'744 self._oDb.execute('SELECT ' + sIdColumn + ',\n' 732 745 ' COUNT(CASE WHEN enmStatus >= \'failure\' THEN 1 END),\n' 733 746 ' MIN(tsDone),\n' … … 738 751 + self.getExtraWhereExprForPeriod(iPeriod) 739 752 + self.getExtraSubjectWhereExpr() + '\n' 740 'GROUP BY idTestCase\n');753 'GROUP BY ' + sIdColumn + '\n'); 741 754 aaoRows = self._oDb.fetchAll() 742 755 743 oPeriod = Report TestCaseFailurePeriod(oSet, iPeriod, self.getStraightPeriodDesc(iPeriod),744 756 oPeriod = ReportPeriodWithTotalBase(oSet, iPeriod, self.getStraightPeriodDesc(iPeriod), 757 self.getPeriodStart(iPeriod), self.getPeriodEnd(iPeriod)); 745 758 746 759 for aoRow in aaoRows: 747 o TestCase = oTestCaseLogic.cachedLookup(aoRow[0]);748 oPeriodRow = Report TestCaseFailureRow(aoRow, oTestCase);749 oPeriod.appendRow(oPeriodRow, oTestCase.idTestCase, oTestCase);760 oSubject = oLogic.cachedLookup(aoRow[0]); 761 oPeriodRow = ReportHitRowWithTotalBase(aoRow[0], oSubject, aoRow[1], aoRow[4], aoRow[2], aoRow[3]); 762 oPeriod.appendRow(oPeriodRow, aoRow[0], oSubject); 750 763 751 764 oSet.appendPeriod(oPeriod); … … 762 775 for iPeriod in xrange(1, self.cPeriods): 763 776 oPeriod = oSet.aoPeriods[iPeriod]; 764 for oTestCase in oPeriod.dFirst.values(): 765 oSet.aoEnterInfo.append(self._getEdgeTestCaseFailureOccurence(oTestCase, iPeriod, fEnter = True)); 777 for idSubject, oSubject in oPeriod.dFirst.items(): 778 oSet.aoEnterInfo.append(self._getEdgeSimpleFailureOccurence(idSubject, sIdColumn, oSubject, 779 iPeriod, fEnter = True)); 766 780 767 781 # Ditto for reasons leaving before the last. 768 782 for iPeriod in xrange(self.cPeriods - 1): 769 783 oPeriod = oSet.aoPeriods[iPeriod]; 770 for oTestCase in oPeriod.dLast.values(): 771 oSet.aoLeaveInfo.append(self._getEdgeTestCaseFailureOccurence(oTestCase, iPeriod, fEnter = False)); 784 for idSubject, oSubject in oPeriod.dLast.items(): 785 oSet.aoLeaveInfo.append(self._getEdgeSimpleFailureOccurence(idSubject, sIdColumn, oSubject, 786 iPeriod, fEnter = False)); 772 787 773 788 oSet.finalizePass2(); … … 775 790 return oSet; 776 791 777 778 def _getEdgeTestCaseFailureOccurence(self, oTestCase, iPeriod, fEnter = True): 792 def _getEdgeSimpleFailureOccurence(self, idSubject, sIdColumn, oSubject, iPeriod, fEnter = True): 779 793 """ 780 794 Helper for the failure reason report that finds the oldest or newest build … … 784 798 is is returned. 785 799 786 Returns Report FailureReasonTransientinstant.800 Returns ReportTransientBase instant. 787 801 788 802 """ … … 797 811 ' Builds,\n' 798 812 ' BuildCategories' + self.getExtraSubjectTables() + '\n' 799 'WHERE TestSets. idTestCase= %s\n'813 'WHERE TestSets.' + sIdColumn + ' = %s\n' 800 814 ' AND TestSets.idBuild = Builds.idBuild\n' 801 815 ' AND TestSets.enmStatus >= \'failure\'\n' … … 808 822 ' TestSets.tsCreated ' + sSorting + '\n' 809 823 'LIMIT 1\n' 810 , ( oTestCase.idTestCase, ));824 , ( idSubject, )); 811 825 aoRow = self._oDb.fetchOne(); 812 826 if aoRow is None: 813 return ReportTestCaseFailureTransient(-1, -1, 'internal-error', -1, -1, 814 self._oDb.getCurrentTimestamp(), oTestCase, iPeriod, fEnter); 815 return ReportTestCaseFailureTransient(idBuild = aoRow[3], iRevision = aoRow[4], sRepository = aoRow[5], 816 idTestSet = aoRow[1], idTestResult = aoRow[0], tsDone = aoRow[2], 817 oTestCase = oTestCase, iPeriod = iPeriod, fEnter = fEnter); 827 return ReportTransientBase(-1, -1, 'internal-error', -1, -1, self._oDb.getCurrentTimestamp(), 828 iPeriod, fEnter, idSubject, oSubject); 829 return ReportTransientBase(idBuild = aoRow[3], iRevision = aoRow[4], sRepository = aoRow[5], 830 idTestSet = aoRow[1], idTestResult = aoRow[0], tsDone = aoRow[2], 831 iPeriod = iPeriod, fEnter = fEnter, idSubject = idSubject, oSubject = oSubject); 832 818 833 819 834
Note:
See TracChangeset
for help on using the changeset viewer.