def __setupStage(self): """ Create all objects within the database with defaults """ self.executionDetails = TestExecutionDetails.create( testSuiteName = self.testSuiteName, executionName = self.executionName, #TODO: make me! scmidentifier = 'N/A', shortFilterDesc = self.shortFilterDesc, testPackDescriptor = self.packFilterDesc, startTime = time.time(), endTime = -1, duration = -1, envservExecutionModeName = 'automated', # FIXME: read from config hostNetAddress = Network.getIPAddressByInterface(), hostMacAddress = Network.getMacAddress(), tasVersion = os.environ['TAS_VERSION']) self.executionDetails.save() if not hasattr(self, 'source'): raise Exception("SQLLiteLogger: Source object has not been set") ResultBaseModel.Meta.database.set_autocommit(False) for group in self.source.groups: for test in group.tests: testDetails = TestDetails.get_or_create( testId = str(test.testId), module = str(test.testFile), testName = test.combineClassMethod(), invalid = test.invalid, manualInspection = test.manualInspection, docstrings = "\n".join(test.docstrings), timeout = test.testTimeout) testState = TestStates.filter(sequenceId = test.state.index).get() testResults = TestResults.create( testDetailsRef = testDetails, executed = False, invalid = test.invalid, result = testState, error = test.error, startTime = -1, duration = -1, manualInspection = test.manualInspection, testExecutionDetailsRef = self.executionDetails, peerRef = None, iterationId = None) testResults.save() testDetails.save() ResultBaseModel.Meta.database.commit() ResultBaseModel.Meta.database.set_autocommit(True)
def gatherTests(self): """ Discover all tests from all sources """ tests, content = [], {} execution = ConfigurationManager().getConfiguration('execution').configuration if execution.scripts.enabled == 'true': if not os.path.exists(execution.scripts.PCDATA): raise Exception('Invalid configuration. Executions scripts do not exist') content['tools'] = execution.scripts.PCDATA if len(self.__testCreators) == 0: raise Exception('No enabled test creators found') for creator in self.__testCreators: newTests = creator.createTests() if len(newTests) == 0: raise Exception('%s provided no tests!' % creator.__class__.__name__) tests += newTests content[creator.execScriptName] = creator.execScriptLocation content[creator.srcName] = creator.srcLocation testIds = [] for test in tests: if test.testId not in testIds: continue raise Exception('Duplicate test ID %s' % test.testId) if len(tests) == 0: raise Exception('No tests found!') del testIds defGroup = Group(self.DEFAULT_GROUP_NAME, self.DEFAULT_GROUP_DESC, tests) source = Source(self.DEFAULT_LOCATION, defGroup) descBuffer = StringIO() for testFilter in self.__testFilters: source = testFilter.filterTests(source) descBuffer.write(testFilter.getAppliedFilterDescription()) desc = descBuffer.getvalue() descBuffer.close() testSuiteName = "FIXME" # TODO: where does this come from? dateTime = datetime.fromtimestamp(time.time()).strftime('%Y-%m-%dT%H:%M:%S') macAddress = Network.getMacAddress() executionName = "%s_%s_%s" % (testSuiteName, dateTime, macAddress) self.__packDetails = (testSuiteName, str(desc), self.__getShortFilterDesc(), executionName, dateTime) self.__makeTar(**content) return source, desc