Chromium Code Reviews| Index: scripts/slave/swarming/get_swarm_results.py |
| diff --git a/scripts/slave/swarming/get_swarm_results.py b/scripts/slave/swarming/get_swarm_results.py |
| index a9886ee26479e278be97ee3fd40fde8d4913fa76..57eb7e7f324be5a72967e4063d35703df658ea9c 100755 |
| --- a/scripts/slave/swarming/get_swarm_results.py |
| +++ b/scripts/slave/swarming/get_swarm_results.py |
| @@ -5,8 +5,10 @@ |
| """Takes in a test name and retrives all the output that the swarm server |
| has produced for tests with that name. This is expected to be called as a |
| -build step.""" |
| +build step. |
| +""" |
| +import optparse |
| import os |
| import sys |
| @@ -78,14 +80,31 @@ def gen_summary_output(failed_tests, exit_code, shards_remaining): |
| return out, exit_code |
| -def GetSwarmResults( |
| - swarm_get_results, swarm_base_url, test_keys, timeout, max_threads): |
| +def v0(client, options, test_name): |
|
Isaac (away)
2013/08/20 22:22:33
v0? Can you add a comment for what this does?
M-A Ruel
2013/08/23 02:18:33
There will be multiple version handler, this is wh
|
| + sys.path.insert(0, client) |
|
Isaac (away)
2013/08/20 22:22:33
This will repeatedly extend sys.path with each cal
M-A Ruel
2013/08/23 02:18:33
This function is only called once indirectly by ma
Isaac (away)
2013/08/26 02:35:46
I mean, can you verify that if you change swarm_ge
M-A Ruel
2013/08/26 14:15:39
My next CL is to delete swarm_get_results; https:/
|
| + import swarm_get_results # pylint: disable=F0401 |
| + |
| + timeout = swarm_get_results.DEFAULT_SHARD_WAIT_TIME |
| + test_keys = swarm_get_results.get_test_keys( |
| + options.swarming, test_name, timeout) |
| + if not test_keys: |
| + print >> sys.stderr, 'No test keys to get results with.' |
| + return 1 |
| + |
| + options.shards = int(options.shards) |
|
Isaac (away)
2013/08/20 22:22:33
not needed if you add type='int' to parser below.
M-A Ruel
2013/08/23 02:18:33
Done.
|
| + if options.shards == -1: |
| + options.shards = len(test_keys) |
| + elif len(test_keys) < options.shards: |
| + print >> sys.stderr, ('Warning: Test should have %d shards, but only %d ' |
| + 'test keys were found' % (options.shards, |
| + len(test_keys))) |
| + |
| gtest_parser = gtest_utils.GTestLogParser() |
| exit_code = None |
| shards_remaining = range(len(test_keys)) |
| first_result = True |
| for index, result in swarm_get_results.yield_results( |
| - swarm_base_url, test_keys, timeout, max_threads): |
| + options.swarming, test_keys, timeout, None): |
| assert index == result['config_instance_index'] |
| if first_result and result['num_config_instances'] != len(test_keys): |
| # There are more test_keys than actual shards. |
| @@ -104,35 +123,41 @@ def GetSwarmResults( |
| return exit_code |
| +def determine_version_and_run_handler(client, options, test_name): |
| + """Executes the proper handler based on the code layout and --version |
| + support. |
| + """ |
| + # TODO(maruel): Determine version when needed. |
| + return v0(client, options, test_name) |
| + |
| + |
| def main(): |
| + """Note: this is solely to run the current master's code and can totally |
| + differ from the underlying script flags. |
| + |
| + To update these flags: |
| + - Update the following code to support both the previous flag and the new |
| + flag. |
| + - Change scripts/master/factory/swarm_commands.py to pass the new flag. |
| + - Restart all the masters using swarming. |
| + - Remove the old flag from this code. |
| + """ |
| client = swarming_utils.find_client(os.getcwd()) |
| if not client: |
| print >> sys.stderr, 'Failed to find swarm(ing)_client' |
| return 1 |
| - # TODO(maruel): Do not import, reproduce the same flags and forward to a |
| - # subprocess.call() instead. |
| - sys.path.insert(0, client) |
| - import swarm_get_results # pylint: disable=F0401 |
| - |
| - parser, options, test_name = swarm_get_results.parse_args() |
| - if not options.shards: |
| - parser.error('The number of shards expected must be passed in.') |
| - test_keys = swarm_get_results.get_test_keys( |
| - options.url, test_name, options.timeout) |
| - if not test_keys: |
| - parser.error('No test keys to get results with.') |
| - |
| - options.shards = int(options.shards) |
| - if options.shards == -1: |
| - options.shards = len(test_keys) |
| - elif len(test_keys) < options.shards: |
| - print >> sys.stderr, ('Warning: Test should have %d shards, but only %d ' |
| - 'test keys were found' % (options.shards, |
| - len(test_keys))) |
| - |
| - return GetSwarmResults( |
| - swarm_get_results, options.url, test_keys, options.timeout, None) |
| + parser = optparse.OptionParser() |
| + parser.add_option('-u', '--swarming', help='Swarm server') |
| + parser.add_option('-s', '--shards', help='Number of shards') |
|
Isaac (away)
2013/08/20 22:22:33
type='int'?
M-A Ruel
2013/08/23 02:18:33
Done.
|
| + (options, args) = parser.parse_args() |
| + if not args: |
| + parser.error('Must specify one test name.') |
| + elif len(args) > 1: |
| + parser.error('Must specify only one test name.') |
| + options.swarming = options.swarming.rstrip('/') |
| + |
| + return determine_version_and_run_handler(client, options, args[0]) |
| if __name__ == '__main__': |