Changeset 61468 in vbox for trunk/src/VBox/ValidationKit/testmanager/core
- Timestamp:
- Jun 5, 2016 2:55:32 AM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/testmanager/core
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/core/base.py
r61282 r61468 133 133 134 134 135 ## List of internal attributes which should be ignored by 136 ## getDataAttributes and related machinery 137 kasInternalAttributes = []; 138 135 139 def __init__(self): 136 140 ModelBase.__init__(self); … … 149 153 for sAttr in asAttrs: 150 154 if sAttr[0] == '_' or sAttr[0] == 'k': 155 continue; 156 if sAttr in self.kasInternalAttributes: 151 157 continue; 152 158 oValue = getattr(self, sAttr); -
trunk/src/VBox/ValidationKit/testmanager/core/report.py
r61291 r61468 1198 1198 if len(asIdGenTestBoxes) > 0: 1199 1199 self._oDb.execute('SELECT *\n' 1200 'FROM TestBoxes \n'1201 'WHERE idGenTestBox in(' + ','.join(asIdGenTestBoxes) + ')\n'1200 'FROM TestBoxesWithStrings\n' 1201 'WHERE idGenTestBox IN (' + ','.join(asIdGenTestBoxes) + ')\n' 1202 1202 'ORDER BY sName'); 1203 1203 for _ in range(self._oDb.getRowCount()): -
trunk/src/VBox/ValidationKit/testmanager/core/schedgroup.py
r61220 r61468 291 291 if tsNow is None: 292 292 oDb.execute('SELECT *\n' 293 'FROM TestBoxes \n'294 'WHERE TestBoxes .idSchedGroup = %s\n'295 ' AND TestBoxes .tsExpire = \'infinity\'::TIMESTAMP\n'296 'ORDER BY TestBoxes .sName, TestBoxes.idTestBox\n'293 'FROM TestBoxesWithStrings\n' 294 'WHERE TestBoxesWithStrings.idSchedGroup = %s\n' 295 ' AND TestBoxesWithStrings.tsExpire = \'infinity\'::TIMESTAMP\n' 296 'ORDER BY TestBoxesWithStrings.sName, TestBoxesWithStrings.idTestBox\n' 297 297 , (self.idSchedGroup,)); 298 298 else: 299 299 oDb.execute('SELECT *\n' 300 'FROM TestBoxes \n'301 'WHERE TestBoxes .idSchedGroup = %s\n'302 ' AND TestBoxes .tsExpire > %s\n'303 ' AND TestBoxes .tsEffective <= %s\n'304 'ORDER BY TestBoxes .sName, TestBoxes.idTestBox\n'300 'FROM TestBoxesWithStrings\n' 301 'WHERE TestBoxesWithStrings.idSchedGroup = %s\n' 302 ' AND TestBoxesWithStrings.tsExpire > %s\n' 303 ' AND TestBoxesWithStrings.tsEffective <= %s\n' 304 'ORDER BY TestBoxesWithStrings.sName, TestBoxesWithStrings.idTestBox\n' 305 305 , (self.idSchedGroup, tsNow, tsNow, tsNow, tsNow)); 306 306 for aoRow in oDb.fetchAll(): -
trunk/src/VBox/ValidationKit/testmanager/core/testbox.py
r61310 r61468 34 34 35 35 # Validation Kit imports. 36 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMExceptionBase, TMInFligthCollision, \ 37 TMInvalidData, TMTooManyRows, TMRowNotFound, ChangeLogEntry, AttributeChangeEntry; 36 from testmanager.core.base import ModelDataBase, ModelDataBaseTestCase, ModelLogicBase, TMInFligthCollision, \ 37 TMInvalidData, TMTooManyRows, TMRowNotFound, ChangeLogEntry, AttributeChangeEntry; 38 from testmanager.core.useraccount import UserAccountLogic; 38 39 39 40 … … 96 97 ksParam_ipLom = 'TestBox_ipLom'; 97 98 ksParam_pctScaleTimeout = 'TestBox_pctScaleTimeout'; 99 ksParam_sComment = 'TestBox_sComment'; 98 100 ksParam_sOs = 'TestBox_sOs'; 99 101 ksParam_sOsVersion = 'TestBox_sOsVersion'; … … 107 109 ksParam_fCpu64BitGuest = 'TestBox_fCpu64BitGuest'; 108 110 ksParam_fChipsetIoMmu = 'TestBox_fChipsetIoMmu'; 111 ksParam_fRawMode = 'TestBox_fRawMode'; 109 112 ksParam_cMbMemory = 'TestBox_cMbMemory'; 110 113 ksParam_cMbScratch = 'TestBox_cMbScratch'; … … 114 117 ksParam_enmPendingCmd = 'TestBox_enmPendingCmd'; 115 118 119 kasInternalAttributes = [ 'idStrDescription', 'idStrComment', 'idStrOs', 'idStrOsVersion', 'idStrCpuVendor', 120 'idStrCpuArch', 'idStrCpuName', 'idStrReport', ]; 116 121 kasAllowNullAttributes = ['idTestBox', 'tsEffective', 'tsExpire', 'uidAuthor', 'idGenTestBox', 'sDescription', 117 'ipLom', 'sOs', 'sOsVersion', 'sCpuVendor', 'sCpuArch', 'sCpuName', 'lCpuRevision', 'cCpus', 118 'fCpuHwVirt', 'fCpuNestedPaging', 'fCpu64BitGuest', 'fChipsetIoMmu', 'cMbMemory', 119 'cMbScratch', 'sReport', 'iTestBoxScriptRev', 'iPythonHexVersion' ]; 122 'ipLom', 'sComment', 'sOs', 'sOsVersion', 'sCpuVendor', 'sCpuArch', 'sCpuName', 123 'lCpuRevision', 'cCpus', 'fCpuHwVirt', 'fCpuNestedPaging', 'fCpu64BitGuest', 'fChipsetIoMmu', 124 'fRawMode', 'cMbMemory', 'cMbScratch', 'sReport', 'iTestBoxScriptRev', 'iPythonHexVersion', 125 ] + kasInternalAttributes; 126 120 127 kasValidValues_enmLomKind = kasLomKindValues; 121 128 kasValidValues_enmPendingCmd = kasTestBoxCmdValues; … … 124 131 kcchMax_sReport = 65535; 125 132 133 134 kcDbColumns = 41; # including the 7 string joins columns 126 135 127 136 def __init__(self): … … 140 149 self.uuidSystem = None; 141 150 self.sName = None; 142 self. sDescription= None;151 self.idStrDescription = None; 143 152 self.idSchedGroup = 1; 144 153 self.fEnabled = False; … … 146 155 self.ipLom = None; 147 156 self.pctScaleTimeout = 100; 148 self.sOs = None; 149 self.sOsVersion = None; 150 self.sCpuVendor = None; 151 self.sCpuArch = None; 152 self.sCpuName = None; 157 self.idStrComment = None; 158 self.idStrOs = None; 159 self.idStrOsVersion = None; 160 self.idStrCpuVendor = None; 161 self.idStrCpuArch = None; 162 self.idStrCpuName = None; 153 163 self.lCpuRevision = None; 154 164 self.cCpus = 1; … … 157 167 self.fCpu64BitGuest = False; 158 168 self.fChipsetIoMmu = False; 169 self.fRawMode = None; 159 170 self.cMbMemory = 1; 160 171 self.cMbScratch = 0; 161 self. sReport= None;172 self.idStrReport = None; 162 173 self.iTestBoxScriptRev = 0; 163 174 self.iPythonHexVersion = 0; 164 175 self.enmPendingCmd = self.ksTestBoxCmd_None; 176 # String table values. 177 self.sDescription = None; 178 self.sComment = None; 179 self.sOs = None; 180 self.sOsVersion = None; 181 self.sCpuVendor = None; 182 self.sCpuArch = None; 183 self.sCpuName = None; 184 self.sReport = None; 165 185 166 186 def initFromDbRow(self, aoRow): 167 187 """ 168 188 Internal worker for initFromDbWithId and initFromDbWithGenId as well as 169 from TestBoxLogic. Expecting a SELECT * FROM TestBoxes result.170 """171 189 from TestBoxLogic. Expecting the result from a query like this: 190 SELECT TestBoxesWithStrings.* FROM TestBoxesWithStrings 191 """ 172 192 if aoRow is None: 173 193 raise TMRowNotFound('TestBox not found.'); … … 181 201 self.uuidSystem = aoRow[6]; 182 202 self.sName = aoRow[7]; 183 self. sDescription= aoRow[8];203 self.idStrDescription = aoRow[8]; 184 204 self.idSchedGroup = aoRow[9]; 185 205 self.fEnabled = aoRow[10]; … … 187 207 self.ipLom = aoRow[12]; 188 208 self.pctScaleTimeout = aoRow[13]; 189 self.sOs = aoRow[14]; 190 self.sOsVersion = aoRow[15]; 191 self.sCpuVendor = aoRow[16]; 192 self.sCpuArch = aoRow[17]; 193 self.sCpuName = aoRow[18]; 194 self.lCpuRevision = aoRow[19]; 195 self.cCpus = aoRow[20]; 196 self.fCpuHwVirt = aoRow[21]; 197 self.fCpuNestedPaging = aoRow[22]; 198 self.fCpu64BitGuest = aoRow[23]; 199 self.fChipsetIoMmu = aoRow[24]; 200 self.cMbMemory = aoRow[25]; 201 self.cMbScratch = aoRow[26]; 202 self.sReport = aoRow[27]; 203 self.iTestBoxScriptRev = aoRow[28]; 204 self.iPythonHexVersion = aoRow[29]; 205 self.enmPendingCmd = aoRow[30]; 209 self.idStrComment = aoRow[14]; 210 self.idStrOs = aoRow[15]; 211 self.idStrOsVersion = aoRow[16]; 212 self.idStrCpuVendor = aoRow[17]; 213 self.idStrCpuArch = aoRow[18]; 214 self.idStrCpuName = aoRow[19]; 215 self.lCpuRevision = aoRow[20]; 216 self.cCpus = aoRow[21]; 217 self.fCpuHwVirt = aoRow[22]; 218 self.fCpuNestedPaging = aoRow[23]; 219 self.fCpu64BitGuest = aoRow[24]; 220 self.fChipsetIoMmu = aoRow[25]; 221 self.fRawMode = aoRow[26]; 222 self.cMbMemory = aoRow[27]; 223 self.cMbScratch = aoRow[28]; 224 self.idStrReport = aoRow[29]; 225 self.iTestBoxScriptRev = aoRow[30]; 226 self.iPythonHexVersion = aoRow[31]; 227 self.enmPendingCmd = aoRow[32]; 228 229 # String table values. 230 if len(aoRow) > 32: 231 self.sDescription = aoRow[33]; 232 self.sComment = aoRow[34]; 233 self.sOs = aoRow[35]; 234 self.sOsVersion = aoRow[36]; 235 self.sCpuVendor = aoRow[37]; 236 self.sCpuArch = aoRow[38]; 237 self.sCpuName = aoRow[39]; 238 self.sReport = aoRow[40]; 239 206 240 return self; 207 241 … … 211 245 """ 212 246 oDb.execute(self.formatSimpleNowAndPeriodQuery(oDb, 213 'SELECT *\n'214 'FROM TestBoxes \n'247 'SELECT TestBoxesWithStrings.*\n' 248 'FROM TestBoxesWithStrings\n' 215 249 'WHERE idTestBox = %s\n' 216 250 , ( idTestBox, ), tsNow, sPeriodBack)); … … 224 258 Initialize the object from the database. 225 259 """ 226 oDb.execute('SELECT *\n'227 'FROM TestBoxes \n'260 oDb.execute('SELECT TestBoxesWithStrings.*\n' 261 'FROM TestBoxesWithStrings\n' 228 262 'WHERE idGenTestBox = %s\n' 229 263 , (idGenTestBox, ) ); … … 425 459 Tries to fetch a testbox by its UUID alone. 426 460 """ 427 self._oDb.execute('SELECT *\n'428 'FROM TestBoxes \n'461 self._oDb.execute('SELECT TestBoxesWithStrings.*\n' 462 'FROM TestBoxesWithStrings\n' 429 463 'WHERE uuidSystem = %s\n' 430 ' AND tsExpire = \'infinity\'::timestamp\n'464 ' AND tsExpire = \'infinity\'::timestamp\n' 431 465 'ORDER BY tsEffective DESC\n', 432 466 (sTestBoxUuid,)); … … 443 477 Fetches testboxes for listing. 444 478 445 Returns an array (list) of TestBoxData items, empty list if none. The446 T estBoxData instances have an extra oStatus member that is either None or447 a TestBoxStatusData instance, and a member tsCurrent holding448 CURRENT_TIMESTAMP.479 Returns an array (list) of TestBoxDataForListing items, empty list if none. 480 The TestBoxDataForListing instances are just TestBoxData with two extra 481 members, an extra oStatus member that is either None or a TestBoxStatusData 482 instance, and a member tsCurrent holding CURRENT_TIMESTAMP. 449 483 450 484 Raises exception on error. 451 485 """ 486 class TestBoxDataForListing(TestBoxData): 487 """ We add two members for the listing. """ 488 def __init__(self): 489 TestBoxData.__init__(self); 490 self.tsCurrent = None; # CURRENT_TIMESTAMP 491 self.oStatus = None; # TestBoxStatusData 492 452 493 from testmanager.core.testboxstatus import TestBoxStatusData; 453 494 454 495 if tsNow is None: 455 self._oDb.execute('SELECT TestBoxes.*, TestBoxStatuses.*\n' 456 'FROM TestBoxes\n' 457 'LEFT OUTER JOIN TestBoxStatuses ON (\n' 458 ' TestBoxStatuses.idTestBox = TestBoxes.idTestBox )\n' 459 'WHERE tsExpire = \'infinity\'::TIMESTAMP\n' 460 'ORDER BY sName\n' 496 self._oDb.execute('SELECT TestBoxesWithStrings.*,\n' 497 ' TestBoxStatuses.*\n' 498 'FROM TestBoxesWithStrings\n' 499 ' LEFT OUTER JOIN TestBoxStatuses\n' 500 ' ON TestBoxStatuses.idTestBox = TestBoxesWithStrings.idTestBox\n' 501 'WHERE TestBoxesWithStrings.tsExpire = \'infinity\'::TIMESTAMP\n' 502 'ORDER BY TestBoxesWithStrings.sName\n' 461 503 'LIMIT %s OFFSET %s\n' 462 504 , (cMaxRows, iStart,)); 463 505 else: 464 self._oDb.execute('SELECT TestBoxes.*, TestBoxStatuses.*\n' 465 'FROM TestBoxes\n' 466 'LEFT OUTER JOIN TestBoxStatuses ON (\n' 467 ' TestBoxStatuses.idTestBox = TestBoxes.idTestBox )\n' 506 self._oDb.execute('SELECT TestBoxesWithStrings.*,\n' 507 ' TestBoxStatuses.*\n' 508 'FROM TestBoxesWithStrings\n' 509 ' LEFT OUTER JOIN TestBoxStatuses\n' 510 ' ON TestBoxStatuses.idTestBox = TestBoxesWithStrings.idTestBox\n' 468 511 'WHERE tsExpire > %s\n' 469 512 ' AND tsEffective <= %s\n' 470 'ORDER BY sName\n'513 'ORDER BY TestBoxesWithStrings.sName\n' 471 514 'LIMIT %s OFFSET %s\n' 472 , ( tsNow, tsNow, cMaxRows, iStart,));515 , ( tsNow, tsNow, cMaxRows, iStart,)); 473 516 474 517 aoRows = []; 475 518 for aoOne in self._oDb.fetchAll(): 476 oTestBox = TestBoxData().initFromDbRow(aoOne); 477 oTestBox.tsCurrent = self._oDb.getCurrentTimestamp(); # pylint: disable=W0201 478 oTestBox.oStatus = None; # pylint: disable=W0201 479 if aoOne[31] is not None: 480 oTestBox.oStatus = TestBoxStatusData().initFromDbRow(aoOne[31:]); # pylint: disable=W0201 519 oTestBox = TestBoxDataForListing().initFromDbRow(aoOne); 520 oTestBox.tsCurrent = self._oDb.getCurrentTimestamp(); 521 if aoOne[TestBoxData.kcDbColumns] is not None: 522 oTestBox.oStatus = TestBoxStatusData().initFromDbRow(aoOne[TestBoxData.kcDbColumns:]); 481 523 aoRows.append(oTestBox); 482 524 return aoRows; … … 494 536 tsNow = self._oDb.getCurrentTimestamp(); 495 537 496 self._oDb.execute('SELECT TestBoxes.*, Users.sUsername\n' 497 'FROM TestBoxes\n' 498 'LEFT OUTER JOIN Users \n' 499 ' ON ( TestBoxes.uidAuthor = Users.uid\n' 500 ' AND Users.tsEffective <= TestBoxes.tsEffective\n' 501 ' AND Users.tsExpire > TestBoxes.tsEffective)\n' 502 'WHERE TestBoxes.tsEffective <= %s\n' 503 ' AND TestBoxes.idTestBox = %s\n' 504 'ORDER BY TestBoxes.tsExpire DESC\n' 538 self._oDb.execute('SELECT TestBoxesWithStrings.*\n' 539 'FROM TestBoxesWithStrings\n' 540 'WHERE TestBoxesWithStrings.tsEffective <= %s\n' 541 ' AND TestBoxesWithStrings.idTestBox = %s\n' 542 'ORDER BY TestBoxesWithStrings.tsExpire DESC\n' 505 543 'LIMIT %s OFFSET %s\n' 506 544 , (tsNow, idTestBox, cMaxRows + 1, iStart,)); 507 545 508 546 aoRows = []; 509 for _ in range(self._oDb.getRowCount()): 510 oRow = self._oDb.fetchOne(); 511 aoRows.append([TestBoxData().initFromDbRow(oRow), oRow[-1],]); 547 for aoDbRow in self._oDb.fetchAll(): 548 aoRows.append(TestBoxData().initFromDbRow(aoDbRow)); 512 549 513 550 # Calculate the changes. 514 551 aoEntries = []; 515 for i in range(0, len(aoRows) - 1):516 (oNew, sAuthor)= aoRows[i];517 (oOld, _ )= aoRows[i + 1];552 for i in xrange(0, len(aoRows) - 1): 553 oNew = aoRows[i]; 554 oOld = aoRows[i + 1]; 518 555 aoChanges = []; 519 556 for sAttr in oNew.getDataAttributes(): 520 if sAttr not in [ 'tsEffective', 'tsExpire', 'uidAuthor' ]:557 if sAttr not in [ 'tsEffective', 'tsExpire', 'uidAuthor', ]: 521 558 oOldAttr = getattr(oOld, sAttr); 522 559 oNewAttr = getattr(oNew, sAttr); 523 560 if oOldAttr != oNewAttr: 524 561 aoChanges.append(AttributeChangeEntry(sAttr, oNewAttr, oOldAttr, str(oNewAttr), str(oOldAttr))); 525 aoEntries.append(ChangeLogEntry(oNew.uidAuthor, sAuthor, oNew.tsEffective, oNew.tsExpire, oNew, oOld, aoChanges));562 aoEntries.append(ChangeLogEntry(oNew.uidAuthor, None, oNew.tsEffective, oNew.tsExpire, oNew, oOld, aoChanges)); 526 563 527 564 # If we're at the end of the log, add the initial entry. 528 565 if len(aoRows) <= cMaxRows and len(aoRows) > 0: 529 (oNew, sAuthor) = aoRows[-1]; 530 aoEntries.append(ChangeLogEntry(oNew.uidAuthor, aoRows[-1][1], oNew.tsEffective, oNew.tsExpire, oNew, None, [])); 531 566 oNew = aoRows[-1]; 567 aoEntries.append(ChangeLogEntry(oNew.uidAuthor, None, oNew.tsEffective, oNew.tsExpire, oNew, None, [])); 568 569 UserAccountLogic(self._oDb).resolveChangeLogAuthors(aoEntries); 532 570 return (aoEntries, len(aoRows) > cMaxRows); 571 533 572 534 573 def addEntry(self, oData, uidAuthor, fCommit = False): … … 542 581 raise TMInvalidData('Invalid data passed to create(): %s' % (dDataErrors,)); 543 582 544 self._oDb.execute('INSERT INTO TestBoxes (\n' 545 ' idTestBox,\n' 546 ' tsEffective,\n' 547 ' tsExpire,\n' 548 ' uidAuthor,\n' 549 ' idGenTestBox,\n' 550 ' ip,\n' 551 ' uuidSystem,\n' 552 ' sName,\n' 553 ' sDescription,\n' 554 ' idSchedGroup,\n' 555 ' fEnabled,\n' 556 ' enmLomKind,\n' 557 ' ipLom,\n' 558 ' pctScaleTimeout,\n' 559 ' sOs,\n' 560 ' sOsVersion,\n' 561 ' sCpuVendor,\n' 562 ' sCpuArch,\n' 563 ' sCpuName,\n' 564 ' lCpuRevision,\n' 565 ' cCpus,\n' 566 ' fCpuHwVirt,\n' 567 ' fCpuNestedPaging,\n' 568 ' fCpu64BitGuest,\n' 569 ' fChipsetIoMmu,\n' 570 ' cMbMemory,\n' 571 ' cMbScratch,\n' 572 ' sReport,\n' 573 ' iTestBoxScriptRev,\n' 574 ' iPythonHexVersion,\n' 575 ' enmPendingCmd\n' 576 ' )' 577 'VALUES (\n' 578 ' DEFAULT,\n' 579 ' CURRENT_TIMESTAMP,\n' 580 ' DEFAULT,\n' 581 ' %s,\n' # uidAuthor 582 ' DEFAULT,\n' 583 ' %s,\n' # ip 584 ' %s,\n' # uuidSystem 585 ' %s,\n' # sName 586 ' %s,\n' # sDescription 587 ' %s,\n' # idSchedGroup 588 ' %s,\n' # fEnabled 589 ' %s,\n' # enmLomKind 590 ' %s,\n' # ipLom 591 ' %s,\n' # pctScaleTimeout 592 ' %s,\n' # sOs 593 ' %s,\n' # sOsVersion 594 ' %s,\n' # sCpuVendor 595 ' %s,\n' # sCpuArch 596 ' %s,\n' # sCpuName 597 ' %s,\n' # lCpuRevision 598 ' %s,\n' # cCpus 599 ' %s,\n' # fCpuHwVirt 600 ' %s,\n' # fCpuNestedPaging 601 ' %s,\n' # fCpu64BitGuest 602 ' %s,\n' # fChipsetIoMmu 603 ' %s,\n' # cMbMemory 604 ' %s,\n' # cMbScratch 605 ' %s,\n' # sReport 606 ' %s,\n' # iTestBoxScriptRev 607 ' %s,\n' # iPythonHexVersion 608 ' %s\n' # enmPendingCmd 609 ' )\n' 610 'RETURNING idTestBox, idGenTestBox, tsEffective' 611 , (uidAuthor, 612 oData.ip, 613 oData.uuidSystem, 614 oData.sName, 615 oData.sDescription, 616 oData.idSchedGroup, 617 oData.fEnabled, 618 oData.enmLomKind, 619 oData.ipLom, 620 oData.pctScaleTimeout, 621 oData.sOs, 622 oData.sOsVersion, 623 oData.sCpuVendor, 624 oData.sCpuArch, 625 oData.sCpuName, 626 oData.lCpuRevision, 627 oData.cCpus, 628 oData.fCpuHwVirt, 629 oData.fCpuNestedPaging, 630 oData.fCpu64BitGuest, 631 oData.fChipsetIoMmu, 632 oData.cMbMemory, 633 oData.cMbScratch, 634 oData.sReport, 635 oData.iTestBoxScriptRev, 636 oData.iPythonHexVersion, 637 oData.enmPendingCmd 638 ) 639 ); 640 oRow = self._oDb.fetchOne(); 583 self._oDb.callProc('TestBoxLogic_addEntry' 584 , ( uidAuthor, 585 oData.ip, # Should we allow setting the IP? 586 oData.uuidSystem, 587 oData.sName, 588 oData.sDescription, 589 oData.idSchedGroup, 590 oData.fEnabled, 591 oData.enmLomKind, 592 oData.ipLom, 593 oData.pctScaleTimeout, 594 oData.sComment, 595 oData.enmPendingCmd, ) ); 596 aoRow = self._oDb.fetchOne(); 641 597 self._oDb.maybeCommit(fCommit); 642 return (oRow[0], oRow[1], oRow[2]); 598 return (aoRow[0], aoRow[1], aoRow[2]); 599 643 600 644 601 def editEntry(self, oData, uidAuthor, fCommit = False): … … 652 609 raise TMInvalidData('Invalid data passed to create(): %s' % (dDataErrors,)); 653 610 654 ## @todo check if the data changed. 655 656 self._oDb.execute('UPDATE ONLY TestBoxes\n' 657 'SET tsExpire = CURRENT_TIMESTAMP\n' 658 'WHERE idGenTestBox = %s\n' 659 ' AND tsExpire = \'infinity\'::timestamp\n' 660 'RETURNING tsExpire\n', 661 (oData.idGenTestBox,)); 662 try: 663 tsEffective = self._oDb.fetchOne()[0]; 664 665 # Would be easier to do this using an insert or update hook, I think. Much easier. 666 667 ## 668 ## @todo The table is growing too fast. Rows are too long. Mixing data from here and there. Split it and 669 ## rethink storage and update strategy! 670 ## 671 672 self._oDb.execute('INSERT INTO TestBoxes (\n' 673 ' idGenTestBox,\n' 674 ' idTestBox,\n' 675 ' tsEffective,\n' 676 ' uidAuthor,\n' 677 ' ip,\n' 678 ' uuidSystem,\n' 679 ' sName,\n' 680 ' sDescription,\n' 681 ' idSchedGroup,\n' 682 ' fEnabled,\n' 683 ' enmLomKind,\n' 684 ' ipLom,\n' 685 ' pctScaleTimeout,\n' 686 ' sOs,\n' 687 ' sOsVersion,\n' 688 ' sCpuVendor,\n' 689 ' sCpuArch,\n' 690 ' sCpuName,\n' 691 ' lCpuRevision,\n' 692 ' cCpus,\n' 693 ' fCpuHwVirt,\n' 694 ' fCpuNestedPaging,\n' 695 ' fCpu64BitGuest,\n' 696 ' fChipsetIoMmu,\n' 697 ' cMbMemory,\n' 698 ' cMbScratch,\n' 699 ' sReport,\n' 700 ' iTestBoxScriptRev,\n' 701 ' iPythonHexVersion,\n' 702 ' enmPendingCmd\n' 703 ' )\n' 704 'SELECT NEXTVAL(\'TestBoxGenIdSeq\'),\n' 705 ' idTestBox,\n' 706 ' %s,\n' # tsEffective 707 ' %s,\n' # uidAuthor 708 ' %s,\n' # ip 709 ' %s,\n' # uuidSystem 710 ' %s,\n' # sName 711 ' %s,\n' # sDescription 712 ' %s,\n' # idSchedGroup 713 ' %s,\n' # fEnabled 714 ' %s,\n' # enmLomKind 715 ' %s,\n' # ipLom 716 ' %s,\n' # pctScaleTimeout 717 ' sOs,\n' 718 ' sOsVersion,\n' 719 ' sCpuVendor,\n' 720 ' sCpuArch,\n' 721 ' sCpuName,\n' 722 ' lCpuRevision,\n' 723 ' cCpus,\n' 724 ' fCpuHwVirt,\n' 725 ' fCpuNestedPaging,\n' 726 ' fCpu64BitGuest,\n' 727 ' fChipsetIoMmu,\n' 728 ' cMbMemory,\n' 729 ' cMbScratch,\n' 730 ' sReport,\n' 731 ' iTestBoxScriptRev,\n' 732 ' iPythonHexVersion,\n' 733 ' %s\n' # enmPendingCmd 734 'FROM TestBoxes\n' 735 'WHERE idGenTestBox = %s\n' 736 'RETURNING idGenTestBox, tsEffective' 737 , (tsEffective, 738 uidAuthor, 739 oData.ip, 740 oData.uuidSystem, 741 oData.sName, 742 oData.sDescription, 743 oData.idSchedGroup, 744 oData.fEnabled, 745 oData.enmLomKind, 746 oData.ipLom, 747 oData.pctScaleTimeout, 748 oData.enmPendingCmd, 749 oData.idGenTestBox, 750 )); 751 aRow = self._oDb.fetchOne(); 752 if aRow is None: 753 raise TMExceptionBase('Insert failed? oRow=None'); 754 idGenTestBox = aRow[0]; 755 tsEffective = aRow[1]; 756 self._oDb.maybeCommit(fCommit); 757 except: 758 self._oDb.rollback(); 759 raise; 760 761 return (idGenTestBox, tsEffective); 611 self._oDb.callProc('TestBoxLogic_editEntry' 612 , ( uidAuthor, 613 oData.idTestBox, 614 oData.ip, # Should we allow setting the IP? 615 oData.uuidSystem, 616 oData.sName, 617 oData.sDescription, 618 oData.idSchedGroup, 619 oData.fEnabled, 620 oData.enmLomKind, 621 oData.ipLom, 622 oData.pctScaleTimeout, 623 oData.sComment, 624 oData.enmPendingCmd, )); 625 aoRow = self._oDb.fetchOne(); 626 self._oDb.maybeCommit(fCommit); 627 return (aoRow[0], aoRow[1]); 628 629 630 def removeEntry(self, uidAuthor, idTestBox, fCascade = False, fCommit = False): 631 """ 632 Delete user account 633 """ 634 self._oDb.callProc('TestBoxLogic_removeEntry' 635 , ( uidAuthor, idTestBox, fCascade,)); 636 self._oDb.maybeCommit(fCommit); 637 return True; 638 762 639 763 640 def updateOnSignOn(self, idTestBox, idGenTestBox, sTestBoxAddr, sOs, sOsVersion, # pylint: disable=R0913,R0914 764 641 sCpuVendor, sCpuArch, sCpuName, lCpuRevision, cCpus, fCpuHwVirt, fCpuNestedPaging, fCpu64BitGuest, 765 fChipsetIoMmu, cMbMemory, cMbScratch, sReport, iTestBoxScriptRev, iPythonHexVersion):642 fChipsetIoMmu, fRawMode, cMbMemory, cMbScratch, sReport, iTestBoxScriptRev, iPythonHexVersion): 766 643 """ 767 644 Update the testbox attributes automatically on behalf of the testbox script. 768 645 Returns the new generation id on success, raises an exception on failure. 769 646 """ 770 try: 771 # Would be easier to do this using an insert or update hook, I think. Much easier. 772 self._oDb.execute('UPDATE ONLY TestBoxes\n' 773 'SET tsExpire = CURRENT_TIMESTAMP\n' 774 'WHERE idGenTestBox = %s\n' 775 ' AND tsExpire = \'infinity\'::timestamp\n' 776 'RETURNING tsExpire\n', 777 (idGenTestBox,)); 778 tsEffective = self._oDb.fetchOne()[0]; 779 780 self._oDb.execute('INSERT INTO TestBoxes (\n' 781 ' idGenTestBox,\n' 782 ' idTestBox,\n' 783 ' tsEffective,\n' 784 ' uidAuthor,\n' 785 ' ip,\n' 786 ' uuidSystem,\n' 787 ' sName,\n' 788 ' sDescription,\n' 789 ' idSchedGroup,\n' 790 ' fEnabled,\n' 791 ' enmLomKind,\n' 792 ' ipLom,\n' 793 ' pctScaleTimeout,\n' 794 ' sOs,\n' 795 ' sOsVersion,\n' 796 ' sCpuVendor,\n' 797 ' sCpuArch,\n' 798 ' sCpuName,\n' 799 ' lCpuRevision,\n' 800 ' cCpus,\n' 801 ' fCpuHwVirt,\n' 802 ' fCpuNestedPaging,\n' 803 ' fCpu64BitGuest,\n' 804 ' fChipsetIoMmu,\n' 805 ' cMbMemory,\n' 806 ' cMbScratch,\n' 807 ' sReport,\n' 808 ' iTestBoxScriptRev,\n' 809 ' iPythonHexVersion,\n' 810 ' enmPendingCmd\n' 811 ' )\n' 812 'SELECT NEXTVAL(\'TestBoxGenIdSeq\'),\n' 813 ' %s,\n' 814 ' %s,\n' 815 ' NULL,\n' # uidAuthor 816 ' %s,\n' 817 ' uuidSystem,\n' 818 ' sName,\n' 819 ' sDescription,\n' 820 ' idSchedGroup,\n' 821 ' fEnabled,\n' 822 ' enmLomKind,\n' 823 ' ipLom,\n' 824 ' pctScaleTimeout,\n' 825 ' %s,\n' # sOs 826 ' %s,\n' # sOsVersion 827 ' %s,\n' # sCpuVendor 828 ' %s,\n' # sCpuArch 829 ' %s,\n' # sCpuName 830 ' %s,\n' # lCpuRevision 831 ' %s,\n' # cCpus 832 ' %s,\n' # fCpuHwVirt 833 ' %s,\n' # fCpuNestedPaging 834 ' %s,\n' # fCpu64BitGuest 835 ' %s,\n' # fChipsetIoMmu 836 ' %s,\n' # cMbMemory 837 ' %s,\n' # cMbScratch 838 ' %s,\n' # sReport 839 ' %s,\n' # iTestBoxScriptRev 840 ' %s,\n' # iPythonHexVersion 841 ' enmPendingCmd\n' 842 'FROM TestBoxes\n' 843 'WHERE idGenTestBox = %s\n' 844 'RETURNING idGenTestBox' 845 , (idTestBox, 846 tsEffective, 847 sTestBoxAddr, 848 sOs, 849 sOsVersion, 850 sCpuVendor, 851 sCpuArch, 852 sCpuName, 853 lCpuRevision, 854 cCpus, 855 fCpuHwVirt, 856 fCpuNestedPaging, 857 fCpu64BitGuest, 858 fChipsetIoMmu, 859 cMbMemory, 860 cMbScratch, 861 sReport, 862 iTestBoxScriptRev, 863 iPythonHexVersion, 864 idGenTestBox, 865 )); 866 idGenTestBox = self._oDb.fetchOne()[0]; 867 self._oDb.commit(); 868 except: 869 self._oDb.rollback(); 870 raise; 871 872 return idGenTestBox; 873 874 def setCommand(self, idTestBox, sOldCommand, sNewCommand, uidAuthor = None, fCommit = False, sComment = None, 875 fNoRollbackOnInFlightCollision = False): 647 _ = idGenTestBox; 648 self._oDb.callProc('TestBoxLogic_updateOnSignOn' 649 , ( idTestBox, 650 sTestBoxAddr, 651 sOs, 652 sOsVersion, 653 sCpuVendor, 654 sCpuArch, 655 sCpuName, 656 lCpuRevision, 657 cCpus, 658 fCpuHwVirt, 659 fCpuNestedPaging, 660 fCpu64BitGuest, 661 fChipsetIoMmu, 662 fRawMode, 663 cMbMemory, 664 cMbScratch, 665 sReport, 666 iTestBoxScriptRev, 667 iPythonHexVersion,)); 668 return self._oDb.fetchOne()[0]; 669 670 671 def setCommand(self, idTestBox, sOldCommand, sNewCommand, uidAuthor = None, fCommit = False, sComment = None): 876 672 """ 877 673 Sets or resets the pending command on a testbox. 878 674 Returns (idGenTestBox, tsEffective) of the new row. 879 675 """ 880 _ = sComment; 881 try: 882 # Would be easier to do this using an insert or update hook, I think. Much easier. 883 self._oDb.execute('UPDATE ONLY TestBoxes\n' 884 'SET tsExpire = CURRENT_TIMESTAMP\n' 885 'WHERE idTestBox = %s\n' 886 ' AND tsExpire = \'infinity\'::timestamp\n' 887 ' AND enmPendingCmd = %s\n' 888 'RETURNING tsExpire\n', 889 (idTestBox, sOldCommand,)); 890 if self._oDb.getRowCount() == 0: 891 raise TMInFligthCollision(); 892 tsEffective = self._oDb.fetchOne()[0]; 893 894 self._oDb.execute('INSERT INTO TestBoxes (\n' 895 ' idGenTestBox,\n' 896 ' idTestBox,\n' 897 ' tsEffective,\n' 898 ' uidAuthor,\n' 899 ' ip,\n' 900 ' uuidSystem,\n' 901 ' sName,\n' 902 ' sDescription,\n' 903 ' idSchedGroup,\n' 904 ' fEnabled,\n' 905 ' enmLomKind,\n' 906 ' ipLom,\n' 907 ' pctScaleTimeout,\n' 908 ' sOs,\n' 909 ' sOsVersion,\n' 910 ' sCpuVendor,\n' 911 ' sCpuArch,\n' 912 ' sCpuName,\n' 913 ' lCpuRevision,\n' 914 ' cCpus,\n' 915 ' fCpuHwVirt,\n' 916 ' fCpuNestedPaging,\n' 917 ' fCpu64BitGuest,\n' 918 ' fChipsetIoMmu,\n' 919 ' cMbMemory,\n' 920 ' cMbScratch,\n' 921 ' sReport,\n' 922 ' iTestBoxScriptRev,\n' 923 ' iPythonHexVersion,\n' 924 ' enmPendingCmd\n' 925 ' )\n' 926 'SELECT NEXTVAL(\'TestBoxGenIdSeq\'),\n' 927 ' %s,\n' # idTestBox 928 ' %s,\n' # tsEffective 929 ' %s,\n' # uidAuthor 930 ' ip,\n' 931 ' uuidSystem,\n' 932 ' sName,\n' 933 ' sDescription,\n' 934 ' idSchedGroup,\n' 935 ' fEnabled,\n' 936 ' enmLomKind,\n' 937 ' ipLom,\n' 938 ' pctScaleTimeout,\n' 939 ' sOs,\n' 940 ' sOsVersion,\n' 941 ' sCpuVendor,\n' 942 ' sCpuArch,\n' 943 ' sCpuName,\n' 944 ' lCpuRevision,\n' 945 ' cCpus,\n' 946 ' fCpuHwVirt,\n' 947 ' fCpuNestedPaging,\n' 948 ' fCpu64BitGuest,\n' 949 ' fChipsetIoMmu,\n' 950 ' cMbMemory,\n' 951 ' cMbScratch,\n' 952 ' sReport,\n' 953 ' iTestBoxScriptRev,\n' 954 ' iPythonHexVersion,\n' 955 ' %s\n' # enmPendingCmd 956 'FROM TestBoxes\n' 957 'WHERE idTestBox = %s\n' 958 ' AND tsExpire = %s\n' 959 ' AND enmPendingCmd = %s\n' 960 'RETURNING idGenTestBox' 961 , (idTestBox, 962 tsEffective, 963 uidAuthor, 964 sNewCommand, 965 idTestBox, 966 tsEffective, 967 sOldCommand, 968 )); 969 idGenTestBox = self._oDb.fetchOne()[0]; 970 if fCommit is True: 971 self._oDb.commit(); 972 973 except TMInFligthCollision: # This is pretty stupid, but don't want to touch testboxcontroller.py now. 974 if not fNoRollbackOnInFlightCollision: 975 self._oDb.rollback(); 976 raise; 977 except: 978 self._oDb.rollback(); 979 raise; 980 981 return (idGenTestBox, tsEffective); 982 676 ## @todo throw TMInFligthCollision again... 677 self._oDb.callProc('TestBoxLogic_setCommand' 678 , ( uidAuthor, idTestBox, sOldCommand, sNewCommand, sComment,)); 679 aoRow = self._oDb.fetchOne(); 680 self._oDb.maybeCommit(fCommit); 681 return (aoRow[0], aoRow[1]); 983 682 984 683 … … 988 687 """ 989 688 self._oDb.execute('SELECT *\n' 990 'FROM TestBoxes \n'689 'FROM TestBoxesWithStrings\n' 991 690 'WHERE tsExpire=\'infinity\'::timestamp;') 992 691 … … 997 696 return aoRet 998 697 999 def _historize(self, idTestBox, uidAuthor, tsExpire = None):1000 """ Historizes the current entry. """1001 if tsExpire is None:1002 self._oDb.execute('UPDATE TestBoxes\n'1003 'SET tsExpire = CURRENT_TIMESTAMP,\n'1004 ' uidAuthor = %s\n'1005 'WHERE idTestBox = %s\n'1006 ' AND tsExpire = \'infinity\'::TIMESTAMP\n'1007 , (uidAuthor, idTestBox,));1008 else:1009 self._oDb.execute('UPDATE TestBoxes\n'1010 'SET tsExpire = %s,\n'1011 ' uidAuthor = %s\n'1012 'WHERE idTestBox = %s\n'1013 ' AND tsExpire = \'infinity\'::TIMESTAMP\n'1014 , (uidAuthor, tsExpire, idTestBox,));1015 return True;1016 1017 1018 def removeEntry(self, uidAuthor, idTestBox, fCascade = False, fCommit=False):1019 """1020 Delete user account1021 """1022 _ = fCascade;1023 1024 fRc = self._historize(idTestBox, uidAuthor, None);1025 if fRc:1026 self._oDb.maybeCommit(fCommit);1027 1028 return fRc1029 1030 698 1031 699 def cachedLookup(self, idTestBox): … … 1041 709 oEntry = self.dCache.get(idTestBox, None); 1042 710 if oEntry is None: 1043 self._oDb.execute('SELECT *\n'1044 'FROM TestBoxes \n'711 self._oDb.execute('SELECT TestBoxesWithStrings.*\n' 712 'FROM TestBoxesWithStrings\n' 1045 713 'WHERE idTestBox = %s\n' 1046 714 ' AND tsExpire = \'infinity\'::TIMESTAMP\n' … … 1048 716 if self._oDb.getRowCount() == 0: 1049 717 # Maybe it was deleted, try get the last entry. 1050 self._oDb.execute('SELECT *\n'718 self._oDb.execute('SELECT TestBoxesWithStrings.*\n' 1051 719 'FROM TestBoxes\n' 1052 720 'WHERE idTestBox = %s\n' … … 1096 764 Issues a reboot command for the given test box. 1097 765 Return True on succes, False on in-flight collision. 1098 May raise DB exception with rollbackon other trouble.766 May raise DB exception on other trouble. 1099 767 """ 1100 768 try: 1101 769 self.setCommand(idTestBox, sOldCommand, TestBoxData.ksTestBoxCmd_Reboot, 1102 uidAuthor = uidAuthor, fCommit = fCommit, sComment = sComment, 1103 fNoRollbackOnInFlightCollision = True); 770 uidAuthor = uidAuthor, fCommit = fCommit, sComment = sComment); 1104 771 except TMInFligthCollision: 1105 772 return False; -
trunk/src/VBox/ValidationKit/testmanager/core/testboxcontroller.py
r61330 r61468 363 363 fCpu64BitGuest = self._getBoolParam( constants.tbreq.SIGNON_PARAM_HAS_64_BIT_GUEST, fDefValue = True); 364 364 fChipsetIoMmu = self._getBoolParam( constants.tbreq.SIGNON_PARAM_HAS_IOMMU); 365 fRawMode = self._getBoolParam( constants.tbreq.SIGNON_PARAM_WITH_RAW_MODE, fDefValue = None); 365 366 cMbMemory = self._getLongParam( constants.tbreq.SIGNON_PARAM_MEM_SIZE, 8, 1073741823); # 8MB..1PB 366 367 cMbScratch = self._getLongParam( constants.tbreq.SIGNON_PARAM_SCRATCH_SIZE, 0, 1073741823); # 0..1PB … … 395 396 # Update the row in TestBoxes if something changed. 396 397 # 397 if oTestBox.cMbScratch != 0:398 if oTestBox.cMbScratch is not None and oTestBox.cMbScratch != 0: 398 399 cPctScratchDiff = (cMbScratch - oTestBox.cMbScratch) * 100 / oTestBox.cMbScratch; 399 400 else: … … 413 414 or fCpu64BitGuest != oTestBox.fCpu64BitGuest \ 414 415 or fChipsetIoMmu != oTestBox.fChipsetIoMmu \ 416 or fRawMode != oTestBox.fRawMode \ 415 417 or cMbMemory != oTestBox.cMbMemory \ 416 418 or abs(cPctScratchDiff) >= min(4 + cMbScratch / 10240, 12) \ … … 432 434 fCpu64BitGuest = fCpu64BitGuest, 433 435 fChipsetIoMmu = fChipsetIoMmu, 436 fRawMode = fRawMode, 434 437 cMbMemory = cMbMemory, 435 438 cMbScratch = cMbScratch, -
trunk/src/VBox/ValidationKit/testmanager/core/testboxstatus.py
r61220 r61468 160 160 not found. May throw an exception on database error. 161 161 """ 162 self._oDb.execute('SELECT *\n' 163 'FROM TestBoxStatuses, TestBoxes\n' 162 self._oDb.execute('SELECT TestBoxStatuses.*,\n' 163 ' TestBoxes.*,\n' 164 ' Str1.sValue,\n' 165 ' Str2.sValue,\n' 166 ' Str3.sValue,\n' 167 ' Str4.sValue,\n' 168 ' Str5.sValue,\n' 169 ' Str6.sValue,\n' 170 ' Str7.sValue,\n' 171 ' Str8.sValue\n' 172 'FROM TestBoxStatuses,\n' 173 ' TestBoxes\n' 174 ' LEFT OUTER JOIN TestBoxStrTab Str1 ON idStrDescription = Str1.idStr\n' 175 ' LEFT OUTER JOIN TestBoxStrTab Str2 ON idStrComment = Str2.idStr\n' 176 ' LEFT OUTER JOIN TestBoxStrTab Str3 ON idStrOs = Str3.idStr\n' 177 ' LEFT OUTER JOIN TestBoxStrTab Str4 ON idStrOsVersion = Str4.idStr\n' 178 ' LEFT OUTER JOIN TestBoxStrTab Str5 ON idStrCpuVendor = Str5.idStr\n' 179 ' LEFT OUTER JOIN TestBoxStrTab Str6 ON idStrCpuArch = Str6.idStr\n' 180 ' LEFT OUTER JOIN TestBoxStrTab Str7 ON idStrCpuName = Str7.idStr\n' 181 ' LEFT OUTER JOIN TestBoxStrTab Str8 ON idStrReport = Str8.idStr\n' 164 182 'WHERE TestBoxStatuses.idTestBox = %s\n' 165 183 ' AND TestBoxes.idTestBox = %s\n' 166 ' AND TestBoxes.tsExpire = \'infinity\':: timestamp\n'184 ' AND TestBoxes.tsExpire = \'infinity\'::TIMESTAMP\n' 167 185 ' AND TestBoxes.uuidSystem = %s\n' 168 186 ' AND TestBoxes.ip = %s\n' -
trunk/src/VBox/ValidationKit/testmanager/core/testcase.pgsql
r56295 r61468 207 207 v_Row.tsEffective := v_tsEffective; 208 208 v_Row.tsExpire := CURRENT_TIMESTAMP; 209 v_Row.uidAuthor := a_uidAuthor; 209 210 SELECT NEXTVAL('TestCaseGenIdSeq') INTO v_Row.idGenTestCase; 210 211 INSERT INTO TestCases VALUES (v_Row.*); -
trunk/src/VBox/ValidationKit/testmanager/core/testcase.py
r61286 r61468 636 636 'fCpu64BitGuest': False, 637 637 'fChipsetIoMmu': False, 638 'fRawMode': False, 638 639 'cMbMemory': 985034, 639 640 'cMbScratch': 1234089, … … 652 653 'fCpu64BitGuest': True, 653 654 'fChipsetIoMmu': True, 655 'fRawMode': True, 654 656 'cMbMemory': 9999999999, 655 657 'cMbScratch': 9999999999999, … … 677 679 'fCpu64BitGuest': oTestBoxData.fCpu64BitGuest, 678 680 'fChipsetIoMmu': oTestBoxData.fChipsetIoMmu, 681 'fRawMode': oTestBoxData.fRawMode, 679 682 'cMbMemory': oTestBoxData.cMbMemory, 680 683 'cMbScratch': oTestBoxData.cMbScratch, -
trunk/src/VBox/ValidationKit/testmanager/core/testresults.py
r61462 r61468 724 724 '', '' ), 725 725 ksResultsSortByTestBoxOsArch: ( 726 ', TestBoxes ',727 ' AND TestSets.idGenTestBox = TestBoxes .idGenTestBox',728 ' TestBoxes .sOs, TestBoxes.sCpuArch',726 ', TestBoxesWithStrings', 727 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 728 ' TestBoxesWithStrings.sOs, TestBoxesWithStrings.sCpuArch', 729 729 '', '' ), 730 730 ksResultsSortByTestBoxOs: ( 731 ', TestBoxes ',732 ' AND TestSets.idGenTestBox = TestBoxes .idGenTestBox',733 ' TestBoxes .sOs',731 ', TestBoxesWithStrings', 732 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 733 ' TestBoxesWithStrings.sOs', 734 734 '', '' ), 735 735 ksResultsSortByTestBoxOsVersion: ( 736 ', TestBoxes ',737 ' AND TestSets.idGenTestBox = TestBoxes .idGenTestBox',738 ' TestBoxes .sOs, TestBoxes.sOsVersion DESC',736 ', TestBoxesWithStrings', 737 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 738 ' TestBoxesWithStrings.sOs, TestBoxesWithStrings.sOsVersion DESC', 739 739 '', '' ), 740 740 ksResultsSortByTestBoxArch: ( 741 ', TestBoxes ',742 ' AND TestSets.idGenTestBox = TestBoxes .idGenTestBox',743 ' TestBoxes .sCpuArch',741 ', TestBoxesWithStrings', 742 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 743 ' TestBoxesWithStrings.sCpuArch', 744 744 '', '' ), 745 745 ksResultsSortByTestBoxCpuVendor: ( 746 ', TestBoxes ',747 ' AND TestSets.idGenTestBox = TestBoxes .idGenTestBox',748 ' TestBoxes .sCpuVendor',746 ', TestBoxesWithStrings', 747 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 748 ' TestBoxesWithStrings.sCpuVendor', 749 749 '', '' ), 750 750 ksResultsSortByTestBoxCpuName: ( 751 ', TestBoxes ',752 ' AND TestSets.idGenTestBox = TestBoxes .idGenTestBox',753 ' TestBoxes .sCpuVendor, TestBoxes.sCpuName',751 ', TestBoxesWithStrings', 752 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 753 ' TestBoxesWithStrings.sCpuVendor, TestBoxesWithStrings.sCpuName', 754 754 '', '' ), 755 755 ksResultsSortByTestBoxCpuRev: ( 756 ', TestBoxes ',757 ' AND TestSets.idGenTestBox = TestBoxes .idGenTestBox',758 ' TestBoxes .sCpuVendor, TestBoxes.lCpuRevision DESC',759 ', TestBoxes .lCpuRevision',760 ', TestBoxes .lCpuRevision' ),756 ', TestBoxesWithStrings', 757 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 758 ' TestBoxesWithStrings.sCpuVendor, TestBoxesWithStrings.lCpuRevision DESC', 759 ', TestBoxesWithStrings.lCpuRevision', 760 ', TestBoxesWithStrings.lCpuRevision' ), 761 761 ksResultsSortByTestBoxCpuFeatures: ( 762 762 ', TestBoxes', 763 763 ' AND TestSets.idGenTestBox = TestBoxes.idGenTestBox', 764 764 ' TestBoxes.fCpuHwVirt DESC, TestBoxes.fCpuNestedPaging DESC, TestBoxes.fCpu64BitGuest DESC, TestBoxes.cCpus DESC', 765 ' , TestBoxes.cCpus',766 ' , TestBoxes.cCpus' ),765 '', 766 '' ), 767 767 ksResultsSortByTestCaseName: ( 768 768 ', TestCases', … … 779 779 kdResultGroupingMap = { 780 780 ksResultsGroupingTypeNone: ( 781 # Grouping tables; # Grouping field; # Grouping where addition. # Sort by overrides. 782 '', None, None, {}, 781 # Grouping tables; 782 '', 783 # Grouping field; 784 None, 785 # Grouping where addition. 786 None, 787 # Sort by overrides. 788 {}, 783 789 ), 784 790 ksResultsGroupingTypeTestGroup: ('', 'TestSets.idTestGroup', None, {},), … … 794 800 ), 795 801 ksResultsGroupingTypeSchedGroup: ( 796 ', TestBoxes', 797 'TestBoxes.idSchedGroup', 798 ' AND TestSets.idGenTestBox = TestBoxes.idGenTestBox', 799 { ksResultsSortByTestBoxName: ( '', None, ' TestBoxes.sName DESC', '', '' ), 800 ksResultsSortByTestBoxOsArch: ( '', None, ' TestBoxes.sOs, TestBoxes.sCpuArch', '', '' ), 801 ksResultsSortByTestBoxOs: ( '', None, ' TestBoxes.sOs', '' ), 802 ksResultsSortByTestBoxOsVersion: ( '', None, ' TestBoxes.sOs, TestBoxes.sOsVersion DESC', '', '' ), 803 ksResultsSortByTestBoxArch: ( '', None, ' TestBoxes.sCpuArch', '' ), 804 ksResultsSortByTestBoxCpuVendor: ( '', None, ' TestBoxes.sCpuVendor', '' ), 805 ksResultsSortByTestBoxCpuName: ( '', None, ' TestBoxes.sCpuVendor, TestBoxes.sCpuName', '', '' ), 802 ', TestBoxesWithStrings', 803 'TestBoxesWithStrings.idSchedGroup', 804 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox', 805 { 806 807 ksResultsSortByTestBoxName: ( 808 # Sorting tables. 809 '', 810 # Sorting table join(s). 811 None, 812 # Start of ORDER BY statement. 813 ' TestBoxesWithStrings.sName DESC', 814 # Extra columns to fetch for the above ORDER BY to work in a SELECT DISTINCT statement. 815 '', 816 # Columns for the GROUP BY 817 '' ), 818 ksResultsSortByTestBoxOsArch: ( '', None, ' TestBoxesWithStrings.sOs, TestBoxesWithStrings.sCpuArch', '', '' ), 819 ksResultsSortByTestBoxOs: ( '', None, ' TestBoxesWithStrings.sOs', '', '' ), 820 ksResultsSortByTestBoxOsVersion: ( '', None, ' TestBoxesWithStrings.sOs, TestBoxesWithStrings.sOsVersion DESC', 821 '', '' ), 822 ksResultsSortByTestBoxArch: ( '', None, ' TestBoxesWithStrings.sCpuArch', '', '' ), 823 ksResultsSortByTestBoxCpuVendor: ( '', None, ' TestBoxesWithStrings.sCpuVendor', '', '' ), 824 ksResultsSortByTestBoxCpuName: ( '', None, ' TestBoxesWithStrings.sCpuVendor, TestBoxesWithStrings.sCpuName', 825 '', '' ), 806 826 ksResultsSortByTestBoxCpuRev: ( 807 '', None, ' TestBoxes.sCpuVendor, TestBoxes.lCpuRevision DESC', ', TestBoxes.lCpuRevision', '' ), 827 '', 828 None, 829 ' TestBoxesWithStrings.sCpuVendor, TestBoxesWithStrings.lCpuRevision DESC', 830 ', TestBoxesWithStrings.lCpuRevision', 831 ', TestBoxesWithStrings.lCpuRevision' ), 808 832 ksResultsSortByTestBoxCpuFeatures: ( 809 ' TestBoxes.fCpuHwVirt DESC, TestBoxes.fCpuNestedPaging DESC, TestBoxes.fCpu64BitGuest DESC, ' 810 + 'TestBoxes.cCpus DESC', 811 ', TestBoxes.cCpus', 833 '', 834 None, 835 ' TestBoxesWithStrings.fCpuHwVirt DESC, TestBoxesWithStrings.fCpuNestedPaging DESC, ' 836 +'TestBoxesWithStrings.fCpu64BitGuest DESC, TestBoxesWithStrings.cCpus DESC', 837 '', 812 838 '' ), } 813 839 ), … … 884 910 ' Builds.sVersion,\n' \ 885 911 ' Builds.iRevision,\n' \ 886 ' TestBoxes .sOs,\n' \887 ' TestBoxes .sOsVersion,\n' \888 ' TestBoxes .sCpuArch,\n' \889 ' TestBoxes .sCpuVendor,\n' \890 ' TestBoxes .sCpuName,\n' \891 ' TestBoxes .cCpus,\n' \892 ' TestBoxes .fCpuHwVirt,\n' \893 ' TestBoxes .fCpuNestedPaging,\n' \894 ' TestBoxes .fCpu64BitGuest,\n' \895 ' TestBoxes .idTestBox,\n' \896 ' TestBoxes .sName,\n' \912 ' TestBoxesWithStrings.sOs,\n' \ 913 ' TestBoxesWithStrings.sOsVersion,\n' \ 914 ' TestBoxesWithStrings.sCpuArch,\n' \ 915 ' TestBoxesWithStrings.sCpuVendor,\n' \ 916 ' TestBoxesWithStrings.sCpuName,\n' \ 917 ' TestBoxesWithStrings.cCpus,\n' \ 918 ' TestBoxesWithStrings.fCpuHwVirt,\n' \ 919 ' TestBoxesWithStrings.fCpuNestedPaging,\n' \ 920 ' TestBoxesWithStrings.fCpu64BitGuest,\n' \ 921 ' TestBoxesWithStrings.idTestBox,\n' \ 922 ' TestBoxesWithStrings.sName,\n' \ 897 923 ' TestResults.tsCreated,\n' \ 898 924 ' COALESCE(TestResults.tsElapsed, CURRENT_TIMESTAMP - TestResults.tsCreated) AS tsElapsedTestResult,\n' \ … … 913 939 'FROM BuildCategories,\n' \ 914 940 ' Builds,\n' \ 915 ' TestBoxes ,\n' \941 ' TestBoxesWithStrings,\n' \ 916 942 ' TestResults,\n' \ 917 943 ' TestCases,\n' \ … … 970 996 ' AND Builds.tsEffective <= TestSets.tsCreated\n' \ 971 997 ' AND Builds.idBuildCategory = BuildCategories.idBuildCategory\n' \ 972 ' AND TestSets.idGenTestBox = TestBoxes .idGenTestBox\n' \998 ' AND TestSets.idGenTestBox = TestBoxesWithStrings.idGenTestBox\n' \ 973 999 ' AND TestSets.idGenTestCase = TestCases.idGenTestCase\n' \ 974 1000 ' AND TestSets.idGenTestCaseArgs = TestCaseArgs.idGenTestCaseArgs\n'; … … 982 1008 ' Builds.sVersion,\n' \ 983 1009 ' Builds.iRevision,\n' \ 984 ' TestBoxes .sOs,\n' \985 ' TestBoxes .sOsVersion,\n' \986 ' TestBoxes .sCpuArch,\n' \987 ' TestBoxes .sCpuVendor,\n' \988 ' TestBoxes .sCpuName,\n' \989 ' TestBoxes .cCpus,\n' \990 ' TestBoxes .fCpuHwVirt,\n' \991 ' TestBoxes .fCpuNestedPaging,\n' \992 ' TestBoxes .fCpu64BitGuest,\n' \993 ' TestBoxes .idTestBox,\n' \994 ' TestBoxes .sName,\n' \1010 ' TestBoxesWithStrings.sOs,\n' \ 1011 ' TestBoxesWithStrings.sOsVersion,\n' \ 1012 ' TestBoxesWithStrings.sCpuArch,\n' \ 1013 ' TestBoxesWithStrings.sCpuVendor,\n' \ 1014 ' TestBoxesWithStrings.sCpuName,\n' \ 1015 ' TestBoxesWithStrings.cCpus,\n' \ 1016 ' TestBoxesWithStrings.fCpuHwVirt,\n' \ 1017 ' TestBoxesWithStrings.fCpuNestedPaging,\n' \ 1018 ' TestBoxesWithStrings.fCpu64BitGuest,\n' \ 1019 ' TestBoxesWithStrings.idTestBox,\n' \ 1020 ' TestBoxesWithStrings.sName,\n' \ 995 1021 ' TestResults.tsCreated,\n' \ 996 1022 ' tsElapsedTestResult,\n' \ … … 1007 1033 sQuery += 'ORDER BY '; 1008 1034 if sSortOrderBy is not None: 1009 sQuery += sSortOrderBy + ',\n ';1035 sQuery += sSortOrderBy.replace('TestBoxes.', 'TestBoxesWithStrings.') + ',\n '; 1010 1036 sQuery += '(TestSets.tsDone IS NULL) DESC, TestSets.idTestSet DESC\n'; 1011 1037 … … 1154 1180 """ 1155 1181 1156 self._oDb.execute('SELECT TestBoxes .*\n'1157 'FROM TestBoxes ,\n'1182 self._oDb.execute('SELECT TestBoxesWithStrings.*\n' 1183 'FROM TestBoxesWithStrings,\n' 1158 1184 ' ( SELECT idTestBox AS idTestBox,\n' 1159 1185 ' MAX(idGenTestBox) AS idGenTestBox\n' … … 1162 1188 ' GROUP BY idTestBox\n' 1163 1189 ' ) AS TestBoxIDs\n' 1164 'WHERE TestBoxes .idGenTestBox = TestBoxIDs.idGenTestBox\n'1165 'ORDER BY TestBoxes .sName\n' );1190 'WHERE TestBoxesWithStrings.idGenTestBox = TestBoxIDs.idGenTestBox\n' 1191 'ORDER BY TestBoxesWithStrings.sName\n' ); 1166 1192 aoRet = [] 1167 1193 for aoRow in self._oDb.fetchAll(): -
trunk/src/VBox/ValidationKit/testmanager/core/testset.py
r61462 r61468 623 623 Returns an array of TestBoxData object representing the gang for the given testset. 624 624 """ 625 self._oDb.execute('SELECT TestBoxes.*\n' 626 'FROM TestBoxes, TestSets\n' 625 self._oDb.execute('SELECT TestBoxes.*,\n' 626 ' Str1.sValue,\n' 627 ' Str2.sValue,\n' 628 ' Str3.sValue,\n' 629 ' Str4.sValue,\n' 630 ' Str5.sValue,\n' 631 ' Str6.sValue,\n' 632 ' Str7.sValue,\n' 633 ' Str8.sValue\n' 634 'FROM TestBoxes\n' 635 ' LEFT OUTER JOIN TestBoxStrTab Str1 ON idStrDescription = Str1.idStr\n' 636 ' LEFT OUTER JOIN TestBoxStrTab Str2 ON idStrComment = Str2.idStr\n' 637 ' LEFT OUTER JOIN TestBoxStrTab Str3 ON idStrOs = Str3.idStr\n' 638 ' LEFT OUTER JOIN TestBoxStrTab Str4 ON idStrOsVersion = Str4.idStr\n' 639 ' LEFT OUTER JOIN TestBoxStrTab Str5 ON idStrCpuVendor = Str5.idStr\n' 640 ' LEFT OUTER JOIN TestBoxStrTab Str6 ON idStrCpuArch = Str6.idStr\n' 641 ' LEFT OUTER JOIN TestBoxStrTab Str7 ON idStrCpuName = Str7.idStr\n' 642 ' LEFT OUTER JOIN TestBoxStrTab Str8 ON idStrReport = Str8.idStr,\n' 643 ' TestSets' 627 644 'WHERE TestSets.idTestSetGangLeader = %s\n' 628 645 ' AND TestSets.idGenTestBox = TestBoxes.idGenTestBox\n' 629 646 'ORDER BY iGangMemberNo ASC\n' 630 , ( idTestSetGangLeader,));647 , ( idTestSetGangLeader,)); 631 648 aaoRows = self._oDb.fetchAll(); 632 649 aoTestBoxes = [];
Note:
See TracChangeset
for help on using the changeset viewer.