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 from slave import recipe_api | 5 from slave import recipe_api |
6 | 6 |
7 ISOLATE_SERVER = 'https://isolateserver.appspot.com' | |
iannucci
2014/01/10 23:50:25
theoretically, this (and the test_isolation_mode->
Ken Russell (switch to Gerrit)
2014/01/11 00:35:38
Yes, let's keep this simple for now and refactor i
| |
8 | |
7 class IsolateApi(recipe_api.RecipeApi): | 9 class IsolateApi(recipe_api.RecipeApi): |
8 """APIs for interacting with isolates.""" | 10 """APIs for interacting with isolates.""" |
9 | 11 |
12 def __init__(self, **kwargs): | |
13 super(IsolateApi, self).__init__(**kwargs) | |
14 self._manifest_hashes = {} | |
15 | |
16 def set_isolate_environment(self, config): | |
17 """Modifies the passed Config (which should generally be api.chromium.c) | |
18 to set up the appropriate GYP_DEFINES to upload isolates to the isolate | |
19 server during the build. This must be called early in your recipe; | |
20 definitely before the checkout and runhooks steps.""" | |
21 config.gyp_env.GYP_DEFINES['test_isolation_mode'] = 'hashtable' | |
22 config.gyp_env.GYP_DEFINES['test_isolation_outdir'] = ISOLATE_SERVER | |
23 | |
10 @recipe_api.inject_test_data | 24 @recipe_api.inject_test_data |
11 def manifest_to_hash(self, targets): | 25 def manifest_to_hash(self, targets): |
12 """Returns a step which runs manifest_to_hash.py against the given array | 26 """Returns a step which runs manifest_to_hash.py against the given array |
13 of targets. Assigns the result to the swarm_hashes factory property. | 27 of targets. Assigns the result to the swarm_hashes factory property. |
14 (This implies this step can currently only be run once per recipe.)""" | 28 (This implies this step can currently only be run once per recipe.)""" |
15 def followup_fn(step_result): | 29 def followup_fn(step_result): |
30 self._manifest_hashes = step_result.json.output | |
16 step_result.presentation.properties['swarm_hashes'] = ( | 31 step_result.presentation.properties['swarm_hashes'] = ( |
17 step_result.json.output) | 32 self._manifest_hashes) |
18 return self.m.python( | 33 return self.m.python( |
19 'manifest_to_hash', | 34 'manifest_to_hash', |
20 self.m.path.build('scripts', 'slave', 'swarming', 'manifest_to_hash.py'), | 35 self.m.path.build('scripts', 'slave', 'swarming', 'manifest_to_hash.py'), |
21 ['--target', self.m.chromium.c.build_config_fs, | 36 ['--target', self.m.chromium.c.build_config_fs, |
22 '--output-json', self.m.json.output(), | 37 '--output-json', self.m.json.output(), |
23 ] + targets, | 38 ] + targets, |
24 followup_fn=followup_fn) | 39 followup_fn=followup_fn) |
40 | |
41 @property | |
42 def manifest_hashes(self): | |
43 """Returns the dictionary of hashes that have been produced during this | |
44 run. These come either from the incoming swarm_hashes factory property, | |
45 or from calling manifest_to_hash, above, at some point during the | |
46 run.""" | |
47 return self.m.properties.get('swarm_hashes', self._manifest_hashes) | |
iannucci
2014/01/10 23:50:25
Nice :)
| |
48 | |
49 def run_isolate_test(self, test, args=None, xvfb=False, name=None, | |
50 annotate=None, results_url=None, perf_dashboard_id=None, | |
51 test_type=None, generate_json_file=False, | |
52 results_directory=None, build_number=None, | |
53 builder_name=None, python_mode=False, spawn_dbus=True, | |
54 parallel=False, **kwargs): | |
iannucci
2014/01/10 23:50:25
You probably should let all of these be taken care
Ken Russell (switch to Gerrit)
2014/01/11 00:35:38
Thanks. Fixed this.
| |
55 """Runs a test which has previously been uploaded to the isolate server. | |
56 Expects to find the test 'test' as a key in the manifest_hashes | |
57 dictionary.""" | |
58 isolate_hash = self.manifest_hashes[test] | |
59 | |
60 if not name: | |
61 name = test | |
iannucci
2014/01/10 23:50:25
idiomatically, I tend to prefer:
name = name or
Ken Russell (switch to Gerrit)
2014/01/11 00:35:38
Done.
| |
62 | |
63 # TODO(kbr): will need this later. Comment out for now for code coverage. | |
64 # The step name must end in 'test' or 'tests' in order for the results to | |
65 # automatically show up on the flakiness dashboard. | |
66 # if not (name.endswith('test') or name.endswith('tests')): | |
67 # name = '%s_tests' % name | |
68 | |
69 if not args: | |
70 args = [] | |
iannucci
2014/01/10 23:50:25
If you make args default to an empty tuple `()`, y
Ken Russell (switch to Gerrit)
2014/01/11 00:35:38
Unfortunately, [] + () does not work. Leaving this
| |
71 | |
72 full_args = [ | |
73 '-H', | |
74 isolate_hash, | |
75 '-I', | |
76 ISOLATE_SERVER | |
77 ] + args | |
78 | |
79 return self.m.chromium.runtests( | |
80 self.m.path.checkout('tools', 'swarming_client', 'run_isolated.py'), | |
81 args=full_args, | |
82 name=name, | |
83 xvfb=xvfb, | |
84 annotate=annotate, | |
85 results_url=results_url, | |
86 perf_dashboard_id=perf_dashboard_id, | |
87 test_type=test_type, | |
88 generate_json_file=generate_json_file, | |
89 results_directory=results_directory, | |
90 build_number=build_number, | |
91 builder_name=builder_name, | |
92 python_mode=python_mode, | |
93 spawn_dbus=spawn_dbus, | |
94 parallel=parallel, | |
95 **kwargs) | |
OLD | NEW |