Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: testing/scripts/run_telemetry_benchmark_as_googletest.py

Issue 2290373002: Adding perf test isolate and gn build target for swarming the benchmarks. (Closed)
Patch Set: Review comments addressed Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « testing/buildbot/manage.py ('k') | tools/mb/mb_config.pyl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Runs an isolate bundled Telemetry benchmark. 6 """Runs an isolate bundled Telemetry benchmark.
7 7
8 This script attempts to emulate the contract of gtest-style tests 8 This script attempts to emulate the contract of gtest-style tests
9 invoked via recipes. The main contract is that the caller passes the 9 invoked via recipes. The main contract is that the caller passes the
10 argument: 10 argument:
11 11
12 --isolated-script-test-output=[FILENAME] 12 --isolated-script-test-output=[FILENAME]
13 13
14 json is written to that file in the format produced by 14 json is written to that file in the format produced by
15 common.parse_common_test_results. 15 common.parse_common_test_results.
16 16
17 This script is intended to be the base command invoked by the isolate, 17 This script is intended to be the base command invoked by the isolate,
18 followed by a subsequent Python script. It could be generalized to 18 followed by a subsequent Python script. It could be generalized to
19 invoke an arbitrary executable. 19 invoke an arbitrary executable.
20 """ 20 """
21 21 import logging
22 import argparse 22 import argparse
23 import json 23 import json
24 import os 24 import os
25 import shutil 25 import shutil
26 import sys 26 import sys
27 import tempfile 27 import tempfile
28 import traceback 28 import traceback
29 29
30 import common 30 import common
31 31
32 # Add src/testing/ into sys.path for importing xvfb. 32 # Add src/testing/ into sys.path for importing xvfb.
33 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 33 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
34 import xvfb 34 import xvfb
35 35
36 # Unfortunately we need to copy these variables from ../test_env.py. 36 # Unfortunately we need to copy these variables from ../test_env.py.
37 # Importing it and using its get_sandbox_env breaks test runs on Linux 37 # Importing it and using its get_sandbox_env breaks test runs on Linux
38 # (it seems to unset DISPLAY). 38 # (it seems to unset DISPLAY).
39 CHROME_SANDBOX_ENV = 'CHROME_DEVEL_SANDBOX' 39 CHROME_SANDBOX_ENV = 'CHROME_DEVEL_SANDBOX'
40 CHROME_SANDBOX_PATH = '/opt/chromium/chrome_sandbox' 40 CHROME_SANDBOX_PATH = '/opt/chromium/chrome_sandbox'
41 41
42 def main(): 42 def main():
43 logging.info("1: IN THE SCRIPT")
dtu 2016/09/01 05:18:38 Are these intentional?
eyaich1 2016/09/01 14:19:35 lol definitely not. this file sholdn't be include
43 parser = argparse.ArgumentParser() 44 parser = argparse.ArgumentParser()
44 parser.add_argument( 45 parser.add_argument(
45 '--isolated-script-test-output', type=argparse.FileType('w'), 46 '--isolated-script-test-output', type=argparse.FileType('w'),
46 required=True) 47 required=True)
47 parser.add_argument('--xvfb', help='Start xvfb.', action='store_true') 48 parser.add_argument('--xvfb', help='Start xvfb.', action='store_true')
48 args, rest_args = parser.parse_known_args() 49 args, rest_args = parser.parse_known_args()
50 logging.info("2: PARSED ARGS")
49 xvfb_proc = None 51 xvfb_proc = None
50 openbox_proc = None 52 openbox_proc = None
51 xcompmgr_proc = None 53 xcompmgr_proc = None
52 env = os.environ.copy() 54 env = os.environ.copy()
53 # Assume we want to set up the sandbox environment variables all the 55 # Assume we want to set up the sandbox environment variables all the
54 # time; doing so is harmless on non-Linux platforms and is needed 56 # time; doing so is harmless on non-Linux platforms and is needed
55 # all the time on Linux. 57 # all the time on Linux.
56 env[CHROME_SANDBOX_ENV] = CHROME_SANDBOX_PATH 58 env[CHROME_SANDBOX_ENV] = CHROME_SANDBOX_PATH
57 if args.xvfb and xvfb.should_start_xvfb(env): 59 if args.xvfb and xvfb.should_start_xvfb(env):
58 xvfb_proc, openbox_proc, xcompmgr_proc = xvfb.start_xvfb(env=env, 60 xvfb_proc, openbox_proc, xcompmgr_proc = xvfb.start_xvfb(env=env,
59 build_dir='.') 61 build_dir='.')
60 assert xvfb_proc and openbox_proc and xcompmgr_proc, 'Failed to start xvfb' 62 assert xvfb_proc and openbox_proc and xcompmgr_proc, 'Failed to start xvfb'
63 logging.info("3: ABOUT TO TRY")
61 try: 64 try:
62 tempfile_dir = tempfile.mkdtemp('telemetry') 65 tempfile_dir = tempfile.mkdtemp('telemetry')
63 valid = True 66 valid = True
64 failures = [] 67 failures = []
65 try: 68 try:
69 logging.info("4: TRY AGAIN")
66 rc = common.run_command([sys.executable] + rest_args + [ 70 rc = common.run_command([sys.executable] + rest_args + [
67 '--output-dir', tempfile_dir, 71 '--output-dir', tempfile_dir,
68 '--output-format=json' 72 '--output-format=json'
69 ], env=env) 73 ], env=env)
74 logging.info("5: AFTER COMMAND")
70 tempfile_name = os.path.join(tempfile_dir, 'results.json') 75 tempfile_name = os.path.join(tempfile_dir, 'results.json')
71 with open(tempfile_name) as f: 76 with open(tempfile_name) as f:
72 results = json.load(f) 77 results = json.load(f)
78 logging.info("6: ABOUT TO WRITE RESULTS")
73 for value in results['per_page_values']: 79 for value in results['per_page_values']:
74 if value['type'] == 'failure': 80 if value['type'] == 'failure':
75 failures.append(results['pages'][str(value['page_id'])]['name']) 81 failures.append(results['pages'][str(value['page_id'])]['name'])
76 valid = bool(rc == 0 or failures) 82 valid = bool(rc == 0 or failures)
77 except Exception: 83 except Exception:
78 traceback.print_exc() 84 traceback.print_exc()
79 valid = False 85 valid = False
80 finally: 86 finally:
81 shutil.rmtree(tempfile_dir) 87 shutil.rmtree(tempfile_dir)
82 88
83 if not valid and not failures: 89 if not valid and not failures:
84 failures = ['(entire test suite)'] 90 failures = ['(entire test suite)']
85 if rc == 0: 91 if rc == 0:
86 rc = 1 # Signal an abnormal exit. 92 rc = 1 # Signal an abnormal exit.
87 93
94 logging.info("7: ABOUT TO DUMP")
88 json.dump({ 95 json.dump({
89 'valid': valid, 96 'valid': valid,
90 'failures': failures, 97 'failures': failures,
91 }, args.isolated_script_test_output) 98 }, args.isolated_script_test_output)
92 return rc 99 return rc
93 100
94 finally: 101 finally:
95 xvfb.kill(xvfb_proc) 102 xvfb.kill(xvfb_proc)
96 xvfb.kill(openbox_proc) 103 xvfb.kill(openbox_proc)
97 xvfb.kill(xcompmgr_proc) 104 xvfb.kill(xcompmgr_proc)
98 105
99 106
100 # This is not really a "script test" so does not need to manually add 107 # This is not really a "script test" so does not need to manually add
101 # any additional compile targets. 108 # any additional compile targets.
102 def main_compile_targets(args): 109 def main_compile_targets(args):
103 json.dump([], args.output) 110 json.dump([], args.output)
104 111
105 112
106 if __name__ == '__main__': 113 if __name__ == '__main__':
107 # Conform minimally to the protocol defined by ScriptTest. 114 # Conform minimally to the protocol defined by ScriptTest.
108 if 'compile_targets' in sys.argv: 115 if 'compile_targets' in sys.argv:
109 funcs = { 116 funcs = {
110 'run': None, 117 'run': None,
111 'compile_targets': main_compile_targets, 118 'compile_targets': main_compile_targets,
112 } 119 }
113 sys.exit(common.run_script(sys.argv[1:], funcs)) 120 sys.exit(common.run_script(sys.argv[1:], funcs))
114 sys.exit(main()) 121 sys.exit(main())
OLDNEW
« no previous file with comments | « testing/buildbot/manage.py ('k') | tools/mb/mb_config.pyl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698