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

Side by Side Diff: scripts/slave/swarming/get_swarm_results_shim.py

Issue 22909021: Add build slave side support for the new swarming.py script. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: tested to work Created 7 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 10
11 import optparse 11 import optparse
12 import os 12 import os
13 import sys 13 import sys
14 14
15 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 15 BASE_DIR = os.path.dirname(os.path.abspath(__file__))
16 16
17 from common import chromium_utils 17 from common import chromium_utils
18 from common import find_depot_tools # pylint: disable=W0611 18 from common import find_depot_tools # pylint: disable=W0611
19 from common import gtest_utils 19 from common import gtest_utils
20 20
21 from slave.swarming import swarming_utils 21 from slave.swarming import swarming_utils
22 22
23 # From depot_tools/ 23 # From depot_tools/
24 import fix_encoding 24 import fix_encoding
25 import subprocess2
25 26
26 27
27 NO_OUTPUT_FOUND = ( 28 NO_OUTPUT_FOUND = (
28 'No output produced by the test, it may have failed to run.\n' 29 'No output produced by the test, it may have failed to run.\n'
29 'Showing all the output, including swarm specific output.\n' 30 'Showing all the output, including swarm specific output.\n'
30 '\n') 31 '\n')
31 32
32 33
33 def gen_shard_output(result, gtest_parser): 34 def gen_shard_output(result, gtest_parser):
34 """Returns output for swarm shard.""" 35 """Returns output for swarm shard."""
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 exit_code = max(exit_code, test_exit_code) 121 exit_code = max(exit_code, test_exit_code)
121 122
122 output, exit_code = gen_summary_output( 123 output, exit_code = gen_summary_output(
123 gtest_parser.FailedTests(), 124 gtest_parser.FailedTests(),
124 exit_code, 125 exit_code,
125 shards_remaining) 126 shards_remaining)
126 print output 127 print output
127 return exit_code 128 return exit_code
128 129
129 130
131 def v0_1(client, options, test_name):
132 """Code starting around r218375.
133
134 TODO(maruel): Put exact revision once committed.
135 """
136 swarming = os.path.join(client, 'swarming.py')
137 cmd = [
138 sys.executable,
139 swarming,
140 'collect',
141 '--swarming', options.swarming,
142 '--decorate',
143 test_name,
144 ]
145 print('Running: %s' % ' '.join(cmd))
146 proc = subprocess2.Popen(cmd, bufsize=0, stdout=subprocess2.PIPE)
147 gtest_parser = gtest_utils.GTestLogParser()
148 for line in proc.stdout.readlines():
149 line = line.rstrip()
150 print line
151 gtest_parser.ProcessLine(line)
152
153 proc.wait()
154 output, exit_code = gen_summary_output(
155 gtest_parser.FailedTests(),
156 proc.returncode,
157 0)
158 print output
159 return exit_code
160
161
130 def determine_version_and_run_handler(client, options, test_name): 162 def determine_version_and_run_handler(client, options, test_name):
131 """Executes the proper handler based on the code layout and --version 163 """Executes the proper handler based on the code layout and --version
132 support. 164 support.
133 """ 165 """
134 # TODO(maruel): Determine version when needed. 166 if os.path.isfile(os.path.join(client, 'swarm_get_results.py')):
135 return v0(client, options, test_name) 167 # Oh, that's old.
168 return v0(client, options, test_name)
169 return v0_1(client, options, test_name)
136 170
137 171
138 def process_build_properties(options, name): 172 def process_build_properties(options, name):
139 """Converts build properties and factory properties into expected flags.""" 173 """Converts build properties and factory properties into expected flags."""
140 taskname = '%s-%s-%s' % ( 174 taskname = '%s-%s-%s' % (
141 options.build_properties.get('buildername'), 175 options.build_properties.get('buildername'),
142 options.build_properties.get('buildnumber'), 176 options.build_properties.get('buildnumber'),
143 name, 177 name,
144 ) 178 )
145 return taskname 179 return taskname
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 # Loads the other flags implicitly. 211 # Loads the other flags implicitly.
178 task_name = process_build_properties(options, args[0]) 212 task_name = process_build_properties(options, args[0])
179 else: 213 else:
180 task_name = args[0] 214 task_name = args[0]
181 return determine_version_and_run_handler(client, options, task_name) 215 return determine_version_and_run_handler(client, options, task_name)
182 216
183 217
184 if __name__ == '__main__': 218 if __name__ == '__main__':
185 fix_encoding.fix_encoding() 219 fix_encoding.fix_encoding()
186 sys.exit(main()) 220 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/swarming/swarming_utils.py » ('j') | scripts/slave/swarming/swarming_utils.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698