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

Side by Side Diff: build/android/test_runner.py

Issue 2695963003: Use logdog butler subcommand to run tests. (Closed)
Patch Set: fixes Created 3 years, 10 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Runs all types of tests from one unified interface.""" 7 """Runs all types of tests from one unified interface."""
8 8
9 import argparse 9 import argparse
10 import collections 10 import collections
11 import contextlib 11 import contextlib
12 import itertools 12 import itertools
13 import logging 13 import logging
14 import os 14 import os
15 import signal 15 import signal
16 import subprocess
16 import sys 17 import sys
17 import threading 18 import threading
18 import traceback 19 import traceback
19 import unittest 20 import unittest
20 21
21 import devil_chromium 22 import devil_chromium
22 from devil import base_error 23 from devil import base_error
23 from devil.android import device_blacklist 24 from devil.android import device_blacklist
24 from devil.android import device_errors 25 from devil.android import device_errors
25 from devil.android import device_utils 26 from devil.android import device_utils
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 'should be used.')) 109 'should be used.'))
109 group.add_argument('--json-results-file', '--test-launcher-summary-output', 110 group.add_argument('--json-results-file', '--test-launcher-summary-output',
110 dest='json_results_file', type=os.path.realpath, 111 dest='json_results_file', type=os.path.realpath,
111 help='If set, will dump results in JSON form ' 112 help='If set, will dump results in JSON form '
112 'to specified file.') 113 'to specified file.')
113 group.add_argument('--trace-output', metavar='FILENAME', 114 group.add_argument('--trace-output', metavar='FILENAME',
114 type=os.path.realpath, 115 type=os.path.realpath,
115 help='Path to save test_runner trace data to. This option ' 116 help='Path to save test_runner trace data to. This option '
116 'has been implemented for gtest, instrumentation ' 117 'has been implemented for gtest, instrumentation '
117 'test and perf test.') 118 'test and perf test.')
119 group.add_argument('--upload-full-logcat',
120 dest='upload_full_logcat',
121 help=('The logcat file to upload to logdog.'))
118 122
119 logcat_output_group = group.add_mutually_exclusive_group() 123 logcat_output_group = group.add_mutually_exclusive_group()
120 logcat_output_group.add_argument( 124 logcat_output_group.add_argument(
121 '--logcat-output-dir', type=os.path.realpath, 125 '--logcat-output-dir', type=os.path.realpath,
122 help='If set, will dump logcats recorded during test run to directory. ' 126 help='If set, will dump logcats recorded during test run to directory. '
123 'File names will be the device ids with timestamps.') 127 'File names will be the device ids with timestamps.')
124 logcat_output_group.add_argument( 128 logcat_output_group.add_argument(
125 '--logcat-output-file', type=os.path.realpath, 129 '--logcat-output-file', type=os.path.realpath,
126 help='If set, will merge logcats recorded during test run and dump them ' 130 help='If set, will merge logcats recorded during test run and dump them '
127 'to the specified file.') 131 'to the specified file.')
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 test_name, 771 test_name,
768 ', '.join('%s %s' % (str(result_counts[test_name][i]), i) 772 ', '.join('%s %s' % (str(result_counts[test_name][i]), i)
769 for i in base_test_result.ResultType.GetTypes())) 773 for i in base_test_result.ResultType.GetTypes()))
770 else: 774 else:
771 all_pass += 1 775 all_pass += 1
772 776
773 logging.critical('%s of %s tests passed in all %s runs', 777 logging.critical('%s of %s tests passed in all %s runs',
774 str(all_pass), 778 str(all_pass),
775 str(tot_tests), 779 str(tot_tests),
776 str(iteration_count)) 780 str(iteration_count))
781 if args.upload_full_logcat:
782 swarming_task_id = os.environ['SWARMING_TASK_ID']
dnj 2017/02/18 07:59:25 This is being bootstrapped through Butler, right?
BigBossZhiling 2017/02/21 20:24:17 Done.
783 project = 'chromium'
784 output = 'logdog,host=services-dot-luci-logdog.appspot.com'
785 prefix = 'android/swarming/logcats/%s' % swarming_task_id
786 service_account_json = ('/creds/service_accounts/'
787 'service-account-luci-logdog-publisher.json')
788
789 if not os.path.exists(args.upload_full_logcat):
790 logging.error(
791 'Logcat sources not found at %s. Unable to upload logcats.',
792 args.upload_full_logcat)
793 else:
794 stream_source_cmdline = [
795 '../../bin/logdog_butler', '-project', project,
796 '-output', output,
797 '-prefix', prefix,
798 '-service-account-json', service_account_json,
799 'stream', '-source', args.upload_full_logcat,
800 '-stream', '-name=unified_logcats']
801 subprocess.call(stream_source_cmdline)
777 802
778 if args.command == 'perf' and (args.steps or args.single_step): 803 if args.command == 'perf' and (args.steps or args.single_step):
779 return 0 804 return 0
780 805
781 return (0 if all(r.DidRunPass() for r in all_iteration_results) 806 return (0 if all(r.DidRunPass() for r in all_iteration_results)
782 else constants.ERROR_EXIT_CODE) 807 else constants.ERROR_EXIT_CODE)
783 808
784 809
785 CommandConfigTuple = collections.namedtuple( 810 CommandConfigTuple = collections.namedtuple(
786 'CommandConfigTuple', 811 'CommandConfigTuple',
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 if e.is_infra_error: 862 if e.is_infra_error:
838 return constants.INFRA_EXIT_CODE 863 return constants.INFRA_EXIT_CODE
839 return constants.ERROR_EXIT_CODE 864 return constants.ERROR_EXIT_CODE
840 except: # pylint: disable=W0702 865 except: # pylint: disable=W0702
841 logging.exception('Unrecognized error occurred.') 866 logging.exception('Unrecognized error occurred.')
842 return constants.ERROR_EXIT_CODE 867 return constants.ERROR_EXIT_CODE
843 868
844 869
845 if __name__ == '__main__': 870 if __name__ == '__main__':
846 sys.exit(main()) 871 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698