blob: 1c99e794a93604e8590c304a8d391e2285a0d9d9 [file] [log] [blame]
Siddharth Shukla8e64d902017-03-12 19:50:18 +01001#!/usr/bin/env python
Jan Tattermusch7897ae92017-06-07 22:57:36 +02002# Copyright 2015 gRPC authors.
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +02003#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02004# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +02007#
Jan Tattermusch7897ae92017-06-07 22:57:36 +02008# http://www.apache.org/licenses/LICENSE-2.0
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +02009#
Jan Tattermusch7897ae92017-06-07 22:57:36 +020010# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +020015"""Run test matrix."""
16
Siddharth Shuklad194f592017-03-11 19:12:43 +010017from __future__ import print_function
18
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +020019import argparse
Jan Tattermuscha1906d52016-09-19 18:37:17 +020020import multiprocessing
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +020021import os
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +020022import sys
Jan Tattermusch5c79a312016-12-20 11:02:50 +010023
24import python_utils.jobset as jobset
25import python_utils.report_utils as report_utils
26from python_utils.filter_pull_request_tests import filter_tests
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +020027
28_ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
29os.chdir(_ROOT)
30
ncteisen888093c2017-12-11 18:00:40 -080031_DEFAULT_RUNTESTS_TIMEOUT = 1 * 60 * 60
Jan Tattermusch29828c52017-09-12 16:42:55 +020032
Jan Tattermusch060eb872016-09-20 16:06:13 +020033# Set the timeout high to allow enough time for sanitizers and pre-building
34# clang docker.
ncteisen888093c2017-12-11 18:00:40 -080035_CPP_RUNTESTS_TIMEOUT = 4 * 60 * 60
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +020036
Jan Tattermusch67cd21e2017-09-19 16:21:20 +020037# C++ TSAN takes longer than other sanitizers
ncteisen888093c2017-12-11 18:00:40 -080038_CPP_TSAN_RUNTESTS_TIMEOUT = 8 * 60 * 60
Jan Tattermusch67cd21e2017-09-19 16:21:20 +020039
Muxi Yanb94f3b32018-02-26 13:06:30 -080040# Set timeout high for ObjC for Cocoapods to install pods
41_OBJC_RUNTESTS_TIMEOUT = 90 * 60
42
Jan Tattermuscha1906d52016-09-19 18:37:17 +020043# Number of jobs assigned to each run_tests.py instance
Matt Kwongfef98962016-10-27 10:45:47 -070044_DEFAULT_INNER_JOBS = 2
Jan Tattermuscha1906d52016-09-19 18:37:17 +020045
Jan Tattermusch5a59c432017-03-07 19:57:13 +010046# report suffix is important for reports to get picked up by internal CI
47_REPORT_SUFFIX = 'sponge_log.xml'
48
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +020049
Jan Tattermusch41d220e2018-01-22 17:02:44 +010050def _safe_report_name(name):
51 """Reports with '+' in target name won't show correctly in ResultStore"""
52 return name.replace('+', 'p')
53
54
Jan Tattermuschac9c9f92017-04-28 20:56:05 +020055def _report_filename(name):
ncteisen888093c2017-12-11 18:00:40 -080056 """Generates report file name"""
Jan Tattermusch41d220e2018-01-22 17:02:44 +010057 return 'report_%s_%s' % (_safe_report_name(name), _REPORT_SUFFIX)
Jan Tattermuschac9c9f92017-04-28 20:56:05 +020058
59
60def _report_filename_internal_ci(name):
ncteisen888093c2017-12-11 18:00:40 -080061 """Generates report file name that leads to better presentation by internal CI"""
Jan Tattermusch41d220e2018-01-22 17:02:44 +010062 return '%s/%s' % (_safe_report_name(name), _REPORT_SUFFIX)
Jan Tattermuschac9c9f92017-04-28 20:56:05 +020063
64
ncteisen888093c2017-12-11 18:00:40 -080065def _docker_jobspec(name,
66 runtests_args=[],
67 runtests_envs={},
Jan Tattermusch29828c52017-09-12 16:42:55 +020068 inner_jobs=_DEFAULT_INNER_JOBS,
69 timeout_seconds=None):
ncteisen888093c2017-12-11 18:00:40 -080070 """Run a single instance of run_tests.py in a docker container"""
71 if not timeout_seconds:
72 timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT
73 test_job = jobset.JobSpec(
74 cmdline=[
75 'python', 'tools/run_tests/run_tests.py', '--use_docker', '-t',
Mehrdad Afshari87cd9942018-01-02 14:40:00 -080076 '-j',
77 str(inner_jobs), '-x',
78 _report_filename(name), '--report_suite_name',
Jan Tattermusch41d220e2018-01-22 17:02:44 +010079 '%s' % _safe_report_name(name)
ncteisen888093c2017-12-11 18:00:40 -080080 ] + runtests_args,
81 environ=runtests_envs,
82 shortname='run_tests_%s' % name,
83 timeout_seconds=timeout_seconds)
84 return test_job
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +020085
86
ncteisen888093c2017-12-11 18:00:40 -080087def _workspace_jobspec(name,
88 runtests_args=[],
89 workspace_name=None,
90 runtests_envs={},
91 inner_jobs=_DEFAULT_INNER_JOBS,
Jan Tattermusch29828c52017-09-12 16:42:55 +020092 timeout_seconds=None):
ncteisen888093c2017-12-11 18:00:40 -080093 """Run a single instance of run_tests.py in a separate workspace"""
94 if not workspace_name:
95 workspace_name = 'workspace_%s' % name
96 if not timeout_seconds:
97 timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT
98 env = {'WORKSPACE_NAME': workspace_name}
99 env.update(runtests_envs)
100 test_job = jobset.JobSpec(
101 cmdline=[
102 'bash', 'tools/run_tests/helper_scripts/run_tests_in_workspace.sh',
Mehrdad Afshari87cd9942018-01-02 14:40:00 -0800103 '-t', '-j',
104 str(inner_jobs), '-x',
105 '../%s' % _report_filename(name), '--report_suite_name',
Jan Tattermusch41d220e2018-01-22 17:02:44 +0100106 '%s' % _safe_report_name(name)
ncteisen888093c2017-12-11 18:00:40 -0800107 ] + runtests_args,
108 environ=env,
109 shortname='run_tests_%s' % name,
110 timeout_seconds=timeout_seconds)
111 return test_job
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200112
113
ncteisen888093c2017-12-11 18:00:40 -0800114def _generate_jobs(languages,
115 configs,
116 platforms,
117 iomgr_platform='native',
118 arch=None,
119 compiler=None,
120 labels=[],
121 extra_args=[],
122 extra_envs={},
123 inner_jobs=_DEFAULT_INNER_JOBS,
124 timeout_seconds=None):
125 result = []
126 for language in languages:
127 for platform in platforms:
128 for config in configs:
129 name = '%s_%s_%s_%s' % (language, platform, config,
130 iomgr_platform)
131 runtests_args = [
132 '-l', language, '-c', config, '--iomgr_platform',
133 iomgr_platform
134 ]
135 if arch or compiler:
136 name += '_%s_%s' % (arch, compiler)
137 runtests_args += ['--arch', arch, '--compiler', compiler]
138 if '--build_only' in extra_args:
139 name += '_buildonly'
140 for extra_env in extra_envs:
141 name += '_%s_%s' % (extra_env, extra_envs[extra_env])
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200142
ncteisen888093c2017-12-11 18:00:40 -0800143 runtests_args += extra_args
144 if platform == 'linux':
145 job = _docker_jobspec(
146 name=name,
147 runtests_args=runtests_args,
148 runtests_envs=extra_envs,
149 inner_jobs=inner_jobs,
150 timeout_seconds=timeout_seconds)
151 else:
152 job = _workspace_jobspec(
153 name=name,
154 runtests_args=runtests_args,
155 runtests_envs=extra_envs,
156 inner_jobs=inner_jobs,
157 timeout_seconds=timeout_seconds)
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200158
ncteisen888093c2017-12-11 18:00:40 -0800159 job.labels = [platform, config, language, iomgr_platform
160 ] + labels
161 result.append(job)
162 return result
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200163
164
Matt Kwongfef98962016-10-27 10:45:47 -0700165def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS):
ncteisen888093c2017-12-11 18:00:40 -0800166 test_jobs = []
167 # supported on linux only
168 test_jobs += _generate_jobs(
169 languages=['sanity', 'php7'],
170 configs=['dbg', 'opt'],
171 platforms=['linux'],
172 labels=['basictests', 'multilang'],
173 extra_args=extra_args,
174 inner_jobs=inner_jobs)
murgatroid991687cab2016-10-11 11:42:01 -0700175
ncteisen888093c2017-12-11 18:00:40 -0800176 # supported on all platforms.
177 test_jobs += _generate_jobs(
178 languages=['c'],
179 configs=['dbg', 'opt'],
180 platforms=['linux', 'macos', 'windows'],
181 labels=['basictests', 'corelang'],
182 extra_args=extra_args,
183 inner_jobs=inner_jobs,
184 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
murgatroid9938007752017-10-18 11:24:17 -0700185
ncteisen888093c2017-12-11 18:00:40 -0800186 test_jobs += _generate_jobs(
187 languages=['csharp', 'python'],
188 configs=['dbg', 'opt'],
189 platforms=['linux', 'macos', 'windows'],
190 labels=['basictests', 'multilang'],
191 extra_args=extra_args,
192 inner_jobs=inner_jobs)
murgatroid991687cab2016-10-11 11:42:01 -0700193
ncteisen888093c2017-12-11 18:00:40 -0800194 # supported on linux and mac.
195 test_jobs += _generate_jobs(
196 languages=['c++'],
197 configs=['dbg', 'opt'],
198 platforms=['linux', 'macos'],
199 labels=['basictests', 'corelang'],
200 extra_args=extra_args,
201 inner_jobs=inner_jobs,
202 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
murgatroid9938007752017-10-18 11:24:17 -0700203
ncteisen888093c2017-12-11 18:00:40 -0800204 test_jobs += _generate_jobs(
205 languages=['grpc-node', 'ruby', 'php'],
206 configs=['dbg', 'opt'],
207 platforms=['linux', 'macos'],
208 labels=['basictests', 'multilang'],
209 extra_args=extra_args,
210 inner_jobs=inner_jobs)
murgatroid991687cab2016-10-11 11:42:01 -0700211
ncteisen888093c2017-12-11 18:00:40 -0800212 # supported on mac only.
213 test_jobs += _generate_jobs(
214 languages=['objc'],
215 configs=['dbg', 'opt'],
216 platforms=['macos'],
217 labels=['basictests', 'multilang'],
218 extra_args=extra_args,
Muxi Yanb94f3b32018-02-26 13:06:30 -0800219 inner_jobs=inner_jobs,
220 timeout_seconds=_OBJC_RUNTESTS_TIMEOUT)
murgatroid991687cab2016-10-11 11:42:01 -0700221
ncteisen888093c2017-12-11 18:00:40 -0800222 # sanitizers
223 test_jobs += _generate_jobs(
224 languages=['c'],
225 configs=['msan', 'asan', 'tsan', 'ubsan'],
226 platforms=['linux'],
227 labels=['sanitizers', 'corelang'],
228 extra_args=extra_args,
229 inner_jobs=inner_jobs,
230 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
231 test_jobs += _generate_jobs(
232 languages=['c++'],
233 configs=['asan'],
234 platforms=['linux'],
235 labels=['sanitizers', 'corelang'],
236 extra_args=extra_args,
237 inner_jobs=inner_jobs,
238 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
239 test_jobs += _generate_jobs(
240 languages=['c++'],
241 configs=['tsan'],
242 platforms=['linux'],
243 labels=['sanitizers', 'corelang'],
244 extra_args=extra_args,
245 inner_jobs=inner_jobs,
246 timeout_seconds=_CPP_TSAN_RUNTESTS_TIMEOUT)
murgatroid991687cab2016-10-11 11:42:01 -0700247
ncteisen888093c2017-12-11 18:00:40 -0800248 return test_jobs
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200249
murgatroid991687cab2016-10-11 11:42:01 -0700250
ncteisen888093c2017-12-11 18:00:40 -0800251def _create_portability_test_jobs(extra_args=[],
252 inner_jobs=_DEFAULT_INNER_JOBS):
253 test_jobs = []
254 # portability C x86
255 test_jobs += _generate_jobs(
256 languages=['c'],
257 configs=['dbg'],
258 platforms=['linux'],
259 arch='x86',
260 compiler='default',
261 labels=['portability', 'corelang'],
262 extra_args=extra_args,
263 inner_jobs=inner_jobs)
murgatroid991687cab2016-10-11 11:42:01 -0700264
ncteisen888093c2017-12-11 18:00:40 -0800265 # portability C and C++ on x64
266 for compiler in [
Jan Tattermusch0614a682018-01-23 11:51:21 +0100267 'gcc4.8', 'gcc5.3', 'gcc7.2', 'gcc_musl', 'clang3.5', 'clang3.6',
268 'clang3.7'
ncteisen888093c2017-12-11 18:00:40 -0800269 ]:
270 test_jobs += _generate_jobs(
271 languages=['c', 'c++'],
272 configs=['dbg'],
273 platforms=['linux'],
274 arch='x64',
275 compiler=compiler,
276 labels=['portability', 'corelang'],
277 extra_args=extra_args,
278 inner_jobs=inner_jobs,
279 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
murgatroid991687cab2016-10-11 11:42:01 -0700280
ncteisen888093c2017-12-11 18:00:40 -0800281 # portability C on Windows 64-bit (x86 is the default)
282 test_jobs += _generate_jobs(
283 languages=['c'],
284 configs=['dbg'],
285 platforms=['windows'],
286 arch='x64',
287 compiler='default',
288 labels=['portability', 'corelang'],
289 extra_args=extra_args,
290 inner_jobs=inner_jobs)
Jan Tattermuschadd32252017-06-26 17:13:14 +0200291
ncteisen888093c2017-12-11 18:00:40 -0800292 # portability C++ on Windows
293 # TODO(jtattermusch): some of the tests are failing, so we force --build_only
294 test_jobs += _generate_jobs(
295 languages=['c++'],
296 configs=['dbg'],
297 platforms=['windows'],
298 arch='default',
299 compiler='default',
300 labels=['portability', 'corelang'],
301 extra_args=extra_args + ['--build_only'],
302 inner_jobs=inner_jobs)
murgatroid991687cab2016-10-11 11:42:01 -0700303
ncteisen888093c2017-12-11 18:00:40 -0800304 # portability C and C++ on Windows using VS2017 (build only)
305 # TODO(jtattermusch): some of the tests are failing, so we force --build_only
306 test_jobs += _generate_jobs(
307 languages=['c', 'c++'],
308 configs=['dbg'],
309 platforms=['windows'],
310 arch='x64',
311 compiler='cmake_vs2017',
312 labels=['portability', 'corelang'],
313 extra_args=extra_args + ['--build_only'],
314 inner_jobs=inner_jobs)
Jan Tattermuscha8003e82017-08-23 15:43:17 +0200315
ncteisen888093c2017-12-11 18:00:40 -0800316 # C and C++ with the c-ares DNS resolver on Linux
317 test_jobs += _generate_jobs(
318 languages=['c', 'c++'],
319 configs=['dbg'],
320 platforms=['linux'],
321 labels=['portability', 'corelang'],
322 extra_args=extra_args,
323 extra_envs={'GRPC_DNS_RESOLVER': 'ares'},
324 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
Yuchen Zeng87b59102016-11-08 10:50:12 -0800325
Vijay Pai9d2d8432018-01-08 15:11:23 -0800326 # C and C++ with no-exceptions on Linux
327 test_jobs += _generate_jobs(
328 languages=['c', 'c++'],
329 configs=['noexcept'],
330 platforms=['linux'],
331 labels=['portability', 'corelang'],
332 extra_args=extra_args,
333 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
334
ncteisen888093c2017-12-11 18:00:40 -0800335 # TODO(zyc): Turn on this test after adding c-ares support on windows.
336 # C with the c-ares DNS resolver on Windows
337 # test_jobs += _generate_jobs(languages=['c'],
338 # configs=['dbg'], platforms=['windows'],
339 # labels=['portability', 'corelang'],
340 # extra_args=extra_args,
341 # extra_envs={'GRPC_DNS_RESOLVER': 'ares'})
Yuchen Zengfdae4bd2016-11-07 17:46:16 -0800342
ncteisen888093c2017-12-11 18:00:40 -0800343 # C and C++ build with cmake on Linux
344 # TODO(jtattermusch): some of the tests are failing, so we force --build_only
345 # to make sure it's buildable at least.
346 test_jobs += _generate_jobs(
347 languages=['c', 'c++'],
348 configs=['dbg'],
349 platforms=['linux'],
350 arch='default',
351 compiler='cmake',
352 labels=['portability', 'corelang'],
353 extra_args=extra_args + ['--build_only'],
354 inner_jobs=inner_jobs)
Jan Tattermuschdfb03bb2017-01-25 19:27:58 +0100355
ncteisen888093c2017-12-11 18:00:40 -0800356 test_jobs += _generate_jobs(
357 languages=['python'],
358 configs=['dbg'],
359 platforms=['linux'],
360 arch='default',
361 compiler='python_alpine',
362 labels=['portability', 'multilang'],
363 extra_args=extra_args,
364 inner_jobs=inner_jobs)
Ken Payson02909062017-05-04 12:33:58 -0700365
ncteisen888093c2017-12-11 18:00:40 -0800366 test_jobs += _generate_jobs(
367 languages=['csharp'],
368 configs=['dbg'],
369 platforms=['linux'],
370 arch='default',
371 compiler='coreclr',
372 labels=['portability', 'multilang'],
373 extra_args=extra_args,
374 inner_jobs=inner_jobs)
murgatroid99804c9e92016-12-05 12:19:57 -0800375
ncteisen888093c2017-12-11 18:00:40 -0800376 test_jobs += _generate_jobs(
377 languages=['c'],
378 configs=['dbg'],
379 platforms=['linux'],
380 iomgr_platform='uv',
381 labels=['portability', 'corelang'],
382 extra_args=extra_args,
383 inner_jobs=inner_jobs,
384 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
murgatroid991191b722017-02-08 11:56:52 -0800385
ncteisen888093c2017-12-11 18:00:40 -0800386 return test_jobs
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200387
388
Jan Tattermusch6d7c6ef2016-09-22 13:40:48 +0200389def _allowed_labels():
ncteisen888093c2017-12-11 18:00:40 -0800390 """Returns a list of existing job labels."""
391 all_labels = set()
392 for job in _create_test_jobs() + _create_portability_test_jobs():
393 for label in job.labels:
394 all_labels.add(label)
395 return sorted(all_labels)
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200396
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200397
Jan Tattermusch68e27bf2016-12-16 14:09:03 +0100398def _runs_per_test_type(arg_str):
ncteisen888093c2017-12-11 18:00:40 -0800399 """Auxiliary function to parse the "runs_per_test" flag."""
400 try:
401 n = int(arg_str)
402 if n <= 0: raise ValueError
403 return n
404 except:
405 msg = '\'{}\' is not a positive integer'.format(arg_str)
406 raise argparse.ArgumentTypeError(msg)
Jan Tattermusch68e27bf2016-12-16 14:09:03 +0100407
408
Matt Kwong7e9bd6c2016-10-24 17:30:25 -0700409if __name__ == "__main__":
ncteisen888093c2017-12-11 18:00:40 -0800410 argp = argparse.ArgumentParser(
411 description='Run a matrix of run_tests.py tests.')
412 argp.add_argument(
413 '-j',
414 '--jobs',
415 default=multiprocessing.cpu_count() / _DEFAULT_INNER_JOBS,
416 type=int,
417 help='Number of concurrent run_tests.py instances.')
418 argp.add_argument(
419 '-f',
420 '--filter',
421 choices=_allowed_labels(),
422 nargs='+',
423 default=[],
424 help='Filter targets to run by label with AND semantics.')
425 argp.add_argument(
426 '--exclude',
427 choices=_allowed_labels(),
428 nargs='+',
429 default=[],
430 help='Exclude targets with any of given labels.')
431 argp.add_argument(
432 '--build_only',
433 default=False,
434 action='store_const',
435 const=True,
436 help='Pass --build_only flag to run_tests.py instances.')
437 argp.add_argument(
438 '--force_default_poller',
439 default=False,
440 action='store_const',
441 const=True,
442 help='Pass --force_default_poller to run_tests.py instances.')
443 argp.add_argument(
444 '--dry_run',
445 default=False,
446 action='store_const',
447 const=True,
448 help='Only print what would be run.')
449 argp.add_argument(
450 '--filter_pr_tests',
451 default=False,
452 action='store_const',
453 const=True,
454 help='Filters out tests irrelevant to pull request changes.')
455 argp.add_argument(
456 '--base_branch',
457 default='origin/master',
458 type=str,
459 help='Branch that pull request is requesting to merge into')
460 argp.add_argument(
461 '--inner_jobs',
462 default=_DEFAULT_INNER_JOBS,
463 type=int,
464 help='Number of jobs in each run_tests.py instance')
465 argp.add_argument(
466 '-n',
467 '--runs_per_test',
468 default=1,
469 type=_runs_per_test_type,
470 help='How many times to run each tests. >1 runs implies ' +
471 'omitting passing test from the output & reports.')
472 argp.add_argument(
473 '--max_time',
474 default=-1,
475 type=int,
476 help='Maximum amount of time to run tests for' +
477 '(other tests will be skipped)')
478 argp.add_argument(
479 '--internal_ci',
480 default=False,
481 action='store_const',
482 const=True,
483 help='Put reports into subdirectories to improve presentation of '
484 'results by Internal CI.')
485 argp.add_argument(
486 '--bq_result_table',
487 default='',
488 type=str,
489 nargs='?',
490 help='Upload test results to a specified BQ table.')
491 args = argp.parse_args()
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200492
ncteisen888093c2017-12-11 18:00:40 -0800493 if args.internal_ci:
494 _report_filename = _report_filename_internal_ci # override the function
Jan Tattermuschac9c9f92017-04-28 20:56:05 +0200495
ncteisen888093c2017-12-11 18:00:40 -0800496 extra_args = []
497 if args.build_only:
498 extra_args.append('--build_only')
499 if args.force_default_poller:
500 extra_args.append('--force_default_poller')
501 if args.runs_per_test > 1:
502 extra_args.append('-n')
503 extra_args.append('%s' % args.runs_per_test)
504 extra_args.append('--quiet_success')
505 if args.max_time > 0:
506 extra_args.extend(('--max_time', '%d' % args.max_time))
507 if args.bq_result_table:
508 extra_args.append('--bq_result_table')
509 extra_args.append('%s' % args.bq_result_table)
510 extra_args.append('--measure_cpu_costs')
511 extra_args.append('--disable_auto_set_flakes')
Matt Kwongfef98962016-10-27 10:45:47 -0700512
ncteisen888093c2017-12-11 18:00:40 -0800513 all_jobs = _create_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) + \
514 _create_portability_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs)
Jan Tattermusch6d7c6ef2016-09-22 13:40:48 +0200515
ncteisen888093c2017-12-11 18:00:40 -0800516 jobs = []
517 for job in all_jobs:
Mehrdad Afshari87cd9942018-01-02 14:40:00 -0800518 if not args.filter or all(
519 filter in job.labels for filter in args.filter):
ncteisen888093c2017-12-11 18:00:40 -0800520 if not any(exclude_label in job.labels
521 for exclude_label in args.exclude):
522 jobs.append(job)
Jan Tattermusch6d7c6ef2016-09-22 13:40:48 +0200523
ncteisen888093c2017-12-11 18:00:40 -0800524 if not jobs:
525 jobset.message(
526 'FAILED', 'No test suites match given criteria.', do_newline=True)
527 sys.exit(1)
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200528
ncteisen888093c2017-12-11 18:00:40 -0800529 print('IMPORTANT: The changes you are testing need to be locally committed')
530 print('because only the committed changes in the current branch will be')
531 print('copied to the docker environment or into subworkspaces.')
murgatroid991687cab2016-10-11 11:42:01 -0700532
ncteisen888093c2017-12-11 18:00:40 -0800533 skipped_jobs = []
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200534
ncteisen888093c2017-12-11 18:00:40 -0800535 if args.filter_pr_tests:
536 print('Looking for irrelevant tests to skip...')
537 relevant_jobs = filter_tests(jobs, args.base_branch)
538 if len(relevant_jobs) == len(jobs):
539 print('No tests will be skipped.')
540 else:
541 print('These tests will be skipped:')
542 skipped_jobs = list(set(jobs) - set(relevant_jobs))
543 # Sort by shortnames to make printing of skipped tests consistent
544 skipped_jobs.sort(key=lambda job: job.shortname)
545 for job in list(skipped_jobs):
546 print(' %s' % job.shortname)
547 jobs = relevant_jobs
Matt Kwong7e9bd6c2016-10-24 17:30:25 -0700548
ncteisen888093c2017-12-11 18:00:40 -0800549 print('Will run these tests:')
550 for job in jobs:
551 if args.dry_run:
552 print(' %s: "%s"' % (job.shortname, ' '.join(job.cmdline)))
553 else:
554 print(' %s' % job.shortname)
555 print
556
Matt Kwong7e9bd6c2016-10-24 17:30:25 -0700557 if args.dry_run:
ncteisen888093c2017-12-11 18:00:40 -0800558 print('--dry_run was used, exiting')
559 sys.exit(1)
560
561 jobset.message('START', 'Running test matrix.', do_newline=True)
562 num_failures, resultset = jobset.run(
563 jobs, newline_on_success=True, travis=True, maxjobs=args.jobs)
564 # Merge skipped tests into results to show skipped tests on report.xml
565 if skipped_jobs:
566 ignored_num_skipped_failures, skipped_results = jobset.run(
567 skipped_jobs, skip_jobs=True)
568 resultset.update(skipped_results)
569 report_utils.render_junit_xml_report(
570 resultset,
571 _report_filename('aggregate_tests'),
572 suite_name='aggregate_tests')
573
574 if num_failures == 0:
575 jobset.message(
576 'SUCCESS',
577 'All run_tests.py instance finished successfully.',
578 do_newline=True)
Matt Kwong7e9bd6c2016-10-24 17:30:25 -0700579 else:
ncteisen888093c2017-12-11 18:00:40 -0800580 jobset.message(
581 'FAILED',
582 'Some run_tests.py instance have failed.',
583 do_newline=True)
584 sys.exit(1)