Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 """Provides the web interface for a report on benchmark alert health.""" | |
| 6 | |
| 7 import datetime | |
| 8 import json | |
| 9 | |
| 10 from dashboard import alerts | |
| 11 from dashboard import list_tests | |
| 12 from dashboard import update_test_suites | |
| 13 from dashboard.common import request_handler | |
| 14 from dashboard.common import utils | |
| 15 from dashboard.models import anomaly | |
| 16 | |
| 17 | |
| 18 class BenchmarkHealthReportHandler(request_handler.RequestHandler): | |
| 19 | |
| 20 def get(self): | |
| 21 """Renders the UI for the group report page.""" | |
| 22 self.RenderStaticHtml('benchmark_health_report.html') | |
| 23 | |
| 24 def post(self): | |
| 25 """Returns data about the alerts for a benchmark. | |
| 26 | |
| 27 Request parameters: | |
| 28 master: If specified, the master to list benchmarks for. If no arguments | |
| 29 are specified, benchmarks will be listed for chromium.perf. | |
| 30 benchmark: If specified, the name of the benchmark to gather details for. | |
| 31 num_days: With benchmark, number of days to get data for. | |
|
eakuefner
2017/02/17 19:11:05
It looks like this is true based on the code below
| |
| 32 bug: If specified, the id of the bug to gather details for. | |
| 33 | |
| 34 Outputs: | |
| 35 JSON for the /group_report page XHR request. | |
| 36 """ | |
| 37 master = self.request.get('master') | |
| 38 benchmark = self.request.get('benchmark') | |
| 39 response_values = {} | |
| 40 | |
| 41 if benchmark: | |
| 42 num_days = int(self.request.get('num_days')) | |
| 43 response_values = self._GetResponseValuesForBenchmark( | |
| 44 benchmark, num_days, master) | |
| 45 else: | |
| 46 response_values = self._GetResponseValuesForMaster(master) | |
| 47 | |
| 48 self.response.out.write(json.dumps(response_values)) | |
| 49 | |
| 50 def _GetResponseValuesForBenchmark(self, benchmark, num_days, master): | |
| 51 values = {} | |
| 52 | |
| 53 # The cached test suite info contains info about monitoring and bots. | |
| 54 benchmarks = update_test_suites.FetchCachedTestSuites() | |
| 55 sheriff = self._GetSheriffForBenchmark(benchmark, master, benchmarks) | |
| 56 if sheriff: | |
| 57 query = anomaly.Anomaly.query(anomaly.Anomaly.sheriff == sheriff) | |
| 58 query = query.filter(anomaly.Anomaly.is_improvement == False) | |
|
eakuefner
2017/02/17 19:11:06
Jessi is trying to do similar stuff in speed relea
sullivan
2017/02/17 20:01:02
A couple of things wrapped up in here:
* We want t
eakuefner
2017/02/17 20:13:48
There's a doc with some notes here https://docs.go
| |
| 59 query = query.filter( | |
| 60 anomaly.Anomaly.timestamp > | |
| 61 datetime.datetime.now() - datetime.timedelta(days=num_days)) | |
| 62 query = query.order(-anomaly.Anomaly.timestamp) | |
| 63 anomalies = query.fetch() | |
| 64 anomalies = [a for a in anomalies if self._BenchmarkName(a) == benchmark] | |
| 65 values['monitored'] = True | |
| 66 values['alerts'] = alerts.AnomalyDicts(anomalies) | |
| 67 else: | |
| 68 values['monitored'] = False | |
| 69 | |
| 70 values['bots'] = benchmarks[benchmark]['mas'][master].keys() | |
| 71 return values | |
| 72 | |
| 73 def _GetSheriffForBenchmark(self, benchmark, master, benchmarks): | |
| 74 # TODO(sullivan): There can be multiple sheriffs; implement this. | |
| 75 if not benchmarks[benchmark]['mon']: | |
| 76 return None | |
| 77 monitored_test_path = benchmarks[benchmark]['mon'][0] | |
| 78 pattern = '%s/*/%s/%s' % (master, benchmark, monitored_test_path) | |
| 79 monitored_tests = list_tests.GetTestsMatchingPattern( | |
| 80 pattern, list_entities=True) | |
| 81 return monitored_tests[0].sheriff | |
| 82 | |
| 83 def _BenchmarkName(self, alert): | |
| 84 return utils.TestPath(alert.test).split('/')[2] | |
| 85 | |
| 86 def _GetResponseValuesForMaster(self, master): | |
| 87 benchmarks = update_test_suites.FetchCachedTestSuites() | |
| 88 benchmarks = [b for b in benchmarks if master in benchmarks[b]['mas']] | |
| 89 return {'benchmarks': sorted(benchmarks)} | |
| OLD | NEW |