VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/batch/check_for_deleted_builds.py@ 103914

Last change on this file since 103914 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: check_for_deleted_builds.py 98103 2023-01-17 14:15:46Z vboxsync $
4# pylint: disable=line-too-long
5
6"""
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.
13"""
14
15from __future__ import print_function;
16
17__copyright__ = \
18"""
19Copyright (C) 2012-2023 Oracle and/or its affiliates.
20
21This file is part of VirtualBox base platform packages, as
22available from https://www.virtualbox.org.
23
24This program is free software; you can redistribute it and/or
25modify it under the terms of the GNU General Public License
26as published by the Free Software Foundation, in version 3 of the
27License.
28
29This program is distributed in the hope that it will be useful, but
30WITHOUT ANY WARRANTY; without even the implied warranty of
31MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32General Public License for more details.
33
34You should have received a copy of the GNU General Public License
35along with this program; if not, see <https://www.gnu.org/licenses>.
36
37The contents of this file may alternatively be used under the terms
38of the Common Development and Distribution License Version 1.0
39(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
40in the VirtualBox distribution, in which case the provisions of the
41CDDL are applicable instead of those of the GPL.
42
43You may elect to license modified versions of this file under the
44terms and conditions of either the GPL or the CDDL or both.
45
46SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
47"""
48__version__ = "$Revision: 98103 $"
49
50# Standard python imports
51import sys;
52import os;
53from optparse import OptionParser; # pylint: disable=deprecated-module
54
55# Add Test Manager's modules path
56g_ksTestManagerDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
57sys.path.append(g_ksTestManagerDir);
58
59# Test Manager imports
60from testmanager.core.db import TMDatabaseConnection;
61from testmanager.core.build import BuildLogic;
62
63
64
65class BuildChecker(object): # pylint: disable=too-few-public-methods
66 """
67 Add build info into Test Manager database.
68 """
69
70 def __init__(self):
71 """
72 Parse command line.
73 """
74
75 oParser = OptionParser();
76 oParser.add_option('-q', '--quiet', dest = 'fQuiet', action = 'store_true', default = False,
77 help = 'Quiet execution');
78 oParser.add_option('--dry-run', dest = 'fRealRun', action = 'store_false', default = False,
79 help = 'Dry run');
80 oParser.add_option('--real-run', dest = 'fRealRun', action = 'store_true', default = False,
81 help = 'Real run');
82
83 (self.oConfig, _) = oParser.parse_args();
84 if not self.oConfig.fQuiet:
85 if not self.oConfig.fRealRun:
86 print('Dry run.');
87 else:
88 print('Real run! Will commit findings!');
89
90
91 def checkBuilds(self):
92 """
93 Add build data record into database.
94 """
95 oDb = TMDatabaseConnection();
96 oBuildLogic = BuildLogic(oDb);
97
98 tsNow = oDb.getCurrentTimestamp();
99 cMaxRows = 1024;
100 iStart = 0;
101 while True:
102 aoBuilds = oBuildLogic.fetchForListing(iStart, cMaxRows, tsNow);
103 if not self.oConfig.fQuiet and aoBuilds:
104 print('Processing builds #%s thru #%s' % (aoBuilds[0].idBuild, aoBuilds[-1].idBuild));
105
106 for oBuild in aoBuilds:
107 if oBuild.fBinariesDeleted is False:
108 rc = oBuild.areFilesStillThere();
109 if rc is False:
110 if not self.oConfig.fQuiet:
111 print('missing files for build #%s / r%s / %s / %s / %s / %s / %s'
112 % (oBuild.idBuild, oBuild.iRevision, oBuild.sVersion, oBuild.oCat.sType,
113 oBuild.oCat.sBranch, oBuild.oCat.sProduct, oBuild.oCat.asOsArches,));
114 print(' %s' % (oBuild.sBinaries,));
115 if self.oConfig.fRealRun is True:
116 oBuild.fBinariesDeleted = True;
117 oBuildLogic.editEntry(oBuild, fCommit = True);
118 elif rc is True and not self.oConfig.fQuiet:
119 print('build #%s still have its files' % (oBuild.idBuild,));
120 elif rc is None and not self.oConfig.fQuiet:
121 print('Unable to determine state of build #%s' % (oBuild.idBuild,));
122
123 # advance
124 if len(aoBuilds) < cMaxRows:
125 break;
126 iStart += len(aoBuilds);
127
128 oDb.close();
129 return 0;
130
131if __name__ == '__main__':
132 sys.exit(BuildChecker().checkBuilds());
133
Note: See TracBrowser for help on using the repository browser.

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