def _MakeBuildbucketBisectJob(bisect_job): """Creates a bisect job object that the buildbucket service can use. Args: bisect_job: The entity (try_job.TryJob) off of which to create the buildbucket job. Returns: A buildbucket_job.BisectJob object populated with the necessary attributes to pass it to the buildbucket service to start the job. """ config = bisect_job.GetConfigDict() if bisect_job.job_type != 'bisect': raise request_handler.InvalidInputError( 'Recipe only supports bisect jobs at this time.') if not bisect_job.master_name.startswith('ChromiumPerf'): raise request_handler.InvalidInputError( 'Recipe is only implemented on for tests run on chromium.perf ' '(and chromium.perf.fyi).') return buildbucket_job.BisectJob( good_revision=config['good_revision'], bad_revision=config['bad_revision'], test_command=config['command'], metric=config['metric'], repeats=config['repeat_count'], timeout_minutes=config['max_time_minutes'], truncate=config['truncate_percent'], bug_id=bisect_job.bug_id, gs_bucket='chrome-perf', original_bot_name=config['original_bot_name'], )
def _MakeBuildbucketBisectJob(bisect_job): """Creates a bisect job object that the buildbucket service can use. Args: bisect_job: The entity (try_job.TryJob) off of which to create the buildbucket job. Returns: A buildbucket_job.BisectJob object populated with the necessary attributes to pass it to the buildbucket service to start the job. """ config = bisect_job.GetConfigDict() if bisect_job.job_type not in ['bisect', 'bisect-fyi']: raise request_handler.InvalidInputError( 'Recipe only supports bisect jobs at this time.') # Recipe bisect supports 'perf' and 'return_code' test types only. # TODO (prasadv): Update bisect form on dashboard to support test_types. test_type = 'perf' if config.get('bisect_mode') == 'return_code': test_type = config['bisect_mode'] return buildbucket_job.BisectJob( try_job_id=bisect_job.key.id(), good_revision=config['good_revision'], bad_revision=config['bad_revision'], test_command=config['command'], metric=config['metric'], repeats=config['repeat_count'], timeout_minutes=config['max_time_minutes'], bug_id=bisect_job.bug_id, gs_bucket='chrome-perf', recipe_tester_name=config['recipe_tester_name'], test_type=test_type, required_initial_confidence=config.get('required_initial_confidence'))
def testCreateJob(self): job = buildbucket_job.BisectJob(**self._args_base) params = job.GetBuildParameters() assert isinstance(params, dict) self.assertIn('builder_name', params) properties = params['properties'] assert isinstance(properties, dict) bisect_config = properties['bisect_config'] assert isinstance(bisect_config, dict) self.assertIn('test_type', bisect_config) self.assertIn('command', bisect_config) self.assertIn('src', bisect_config['command']) self.assertIn('metric', bisect_config) self.assertIn('good_revision', bisect_config) self.assertIn('bad_revision', bisect_config) self.assertIn('repeat_count', bisect_config) self.assertIn('max_time_minutes', bisect_config)
def post(self): if not utils.IsInternalUser(): self.response.out.write(json.dumps({ 'error': 'You are not authorized to post to this endpoint.', })) return job = buildbucket_job.BisectJob( 'linux_perf_bisector', self.request.get('good_revision'), self.request.get('bad_revision'), self.request.get('command'), self.request.get('metric'), self.request.get('repeat_count'), self.request.get('max_time_minutes'), self.request.get('bug_id'), self.request.get('gs_bucket'), self.request.get('recipe_tester_name'), self.request.get('builder_host'), self.request.get('builder_port')) buildbucket_service.PutJob(job) self.response.out.write(job.response_fields)
def testUnsupportedPlatform(self): self._args_base['original_bot_name'] = 'MSDOS' with self.assertRaises(NotImplementedError): job = buildbucket_job.BisectJob(**self._args_base) _ = job.GetBuildParameters()
def testMissingRequiredArgs(self): self._args_base['test_command'] = None with self.assertRaises(ValueError): job = buildbucket_job.BisectJob(**self._args_base) _ = job.GetBuildParameters()