VirtualBox

Ignore:
Timestamp:
May 30, 2016 12:22:41 PM (9 years ago)
Author:
vboxsync
Message:

wuireport.py,++: Added build box failure report. When requesting details on a testcase (or more), you'll now get a report on the test case variations too. Made links include the period length+count and effective date

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/core/report.py

    r61278 r61286  
    3535from testmanager.core.dbobjcache    import DatabaseObjCache;
    3636from testmanager.core.failurereason import FailureReasonLogic;
    37 from testmanager.core.testbox       import TestBoxData;
     37from testmanager.core.testbox       import TestBoxLogic, TestBoxData;
    3838from testmanager.core.testcase      import TestCaseLogic;
     39from testmanager.core.testcaseargs  import TestCaseArgsLogic;
    3940from common                         import constants;
    4041
     
    198199class ReportTransientBase(object):
    199200    """ 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):
    201203        self.idBuild            = idBuild;      # Build ID.
    202204        self.iRevision          = iRevision;    # SVN revision for build.
     
    207209        self.iPeriod            = iPeriod;      # Data set period.
    208210        self.fEnter             = fEnter;       # True if enter event, False if leave event.
     211        self.idSubject          = idSubject;
     212        self.oSubject           = oSubject;
    209213
    210214class ReportFailureReasonTransient(ReportTransientBase):
     
    212216    def __init__(self, idBuild, iRevision, sRepository, idTestSet, idTestResult, tsDone,  # pylint: disable=R0913
    213217                 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);
    215220        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=R0913
    220                  iPeriod, fEnter, oTestCase):
    221         ReportTransientBase.__init__(self, idBuild, iRevision, sRepository, idTestSet, idTestResult, tsDone, iPeriod, fEnter);
    222         self.oTestCase          = oTestCase;      # TestCaseDataEx
    223 
    224221
    225222
     
    246243        self.idFailureReason    = aoRow[0];
    247244        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]);
    253245
    254246
     
    369361        ReportPeriodBase.__init__(self, oSet, iPeriod, sDesc, tsFrom, tsTo);
    370362        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);
    376363
    377364
     
    513500        ReportPeriodSetBase.__init__(self, 'idFailureReason');
    514501
    515 class ReportTestCaseFailureSet(ReportPeriodSetWithTotalBase):
    516     """ What ReportLazyModel.getTestCaseFailures returns. """
    517     def __init__(self):
    518         ReportPeriodSetWithTotalBase.__init__(self, 'idTestCase');
    519502
    520503
     
    720703        Gets the test case failures of the subject in the specified period.
    721704
    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);
    727741
    728742        # Retrieve the period results.
    729         oSet = ReportTestCaseFailureSet();
    730743        for iPeriod in xrange(self.cPeriods):
    731             self._oDb.execute('SELECT   idTestCase,\n'
     744            self._oDb.execute('SELECT   ' + sIdColumn + ',\n'
    732745                              '         COUNT(CASE WHEN enmStatus >= \'failure\' THEN 1 END),\n'
    733746                              '         MIN(tsDone),\n'
     
    738751                              + self.getExtraWhereExprForPeriod(iPeriod)
    739752                              + self.getExtraSubjectWhereExpr() + '\n'
    740                               'GROUP BY idTestCase\n');
     753                              'GROUP BY ' + sIdColumn + '\n');
    741754            aaoRows = self._oDb.fetchAll()
    742755
    743             oPeriod = ReportTestCaseFailurePeriod(oSet, iPeriod, self.getStraightPeriodDesc(iPeriod),
    744                                                   self.getPeriodStart(iPeriod), self.getPeriodEnd(iPeriod));
     756            oPeriod = ReportPeriodWithTotalBase(oSet, iPeriod, self.getStraightPeriodDesc(iPeriod),
     757                                                self.getPeriodStart(iPeriod), self.getPeriodEnd(iPeriod));
    745758
    746759            for aoRow in aaoRows:
    747                 oTestCase = oTestCaseLogic.cachedLookup(aoRow[0]);
    748                 oPeriodRow = ReportTestCaseFailureRow(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);
    750763
    751764            oSet.appendPeriod(oPeriod);
     
    762775        for iPeriod in xrange(1, self.cPeriods):
    763776            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));
    766780
    767781        # Ditto for reasons leaving before the last.
    768782        for iPeriod in xrange(self.cPeriods - 1):
    769783            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));
    772787
    773788        oSet.finalizePass2();
     
    775790        return oSet;
    776791
    777 
    778     def _getEdgeTestCaseFailureOccurence(self, oTestCase, iPeriod, fEnter = True):
     792    def _getEdgeSimpleFailureOccurence(self, idSubject, sIdColumn, oSubject, iPeriod, fEnter = True):
    779793        """
    780794        Helper for the failure reason report that finds the oldest or newest build
     
    784798        is is returned.
    785799
    786         Returns ReportFailureReasonTransient instant.
     800        Returns ReportTransientBase instant.
    787801
    788802        """
     
    797811                          '         Builds,\n'
    798812                          '         BuildCategories' + self.getExtraSubjectTables() + '\n'
    799                           'WHERE    TestSets.idTestCase       = %s\n'
     813                          'WHERE    TestSets.' + sIdColumn + '      = %s\n'
    800814                          '     AND TestSets.idBuild          = Builds.idBuild\n'
    801815                          '     AND TestSets.enmStatus       >= \'failure\'\n'
     
    808822                          '         TestSets.tsCreated ' + sSorting + '\n'
    809823                          'LIMIT 1\n'
    810                           , ( oTestCase.idTestCase, ));
     824                          , ( idSubject, ));
    811825        aoRow = self._oDb.fetchOne();
    812826        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
    818833
    819834
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette