| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 os |
| 5 import urllib | 6 import urllib |
| 6 | 7 |
| 7 from recipe_engine import recipe_api | 8 from recipe_engine import recipe_api |
| 8 | 9 |
| 9 | 10 |
| 10 class PerfDashboardApi(recipe_api.RecipeApi): | 11 class PerfDashboardApi(recipe_api.RecipeApi): |
| 11 """Provides steps to take a list of perf points and post them to the | 12 """Provides steps to take a list of perf points and post them to the |
| 12 Chromium Perf Dashboard. Can also use the test url for testing purposes.""" | 13 Chromium Perf Dashboard. Can also use the test url for testing purposes.""" |
| 13 | 14 |
| 14 def get_skeleton_point(self, test, revision, value, bot=None): | 15 def get_skeleton_point(self, test, revision, value, bot=None): |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 'masters': self.m.properties['mastername'], | 49 'masters': self.m.properties['mastername'], |
| 49 'bots': bot or self.m.properties['buildername'], | 50 'bots': bot or self.m.properties['buildername'], |
| 50 'tests': test, | 51 'tests': test, |
| 51 'rev': revision, | 52 'rev': revision, |
| 52 }) | 53 }) |
| 53 presentation.links['Results Dashboard'] = ('%s/report?%s' % | 54 presentation.links['Results Dashboard'] = ('%s/report?%s' % |
| 54 (self.c.url, params)) | 55 (self.c.url, params)) |
| 55 | 56 |
| 56 def set_default_config(self): | 57 def set_default_config(self): |
| 57 """If in golo, use real perf server, otherwise use testing perf server.""" | 58 """If in golo, use real perf server, otherwise use testing perf server.""" |
| 58 if self.m.properties.get('use_mirror', True): # We're on a bot | 59 # TODO: This property should be passed explicitly supplied by the recipe |
| 60 # scheduler, not inferred from arbitrary bot environment. |
| 61 on_production_bot = self.m.properties.get('perf_production', |
| 62 not any(v in os.environ for v in ( |
| 63 'TESTING_MASTERNAME', |
| 64 'TESTING_SLAVENAME', |
| 65 ))) |
| 66 if on_production_bot: # We're on a bot |
| 59 self.set_config('production') | 67 self.set_config('production') |
| 60 else: | 68 else: |
| 61 self.set_config('testing') | 69 self.set_config('testing') |
| 62 | 70 |
| 63 def post(self, data): | 71 def post(self, data): |
| 64 """Takes a data object which can be jsonified and posts it to url.""" | 72 """Takes a data object which can be jsonified and posts it to url.""" |
| 65 self.m.python(name='perf dashboard post', | 73 self.m.python(name='perf dashboard post', |
| 66 script=self.resource('post_json.py'), | 74 script=self.resource('post_json.py'), |
| 67 stdin=self.m.json.input({ | 75 stdin=self.m.json.input({ |
| 68 'url': '%s/add_point' % self.c.url, | 76 'url': '%s/add_point' % self.c.url, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 91 self.warning(response, reason) | 99 self.warning(response, reason) |
| 92 | 100 |
| 93 def halt(self, step_result, reason): # pragma: no cover | 101 def halt(self, step_result, reason): # pragma: no cover |
| 94 step_result.presentation.step_text = reason | 102 step_result.presentation.step_text = reason |
| 95 step_result.presentation.status = self.m.step.FAILURE | 103 step_result.presentation.status = self.m.step.FAILURE |
| 96 raise self.m.step.StepFailure(reason) | 104 raise self.m.step.StepFailure(reason) |
| 97 | 105 |
| 98 def warning(self, step_result, reason): # pragma: no cover | 106 def warning(self, step_result, reason): # pragma: no cover |
| 99 step_result.presentation.step_text = reason | 107 step_result.presentation.step_text = reason |
| 100 step_result.presentation.status = self.m.step.WARNING | 108 step_result.presentation.status = self.m.step.WARNING |
| OLD | NEW |