blob: 49be8f1d7e4d90ed19509ce7be105f0e5cc8859b [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
Jan Tattermuscha1906d52016-09-19 18:37:17 +020040# Number of jobs assigned to each run_tests.py instance
Matt Kwongfef98962016-10-27 10:45:47 -070041_DEFAULT_INNER_JOBS = 2
Jan Tattermuscha1906d52016-09-19 18:37:17 +020042
Jan Tattermusch5a59c432017-03-07 19:57:13 +010043# report suffix is important for reports to get picked up by internal CI
44_REPORT_SUFFIX = 'sponge_log.xml'
45
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +020046
Jan Tattermuschac9c9f92017-04-28 20:56:05 +020047def _report_filename(name):
ncteisen888093c2017-12-11 18:00:40 -080048 """Generates report file name"""
49 return 'report_%s_%s' % (name, _REPORT_SUFFIX)
Jan Tattermuschac9c9f92017-04-28 20:56:05 +020050
51
52def _report_filename_internal_ci(name):
ncteisen888093c2017-12-11 18:00:40 -080053 """Generates report file name that leads to better presentation by internal CI"""
54 return '%s/%s' % (name, _REPORT_SUFFIX)
Jan Tattermuschac9c9f92017-04-28 20:56:05 +020055
56
ncteisen888093c2017-12-11 18:00:40 -080057def _docker_jobspec(name,
58 runtests_args=[],
59 runtests_envs={},
Jan Tattermusch29828c52017-09-12 16:42:55 +020060 inner_jobs=_DEFAULT_INNER_JOBS,
61 timeout_seconds=None):
ncteisen888093c2017-12-11 18:00:40 -080062 """Run a single instance of run_tests.py in a docker container"""
63 if not timeout_seconds:
64 timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT
65 test_job = jobset.JobSpec(
66 cmdline=[
67 'python', 'tools/run_tests/run_tests.py', '--use_docker', '-t',
68 '-j', str(inner_jobs), '-x', _report_filename(name),
69 '--report_suite_name', '%s' % name
70 ] + runtests_args,
71 environ=runtests_envs,
72 shortname='run_tests_%s' % name,
73 timeout_seconds=timeout_seconds)
74 return test_job
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +020075
76
ncteisen888093c2017-12-11 18:00:40 -080077def _workspace_jobspec(name,
78 runtests_args=[],
79 workspace_name=None,
80 runtests_envs={},
81 inner_jobs=_DEFAULT_INNER_JOBS,
Jan Tattermusch29828c52017-09-12 16:42:55 +020082 timeout_seconds=None):
ncteisen888093c2017-12-11 18:00:40 -080083 """Run a single instance of run_tests.py in a separate workspace"""
84 if not workspace_name:
85 workspace_name = 'workspace_%s' % name
86 if not timeout_seconds:
87 timeout_seconds = _DEFAULT_RUNTESTS_TIMEOUT
88 env = {'WORKSPACE_NAME': workspace_name}
89 env.update(runtests_envs)
90 test_job = jobset.JobSpec(
91 cmdline=[
92 'bash', 'tools/run_tests/helper_scripts/run_tests_in_workspace.sh',
93 '-t', '-j', str(inner_jobs), '-x', '../%s' % _report_filename(name),
94 '--report_suite_name', '%s' % name
95 ] + runtests_args,
96 environ=env,
97 shortname='run_tests_%s' % name,
98 timeout_seconds=timeout_seconds)
99 return test_job
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200100
101
ncteisen888093c2017-12-11 18:00:40 -0800102def _generate_jobs(languages,
103 configs,
104 platforms,
105 iomgr_platform='native',
106 arch=None,
107 compiler=None,
108 labels=[],
109 extra_args=[],
110 extra_envs={},
111 inner_jobs=_DEFAULT_INNER_JOBS,
112 timeout_seconds=None):
113 result = []
114 for language in languages:
115 for platform in platforms:
116 for config in configs:
117 name = '%s_%s_%s_%s' % (language, platform, config,
118 iomgr_platform)
119 runtests_args = [
120 '-l', language, '-c', config, '--iomgr_platform',
121 iomgr_platform
122 ]
123 if arch or compiler:
124 name += '_%s_%s' % (arch, compiler)
125 runtests_args += ['--arch', arch, '--compiler', compiler]
126 if '--build_only' in extra_args:
127 name += '_buildonly'
128 for extra_env in extra_envs:
129 name += '_%s_%s' % (extra_env, extra_envs[extra_env])
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200130
ncteisen888093c2017-12-11 18:00:40 -0800131 runtests_args += extra_args
132 if platform == 'linux':
133 job = _docker_jobspec(
134 name=name,
135 runtests_args=runtests_args,
136 runtests_envs=extra_envs,
137 inner_jobs=inner_jobs,
138 timeout_seconds=timeout_seconds)
139 else:
140 job = _workspace_jobspec(
141 name=name,
142 runtests_args=runtests_args,
143 runtests_envs=extra_envs,
144 inner_jobs=inner_jobs,
145 timeout_seconds=timeout_seconds)
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200146
ncteisen888093c2017-12-11 18:00:40 -0800147 job.labels = [platform, config, language, iomgr_platform
148 ] + labels
149 result.append(job)
150 return result
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200151
152
Matt Kwongfef98962016-10-27 10:45:47 -0700153def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS):
ncteisen888093c2017-12-11 18:00:40 -0800154 test_jobs = []
155 # supported on linux only
156 test_jobs += _generate_jobs(
157 languages=['sanity', 'php7'],
158 configs=['dbg', 'opt'],
159 platforms=['linux'],
160 labels=['basictests', 'multilang'],
161 extra_args=extra_args,
162 inner_jobs=inner_jobs)
murgatroid991687cab2016-10-11 11:42:01 -0700163
ncteisen888093c2017-12-11 18:00:40 -0800164 # supported on all platforms.
165 test_jobs += _generate_jobs(
166 languages=['c'],
167 configs=['dbg', 'opt'],
168 platforms=['linux', 'macos', 'windows'],
169 labels=['basictests', 'corelang'],
170 extra_args=extra_args,
171 inner_jobs=inner_jobs,
172 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
murgatroid9938007752017-10-18 11:24:17 -0700173
ncteisen888093c2017-12-11 18:00:40 -0800174 test_jobs += _generate_jobs(
175 languages=['csharp', 'python'],
176 configs=['dbg', 'opt'],
177 platforms=['linux', 'macos', 'windows'],
178 labels=['basictests', 'multilang'],
179 extra_args=extra_args,
180 inner_jobs=inner_jobs)
murgatroid991687cab2016-10-11 11:42:01 -0700181
ncteisen888093c2017-12-11 18:00:40 -0800182 # supported on linux and mac.
183 test_jobs += _generate_jobs(
184 languages=['c++'],
185 configs=['dbg', 'opt'],
186 platforms=['linux', 'macos'],
187 labels=['basictests', 'corelang'],
188 extra_args=extra_args,
189 inner_jobs=inner_jobs,
190 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
murgatroid9938007752017-10-18 11:24:17 -0700191
ncteisen888093c2017-12-11 18:00:40 -0800192 test_jobs += _generate_jobs(
193 languages=['grpc-node', 'ruby', 'php'],
194 configs=['dbg', 'opt'],
195 platforms=['linux', 'macos'],
196 labels=['basictests', 'multilang'],
197 extra_args=extra_args,
198 inner_jobs=inner_jobs)
murgatroid991687cab2016-10-11 11:42:01 -0700199
ncteisen888093c2017-12-11 18:00:40 -0800200 # supported on mac only.
201 test_jobs += _generate_jobs(
202 languages=['objc'],
203 configs=['dbg', 'opt'],
204 platforms=['macos'],
205 labels=['basictests', 'multilang'],
206 extra_args=extra_args,
207 inner_jobs=inner_jobs)
murgatroid991687cab2016-10-11 11:42:01 -0700208
ncteisen888093c2017-12-11 18:00:40 -0800209 # sanitizers
210 test_jobs += _generate_jobs(
211 languages=['c'],
212 configs=['msan', 'asan', 'tsan', 'ubsan'],
213 platforms=['linux'],
214 labels=['sanitizers', 'corelang'],
215 extra_args=extra_args,
216 inner_jobs=inner_jobs,
217 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
218 test_jobs += _generate_jobs(
219 languages=['c++'],
220 configs=['asan'],
221 platforms=['linux'],
222 labels=['sanitizers', 'corelang'],
223 extra_args=extra_args,
224 inner_jobs=inner_jobs,
225 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
226 test_jobs += _generate_jobs(
227 languages=['c++'],
228 configs=['tsan'],
229 platforms=['linux'],
230 labels=['sanitizers', 'corelang'],
231 extra_args=extra_args,
232 inner_jobs=inner_jobs,
233 timeout_seconds=_CPP_TSAN_RUNTESTS_TIMEOUT)
murgatroid991687cab2016-10-11 11:42:01 -0700234
ncteisen888093c2017-12-11 18:00:40 -0800235 return test_jobs
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200236
murgatroid991687cab2016-10-11 11:42:01 -0700237
ncteisen888093c2017-12-11 18:00:40 -0800238def _create_portability_test_jobs(extra_args=[],
239 inner_jobs=_DEFAULT_INNER_JOBS):
240 test_jobs = []
241 # portability C x86
242 test_jobs += _generate_jobs(
243 languages=['c'],
244 configs=['dbg'],
245 platforms=['linux'],
246 arch='x86',
247 compiler='default',
248 labels=['portability', 'corelang'],
249 extra_args=extra_args,
250 inner_jobs=inner_jobs)
murgatroid991687cab2016-10-11 11:42:01 -0700251
ncteisen888093c2017-12-11 18:00:40 -0800252 # portability C and C++ on x64
253 for compiler in [
254 'gcc4.8', 'gcc5.3', 'gcc_musl', 'clang3.5', 'clang3.6', 'clang3.7'
255 ]:
256 test_jobs += _generate_jobs(
257 languages=['c', 'c++'],
258 configs=['dbg'],
259 platforms=['linux'],
260 arch='x64',
261 compiler=compiler,
262 labels=['portability', 'corelang'],
263 extra_args=extra_args,
264 inner_jobs=inner_jobs,
265 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
murgatroid991687cab2016-10-11 11:42:01 -0700266
ncteisen888093c2017-12-11 18:00:40 -0800267 # portability C on Windows 64-bit (x86 is the default)
268 test_jobs += _generate_jobs(
269 languages=['c'],
270 configs=['dbg'],
271 platforms=['windows'],
272 arch='x64',
273 compiler='default',
274 labels=['portability', 'corelang'],
275 extra_args=extra_args,
276 inner_jobs=inner_jobs)
Jan Tattermuschadd32252017-06-26 17:13:14 +0200277
ncteisen888093c2017-12-11 18:00:40 -0800278 # portability C++ on Windows
279 # TODO(jtattermusch): some of the tests are failing, so we force --build_only
280 test_jobs += _generate_jobs(
281 languages=['c++'],
282 configs=['dbg'],
283 platforms=['windows'],
284 arch='default',
285 compiler='default',
286 labels=['portability', 'corelang'],
287 extra_args=extra_args + ['--build_only'],
288 inner_jobs=inner_jobs)
murgatroid991687cab2016-10-11 11:42:01 -0700289
ncteisen888093c2017-12-11 18:00:40 -0800290 # portability C and C++ on Windows using VS2017 (build only)
291 # TODO(jtattermusch): some of the tests are failing, so we force --build_only
292 test_jobs += _generate_jobs(
293 languages=['c', 'c++'],
294 configs=['dbg'],
295 platforms=['windows'],
296 arch='x64',
297 compiler='cmake_vs2017',
298 labels=['portability', 'corelang'],
299 extra_args=extra_args + ['--build_only'],
300 inner_jobs=inner_jobs)
Jan Tattermuscha8003e82017-08-23 15:43:17 +0200301
ncteisen888093c2017-12-11 18:00:40 -0800302 # C and C++ with the c-ares DNS resolver on Linux
303 test_jobs += _generate_jobs(
304 languages=['c', 'c++'],
305 configs=['dbg'],
306 platforms=['linux'],
307 labels=['portability', 'corelang'],
308 extra_args=extra_args,
309 extra_envs={'GRPC_DNS_RESOLVER': 'ares'},
310 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
Yuchen Zeng87b59102016-11-08 10:50:12 -0800311
ncteisen888093c2017-12-11 18:00:40 -0800312 # TODO(zyc): Turn on this test after adding c-ares support on windows.
313 # C with the c-ares DNS resolver on Windows
314 # test_jobs += _generate_jobs(languages=['c'],
315 # configs=['dbg'], platforms=['windows'],
316 # labels=['portability', 'corelang'],
317 # extra_args=extra_args,
318 # extra_envs={'GRPC_DNS_RESOLVER': 'ares'})
Yuchen Zengfdae4bd2016-11-07 17:46:16 -0800319
ncteisen888093c2017-12-11 18:00:40 -0800320 # C and C++ build with cmake on Linux
321 # TODO(jtattermusch): some of the tests are failing, so we force --build_only
322 # to make sure it's buildable at least.
323 test_jobs += _generate_jobs(
324 languages=['c', 'c++'],
325 configs=['dbg'],
326 platforms=['linux'],
327 arch='default',
328 compiler='cmake',
329 labels=['portability', 'corelang'],
330 extra_args=extra_args + ['--build_only'],
331 inner_jobs=inner_jobs)
Jan Tattermuschdfb03bb2017-01-25 19:27:58 +0100332
ncteisen888093c2017-12-11 18:00:40 -0800333 test_jobs += _generate_jobs(
334 languages=['python'],
335 configs=['dbg'],
336 platforms=['linux'],
337 arch='default',
338 compiler='python_alpine',
339 labels=['portability', 'multilang'],
340 extra_args=extra_args,
341 inner_jobs=inner_jobs)
Ken Payson02909062017-05-04 12:33:58 -0700342
ncteisen888093c2017-12-11 18:00:40 -0800343 test_jobs += _generate_jobs(
344 languages=['csharp'],
345 configs=['dbg'],
346 platforms=['linux'],
347 arch='default',
348 compiler='coreclr',
349 labels=['portability', 'multilang'],
350 extra_args=extra_args,
351 inner_jobs=inner_jobs)
murgatroid99804c9e92016-12-05 12:19:57 -0800352
ncteisen888093c2017-12-11 18:00:40 -0800353 test_jobs += _generate_jobs(
354 languages=['c'],
355 configs=['dbg'],
356 platforms=['linux'],
357 iomgr_platform='uv',
358 labels=['portability', 'corelang'],
359 extra_args=extra_args,
360 inner_jobs=inner_jobs,
361 timeout_seconds=_CPP_RUNTESTS_TIMEOUT)
murgatroid991191b722017-02-08 11:56:52 -0800362
ncteisen888093c2017-12-11 18:00:40 -0800363 return test_jobs
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200364
365
Jan Tattermusch6d7c6ef2016-09-22 13:40:48 +0200366def _allowed_labels():
ncteisen888093c2017-12-11 18:00:40 -0800367 """Returns a list of existing job labels."""
368 all_labels = set()
369 for job in _create_test_jobs() + _create_portability_test_jobs():
370 for label in job.labels:
371 all_labels.add(label)
372 return sorted(all_labels)
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200373
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200374
Jan Tattermusch68e27bf2016-12-16 14:09:03 +0100375def _runs_per_test_type(arg_str):
ncteisen888093c2017-12-11 18:00:40 -0800376 """Auxiliary function to parse the "runs_per_test" flag."""
377 try:
378 n = int(arg_str)
379 if n <= 0: raise ValueError
380 return n
381 except:
382 msg = '\'{}\' is not a positive integer'.format(arg_str)
383 raise argparse.ArgumentTypeError(msg)
Jan Tattermusch68e27bf2016-12-16 14:09:03 +0100384
385
Matt Kwong7e9bd6c2016-10-24 17:30:25 -0700386if __name__ == "__main__":
ncteisen888093c2017-12-11 18:00:40 -0800387 argp = argparse.ArgumentParser(
388 description='Run a matrix of run_tests.py tests.')
389 argp.add_argument(
390 '-j',
391 '--jobs',
392 default=multiprocessing.cpu_count() / _DEFAULT_INNER_JOBS,
393 type=int,
394 help='Number of concurrent run_tests.py instances.')
395 argp.add_argument(
396 '-f',
397 '--filter',
398 choices=_allowed_labels(),
399 nargs='+',
400 default=[],
401 help='Filter targets to run by label with AND semantics.')
402 argp.add_argument(
403 '--exclude',
404 choices=_allowed_labels(),
405 nargs='+',
406 default=[],
407 help='Exclude targets with any of given labels.')
408 argp.add_argument(
409 '--build_only',
410 default=False,
411 action='store_const',
412 const=True,
413 help='Pass --build_only flag to run_tests.py instances.')
414 argp.add_argument(
415 '--force_default_poller',
416 default=False,
417 action='store_const',
418 const=True,
419 help='Pass --force_default_poller to run_tests.py instances.')
420 argp.add_argument(
421 '--dry_run',
422 default=False,
423 action='store_const',
424 const=True,
425 help='Only print what would be run.')
426 argp.add_argument(
427 '--filter_pr_tests',
428 default=False,
429 action='store_const',
430 const=True,
431 help='Filters out tests irrelevant to pull request changes.')
432 argp.add_argument(
433 '--base_branch',
434 default='origin/master',
435 type=str,
436 help='Branch that pull request is requesting to merge into')
437 argp.add_argument(
438 '--inner_jobs',
439 default=_DEFAULT_INNER_JOBS,
440 type=int,
441 help='Number of jobs in each run_tests.py instance')
442 argp.add_argument(
443 '-n',
444 '--runs_per_test',
445 default=1,
446 type=_runs_per_test_type,
447 help='How many times to run each tests. >1 runs implies ' +
448 'omitting passing test from the output & reports.')
449 argp.add_argument(
450 '--max_time',
451 default=-1,
452 type=int,
453 help='Maximum amount of time to run tests for' +
454 '(other tests will be skipped)')
455 argp.add_argument(
456 '--internal_ci',
457 default=False,
458 action='store_const',
459 const=True,
460 help='Put reports into subdirectories to improve presentation of '
461 'results by Internal CI.')
462 argp.add_argument(
463 '--bq_result_table',
464 default='',
465 type=str,
466 nargs='?',
467 help='Upload test results to a specified BQ table.')
468 args = argp.parse_args()
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200469
ncteisen888093c2017-12-11 18:00:40 -0800470 if args.internal_ci:
471 _report_filename = _report_filename_internal_ci # override the function
Jan Tattermuschac9c9f92017-04-28 20:56:05 +0200472
ncteisen888093c2017-12-11 18:00:40 -0800473 extra_args = []
474 if args.build_only:
475 extra_args.append('--build_only')
476 if args.force_default_poller:
477 extra_args.append('--force_default_poller')
478 if args.runs_per_test > 1:
479 extra_args.append('-n')
480 extra_args.append('%s' % args.runs_per_test)
481 extra_args.append('--quiet_success')
482 if args.max_time > 0:
483 extra_args.extend(('--max_time', '%d' % args.max_time))
484 if args.bq_result_table:
485 extra_args.append('--bq_result_table')
486 extra_args.append('%s' % args.bq_result_table)
487 extra_args.append('--measure_cpu_costs')
488 extra_args.append('--disable_auto_set_flakes')
Matt Kwongfef98962016-10-27 10:45:47 -0700489
ncteisen888093c2017-12-11 18:00:40 -0800490 all_jobs = _create_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) + \
491 _create_portability_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs)
Jan Tattermusch6d7c6ef2016-09-22 13:40:48 +0200492
ncteisen888093c2017-12-11 18:00:40 -0800493 jobs = []
494 for job in all_jobs:
495 if not args.filter or all(filter in job.labels
496 for filter in args.filter):
497 if not any(exclude_label in job.labels
498 for exclude_label in args.exclude):
499 jobs.append(job)
Jan Tattermusch6d7c6ef2016-09-22 13:40:48 +0200500
ncteisen888093c2017-12-11 18:00:40 -0800501 if not jobs:
502 jobset.message(
503 'FAILED', 'No test suites match given criteria.', do_newline=True)
504 sys.exit(1)
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200505
ncteisen888093c2017-12-11 18:00:40 -0800506 print('IMPORTANT: The changes you are testing need to be locally committed')
507 print('because only the committed changes in the current branch will be')
508 print('copied to the docker environment or into subworkspaces.')
murgatroid991687cab2016-10-11 11:42:01 -0700509
ncteisen888093c2017-12-11 18:00:40 -0800510 skipped_jobs = []
Jan Tattermusch9c79e8d2016-09-19 14:33:18 +0200511
ncteisen888093c2017-12-11 18:00:40 -0800512 if args.filter_pr_tests:
513 print('Looking for irrelevant tests to skip...')
514 relevant_jobs = filter_tests(jobs, args.base_branch)
515 if len(relevant_jobs) == len(jobs):
516 print('No tests will be skipped.')
517 else:
518 print('These tests will be skipped:')
519 skipped_jobs = list(set(jobs) - set(relevant_jobs))
520 # Sort by shortnames to make printing of skipped tests consistent
521 skipped_jobs.sort(key=lambda job: job.shortname)
522 for job in list(skipped_jobs):
523 print(' %s' % job.shortname)
524 jobs = relevant_jobs
Matt Kwong7e9bd6c2016-10-24 17:30:25 -0700525
ncteisen888093c2017-12-11 18:00:40 -0800526 print('Will run these tests:')
527 for job in jobs:
528 if args.dry_run:
529 print(' %s: "%s"' % (job.shortname, ' '.join(job.cmdline)))
530 else:
531 print(' %s' % job.shortname)
532 print
533
Matt Kwong7e9bd6c2016-10-24 17:30:25 -0700534 if args.dry_run:
ncteisen888093c2017-12-11 18:00:40 -0800535 print('--dry_run was used, exiting')
536 sys.exit(1)
537
538 jobset.message('START', 'Running test matrix.', do_newline=True)
539 num_failures, resultset = jobset.run(
540 jobs, newline_on_success=True, travis=True, maxjobs=args.jobs)
541 # Merge skipped tests into results to show skipped tests on report.xml
542 if skipped_jobs:
543 ignored_num_skipped_failures, skipped_results = jobset.run(
544 skipped_jobs, skip_jobs=True)
545 resultset.update(skipped_results)
546 report_utils.render_junit_xml_report(
547 resultset,
548 _report_filename('aggregate_tests'),
549 suite_name='aggregate_tests')
550
551 if num_failures == 0:
552 jobset.message(
553 'SUCCESS',
554 'All run_tests.py instance finished successfully.',
555 do_newline=True)
Matt Kwong7e9bd6c2016-10-24 17:30:25 -0700556 else:
ncteisen888093c2017-12-11 18:00:40 -0800557 jobset.message(
558 'FAILED',
559 'Some run_tests.py instance have failed.',
560 do_newline=True)
561 sys.exit(1)