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

Side by Side Diff: scripts/slave/get_swarm_results.py

Issue 23176003: Create proper wrapper scripts to decouple from swarm_client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: rework Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Takes in a test name and retrives all the output that the swarm server 6 """Takes in a test name and retrives all the output that the swarm server
7 has produced for tests with that name. This is expected to be called as a 7 has produced for tests with that name. This is expected to be called as a
8 build step.""" 8 build step."""
9 9
10 import os 10 import os
11 import sys 11 import sys
12 12
13 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 13 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
14 14
15 from common import find_depot_tools # pylint: disable=W0611 15 from common import find_depot_tools # pylint: disable=W0611
16 from common import gtest_utils 16 from common import gtest_utils
17 from slave import trigger_swarm
17 18
18 # From depot tools/ 19 # From depot tools/
19 import fix_encoding 20 import fix_encoding
20 21
21 22
22 NO_OUTPUT_FOUND = ( 23 NO_OUTPUT_FOUND = (
23 'No output produced by the test, it may have failed to run.\n' 24 'No output produced by the test, it may have failed to run.\n'
24 'Showing all the output, including swarm specific output.\n' 25 'Showing all the output, including swarm specific output.\n'
25 '\n') 26 '\n')
26 27
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 97
97 output, exit_code = gen_summary_output( 98 output, exit_code = gen_summary_output(
98 gtest_parser.FailedTests(), 99 gtest_parser.FailedTests(),
99 exit_code, 100 exit_code,
100 shards_remaining) 101 shards_remaining)
101 print output 102 print output
102 return exit_code 103 return exit_code
103 104
104 105
105 def main(): 106 def main():
106 src_swarming_client = os.path.join( 107 client = trigger_swarm.find_swarming_client()
107 os.getcwd(), 'src', 'tools', 'swarming_client') 108 if not client:
108 109 print >> sys.stderr, 'Failed to find swarm(ing)_client'
109 # This is the previous path. This can be removed around 2013-12-01.
110 src_swarm_client = os.path.join(os.getcwd(), 'src', 'tools', 'swarm_client')
111
112 if os.path.isdir(src_swarming_client):
113 sys.path.insert(0, src_swarming_client)
114 elif os.path.isdir(src_swarm_client):
115 sys.path.insert(0, src_swarm_client)
116 else:
117 print >> sys.stderr, 'Failed to find swarm_client at %s or %s' % (
118 src_swarming_client, src_swarm_client)
119 return 1 110 return 1
120 111
112 # TODO(maruel): Do not import, reproduce the same flags and forward to a
113 # subprocess.call() instead.
114 sys.path.insert(0, client)
121 import swarm_get_results # pylint: disable=F0401 115 import swarm_get_results # pylint: disable=F0401
122 116
123 parser, options, test_name = swarm_get_results.parse_args() 117 parser, options, test_name = swarm_get_results.parse_args()
124 if not options.shards: 118 if not options.shards:
125 parser.error('The number of shards expected must be passed in.') 119 parser.error('The number of shards expected must be passed in.')
126 test_keys = swarm_get_results.get_test_keys( 120 test_keys = swarm_get_results.get_test_keys(
127 options.url, test_name, options.timeout) 121 options.url, test_name, options.timeout)
128 if not test_keys: 122 if not test_keys:
129 parser.error('No test keys to get results with.') 123 parser.error('No test keys to get results with.')
130 124
131 options.shards = int(options.shards) 125 options.shards = int(options.shards)
132 if options.shards == -1: 126 if options.shards == -1:
133 options.shards = len(test_keys) 127 options.shards = len(test_keys)
134 elif len(test_keys) < options.shards: 128 elif len(test_keys) < options.shards:
135 print >> sys.stderr, ('Warning: Test should have %d shards, but only %d ' 129 print >> sys.stderr, ('Warning: Test should have %d shards, but only %d '
136 'test keys were found' % (options.shards, 130 'test keys were found' % (options.shards,
137 len(test_keys))) 131 len(test_keys)))
138 132
139 return GetSwarmResults( 133 return GetSwarmResults(
140 swarm_get_results, options.url, test_keys, options.timeout, None) 134 swarm_get_results, options.url, test_keys, options.timeout, None)
141 135
142 136
143 if __name__ == '__main__': 137 if __name__ == '__main__':
144 fix_encoding.fix_encoding() 138 fix_encoding.fix_encoding()
145 sys.exit(main()) 139 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698