- Timestamp:
- May 29, 2016 9:06:04 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 107575
- Location:
- trunk/src/VBox/ValidationKit/testmanager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/batch/virtual_test_sheriff.py
r61282 r61283 73 73 self.oLogin = None; 74 74 self.uidSelf = -1; 75 self.oLogFile = None; 75 76 76 77 oParser = OptionParser(); 77 oParser.add_option('--start-hours-ago', dest = 'cStartHoursAgo', metavar = '<hours>', default = 0, 78 oParser.add_option('--start-hours-ago', dest = 'cStartHoursAgo', metavar = '<hours>', default = 0, type = 'int', 78 79 help = 'When to start specified as hours relative to current time. Defauls is right now.', ); 79 oParser.add_option('--hours-period', dest = 'c PeriodInHours', metavar = '<period-in-hours>', default = 2,80 oParser.add_option('--hours-period', dest = 'cHoursBack', metavar = '<period-in-hours>', default = 2, type = 'int', 80 81 help = 'Work period specified in hours. Defauls is 2 hours.'); 81 82 oParser.add_option('--real-run-back', dest = 'fRealRun', action = 'store_true', default = False, … … 83 84 oParser.add_option('-q', '--quiet', dest = 'fQuiet', action = 'store_true', default = False, 84 85 help = 'Quiet execution'); 85 oParser.add_option('-l', '--log', dest = 'sBuildLogPath', metavar = '<url>', 86 oParser.add_option('-l', '--log', dest = 'sBuildLogPath', metavar = '<url>', default = None, 86 87 help = 'URL to the build logs (optional).'); 87 88 oParser.add_option('--debug', dest = 'fDebug', action = 'store_true', default = False, … … 90 91 (self.oConfig, _) = oParser.parse_args(); 91 92 93 if self.oConfig.sBuildLogPath is not None and len(self.oConfig.sBuildLogPath) > 0: 94 self.oLogFile = open(self.oConfig.sBuildLogPath, "a"); 95 self.oLogFile.write('VirtualTestSheriff: $Revision$ \n'); 96 97 92 98 def eprint(self, sText): 93 99 """ … … 96 102 """ 97 103 print 'error: %s' % (sText,); 104 if self.oLogFile is not None: 105 self.oLogFile.write('error: %s\n' % (sText,)); 98 106 return 1; 99 107 … … 102 110 Prints debug info. 103 111 """ 104 if not self.oConfig.fDebug: 105 print 'debug: %s' % (sText, ); 112 if self.oConfig.fDebug: 113 if not self.oConfig.fQuiet: 114 print 'debug: %s' % (sText, ); 115 if self.oLogFile is not None: 116 self.oLogFile.write('debug: %s\n' % (sText,)); 106 117 return 0; 107 118 … … 112 123 if not self.oConfig.fQuiet: 113 124 print 'info: %s' % (sText,); 125 if self.oLogFile is not None: 126 self.oLogFile.write('info: %s\n' % (sText,)); 114 127 return 0; 115 128 … … 127 140 and (not self.oConfig.fDebug or self.oConfig.fRealRun): 128 141 return rcExit; 129 tsNow = self.oConfig.tsNow if self.oConfig.fDebug else None; 142 tsNow = self.tsNow if self.oConfig.fDebug else None; 143 cHoursBack = self.oConfig.cHoursBack if self.oConfig.fDebug else 2; 130 144 oTestBoxLogic = TestBoxLogic(self.oDb); 131 145 … … 133 147 # Get list of bad test boxes for given period and check them out individually. 134 148 # 135 aidBadTestBoxes = self.oTestSetLogic.fetchBadTestBoxIds( );149 aidBadTestBoxes = self.oTestSetLogic.fetchBadTestBoxIds(cHoursBack = cHoursBack, tsNow = tsNow); 136 150 for idTestBox in aidBadTestBoxes: 137 151 # Skip if the testbox is already disabled or has a pending reboot command. … … 151 165 152 166 # Get the most recent testsets for this box (descending on tsDone) and see how bad it is. 153 aoSets = self.oTestSetLogic.fetchResultForTestBox(idTestBox, cHoursBack = 2, tsNow = tsNow);167 aoSets = self.oTestSetLogic.fetchResultForTestBox(idTestBox, cHoursBack = cHoursBack, tsNow = tsNow); 154 168 cOkay = 0; 155 169 cBad = 0; … … 160 174 else: 161 175 ## @todo maybe check the elapsed time here, it could still be a bad run. 162 iFirstOkay = iSet;163 176 cOkay += 1; 177 if iFirstOkay > iSet: 178 iFirstOkay = iSet; 164 179 if iSet > 10: 165 180 break; … … 168 183 # history and at least three in the last 10 results. 169 184 if iFirstOkay >= 2 and cBad > 2: 170 if oTestBoxLogic.hasTestBoxRecentlyBeenRebooted(idTestBox, cHoursBack = 2, tsNow = tsNow):185 if oTestBoxLogic.hasTestBoxRecentlyBeenRebooted(idTestBox, cHoursBack = cHoursBack, tsNow = tsNow): 171 186 self.vprint('Disabling testbox #%u (%s) - iFirstOkay=%u cBad=%u cOkay=%u' 172 187 % ( idTestBox, oTestBox.sName, iFirstOkay, cBad, cOkay)); 173 if self.oConfig.fRealRun :188 if self.oConfig.fRealRun is True: 174 189 try: 175 190 oTestBoxLogic.disableTestBox(idTestBox, self.uidSelf, fCommit = True, … … 181 196 self.vprint('Rebooting testbox #%u (%s) - iFirstOkay=%u cBad=%u cOkay=%u' 182 197 % ( idTestBox, oTestBox.sName, iFirstOkay, cBad, cOkay)); 183 if self.oConfig.fRealRun :198 if self.oConfig.fRealRun is True: 184 199 try: 185 200 oTestBoxLogic.rebootTestBox(idTestBox, self.uidSelf, fCommit = True, … … 188 203 except Exception as oXcpt: 189 204 rcExit = self.eprint('Error rebooting testbox #%u (%u): %s\n' % (idTestBox, oTestBox.sName, oXcpt,)); 205 else: 206 self.dprint('badTestBoxManagement: #%u (%s) looks ok: iFirstOkay=%u cBad=%u cOkay=%u' 207 % ( idTestBox, oTestBox.sName, iFirstOkay, cBad, cOkay)); 190 208 return rcExit; 191 209 … … 234 252 self.oDb.close(); 235 253 self.oDb = None; 254 if self.oLogFile is not None: 255 self.oLogFile.close(); 256 self.oLogFile = None; 236 257 return rcExit; 237 258 -
trunk/src/VBox/ValidationKit/testmanager/core/testbox.py
r61282 r61283 908 908 'WHERE idTestBox = %s\n' 909 909 ' AND tsExpire < %s\n' 910 ' AND tsExpire >= %s - interval \'% uhours\'\n'910 ' AND tsExpire >= %s - interval \'%s hours\'\n' 911 911 ' AND enmPendingCmd IN (%s, %s)\n' 912 912 , ( idTestBox, tsNow, tsNow, cHoursBack,
Note:
See TracChangeset
for help on using the changeset viewer.