Changeset 65040 in vbox for trunk/src/VBox/ValidationKit/testmanager/core
- Timestamp:
- Dec 31, 2016 2:29:50 AM (8 years ago)
- Location:
- trunk/src/VBox/ValidationKit/testmanager/core
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/core/build.py
r62548 r65040 479 479 Build database logic (covers build categories as well as builds). 480 480 """ 481 482 def __init__(self, oDb): 483 ModelLogicBase.__init__(self, oDb) 484 self.dCache = None; 481 485 482 486 # … … 609 613 self._oDb.maybeCommit(fCommit); 610 614 return True; 615 616 def cachedLookup(self, idBuild): 617 """ 618 Looks up the most recent BuildDataEx object for idBuild 619 via an object cache. 620 621 Returns a shared BuildDataEx object. None if not found. 622 Raises exception on DB error. 623 """ 624 if self.dCache is None: 625 self.dCache = self._oDb.getCache('BuildDataEx'); 626 oEntry = self.dCache.get(idBuild, None); 627 if oEntry is None: 628 self._oDb.execute('SELECT Builds.*, BuildCategories.*\n' 629 'FROM Builds, BuildCategories\n' 630 'WHERE Builds.idBuild = %s\n' 631 ' AND Builds.idBuildCategory = BuildCategories.idBuildCategory\n' 632 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 633 , (idBuild, )); 634 if self._oDb.getRowCount() == 0: 635 # Maybe it was deleted, try get the last entry. 636 self._oDb.execute('SELECT Builds.*, BuildCategories.*\n' 637 'FROM Builds, BuildCategories\n' 638 'WHERE Builds.idBuild = %s\n' 639 ' AND Builds.idBuildCategory = BuildCategories.idBuildCategory\n' 640 'ORDER BY tsExpire DESC\n' 641 'LIMIT 1\n' 642 , (idBuild, )); 643 elif self._oDb.getRowCount() > 1: 644 raise self._oDb.integrityException('%s infinity rows for %s' % (self._oDb.getRowCount(), idBuild)); 645 646 if self._oDb.getRowCount() == 1: 647 aaoRow = self._oDb.fetchOne(); 648 oEntry = BuildDataEx(); 649 oEntry.initFromDbRow(aaoRow); 650 self.dCache[idBuild] = oEntry; 651 return oEntry; 611 652 612 653 -
trunk/src/VBox/ValidationKit/testmanager/core/buildblacklist.py
r62484 r65040 123 123 Build Back List logic. 124 124 """ 125 126 def __init__(self, oDb): 127 ModelLogicBase.__init__(self, oDb) 128 self.dCache = None; 125 129 126 130 def fetchForListing(self, iStart, cMaxRows, tsNow): … … 223 227 self._oDb.maybeCommit(fCommit); 224 228 return True; 229 230 231 def cachedLookup(self, idBlacklisting): 232 """ 233 Looks up the most recent BuildBlacklistData object for idBlacklisting 234 via an object cache. 235 236 Returns a shared BuildBlacklistData object. None if not found. 237 Raises exception on DB error. 238 """ 239 if self.dCache is None: 240 self.dCache = self._oDb.getCache('BuildBlacklistData'); 241 oEntry = self.dCache.get(idBlacklisting, None); 242 if oEntry is None: 243 self._oDb.execute('SELECT *\n' 244 'FROM BuildBlacklist\n' 245 'WHERE idBlacklisting = %s\n' 246 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 247 , (idBlacklisting, )); 248 if self._oDb.getRowCount() == 0: 249 # Maybe it was deleted, try get the last entry. 250 self._oDb.execute('SELECT *\n' 251 'FROM BuildBlacklist\n' 252 'WHERE idBlacklisting = %s\n' 253 'ORDER BY tsExpire DESC\n' 254 'LIMIT 1\n' 255 , (idBlacklisting, )); 256 elif self._oDb.getRowCount() > 1: 257 raise self._oDb.integrityException('%s infinity rows for %s' % (self._oDb.getRowCount(), idBlacklisting)); 258 259 if self._oDb.getRowCount() == 1: 260 aaoRow = self._oDb.fetchOne(); 261 oEntry = BuildBlacklistData(); 262 oEntry.initFromDbRow(aaoRow); 263 self.dCache[idBlacklisting] = oEntry; 264 return oEntry; 225 265 226 266 -
trunk/src/VBox/ValidationKit/testmanager/core/buildsource.py
r62484 r65040 154 154 Build source database logic. 155 155 """ 156 157 def __init__(self, oDb): 158 ModelLogicBase.__init__(self, oDb) 159 self.dCache = None; 156 160 157 161 # … … 325 329 return True; 326 330 331 def cachedLookup(self, idBuildSrc): 332 """ 333 Looks up the most recent BuildSourceData object for idBuildSrc 334 via an object cache. 335 336 Returns a shared BuildSourceData object. None if not found. 337 Raises exception on DB error. 338 """ 339 if self.dCache is None: 340 self.dCache = self._oDb.getCache('BuildSourceData'); 341 oEntry = self.dCache.get(idBuildSrc, None); 342 if oEntry is None: 343 self._oDb.execute('SELECT *\n' 344 'FROM BuildSources\n' 345 'WHERE idBuildSrc = %s\n' 346 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 347 , (idBuildSrc, )); 348 if self._oDb.getRowCount() == 0: 349 # Maybe it was deleted, try get the last entry. 350 self._oDb.execute('SELECT *\n' 351 'FROM BuildSources\n' 352 'WHERE idBuildSrc = %s\n' 353 'ORDER BY tsExpire DESC\n' 354 'LIMIT 1\n' 355 , (idBuildSrc, )); 356 elif self._oDb.getRowCount() > 1: 357 raise self._oDb.integrityException('%s infinity rows for %s' % (self._oDb.getRowCount(), idBuildSrc)); 358 359 if self._oDb.getRowCount() == 1: 360 aaoRow = self._oDb.fetchOne(); 361 oEntry = BuildSourceData(); 362 oEntry.initFromDbRow(aaoRow); 363 self.dCache[idBuildSrc] = oEntry; 364 return oEntry; 327 365 328 366 # -
trunk/src/VBox/ValidationKit/testmanager/core/failurereason.py
r62484 r65040 213 213 'ORDER BY sShort ASC\n' 214 214 'LIMIT %s OFFSET %s\n' 215 , ( tsNow, tsNow, idFailureCategory, cMaxRows, iStart,));215 , ( idFailureCategory, tsNow, tsNow, cMaxRows, iStart,)); 216 216 217 217 aoRows = [] -
trunk/src/VBox/ValidationKit/testmanager/core/globalresource.py
r62484 r65040 120 120 """ 121 121 122 def __init__(self, oDb): 123 ModelLogicBase.__init__(self, oDb) 124 self.dCache = None; 125 122 126 def fetchForListing(self, iStart, cMaxRows, tsNow): 123 127 """ … … 146 150 aoRows.append(GlobalResourceData().initFromDbRow(aoRow)) 147 151 return aoRows 152 153 154 def cachedLookup(self, idGlobalRsrc): 155 """ 156 Looks up the most recent GlobalResourceData object for idGlobalRsrc 157 via an object cache. 158 159 Returns a shared GlobalResourceData object. None if not found. 160 Raises exception on DB error. 161 """ 162 if self.dCache is None: 163 self.dCache = self._oDb.getCache('GlobalResourceData'); 164 oEntry = self.dCache.get(idGlobalRsrc, None); 165 if oEntry is None: 166 self._oDb.execute('SELECT *\n' 167 'FROM GlobalResources\n' 168 'WHERE idGlobalRsrc = %s\n' 169 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 170 , (idGlobalRsrc, )); 171 if self._oDb.getRowCount() == 0: 172 # Maybe it was deleted, try get the last entry. 173 self._oDb.execute('SELECT *\n' 174 'FROM GlobalResources\n' 175 'WHERE idGlobalRsrc = %s\n' 176 'ORDER BY tsExpire DESC\n' 177 'LIMIT 1\n' 178 , (idGlobalRsrc, )); 179 elif self._oDb.getRowCount() > 1: 180 raise self._oDb.integrityException('%s infinity rows for %s' % (self._oDb.getRowCount(), idGlobalRsrc)); 181 182 if self._oDb.getRowCount() == 1: 183 aaoRow = self._oDb.fetchOne(); 184 oEntry = GlobalResourceData(); 185 oEntry.initFromDbRow(aaoRow); 186 self.dCache[idGlobalRsrc] = oEntry; 187 return oEntry; 188 148 189 149 190 def getAll(self, tsEffective = None): -
trunk/src/VBox/ValidationKit/testmanager/core/schedgroup.py
r62484 r65040 425 425 SchedGroup logic. 426 426 """ 427 428 def __init__(self, oDb): 429 ModelLogicBase.__init__(self, oDb); 430 self.dCache = None; 427 431 428 432 # … … 610 614 return True; 611 615 616 617 def cachedLookup(self, idSchedGroup): 618 """ 619 Looks up the most recent SchedGroupData object for idSchedGroup 620 via an object cache. 621 622 Returns a shared SchedGroupData object. None if not found. 623 Raises exception on DB error. 624 """ 625 if self.dCache is None: 626 self.dCache = self._oDb.getCache('SchedGroup'); 627 628 oEntry = self.dCache.get(idSchedGroup, None); 629 if oEntry is None: 630 self._oDb.execute('SELECT *\n' 631 'FROM SchedGroups\n' 632 'WHERE idSchedGroup = %s\n' 633 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 634 , (idSchedGroup, )); 635 if self._oDb.getRowCount() == 0: 636 # Maybe it was deleted, try get the last entry. 637 self._oDb.execute('SELECT *\n' 638 'FROM SchedGroups\n' 639 'WHERE idSchedGroup = %s\n' 640 'ORDER BY tsExpire DESC\n' 641 'LIMIT 1\n' 642 , (idSchedGroup, )); 643 elif self._oDb.getRowCount() > 1: 644 raise self._oDb.integrityException('%s infinity rows for %s' % (self._oDb.getRowCount(), idSchedGroup)); 645 646 if self._oDb.getRowCount() == 1: 647 oEntry = SchedGroupData().initFromDbRow(self._oDb.fetchOne()); 648 self.dCache[idSchedGroup] = oEntry; 649 return oEntry; 612 650 613 651 -
trunk/src/VBox/ValidationKit/testmanager/core/systemchangelog.py
r65039 r65040 31 31 32 32 # Validation Kit imports. 33 from testmanager.core.base import ModelLogicBase;33 from testmanager.core.base import ModelLogicBase; 34 34 from testmanager.core.useraccount import UserAccountLogic; 35 from testmanager.core.systemlog import SystemLogData; 35 36 36 37 … … 40 41 """ 41 42 42 def __init__(self, tsEffective, oAuthor, s What, idWhat, sDesc):43 def __init__(self, tsEffective, oAuthor, sEvent, idWhat, sDesc): 43 44 self.tsEffective = tsEffective; 44 45 self.oAuthor = oAuthor; 45 self.s What = sWhat;46 self.sEvent = sEvent; 46 47 self.idWhat = idWhat; 47 48 self.sDesc = sDesc; … … 55 56 ## @name What kind of change. 56 57 ## @{ 57 ksWhat_TestBox = 'TestBox'; 58 ksWhat_TestCase = 'TestCase'; 59 ksWhat_Blacklisting = 'Blacklisting'; 60 ksWhat_Build = 'Build'; 61 ksWhat_BuildSource = 'BuildSource'; 62 ksWhat_FailureCategory = 'FailureCategory'; 63 ksWhat_FailureReason = 'FailureReason'; 64 ksWhat_GlobalRsrc = 'GlobalRsrc'; 65 ksWhat_SchedGroup = 'SchedGroup'; 66 ksWhat_SystemLog = 'SystemLog'; 67 ksWhat_TestGroup = 'TestGroup'; 68 ksWhat_User = 'User'; 69 ksWhat_TestResult = 'TestResult'; 58 ksWhat_TestBox = 'chlog::TestBox'; 59 ksWhat_TestCase = 'chlog::TestCase'; 60 ksWhat_Blacklisting = 'chlog::Blacklisting'; 61 ksWhat_Build = 'chlog::Build'; 62 ksWhat_BuildSource = 'chlog::BuildSource'; 63 ksWhat_FailureCategory = 'chlog::FailureCategory'; 64 ksWhat_FailureReason = 'chlog::FailureReason'; 65 ksWhat_GlobalRsrc = 'chlog::GlobalRsrc'; 66 ksWhat_SchedGroup = 'chlog::SchedGroup'; 67 ksWhat_TestGroup = 'chlog::TestGroup'; 68 ksWhat_User = 'chlog::User'; 69 ksWhat_TestResult = 'chlog::TestResult'; 70 70 ## @} 71 71 … … 84 84 ksWhat_GlobalRsrc: ( 'GlobalResources', 'idGlobalRsrc', None, ), 85 85 ksWhat_SchedGroup: ( 'SchedGroupes', 'idSchedGroup', None, ), 86 ksWhat_SystemLog: ( 'SystemLog', 'tsCreated', ksClue_TimestampId, ),87 86 ksWhat_TestGroup: ( 'TestGroupes', 'idTestGroup', None, ), 88 87 ksWhat_User: ( 'Users', 'idUser', None, ), 89 88 ksWhat_TestResult: ( 'TestResults', 'idTestResult', None, ), 90 89 }; 90 for sEvent in SystemLogData.kasEvents: 91 kdWhatToTable[sEvent] = ( 'SystemLog', 'tsCreated', ksClue_TimestampId, ); 91 92 92 93 ## @todo move to config.py? … … 155 156 sQuery = '(\n' 156 157 sQuery += ' SELECT NULL AS uidAuthor,\n'; 157 sQuery += ' tsCreated astsEffective,\n';158 sQuery += ' \'' + self.ksWhat_SystemLog + '\' AS sWhat,\n';159 sQuery += ' NULL AS idWhat,\n';160 sQuery += ' CONCAT(sEvent, \': \', sLogText)AS sDesc\n';158 sQuery += ' tsCreated AS tsEffective,\n'; 159 sQuery += ' sEvent AS sEvent,\n'; 160 sQuery += ' NULL AS idWhat,\n'; 161 sQuery += ' sLogText AS sDesc\n'; 161 162 sQuery += ' FROM SystemLog\n'; 162 163 sQuery += sWhereTime.replace('tsEffective', 'tsCreated'); -
trunk/src/VBox/ValidationKit/testmanager/core/testbox.py
r65039 r65040 995 995 # Maybe it was deleted, try get the last entry. 996 996 self._oDb.execute('SELECT TestBoxesWithStrings.*\n' 997 'FROM TestBoxes \n'997 'FROM TestBoxesWithStrings\n' 998 998 'WHERE idTestBox = %s\n' 999 999 'ORDER BY tsExpire DESC\n' -
trunk/src/VBox/ValidationKit/testmanager/core/testgroup.py
r62484 r65040 372 372 """ 373 373 374 def __init__(self, oDb): 375 ModelLogicBase.__init__(self, oDb) 376 self.dCache = None; 377 374 378 # 375 379 # Standard methods. … … 550 554 return True; 551 555 556 def cachedLookup(self, idTestGroup): 557 """ 558 Looks up the most recent TestGroupDataEx object for idTestGroup 559 via an object cache. 560 561 Returns a shared TestGroupDataEx object. None if not found. 562 Raises exception on DB error. 563 """ 564 if self.dCache is None: 565 self.dCache = self._oDb.getCache('TestGroupDataEx'); 566 oEntry = self.dCache.get(idTestGroup, None); 567 if oEntry is None: 568 fNeedTsNow = False; 569 self._oDb.execute('SELECT *\n' 570 'FROM TestGroups\n' 571 'WHERE idTestGroup = %s\n' 572 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' 573 , (idTestGroup, )); 574 if self._oDb.getRowCount() == 0: 575 # Maybe it was deleted, try get the last entry. 576 self._oDb.execute('SELECT *\n' 577 'FROM TestGroups\n' 578 'WHERE idTestGroup = %s\n' 579 'ORDER BY tsExpire DESC\n' 580 'LIMIT 1\n' 581 , (idTestGroup, )); 582 fNeedTsNow = True; 583 elif self._oDb.getRowCount() > 1: 584 raise self._oDb.integrityException('%s infinity rows for %s' % (self._oDb.getRowCount(), idTestGroup)); 585 586 if self._oDb.getRowCount() == 1: 587 aaoRow = self._oDb.fetchOne(); 588 oEntry = TestGroupDataEx(); 589 tsNow = oEntry.initFromDbRow(aaoRow).tsEffective if fNeedTsNow else None; 590 oEntry.initFromDbRowEx(aaoRow, self._oDb, tsNow); 591 self.dCache[idTestGroup] = oEntry; 592 return oEntry; 593 552 594 553 595 #
Note:
See TracChangeset
for help on using the changeset viewer.