def _Complete(self): logging.debug('Job [%s]: Completed', self.job_id) if self.use_execution_engine: scheduler.Complete(self) # Only proceed if this thread/process is the one that successfully marked # a job done. if not MarkDone(self.job_id): return logging.debug('Job [%s]: Marked done', self.job_id) if not self._IsTryJob() and not self.use_execution_engine: self.difference_count = len(self.state.Differences()) try: # TODO(dberris): Migrate results2 generation to tasks and evaluators. results2.ScheduleResults2Generation(self) except taskqueue.Error as e: logging.debug('Failed ScheduleResults2Generation: %s', str(e)) self._FormatAndPostBugCommentOnComplete() self._UpdateGerritIfNeeded() scheduler.Complete(self)
def get(self, job_id): try: job = job_module.JobFromId(job_id) if not job: raise results2.Results2Error('Error: Unknown job %s' % job_id) if not job.completed: self.response.out.write(json.dumps({'status': 'job-incomplete'})) return url = results2.GetCachedResults2(job) if url: self.response.out.write(json.dumps({'status': 'complete', 'url': url})) return if results2.ScheduleResults2Generation(job): self.response.out.write(json.dumps({'status': 'pending'})) return self.response.out.write(json.dumps({'status': 'failed'})) except results2.Results2Error as e: self.response.set_status(400) self.response.out.write(e.message)
def _Complete(self): try: results2.ScheduleResults2Generation(self) except taskqueue.Error: pass # Format bug comment. if not self.auto_explore: # There is no comparison metric. title = "<b>%s Job complete. See results below.</b>" % _ROUND_PUSHPIN self._PostBugComment('\n'.join((title, self.url))) return # There is a comparison metric. differences = tuple(self.state.Differences()) if not differences: title = "<b>%s Couldn't reproduce a difference.</b>" % _ROUND_PUSHPIN self._PostBugComment('\n'.join((title, self.url))) return # Include list of Changes. owner = None cc_list = set() commit_details = [] for _, change in differences: if change.patch: commit_info = change.patch.AsDict() else: commit_info = change.last_commit.AsDict() # TODO: Assign the largest difference, not the last one. owner = commit_info['author'] cc_list.add(commit_info['author']) if 'reviewers' in commit_info: cc_list |= frozenset(commit_info['reviewers']) commit_details.append(_FormatCommitForBug(commit_info)) # Header. if len(differences) == 1: status = 'Found a significant difference after 1 commit.' else: status = ( 'Found significant differences after each of %d commits.' % len(differences)) title = '<b>%s %s</b>' % (_ROUND_PUSHPIN, status) header = '\n'.join((title, self.url)) # Body. body = '\n\n'.join(commit_details) # Footer. footer = ('Understanding performance regressions:\n' ' http://g.co/ChromePerformanceRegressions') # Bring it all together. comment = '\n\n'.join((header, body, footer)) current_bug_status = self._GetBugStatus() if (not current_bug_status or current_bug_status in ['Untriaged', 'Unconfirmed', 'Available']): # Set the bug status and owner if this bug is opened and unowned. self._PostBugComment(comment, status='Assigned', cc_list=sorted(cc_list), owner=owner) else: # Only update the comment and cc list if this bug is assigned or closed. self._PostBugComment(comment, cc_list=sorted(cc_list))
def testScheduleResults2Generation2_AlreadyRunning(self, mock_add): mock_add.side_effect = taskqueue.TaskAlreadyExistsError job = _JobStub(_JOB_WITH_DIFFERENCES, '123') result = results2.ScheduleResults2Generation(job) self.assertTrue(result)
def testScheduleResults2Generation2_FailedPreviously(self, mock_add): mock_add.side_effect = taskqueue.TombstonedTaskError job = _JobStub(_JOB_WITH_DIFFERENCES, '123') result = results2.ScheduleResults2Generation(job) self.assertFalse(result)
def testScheduleResults2Generation2_AlreadyRunning(self): job = _JobStub(_JOB_WITH_DIFFERENCES, '123') result = results2.ScheduleResults2Generation(job) self.assertTrue(result)
def testScheduleResults2Generation2_FailedPreviously(self): job = _JobStub(_JOB_WITH_DIFFERENCES, '123') result = results2.ScheduleResults2Generation(job) self.assertFalse(result)