| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 import os | 6 import os |
| 7 | 7 |
| 8 from recipe_engine import recipe_api | 8 from recipe_engine import recipe_api |
| 9 from . import perf_test | 9 from . import perf_test |
| 10 | 10 |
| 11 BUCKET = 'chrome-perf' | 11 BUCKET = 'chrome-perf' |
| 12 RESULTS_GS_DIR = 'bisect-results' | 12 RESULTS_GS_DIR = 'bisect-results' |
| 13 | 13 |
| 14 | 14 |
| 15 class BisectTesterApi(recipe_api.RecipeApi): | 15 class BisectTesterApi(recipe_api.RecipeApi): |
| 16 """A module for the bisect tester bot using the chromium recipe.""" | 16 """A module for the bisect tester bot using the chromium recipe.""" |
| 17 | 17 |
| 18 def __init__(self, **kwargs): | 18 def __init__(self, **kwargs): |
| 19 super(BisectTesterApi, self).__init__(**kwargs) | 19 super(BisectTesterApi, self).__init__(**kwargs) |
| 20 self._device_to_test = None |
| 21 |
| 22 @property |
| 23 def device_to_test(self): |
| 24 return self._device_to_test |
| 25 |
| 26 @device_to_test.setter |
| 27 def device_to_test(self, value): |
| 28 self._device_to_test = value |
| 20 | 29 |
| 21 def local_test_enabled(self): | 30 def local_test_enabled(self): |
| 22 buildername = os.environ.get('BUILDBOT_BUILDERNAME') | 31 buildername = os.environ.get('BUILDBOT_BUILDERNAME') |
| 23 cr_config = self.m.chromium.c | 32 cr_config = self.m.chromium.c |
| 24 if buildername and buildername.endswith('_bisect') and cr_config: | 33 if buildername and buildername.endswith('_bisect') and cr_config or ( |
| 34 self.m.properties.get('local_test')): |
| 25 return True # pragma: no cover | 35 return True # pragma: no cover |
| 26 return False | 36 return False |
| 27 | 37 |
| 28 def load_config_from_dict(self, bisect_config): | 38 def load_config_from_dict(self, bisect_config): |
| 29 """Copies the required configuration keys to a new dict.""" | 39 """Copies the required configuration keys to a new dict.""" |
| 30 return { | 40 return { |
| 31 'command': bisect_config['command'], | 41 'command': bisect_config['command'], |
| 32 'metric': bisect_config.get('metric'), | 42 'metric': bisect_config.get('metric'), |
| 33 'repeat_count': int(bisect_config.get('repeat_count', 20)), | 43 'repeat_count': int(bisect_config.get('repeat_count', 20)), |
| 34 # The default is to NOT timeout, hence 0. | 44 # The default is to NOT timeout, hence 0. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 54 job_name = (test_parameters.get('job_name') or | 64 job_name = (test_parameters.get('job_name') or |
| 55 self.m.properties.get('job_name')) | 65 self.m.properties.get('job_name')) |
| 56 gs_filename = '%s/%s.results' % (RESULTS_GS_DIR, job_name) | 66 gs_filename = '%s/%s.results' % (RESULTS_GS_DIR, job_name) |
| 57 contents = {'results': results, 'output': output, 'retcodes': retcodes} | 67 contents = {'results': results, 'output': output, 'retcodes': retcodes} |
| 58 contents_json = json.dumps(contents) | 68 contents_json = json.dumps(contents) |
| 59 local_save_results = self.m.python('saving json to temp file', | 69 local_save_results = self.m.python('saving json to temp file', |
| 60 self.resource('put_temp.py'), | 70 self.resource('put_temp.py'), |
| 61 stdout=self.m.raw_io.output(), | 71 stdout=self.m.raw_io.output(), |
| 62 stdin=self.m.raw_io.input( | 72 stdin=self.m.raw_io.input( |
| 63 contents_json)) | 73 contents_json)) |
| 74 |
| 64 local_file = local_save_results.stdout.splitlines()[0].strip() | 75 local_file = local_save_results.stdout.splitlines()[0].strip() |
| 65 # TODO(robertocn): Look into using self.m.json.input(contents) instead of | 76 # TODO(robertocn): Look into using self.m.json.input(contents) instead of |
| 66 # local_file. | 77 # local_file. |
| 67 self.m.gsutil.upload(local_file, BUCKET, gs_filename) | 78 self.m.gsutil.upload(local_file, BUCKET, gs_filename) |
| 68 | 79 |
| 69 def upload_job_url(self): | 80 def upload_job_url(self): |
| 70 """Puts the URL to the job's status on a GS file.""" | 81 """Puts the URL to the job's status on a GS file.""" |
| 71 # If we are running the test locally there is no need for this. | 82 # If we are running the test locally there is no need for this. |
| 72 if self.local_test_enabled(): | 83 if self.local_test_enabled(): |
| 73 return # pragma: no cover | 84 return # pragma: no cover |
| 74 gs_filename = RESULTS_GS_DIR + '/' + self.m.properties.get( | 85 gs_filename = RESULTS_GS_DIR + '/' + self.m.properties.get( |
| 75 'job_name') | 86 'job_name') |
| 76 if 'TESTING_MASTER_HOST' in os.environ: # pragma: no cover | 87 if 'TESTING_MASTER_HOST' in os.environ: # pragma: no cover |
| 77 url = "http://%s:8041/json/builders/%s/builds/%s" % ( | 88 url = "http://%s:8041/json/builders/%s/builds/%s" % ( |
| 78 os.environ['TESTING_MASTER_HOST'], | 89 os.environ['TESTING_MASTER_HOST'], |
| 79 self.m.properties['buildername'], | 90 self.m.properties['buildername'], |
| 80 self.m.properties['buildnumber']) | 91 self.m.properties['buildnumber']) |
| 81 else: | 92 else: |
| 82 url = "http://build.chromium.org/p/%s/json/builders/%s/builds/%s" % ( | 93 url = "http://build.chromium.org/p/%s/json/builders/%s/builds/%s" % ( |
| 83 self.m.properties['mastername'], | 94 self.m.properties['mastername'], |
| 84 self.m.properties['buildername'], | 95 self.m.properties['buildername'], |
| 85 self.m.properties['buildnumber']) | 96 self.m.properties['buildnumber']) |
| 86 local_save_results = self.m.python('saving url to temp file', | 97 local_save_results = self.m.python('saving url to temp file', |
| 87 self.resource('put_temp.py'), | 98 self.resource('put_temp.py'), |
| 88 stdout=self.m.raw_io.output(), | 99 stdout=self.m.raw_io.output(), |
| 89 stdin=self.m.raw_io.input(url)) | 100 stdin=self.m.raw_io.input(url)) |
| 90 local_file = local_save_results.stdout.splitlines()[0].strip() | 101 local_file = local_save_results.stdout.splitlines()[0].strip() |
| 91 self.m.gsutil.upload( | 102 self.m.gsutil.upload( |
| 92 local_file, BUCKET, gs_filename, name=str(gs_filename)) | 103 local_file, BUCKET, gs_filename, name=str(gs_filename)) |
| OLD | NEW |