Commit 4210b3d4 authored by Juan Antonio Navarro Perez's avatar Juan Antonio Navarro Perez Committed by Commit Bot

[tools/perf] Start creating flakiness_cli

This first version just adds an entry point for the script, and simple
api calls to test-results server to retrieve the json data.

Bug: 875251
Change-Id: I14de8275e1e9ffe28935d5e172add60011ec5b62
Reviewed-on: https://chromium-review.googlesource.com/1179837
Commit-Queue: Juan Antonio Navarro Pérez <perezju@chromium.org>
Reviewed-by: default avatarNed Nguyen <nednguyen@google.com>
Cr-Commit-Position: refs/heads/master@{#584784}
parent 7834ffb0
#!/usr/bin/env python
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""This tool provides a command line interface for the flakiness dashboard."""
import argparse
import sys
from test_results import api
def main():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='action')
subparsers.required = True
subparser = subparsers.add_parser('builders')
subparser = subparsers.add_parser('results')
subparser.add_argument('master')
subparser.add_argument('builder')
subparser.add_argument('test_type')
args = parser.parse_args()
if args.action == 'builders':
print api.GetBuilders()
elif args.action == 'results':
print api.GetTestResults(args.master, args.builder, args.test_type)
else:
raise NotImplementedError(args.action)
if __name__ == '__main__':
sys.exit(main())
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import json
import urllib
import urllib2
TEST_RESULTS_SERVER = 'http://test-results.appspot.com'
TOOL_USER_AGENT = 'flakiness_cli/0.1'
def _Request(path, params=None):
"""Request json data from the test results server."""
url = TEST_RESULTS_SERVER + path
if params:
url += '?' + urllib.urlencode(params)
request = urllib2.Request(url, headers={'User-Agent': TOOL_USER_AGENT})
response = urllib2.urlopen(request)
return json.load(response)
def GetBuilders():
"""Retrieve json with list of all known masters, builders, and test_types."""
return _Request('/data/builders')
def GetTestResults(master, builder, test_type):
"""Retrieve test results json for a given master, builder, and test_type."""
return _Request('/testfile', {
'name': 'results.json',
'master': master,
'builder': builder,
'testtype': test_type})
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment