def test_ended(self, run_id): # first of all, we want to mark it done in the DB self.update_metadata(run_id, stopped=True, active=False, ended=time.time()) # we want to ping all observers that things are done # for a given test. # get the list of observers args = self._db.get_metadata(run_id) observers = _compute_observers(args.get('observer')) if observers == []: return # rebuild the test result instance test_result = RemoteTestResult(args=args) test_result.args = args data = list(self._db.get_data(run_id, size=1)) if len(data) > 0: started = datetime.datetime.utcfromtimestamp(data[0]['started']) test_result.startTestRun(when=started) test_result.set_counts(self._db.get_counts(run_id)) # for each observer we call it with the test results for observer in observers: try: observer(test_result, args) except Exception: # the observer code failed. We want to log it logger.error('%r failed' % observer)
def test_result(self): if self._test_result is None: if self.args.get('attach', False): self._test_result = RemoteTestResult(args=self.args) self.refresh_rate = 500 else: self._test_result = TestResult(args=self.args) return self._test_result
def test_result(self): if self._test_result is None: if self.args.get('attach', False): self._test_result = RemoteTestResult(args=self.args) self.refresh_rate = 500 else: self._test_result = TestResult(args=self.args) # we want to reattach the outputs from Local for output in self.outputs: self._test_result.add_observer(output) return self._test_result
def test_ended(self, run_id): # first of all, we want to mark it done in the DB logger.debug('test %s ended marking the metadata' % run_id) self.update_metadata(run_id, stopped=True, active=False, ended=time.time()) # we want to ping all observers that things are done # for a given test. # get the list of observers args = self._db.get_metadata(run_id) observers = _compute_observers(args.get('observer')) if observers == []: self._db.summarize_run(run_id) return logger.debug('test %s ended calling the observers' % run_id) # if we are using the web dashboard - we're just providing a link if self.broker.web_root is not None: test_result = '%s/run/%s' % (self.broker.web_root, run_id) else: # rebuild the test result instance test_result = RemoteTestResult(args=args) test_result.args = args if 'started' in args: started = args['started'] started = datetime.datetime.utcfromtimestamp(started) test_result.startTestRun(when=started) test_result.set_counts(self._db.get_counts(run_id)) # for each observer we call it with the test results for observer in observers: options = {} prefix = 'observer_%s_' % observer.name for name, value in args.items(): if name.startswith(prefix): options[name[len(prefix):]] = value # get the options try: observer(args=args, **options)(test_result) except Exception: # the observer code failed. We want to log it logger.error('%r failed' % observer) self._db.summarize_run(run_id)