OLD | NEW |
1 # Copyright (C) 2012 Google Inc. All rights reserved. | 1 # Copyright (C) 2012 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 paths = [] | 146 paths = [] |
147 for arg in self._args: | 147 for arg in self._args: |
148 if filesystem.exists(filesystem.join(self._base_path, arg)): | 148 if filesystem.exists(filesystem.join(self._base_path, arg)): |
149 paths.append(arg) | 149 paths.append(arg) |
150 else: | 150 else: |
151 relpath = filesystem.relpath(arg, self._base_path) | 151 relpath = filesystem.relpath(arg, self._base_path) |
152 if filesystem.exists(filesystem.join(self._base_path, relpath)): | 152 if filesystem.exists(filesystem.join(self._base_path, relpath)): |
153 paths.append(filesystem.normpath(relpath)) | 153 paths.append(filesystem.normpath(relpath)) |
154 else: | 154 else: |
155 _log.warn('Path was not found:' + arg) | 155 _log.warning('Path was not found:' + arg) |
156 | 156 |
157 skipped_directories = set(['.svn', 'resources']) | 157 skipped_directories = set(['.svn', 'resources']) |
158 test_files = find_files.find(filesystem, self._base_path, paths, skipped
_directories, _is_test_file) | 158 test_files = find_files.find(filesystem, self._base_path, paths, skipped
_directories, _is_test_file) |
159 tests = [] | 159 tests = [] |
160 for path in test_files: | 160 for path in test_files: |
161 relative_path = filesystem.relpath(path, self._base_path).replace('\
\', '/') | 161 relative_path = filesystem.relpath(path, self._base_path).replace('\
\', '/') |
162 if self._options.use_skipped_list and self._port.skips_perf_test( | 162 if self._options.use_skipped_list and self._port.skips_perf_test( |
163 relative_path) and filesystem.normpath(relative_path) not in
paths: | 163 relative_path) and filesystem.normpath(relative_path) not in
paths: |
164 continue | 164 continue |
165 test = PerfTestFactory.create_perf_test(self._port, relative_path, p
ath, | 165 test = PerfTestFactory.create_perf_test(self._port, relative_path, p
ath, |
(...skipping 25 matching lines...) Expand all Loading... |
191 _log.error("Build not up to date for %s" % self._port._path_to_drive
r()) | 191 _log.error("Build not up to date for %s" % self._port._path_to_drive
r()) |
192 return self.EXIT_CODE_BAD_BUILD | 192 return self.EXIT_CODE_BAD_BUILD |
193 | 193 |
194 run_count = 0 | 194 run_count = 0 |
195 repeat = self._options.repeat | 195 repeat = self._options.repeat |
196 while run_count < repeat: | 196 while run_count < repeat: |
197 run_count += 1 | 197 run_count += 1 |
198 | 198 |
199 tests = self._collect_tests() | 199 tests = self._collect_tests() |
200 runs = ' (Run %d of %d)' % (run_count, repeat) if repeat > 1 else '' | 200 runs = ' (Run %d of %d)' % (run_count, repeat) if repeat > 1 else '' |
201 _log.info("Running %d tests%s" % (len(tests), runs)) | 201 _log.info("Running %d tests%s", len(tests), runs) |
202 | 202 |
203 for test in tests: | 203 for test in tests: |
204 if not test.prepare(self._options.time_out_ms): | 204 if not test.prepare(self._options.time_out_ms): |
205 return self.EXIT_CODE_BAD_PREPARATION | 205 return self.EXIT_CODE_BAD_PREPARATION |
206 | 206 |
207 try: | 207 try: |
208 if needs_http: | 208 if needs_http: |
209 self._start_http_servers() | 209 self._start_http_servers() |
210 unexpected = self._run_tests_set(sorted(list(tests), key=lambda
test: test.test_name())) | 210 unexpected = self._run_tests_set(sorted(list(tests), key=lambda
test: test.test_name())) |
211 | 211 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 tests = current_test['tests'] | 306 tests = current_test['tests'] |
307 | 307 |
308 return contents | 308 return contents |
309 | 309 |
310 @staticmethod | 310 @staticmethod |
311 def _datetime_in_ES5_compatible_iso_format(datetime): | 311 def _datetime_in_ES5_compatible_iso_format(datetime): |
312 return datetime.strftime('%Y-%m-%dT%H:%M:%S.%f') | 312 return datetime.strftime('%Y-%m-%dT%H:%M:%S.%f') |
313 | 313 |
314 def _merge_slave_config_json(self, slave_config_json_path, contents): | 314 def _merge_slave_config_json(self, slave_config_json_path, contents): |
315 if not self._host.filesystem.isfile(slave_config_json_path): | 315 if not self._host.filesystem.isfile(slave_config_json_path): |
316 _log.error("Missing slave configuration JSON file: %s" % slave_confi
g_json_path) | 316 _log.error("Missing slave configuration JSON file: %s", slave_config
_json_path) |
317 return None | 317 return None |
318 | 318 |
319 try: | 319 try: |
320 slave_config_json = self._host.filesystem.open_text_file_for_reading
(slave_config_json_path) | 320 slave_config_json = self._host.filesystem.open_text_file_for_reading
(slave_config_json_path) |
321 slave_config = json.load(slave_config_json) | 321 slave_config = json.load(slave_config_json) |
322 for key in slave_config: | 322 for key in slave_config: |
323 contents['builder' + key.capitalize()] = slave_config[key] | 323 contents['builder' + key.capitalize()] = slave_config[key] |
324 return contents | 324 return contents |
325 except Exception as error: | 325 except Exception as error: |
326 _log.error("Failed to merge slave configuration JSON file %s: %s" %
(slave_config_json_path, error)) | 326 _log.error("Failed to merge slave configuration JSON file %s: %s", s
lave_config_json_path, error) |
327 return None | 327 return None |
328 | 328 |
329 def _merge_outputs_if_needed(self, output_json_path, output): | 329 def _merge_outputs_if_needed(self, output_json_path, output): |
330 if self._options.reset_results or not self._host.filesystem.isfile(outpu
t_json_path): | 330 if self._options.reset_results or not self._host.filesystem.isfile(outpu
t_json_path): |
331 return [output] | 331 return [output] |
332 try: | 332 try: |
333 existing_outputs = json.loads(self._host.filesystem.read_text_file(o
utput_json_path)) | 333 existing_outputs = json.loads(self._host.filesystem.read_text_file(o
utput_json_path)) |
334 return existing_outputs + [output] | 334 return existing_outputs + [output] |
335 except Exception as error: | 335 except Exception as error: |
336 _log.error("Failed to merge output JSON file %s: %s" % (output_json_
path, error)) | 336 _log.error("Failed to merge output JSON file %s: %s", output_json_pa
th, error) |
337 return None | 337 return None |
338 | 338 |
339 def _upload_json(self, test_results_server, json_path, host_path="/api/repor
t", file_uploader=FileUploader): | 339 def _upload_json(self, test_results_server, json_path, host_path="/api/repor
t", file_uploader=FileUploader): |
340 url = "https://%s%s" % (test_results_server, host_path) | 340 url = "https://%s%s" % (test_results_server, host_path) |
341 uploader = file_uploader(url, 120) | 341 uploader = file_uploader(url, 120) |
342 try: | 342 try: |
343 response = uploader.upload_single_text_file(self._host.filesystem, '
application/json', json_path) | 343 response = uploader.upload_single_text_file(self._host.filesystem, '
application/json', json_path) |
344 except Exception as error: | 344 except Exception as error: |
345 _log.error("Failed to upload JSON file to %s in 120s: %s" % (url, er
ror)) | 345 _log.error("Failed to upload JSON file to %s in 120s: %s", url, erro
r) |
346 return False | 346 return False |
347 | 347 |
348 response_body = [line.strip('\n') for line in response] | 348 response_body = [line.strip('\n') for line in response] |
349 if response_body != ['OK']: | 349 if response_body != ['OK']: |
350 try: | 350 try: |
351 parsed_response = json.loads('\n'.join(response_body)) | 351 parsed_response = json.loads('\n'.join(response_body)) |
352 except: | 352 except: |
353 _log.error("Uploaded JSON to %s but got a bad response:" % url) | 353 _log.error("Uploaded JSON to %s but got a bad response:", url) |
354 for line in response_body: | 354 for line in response_body: |
355 _log.error(line) | 355 _log.error(line) |
356 return False | 356 return False |
357 if parsed_response.get('status') != 'OK': | 357 if parsed_response.get('status') != 'OK': |
358 _log.error("Uploaded JSON to %s but got an error:" % url) | 358 _log.error("Uploaded JSON to %s but got an error:", url) |
359 _log.error(json.dumps(parsed_response, indent=4)) | 359 _log.error(json.dumps(parsed_response, indent=4)) |
360 return False | 360 return False |
361 | 361 |
362 _log.info("JSON file uploaded to %s." % url) | 362 _log.info("JSON file uploaded to %s.", url) |
363 return True | 363 return True |
364 | 364 |
365 def _run_tests_set(self, tests): | 365 def _run_tests_set(self, tests): |
366 failures = 0 | 366 failures = 0 |
367 self._results = [] | 367 self._results = [] |
368 | 368 |
369 for i, test in enumerate(tests): | 369 for i, test in enumerate(tests): |
370 _log.info('Running %s (%d of %d)' % (test.test_name(), i + 1, len(te
sts))) | 370 _log.info('Running %s (%d of %d)', test.test_name(), i + 1, len(test
s)) |
371 start_time = time.time() | 371 start_time = time.time() |
372 metrics = test.run(self._options.time_out_ms) | 372 metrics = test.run(self._options.time_out_ms) |
373 if metrics: | 373 if metrics: |
374 self._results.append((test, metrics)) | 374 self._results.append((test, metrics)) |
375 else: | 375 else: |
376 failures += 1 | 376 failures += 1 |
377 _log.error('FAILED') | 377 _log.error('FAILED') |
378 | 378 |
379 _log.info('Finished: %f s' % (time.time() - start_time)) | 379 _log.info('Finished: %f s', time.time() - start_time) |
380 _log.info('') | 380 _log.info('') |
381 | 381 |
382 return failures | 382 return failures |
OLD | NEW |