VirtualBox

Changeset 62544 in vbox


Ignore:
Timestamp:
Jul 25, 2016 3:58:37 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
109113
Message:

test manager: new batch job: check_for_deleted_builds.py

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/batch/check_for_deleted_builds.py

    r62540 r62544  
    55
    66"""
    7 Interface used by the tinderbox server side software to add a fresh build.
     7Admin job for checking detecting deleted builds.
     8
     9This is necessary when the tinderbox <-> test manager interface was
     10busted and the build info in is out of sync.  The result is generally
     11a lot of skipped tests because of missing builds, typically during
     12bisecting problems.
    813"""
    914
     
    4247# Test Manager imports
    4348from testmanager.core.db    import TMDatabaseConnection;
    44 from testmanager.core.build import BuildDataEx, BuildLogic, BuildCategoryData;
     49from testmanager.core.build import BuildLogic;
    4550
    46 class Build(object): # pylint: disable=R0903
     51class BuildChecker(object): # pylint: disable=R0903
    4752    """
    4853    Add build info into Test Manager database.
     
    5560
    5661        oParser = OptionParser();
    57         oParser.add_option('-q', '--quiet', dest = 'fQuiet', action = 'store_true',
     62        oParser.add_option('-q', '--quiet', dest = 'fQuiet', action = 'store_true',  default = False,
    5863                           help = 'Quiet execution');
    59         oParser.add_option('-b', '--branch', dest = 'sBranch', metavar = '<branch>',
    60                            help = 'branch name (default: trunk)', default = 'trunk');
    61         oParser.add_option('-p', '--product', dest = 'sProductName', metavar = '<name>',
    62                            help = 'The product name.');
    63         oParser.add_option('-r', '--revision', dest = 'iRevision', metavar = '<rev>',
    64                            help = 'revision number');
    65         oParser.add_option('-R', '--repository', dest = 'sRepository', metavar = '<repository>',
    66                            help = 'Version control repository name.');
    67         oParser.add_option('-t', '--type', dest = 'sBuildType', metavar = '<type>',
    68                            help = 'build type (debug, release etc.)');
    69         oParser.add_option('-v', '--version', dest = 'sProductVersion', metavar = '<ver>',
    70                            help = 'The product version number (suitable for RTStrVersionCompare)');
    71         oParser.add_option('-o', '--os-arch', dest = 'asTargetOsArches', metavar = '<os.arch>', action = 'append',
    72                            help = 'Target OS and architecture. This option can be repeated.');
    73         oParser.add_option('-l', '--log', dest = 'sBuildLogPath', metavar = '<url>',
    74                            help = 'URL to the build logs (optional).');
    75         oParser.add_option('-f', '--file', dest = 'asFiles', metavar = '<file|url>', action = 'append',
    76                            help = 'URLs or build share relative path to a build output file. This option can be repeated.');
     64        oParser.add_option('--dry-run', dest = 'fRealRun',   action = 'store_false', default = False,
     65                           help = 'Dry run');
     66        oParser.add_option('--real-run', dest = 'fRealRun',  action = 'store_true',  default = False,
     67                           help = 'Real run');
    7768
    7869        (self.oConfig, _) = oParser.parse_args();
     70        if not self.oConfig.fQuiet:
     71            if not self.oConfig.fRealRun:
     72                print 'Dry run.';
     73            else:
     74                print 'Real run! Will commit findings!';
    7975
    80         # Check command line
    81         asMissing = [];
    82         if self.oConfig.sBranch is None:            asMissing.append('--branch');
    83         if self.oConfig.iRevision is None:          asMissing.append('--revision');
    84         if self.oConfig.sProductVersion is None:    asMissing.append('--version');
    85         if self.oConfig.sProductName is None:       asMissing.append('--product');
    86         if self.oConfig.sBuildType is None:         asMissing.append('--type');
    87         if self.oConfig.asTargetOsArches is None:   asMissing.append('--os-arch');
    88         if self.oConfig.asFiles is None:            asMissing.append('--file');
    89         if len(asMissing) > 0:
    90             sys.stderr.write('syntax error: Missing: %s\n' % (asMissing,));
    91             sys.exit(1);
    92         # Temporary default.
    93         if self.oConfig.sRepository is None:
    94             self.oConfig.sRepository = 'vbox';
    9576
    96     def add(self):
     77    def checkBuilds(self):
    9778        """
    9879        Add build data record into database.
    9980        """
    100         oDb = TMDatabaseConnection()
     81        oDb = TMDatabaseConnection();
     82        oBuildLogic = BuildLogic(oDb);
    10183
    102         # Assemble the build data.
    103         oBuildData = BuildDataEx()
    104         oBuildData.idBuildCategory    = None;
    105         oBuildData.iRevision          = self.oConfig.iRevision
    106         oBuildData.sVersion           = self.oConfig.sProductVersion
    107         oBuildData.sLogUrl            = self.oConfig.sBuildLogPath
    108         oBuildData.sBinaries          = ','.join(self.oConfig.asFiles);
    109         oBuildData.oCat = BuildCategoryData().initFromValues(sProduct    = self.oConfig.sProductName,
    110                                                              sRepository = self.oConfig.sRepository,
    111                                                              sBranch     = self.oConfig.sBranch,
    112                                                              sType       = self.oConfig.sBuildType,
    113                                                              asOsArches  = self.oConfig.asTargetOsArches);
     84        tsNow    = oDb.getCurrentTimestamp();
     85        cMaxRows = 1024;
     86        iStart   = 0;
     87        while True:
     88            aoBuilds = oBuildLogic.fetchForListing(iStart, cMaxRows, tsNow);
     89            for oBuild in aoBuilds:
     90                if oBuild.fBinariesDeleted is False:
     91                    rc = oBuild.areFilesStillThere();
     92                    if rc is False:
     93                        if not self.oConfig.fQuiet:
     94                            print 'missing files for build #%s' % (oBuild.idBuild,);
     95                        if self.oConfig.fRealRun is True:
     96                            oBuild.fBinariesDeleted = True;
     97                            oBuildLogic.editEntry(oBuild, fCommit = True);
    11498
    115         # Add record to database
    116         try:
    117             BuildLogic(oDb).addEntry(oBuildData, fCommit = True);
    118         except:
    119             if self.oConfig.fQuiet:
    120                 sys.exit(1);
    121             raise;
     99            # advance
     100            if len(aoBuilds) < cMaxRows:
     101                break;
     102            iStart += len(aoBuilds);
     103
    122104        oDb.close();
    123105        return 0;
    124106
    125107if __name__ == '__main__':
    126     sys.exit(Build().add());
     108    sys.exit(BuildChecker().checkBuilds());
    127109
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