Nathaniel Manista | ae4fbcd | 2015-09-23 16:29:44 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python2.7 |
Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 2 | # Copyright 2015, Google Inc. |
Craig Tiller | c2c7921 | 2015-02-16 12:00:01 -0800 | [diff] [blame] | 3 | # All rights reserved. |
| 4 | # |
| 5 | # Redistribution and use in source and binary forms, with or without |
| 6 | # modification, are permitted provided that the following conditions are |
| 7 | # met: |
| 8 | # |
| 9 | # * Redistributions of source code must retain the above copyright |
| 10 | # notice, this list of conditions and the following disclaimer. |
| 11 | # * Redistributions in binary form must reproduce the above |
| 12 | # copyright notice, this list of conditions and the following disclaimer |
| 13 | # in the documentation and/or other materials provided with the |
| 14 | # distribution. |
| 15 | # * Neither the name of Google Inc. nor the names of its |
| 16 | # contributors may be used to endorse or promote products derived from |
| 17 | # this software without specific prior written permission. |
| 18 | # |
| 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 31 | """Run tests in parallel.""" |
| 32 | |
| 33 | import argparse |
Craig Tiller | 9279ac2 | 2016-01-20 17:05:23 -0800 | [diff] [blame] | 34 | import ast |
Masood Malekghassemi | 3b5b206 | 2016-06-02 20:27:20 -0700 | [diff] [blame] | 35 | import collections |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 36 | import glob |
| 37 | import itertools |
Craig Tiller | 261dd98 | 2015-01-16 16:41:45 -0800 | [diff] [blame] | 38 | import json |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 39 | import multiprocessing |
Craig Tiller | 1cc11db | 2015-01-15 22:50:50 -0800 | [diff] [blame] | 40 | import os |
Masood Malekghassemi | 3b5b206 | 2016-06-02 20:27:20 -0700 | [diff] [blame] | 41 | import os.path |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 42 | import platform |
| 43 | import random |
Craig Tiller | fe406ec | 2015-02-24 13:55:12 -0800 | [diff] [blame] | 44 | import re |
Craig Tiller | 8287523 | 2015-09-25 13:57:34 -0700 | [diff] [blame] | 45 | import socket |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 46 | import subprocess |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 47 | import sys |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 48 | import tempfile |
| 49 | import traceback |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 50 | import time |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 51 | import urllib2 |
Jan Tattermusch | 03c0106 | 2015-12-11 14:28:56 -0800 | [diff] [blame] | 52 | import uuid |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 53 | |
| 54 | import jobset |
Adele Zhou | a30f829 | 2015-11-02 13:15:46 -0800 | [diff] [blame] | 55 | import report_utils |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 56 | import watch_dirs |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 57 | |
Craig Tiller | b361b4e | 2016-01-06 11:44:17 -0800 | [diff] [blame] | 58 | |
Jan Tattermusch | 3b5121b | 2016-02-22 17:41:05 -0800 | [diff] [blame] | 59 | _ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..')) |
| 60 | os.chdir(_ROOT) |
Craig Tiller | 2cc2b84 | 2015-02-27 11:38:31 -0800 | [diff] [blame] | 61 | |
| 62 | |
Craig Tiller | 0680527 | 2015-06-11 14:46:47 -0700 | [diff] [blame] | 63 | _FORCE_ENVIRON_FOR_WRAPPERS = {} |
| 64 | |
| 65 | |
Craig Tiller | 123f137 | 2016-06-15 15:06:14 -0700 | [diff] [blame] | 66 | _POLLING_STRATEGIES = { |
Sree Kuchibhotla | c3a9fae | 2016-06-21 16:31:08 -0700 | [diff] [blame] | 67 | 'linux': ['epoll', 'poll', 'legacy'] |
Craig Tiller | 123f137 | 2016-06-15 15:06:14 -0700 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | |
Craig Tiller | d50993d | 2015-08-05 08:04:36 -0700 | [diff] [blame] | 71 | def platform_string(): |
Nicolas "Pixel" Noble | f72d7b5 | 2015-12-03 03:07:43 +0100 | [diff] [blame] | 72 | return jobset.platform_string() |
Craig Tiller | d50993d | 2015-08-05 08:04:36 -0700 | [diff] [blame] | 73 | |
| 74 | |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 75 | # SimpleConfig: just compile with CONFIG=config, and run the binary to test |
Craig Tiller | a0f8517 | 2016-01-20 15:56:06 -0800 | [diff] [blame] | 76 | class Config(object): |
Craig Tiller | b50d166 | 2015-01-15 17:28:21 -0800 | [diff] [blame] | 77 | |
Craig Tiller | a0f8517 | 2016-01-20 15:56:06 -0800 | [diff] [blame] | 78 | def __init__(self, config, environ=None, timeout_multiplier=1, tool_prefix=[]): |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 79 | if environ is None: |
| 80 | environ = {} |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 81 | self.build_config = config |
Craig Tiller | 547db2b | 2015-01-30 14:08:39 -0800 | [diff] [blame] | 82 | self.environ = environ |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 83 | self.environ['CONFIG'] = config |
Craig Tiller | a0f8517 | 2016-01-20 15:56:06 -0800 | [diff] [blame] | 84 | self.tool_prefix = tool_prefix |
Masood Malekghassemi | 26ea9e2 | 2015-10-09 15:19:17 -0700 | [diff] [blame] | 85 | self.timeout_multiplier = timeout_multiplier |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 86 | |
Craig Tiller | 74189cd | 2016-06-23 15:39:06 -0700 | [diff] [blame] | 87 | def job_spec(self, cmdline, timeout_seconds=5*60, |
Craig Tiller | de7edf8 | 2016-03-20 09:12:16 -0700 | [diff] [blame] | 88 | shortname=None, environ={}, cpu_cost=1.0, flaky=False): |
Craig Tiller | 49f6132 | 2015-03-03 13:02:11 -0800 | [diff] [blame] | 89 | """Construct a jobset.JobSpec for a test under this config |
| 90 | |
| 91 | Args: |
| 92 | cmdline: a list of strings specifying the command line the test |
| 93 | would like to run |
Craig Tiller | 49f6132 | 2015-03-03 13:02:11 -0800 | [diff] [blame] | 94 | """ |
Craig Tiller | 4fc9003 | 2015-05-21 10:39:52 -0700 | [diff] [blame] | 95 | actual_environ = self.environ.copy() |
| 96 | for k, v in environ.iteritems(): |
| 97 | actual_environ[k] = v |
Craig Tiller | a0f8517 | 2016-01-20 15:56:06 -0800 | [diff] [blame] | 98 | return jobset.JobSpec(cmdline=self.tool_prefix + cmdline, |
Jan Tattermusch | 9a7d30c | 2015-04-23 16:12:55 -0700 | [diff] [blame] | 99 | shortname=shortname, |
Craig Tiller | 4fc9003 | 2015-05-21 10:39:52 -0700 | [diff] [blame] | 100 | environ=actual_environ, |
Craig Tiller | 56c6b6a | 2016-01-20 08:27:37 -0800 | [diff] [blame] | 101 | cpu_cost=cpu_cost, |
Craig Tiller | 94d04a5 | 2016-01-20 10:58:23 -0800 | [diff] [blame] | 102 | timeout_seconds=(self.timeout_multiplier * timeout_seconds if timeout_seconds else None), |
Craig Tiller | de7edf8 | 2016-03-20 09:12:16 -0700 | [diff] [blame] | 103 | flake_retries=5 if flaky or args.allow_flakes else 0, |
Craig Tiller | 35505de | 2015-10-08 13:31:33 -0700 | [diff] [blame] | 104 | timeout_retries=3 if args.allow_flakes else 0) |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 105 | |
| 106 | |
murgatroid99 | cf08daf | 2015-09-21 15:33:16 -0700 | [diff] [blame] | 107 | def get_c_tests(travis, test_lang) : |
| 108 | out = [] |
| 109 | platforms_str = 'ci_platforms' if travis else 'platforms' |
| 110 | with open('tools/run_tests/tests.json') as f: |
murgatroid99 | 89899b1 | 2015-09-22 09:14:48 -0700 | [diff] [blame] | 111 | js = json.load(f) |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 112 | return [tgt |
| 113 | for tgt in js |
| 114 | if tgt['language'] == test_lang and |
| 115 | platform_string() in tgt[platforms_str] and |
| 116 | not (travis and tgt['flaky'])] |
murgatroid99 | cf08daf | 2015-09-21 15:33:16 -0700 | [diff] [blame] | 117 | |
murgatroid99 | fafeeb3 | 2015-09-22 09:13:03 -0700 | [diff] [blame] | 118 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 119 | def _check_compiler(compiler, supported_compilers): |
| 120 | if compiler not in supported_compilers: |
Jan Tattermusch | b2531e2 | 2016-03-25 16:14:41 -0700 | [diff] [blame] | 121 | raise Exception('Compiler %s not supported (on this platform).' % compiler) |
| 122 | |
| 123 | |
| 124 | def _check_arch(arch, supported_archs): |
| 125 | if arch not in supported_archs: |
| 126 | raise Exception('Architecture %s not supported.' % arch) |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 127 | |
| 128 | |
Jan Tattermusch | c4cbe39 | 2016-02-22 19:29:38 -0800 | [diff] [blame] | 129 | def _is_use_docker_child(): |
| 130 | """Returns True if running running as a --use_docker child.""" |
| 131 | return True if os.getenv('RUN_TESTS_COMMAND') else False |
| 132 | |
| 133 | |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 134 | class CLanguage(object): |
| 135 | |
Craig Tiller | e9c959d | 2015-01-18 10:23:26 -0800 | [diff] [blame] | 136 | def __init__(self, make_target, test_lang): |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 137 | self.make_target = make_target |
Craig Tiller | d50993d | 2015-08-05 08:04:36 -0700 | [diff] [blame] | 138 | self.platform = platform_string() |
Craig Tiller | 711bbe6 | 2015-08-19 12:35:16 -0700 | [diff] [blame] | 139 | self.test_lang = test_lang |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 140 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 141 | def configure(self, config, args): |
| 142 | self.config = config |
| 143 | self.args = args |
| 144 | if self.platform == 'windows': |
Jan Tattermusch | c96caf8 | 2016-02-22 17:31:02 -0800 | [diff] [blame] | 145 | self._make_options = [_windows_toolset_option(self.args.compiler), |
| 146 | _windows_arch_option(self.args.arch)] |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 147 | else: |
Jan Tattermusch | d4726c1 | 2016-02-23 16:57:36 -0800 | [diff] [blame] | 148 | self._docker_distro, self._make_options = self._compiler_options(self.args.use_docker, |
| 149 | self.args.compiler) |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 150 | |
| 151 | def test_specs(self): |
Craig Tiller | 547db2b | 2015-01-30 14:08:39 -0800 | [diff] [blame] | 152 | out = [] |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 153 | binaries = get_c_tests(self.args.travis, self.test_lang) |
Craig Tiller | 946ce7a | 2016-04-06 10:35:58 -0700 | [diff] [blame] | 154 | for target in binaries: |
Craig Tiller | 123f137 | 2016-06-15 15:06:14 -0700 | [diff] [blame] | 155 | polling_strategies = (_POLLING_STRATEGIES.get(self.platform, ['all']) |
Craig Tiller | 946ce7a | 2016-04-06 10:35:58 -0700 | [diff] [blame] | 156 | if target.get('uses_polling', True) |
| 157 | else ['all']) |
| 158 | for polling_strategy in polling_strategies: |
| 159 | env={'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH': |
| 160 | _ROOT + '/src/core/lib/tsi/test_creds/ca.pem', |
Craig Tiller | ed73510 | 2016-04-06 12:59:23 -0700 | [diff] [blame] | 161 | 'GRPC_POLL_STRATEGY': polling_strategy} |
Craig Tiller | 946ce7a | 2016-04-06 10:35:58 -0700 | [diff] [blame] | 162 | shortname_ext = '' if polling_strategy=='all' else ' polling=%s' % polling_strategy |
Craig Tiller | b38197e | 2016-02-26 10:14:54 -0800 | [diff] [blame] | 163 | if self.config.build_config in target['exclude_configs']: |
| 164 | continue |
| 165 | if self.platform == 'windows': |
| 166 | binary = 'vsprojects/%s%s/%s.exe' % ( |
| 167 | 'x64/' if self.args.arch == 'x64' else '', |
| 168 | _MSBUILD_CONFIG[self.config.build_config], |
| 169 | target['name']) |
Craig Tiller | ca62ff0 | 2016-02-24 22:22:57 -0800 | [diff] [blame] | 170 | else: |
Craig Tiller | b38197e | 2016-02-26 10:14:54 -0800 | [diff] [blame] | 171 | binary = 'bins/%s/%s' % (self.config.build_config, target['name']) |
| 172 | if os.path.isfile(binary): |
| 173 | if 'gtest' in target and target['gtest']: |
| 174 | # here we parse the output of --gtest_list_tests to build up a |
| 175 | # complete list of the tests contained in a binary |
| 176 | # for each test, we then add a job to run, filtering for just that |
| 177 | # test |
| 178 | with open(os.devnull, 'w') as fnull: |
| 179 | tests = subprocess.check_output([binary, '--gtest_list_tests'], |
| 180 | stderr=fnull) |
| 181 | base = None |
| 182 | for line in tests.split('\n'): |
| 183 | i = line.find('#') |
| 184 | if i >= 0: line = line[:i] |
| 185 | if not line: continue |
| 186 | if line[0] != ' ': |
| 187 | base = line.strip() |
| 188 | else: |
| 189 | assert base is not None |
| 190 | assert line[1] == ' ' |
| 191 | test = base + line.strip() |
| 192 | cmdline = [binary] + ['--gtest_filter=%s' % test] |
| 193 | out.append(self.config.job_spec(cmdline, [binary], |
Craig Tiller | 334db35 | 2016-02-26 15:19:49 -0800 | [diff] [blame] | 194 | shortname='%s:%s %s' % (binary, test, shortname_ext), |
Craig Tiller | b38197e | 2016-02-26 10:14:54 -0800 | [diff] [blame] | 195 | cpu_cost=target['cpu_cost'], |
| 196 | environ=env)) |
| 197 | else: |
| 198 | cmdline = [binary] + target['args'] |
| 199 | out.append(self.config.job_spec(cmdline, [binary], |
| 200 | shortname=' '.join(cmdline) + shortname_ext, |
| 201 | cpu_cost=target['cpu_cost'], |
Craig Tiller | c227815 | 2016-03-21 08:59:54 -0700 | [diff] [blame] | 202 | flaky=target.get('flaky', False), |
Craig Tiller | b38197e | 2016-02-26 10:14:54 -0800 | [diff] [blame] | 203 | environ=env)) |
| 204 | elif self.args.regex == '.*' or self.platform == 'windows': |
| 205 | print '\nWARNING: binary not found, skipping', binary |
Nicolas Noble | e144536 | 2015-05-11 17:40:26 -0700 | [diff] [blame] | 206 | return sorted(out) |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 207 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 208 | def make_targets(self): |
| 209 | test_regex = self.args.regex |
| 210 | if self.platform != 'windows' and self.args.regex != '.*': |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 211 | # use the regex to minimize the number of things to build |
Craig Tiller | b0f275e | 2016-01-27 10:45:50 -0800 | [diff] [blame] | 212 | return [os.path.basename(target['name']) |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 213 | for target in get_c_tests(False, self.test_lang) |
Craig Tiller | b0f275e | 2016-01-27 10:45:50 -0800 | [diff] [blame] | 214 | if re.search(test_regex, '/' + target['name'])] |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 215 | if self.platform == 'windows': |
Craig Tiller | 7bb3efd | 2015-09-01 08:04:03 -0700 | [diff] [blame] | 216 | # don't build tools on windows just yet |
| 217 | return ['buildtests_%s' % self.make_target] |
Craig Tiller | 7552f0f | 2015-06-19 17:46:20 -0700 | [diff] [blame] | 218 | return ['buildtests_%s' % self.make_target, 'tools_%s' % self.make_target] |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 219 | |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 220 | def make_options(self): |
Jan Tattermusch | c96caf8 | 2016-02-22 17:31:02 -0800 | [diff] [blame] | 221 | return self._make_options; |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 222 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 223 | def pre_build_steps(self): |
Jan Tattermusch | 874aec0 | 2015-10-07 19:26:19 -0700 | [diff] [blame] | 224 | if self.platform == 'windows': |
| 225 | return [['tools\\run_tests\\pre_build_c.bat']] |
| 226 | else: |
| 227 | return [] |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 228 | |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 229 | def build_steps(self): |
| 230 | return [] |
| 231 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 232 | def post_tests_steps(self): |
| 233 | if self.platform == 'windows': |
| 234 | return [] |
| 235 | else: |
| 236 | return [['tools/run_tests/post_tests_c.sh']] |
| 237 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 238 | def makefile_name(self): |
| 239 | return 'Makefile' |
| 240 | |
Jan Tattermusch | 6d258c5 | 2016-06-10 09:36:51 -0700 | [diff] [blame] | 241 | def _clang_make_options(self, version_suffix=''): |
| 242 | return ['CC=clang%s' % version_suffix, |
| 243 | 'CXX=clang++%s' % version_suffix, |
| 244 | 'LD=clang%s' % version_suffix, |
| 245 | 'LDXX=clang++%s' % version_suffix] |
Jan Tattermusch | d4726c1 | 2016-02-23 16:57:36 -0800 | [diff] [blame] | 246 | |
Jan Tattermusch | 6d258c5 | 2016-06-10 09:36:51 -0700 | [diff] [blame] | 247 | def _gcc_make_options(self, version_suffix): |
| 248 | return ['CC=gcc%s' % version_suffix, |
| 249 | 'CXX=g++%s' % version_suffix, |
| 250 | 'LD=gcc%s' % version_suffix, |
| 251 | 'LDXX=g++%s' % version_suffix] |
Jan Tattermusch | 9bb7062 | 2016-03-18 10:28:54 -0700 | [diff] [blame] | 252 | |
Jan Tattermusch | d4726c1 | 2016-02-23 16:57:36 -0800 | [diff] [blame] | 253 | def _compiler_options(self, use_docker, compiler): |
| 254 | """Returns docker distro and make options to use for given compiler.""" |
Jan Tattermusch | fd3857b | 2016-06-03 12:24:03 -0700 | [diff] [blame] | 255 | if not use_docker and not _is_use_docker_child(): |
Jan Tattermusch | c4cbe39 | 2016-02-22 19:29:38 -0800 | [diff] [blame] | 256 | _check_compiler(compiler, ['default']) |
| 257 | |
| 258 | if compiler == 'gcc4.9' or compiler == 'default': |
Jan Tattermusch | d4726c1 | 2016-02-23 16:57:36 -0800 | [diff] [blame] | 259 | return ('jessie', []) |
Jan Tattermusch | c4cbe39 | 2016-02-22 19:29:38 -0800 | [diff] [blame] | 260 | elif compiler == 'gcc4.4': |
Jan Tattermusch | 6d258c5 | 2016-06-10 09:36:51 -0700 | [diff] [blame] | 261 | return ('wheezy', self._gcc_make_options(version_suffix='-4.4')) |
| 262 | elif compiler == 'gcc4.6': |
| 263 | return ('wheezy', self._gcc_make_options(version_suffix='-4.6')) |
Jan Tattermusch | c4cbe39 | 2016-02-22 19:29:38 -0800 | [diff] [blame] | 264 | elif compiler == 'gcc5.3': |
Jan Tattermusch | d4726c1 | 2016-02-23 16:57:36 -0800 | [diff] [blame] | 265 | return ('ubuntu1604', []) |
| 266 | elif compiler == 'clang3.4': |
Jan Tattermusch | 6d258c5 | 2016-06-10 09:36:51 -0700 | [diff] [blame] | 267 | # on ubuntu1404, clang-3.4 alias doesn't exist, just use 'clang' |
Jan Tattermusch | d4726c1 | 2016-02-23 16:57:36 -0800 | [diff] [blame] | 268 | return ('ubuntu1404', self._clang_make_options()) |
Jan Tattermusch | 6d258c5 | 2016-06-10 09:36:51 -0700 | [diff] [blame] | 269 | elif compiler == 'clang3.5': |
| 270 | return ('jessie', self._clang_make_options(version_suffix='-3.5')) |
Jan Tattermusch | d4726c1 | 2016-02-23 16:57:36 -0800 | [diff] [blame] | 271 | elif compiler == 'clang3.6': |
Jan Tattermusch | 6d258c5 | 2016-06-10 09:36:51 -0700 | [diff] [blame] | 272 | return ('ubuntu1604', self._clang_make_options(version_suffix='-3.6')) |
| 273 | elif compiler == 'clang3.7': |
| 274 | return ('ubuntu1604', self._clang_make_options(version_suffix='-3.7')) |
Jan Tattermusch | c4cbe39 | 2016-02-22 19:29:38 -0800 | [diff] [blame] | 275 | else: |
| 276 | raise Exception('Compiler %s not supported.' % compiler) |
| 277 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 278 | def dockerfile_dir(self): |
Jan Tattermusch | c4cbe39 | 2016-02-22 19:29:38 -0800 | [diff] [blame] | 279 | return 'tools/dockerfile/test/cxx_%s_%s' % (self._docker_distro, |
| 280 | _docker_arch_suffix(self.args.arch)) |
Jan Tattermusch | 788ee23 | 2016-01-26 12:19:44 -0800 | [diff] [blame] | 281 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 282 | def __str__(self): |
| 283 | return self.make_target |
| 284 | |
Craig Tiller | cc0535d | 2015-12-08 15:14:47 -0800 | [diff] [blame] | 285 | |
murgatroid99 | 2c8d516 | 2015-01-26 10:41:21 -0800 | [diff] [blame] | 286 | class NodeLanguage(object): |
| 287 | |
Jan Tattermusch | e477b84 | 2016-02-06 22:19:01 -0800 | [diff] [blame] | 288 | def __init__(self): |
Michael Lumish | aaa876a | 2016-02-10 15:27:58 -0800 | [diff] [blame] | 289 | self.platform = platform_string() |
Jan Tattermusch | e477b84 | 2016-02-06 22:19:01 -0800 | [diff] [blame] | 290 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 291 | def configure(self, config, args): |
| 292 | self.config = config |
| 293 | self.args = args |
murgatroid99 | 9fab438 | 2016-04-29 15:05:00 -0700 | [diff] [blame] | 294 | _check_compiler(self.args.compiler, ['default', 'node0.12', |
| 295 | 'node4', 'node5']) |
| 296 | if self.args.compiler == 'default': |
| 297 | self.node_version = '4' |
| 298 | else: |
| 299 | # Take off the word "node" |
| 300 | self.node_version = self.args.compiler[4:] |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 301 | |
| 302 | def test_specs(self): |
Michael Lumish | aaa876a | 2016-02-10 15:27:58 -0800 | [diff] [blame] | 303 | if self.platform == 'windows': |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 304 | return [self.config.job_spec(['tools\\run_tests\\run_node.bat'], None)] |
Michael Lumish | aaa876a | 2016-02-10 15:27:58 -0800 | [diff] [blame] | 305 | else: |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 306 | return [self.config.job_spec(['tools/run_tests/run_node.sh', self.node_version], |
| 307 | None, |
| 308 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)] |
murgatroid99 | 2c8d516 | 2015-01-26 10:41:21 -0800 | [diff] [blame] | 309 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 310 | def pre_build_steps(self): |
Michael Lumish | aaa876a | 2016-02-10 15:27:58 -0800 | [diff] [blame] | 311 | if self.platform == 'windows': |
| 312 | return [['tools\\run_tests\\pre_build_node.bat']] |
| 313 | else: |
| 314 | return [['tools/run_tests/pre_build_node.sh', self.node_version]] |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 315 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 316 | def make_targets(self): |
murgatroid99 | db5b160 | 2015-10-01 13:20:11 -0700 | [diff] [blame] | 317 | return [] |
murgatroid99 | 2c8d516 | 2015-01-26 10:41:21 -0800 | [diff] [blame] | 318 | |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 319 | def make_options(self): |
| 320 | return [] |
| 321 | |
murgatroid99 | 2c8d516 | 2015-01-26 10:41:21 -0800 | [diff] [blame] | 322 | def build_steps(self): |
Michael Lumish | aaa876a | 2016-02-10 15:27:58 -0800 | [diff] [blame] | 323 | if self.platform == 'windows': |
| 324 | return [['tools\\run_tests\\build_node.bat']] |
| 325 | else: |
| 326 | return [['tools/run_tests/build_node.sh', self.node_version]] |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 327 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 328 | def post_tests_steps(self): |
| 329 | return [] |
| 330 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 331 | def makefile_name(self): |
| 332 | return 'Makefile' |
| 333 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 334 | def dockerfile_dir(self): |
| 335 | return 'tools/dockerfile/test/node_jessie_%s' % _docker_arch_suffix(self.args.arch) |
Jan Tattermusch | 788ee23 | 2016-01-26 12:19:44 -0800 | [diff] [blame] | 336 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 337 | def __str__(self): |
| 338 | return 'node' |
| 339 | |
Craig Tiller | 9977582 | 2015-01-30 13:07:16 -0800 | [diff] [blame] | 340 | |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 341 | class PhpLanguage(object): |
| 342 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 343 | def configure(self, config, args): |
| 344 | self.config = config |
| 345 | self.args = args |
| 346 | _check_compiler(self.args.compiler, ['default']) |
| 347 | |
| 348 | def test_specs(self): |
| 349 | return [self.config.job_spec(['src/php/bin/run_tests.sh'], None, |
| 350 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)] |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 351 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 352 | def pre_build_steps(self): |
| 353 | return [] |
| 354 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 355 | def make_targets(self): |
Craig Tiller | af7cf54 | 2015-05-22 10:07:34 -0700 | [diff] [blame] | 356 | return ['static_c', 'shared_c'] |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 357 | |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 358 | def make_options(self): |
| 359 | return [] |
| 360 | |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 361 | def build_steps(self): |
| 362 | return [['tools/run_tests/build_php.sh']] |
| 363 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 364 | def post_tests_steps(self): |
Stanley Cheung | a6b9548 | 2016-01-13 16:10:48 -0800 | [diff] [blame] | 365 | return [['tools/run_tests/post_tests_php.sh']] |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 366 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 367 | def makefile_name(self): |
| 368 | return 'Makefile' |
| 369 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 370 | def dockerfile_dir(self): |
| 371 | return 'tools/dockerfile/test/php_jessie_%s' % _docker_arch_suffix(self.args.arch) |
Jan Tattermusch | 788ee23 | 2016-01-26 12:19:44 -0800 | [diff] [blame] | 372 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 373 | def __str__(self): |
| 374 | return 'php' |
| 375 | |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 376 | |
Masood Malekghassemi | 3b5b206 | 2016-06-02 20:27:20 -0700 | [diff] [blame] | 377 | class PythonConfig(collections.namedtuple('PythonConfig', [ |
Masood Malekghassemi | cab9d4f | 2016-06-28 09:09:31 -0700 | [diff] [blame^] | 378 | 'name', 'build', 'run'])): |
| 379 | """Tuple of commands (named s.t. 'what it says on the tin' applies)""" |
Masood Malekghassemi | 3b5b206 | 2016-06-02 20:27:20 -0700 | [diff] [blame] | 380 | |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 381 | class PythonLanguage(object): |
| 382 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 383 | def configure(self, config, args): |
| 384 | self.config = config |
| 385 | self.args = args |
Masood Malekghassemi | cab9d4f | 2016-06-28 09:09:31 -0700 | [diff] [blame^] | 386 | self.pythons = self._get_pythons(self.args) |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 387 | |
| 388 | def test_specs(self): |
Jan Tattermusch | 072ebaa | 2016-03-01 18:33:12 -0800 | [diff] [blame] | 389 | # load list of known test suites |
Masood Malekghassemi | 1ff429d | 2016-06-02 16:39:20 -0700 | [diff] [blame] | 390 | with open('src/python/grpcio_tests/tests/tests.json') as tests_json_file: |
Jan Tattermusch | 072ebaa | 2016-03-01 18:33:12 -0800 | [diff] [blame] | 391 | tests_json = json.load(tests_json_file) |
Masood Malekghassemi | 2b84162 | 2015-07-28 17:39:02 -0700 | [diff] [blame] | 392 | environment = dict(_FORCE_ENVIRON_FOR_WRAPPERS) |
Masood Malekghassemi | 1c062bd | 2016-06-13 18:41:36 -0700 | [diff] [blame] | 393 | return [self.config.job_spec( |
Masood Malekghassemi | cab9d4f | 2016-06-28 09:09:31 -0700 | [diff] [blame^] | 394 | config.run, |
Masood Malekghassemi | e6a23e2 | 2016-06-28 13:58:42 -0700 | [diff] [blame] | 395 | timeout_seconds=5*60, |
Masood Malekghassemi | 1c062bd | 2016-06-13 18:41:36 -0700 | [diff] [blame] | 396 | environ=dict(environment.items() + |
| 397 | [('GRPC_PYTHON_TESTRUNNER_FILTER', suite_name)]), |
Masood Malekghassemi | cab9d4f | 2016-06-28 09:09:31 -0700 | [diff] [blame^] | 398 | shortname='%s.test.%s' % (config.name, suite_name),) |
Masood Malekghassemi | 1c062bd | 2016-06-13 18:41:36 -0700 | [diff] [blame] | 399 | for suite_name in tests_json |
| 400 | for config in self.pythons] |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 401 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 402 | def pre_build_steps(self): |
| 403 | return [] |
| 404 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 405 | def make_targets(self): |
Masood Malekghassemi | 3b5b206 | 2016-06-02 20:27:20 -0700 | [diff] [blame] | 406 | return [] |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 407 | |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 408 | def make_options(self): |
| 409 | return [] |
| 410 | |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 411 | def build_steps(self): |
Masood Malekghassemi | cab9d4f | 2016-06-28 09:09:31 -0700 | [diff] [blame^] | 412 | return [config.build for config in self.pythons] |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 413 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 414 | def post_tests_steps(self): |
| 415 | return [] |
| 416 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 417 | def makefile_name(self): |
| 418 | return 'Makefile' |
| 419 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 420 | def dockerfile_dir(self): |
| 421 | return 'tools/dockerfile/test/python_jessie_%s' % _docker_arch_suffix(self.args.arch) |
Jan Tattermusch | 788ee23 | 2016-01-26 12:19:44 -0800 | [diff] [blame] | 422 | |
Masood Malekghassemi | cab9d4f | 2016-06-28 09:09:31 -0700 | [diff] [blame^] | 423 | def _get_pythons(self, args): |
| 424 | if args.arch == 'x86': |
| 425 | bits = '32' |
Masood Malekghassemi | 3b5b206 | 2016-06-02 20:27:20 -0700 | [diff] [blame] | 426 | else: |
Masood Malekghassemi | cab9d4f | 2016-06-28 09:09:31 -0700 | [diff] [blame^] | 427 | bits = '64' |
| 428 | if os.name == 'nt': |
| 429 | shell = ['bash'] |
| 430 | builder = [os.path.abspath('tools/run_tests/build_python_msys2.sh')] |
| 431 | builder_prefix_arguments = ['MINGW{}'.format(bits)] |
| 432 | venv_relative_python = ['Scripts/python.exe'] |
| 433 | toolchain = ['mingw32'] |
| 434 | python_pattern_function = lambda major, minor, bits: ( |
| 435 | '/c/Python{major}{minor}/python.exe'.format(major=major, minor=minor, bits=bits) |
| 436 | if bits == '64' else |
| 437 | '/c/Python{major}{minor}_{bits}bits/python.exe'.format( |
| 438 | major=major, minor=minor, bits=bits)) |
| 439 | else: |
| 440 | shell = [] |
| 441 | builder = [os.path.abspath('tools/run_tests/build_python.sh')] |
| 442 | builder_prefix_arguments = [] |
| 443 | venv_relative_python = ['bin/python'] |
| 444 | toolchain = ['unix'] |
| 445 | # Bit-ness is handled by the test machine's environment |
| 446 | python_pattern_function = lambda major, minor, bits: 'python{major}.{minor}'.format(major=major, minor=minor) |
| 447 | runner = [os.path.abspath('tools/run_tests/run_python.sh')] |
| 448 | python_config_generator = lambda name, major, minor, bits: PythonConfig( |
| 449 | name, |
| 450 | shell + builder + builder_prefix_arguments |
| 451 | + [python_pattern_function(major=major, minor=minor, bits=bits)] |
| 452 | + [name] + venv_relative_python + toolchain, |
| 453 | shell + runner + [os.path.join(name, venv_relative_python[0])]) |
| 454 | python27_config = python_config_generator(name='py27', major='2', minor='7', bits=bits) |
| 455 | python34_config = python_config_generator(name='py34', major='3', minor='4', bits=bits) |
| 456 | if args.compiler == 'default': |
| 457 | if os.name == 'nt': |
| 458 | return (python27_config,) |
| 459 | else: |
| 460 | return (python27_config, python34_config,) |
| 461 | elif args.compiler == 'python2.7': |
Masood Malekghassemi | 3b5b206 | 2016-06-02 20:27:20 -0700 | [diff] [blame] | 462 | return (python27_config,) |
Masood Malekghassemi | cab9d4f | 2016-06-28 09:09:31 -0700 | [diff] [blame^] | 463 | elif args.compiler == 'python3.4': |
Masood Malekghassemi | 3b5b206 | 2016-06-02 20:27:20 -0700 | [diff] [blame] | 464 | return (python34_config,) |
Jan Tattermusch | 825471c | 2016-04-25 16:52:25 -0700 | [diff] [blame] | 465 | else: |
Masood Malekghassemi | cab9d4f | 2016-06-28 09:09:31 -0700 | [diff] [blame^] | 466 | raise Exception('Compiler %s not supported.' % args.compiler) |
Jan Tattermusch | 825471c | 2016-04-25 16:52:25 -0700 | [diff] [blame] | 467 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 468 | def __str__(self): |
| 469 | return 'python' |
| 470 | |
Craig Tiller | d625d81 | 2015-04-08 15:52:35 -0700 | [diff] [blame] | 471 | |
murgatroid99 | 6a4c4fa | 2015-02-27 12:08:57 -0800 | [diff] [blame] | 472 | class RubyLanguage(object): |
| 473 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 474 | def configure(self, config, args): |
| 475 | self.config = config |
| 476 | self.args = args |
| 477 | _check_compiler(self.args.compiler, ['default']) |
| 478 | |
| 479 | def test_specs(self): |
Craig Tiller | eb5e437 | 2016-06-23 16:16:10 -0700 | [diff] [blame] | 480 | return [self.config.job_spec(['tools/run_tests/run_ruby.sh'], |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 481 | timeout_seconds=10*60, |
| 482 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)] |
murgatroid99 | 6a4c4fa | 2015-02-27 12:08:57 -0800 | [diff] [blame] | 483 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 484 | def pre_build_steps(self): |
Nicolas "Pixel" Noble | bcf988f | 2015-10-08 03:00:42 +0200 | [diff] [blame] | 485 | return [['tools/run_tests/pre_build_ruby.sh']] |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 486 | |
Jan Tattermusch | 4651bef | 2016-02-23 08:31:25 -0800 | [diff] [blame] | 487 | def make_targets(self): |
murgatroid99 | 7d243df | 2016-02-18 09:58:05 -0800 | [diff] [blame] | 488 | return [] |
murgatroid99 | 6a4c4fa | 2015-02-27 12:08:57 -0800 | [diff] [blame] | 489 | |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 490 | def make_options(self): |
| 491 | return [] |
| 492 | |
murgatroid99 | 6a4c4fa | 2015-02-27 12:08:57 -0800 | [diff] [blame] | 493 | def build_steps(self): |
| 494 | return [['tools/run_tests/build_ruby.sh']] |
| 495 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 496 | def post_tests_steps(self): |
Nicolas "Pixel" Noble | 7ef1e53 | 2015-12-02 00:55:33 +0100 | [diff] [blame] | 497 | return [['tools/run_tests/post_tests_ruby.sh']] |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 498 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 499 | def makefile_name(self): |
| 500 | return 'Makefile' |
| 501 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 502 | def dockerfile_dir(self): |
| 503 | return 'tools/dockerfile/test/ruby_jessie_%s' % _docker_arch_suffix(self.args.arch) |
Jan Tattermusch | 788ee23 | 2016-01-26 12:19:44 -0800 | [diff] [blame] | 504 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 505 | def __str__(self): |
| 506 | return 'ruby' |
| 507 | |
Craig Tiller | d625d81 | 2015-04-08 15:52:35 -0700 | [diff] [blame] | 508 | |
Jan Tattermusch | 1970a5b | 2015-03-03 15:17:25 -0800 | [diff] [blame] | 509 | class CSharpLanguage(object): |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 510 | |
Jan Tattermusch | b00aa67 | 2015-06-01 15:48:03 -0700 | [diff] [blame] | 511 | def __init__(self): |
Craig Tiller | d50993d | 2015-08-05 08:04:36 -0700 | [diff] [blame] | 512 | self.platform = platform_string() |
Jan Tattermusch | b00aa67 | 2015-06-01 15:48:03 -0700 | [diff] [blame] | 513 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 514 | def configure(self, config, args): |
| 515 | self.config = config |
| 516 | self.args = args |
Jan Tattermusch | 6d28d35 | 2016-03-25 15:07:22 -0700 | [diff] [blame] | 517 | if self.platform == 'windows': |
Jan Tattermusch | b2531e2 | 2016-03-25 16:14:41 -0700 | [diff] [blame] | 518 | # Explicitly choosing between x86 and x64 arch doesn't work yet |
| 519 | _check_arch(self.args.arch, ['default']) |
Jan Tattermusch | 6e2f88c | 2016-06-21 10:52:40 -0700 | [diff] [blame] | 520 | # CoreCLR use 64bit runtime by default. |
| 521 | arch_option = 'x64' if self.args.compiler == 'coreclr' else self.args.arch |
Jan Tattermusch | 6d28d35 | 2016-03-25 15:07:22 -0700 | [diff] [blame] | 522 | self._make_options = [_windows_toolset_option(self.args.compiler), |
Jan Tattermusch | 6e2f88c | 2016-06-21 10:52:40 -0700 | [diff] [blame] | 523 | _windows_arch_option(arch_option)] |
Jan Tattermusch | 6d28d35 | 2016-03-25 15:07:22 -0700 | [diff] [blame] | 524 | else: |
Jan Tattermusch | bc98af1 | 2016-06-17 18:38:27 -0700 | [diff] [blame] | 525 | _check_compiler(self.args.compiler, ['default', 'coreclr']) |
| 526 | if self.platform == 'linux' and self.args.compiler == 'coreclr': |
| 527 | self._docker_distro = 'coreclr' |
Jan Tattermusch | 743decd | 2016-06-21 11:40:47 -0700 | [diff] [blame] | 528 | else: |
| 529 | self._docker_distro = 'jessie' |
Jan Tattermusch | 76511a5 | 2016-06-17 14:00:57 -0700 | [diff] [blame] | 530 | |
Jan Tattermusch | 6d28d35 | 2016-03-25 15:07:22 -0700 | [diff] [blame] | 531 | if self.platform == 'mac': |
Jan Tattermusch | 2a322c2 | 2016-03-30 13:55:07 -0700 | [diff] [blame] | 532 | # TODO(jtattermusch): EMBED_ZLIB=true currently breaks the mac build |
Jan Tattermusch | 6d08220 | 2016-06-21 10:03:38 -0700 | [diff] [blame] | 533 | self._make_options = ['EMBED_OPENSSL=true'] |
| 534 | if self.args.compiler != 'coreclr': |
| 535 | # On Mac, official distribution of mono is 32bit. |
| 536 | self._make_options += ['CFLAGS=-m32', 'LDFLAGS=-m32'] |
Jan Tattermusch | 6d28d35 | 2016-03-25 15:07:22 -0700 | [diff] [blame] | 537 | else: |
| 538 | self._make_options = ['EMBED_OPENSSL=true', 'EMBED_ZLIB=true'] |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 539 | |
| 540 | def test_specs(self): |
Jan Tattermusch | 03c0106 | 2015-12-11 14:28:56 -0800 | [diff] [blame] | 541 | with open('src/csharp/tests.json') as f: |
Jan Tattermusch | 38ed2cf | 2016-04-09 16:24:16 -0700 | [diff] [blame] | 542 | tests_by_assembly = json.load(f) |
Jan Tattermusch | 03c0106 | 2015-12-11 14:28:56 -0800 | [diff] [blame] | 543 | |
Jan Tattermusch | a2d964c | 2016-02-22 17:33:09 -0800 | [diff] [blame] | 544 | msbuild_config = _MSBUILD_CONFIG[self.config.build_config] |
Jan Tattermusch | bc98af1 | 2016-06-17 18:38:27 -0700 | [diff] [blame] | 545 | nunit_args = ['--labels=All'] |
Jan Tattermusch | 76511a5 | 2016-06-17 14:00:57 -0700 | [diff] [blame] | 546 | assembly_subdir = 'bin/%s' % msbuild_config |
| 547 | assembly_extension = '.exe' |
| 548 | |
| 549 | if self.args.compiler == 'coreclr': |
Jan Tattermusch | 64c137c | 2016-06-20 17:54:19 -0700 | [diff] [blame] | 550 | if self.platform == 'linux': |
| 551 | assembly_subdir += '/netstandard1.5/debian.8-x64' |
| 552 | assembly_extension = '' |
Jan Tattermusch | 14a301d | 2016-06-27 17:45:29 -0700 | [diff] [blame] | 553 | elif self.platform == 'mac': |
Jan Tattermusch | 6d08220 | 2016-06-21 10:03:38 -0700 | [diff] [blame] | 554 | assembly_subdir += '/netstandard1.5/osx.10.11-x64' |
| 555 | assembly_extension = '' |
Jan Tattermusch | 64c137c | 2016-06-20 17:54:19 -0700 | [diff] [blame] | 556 | else: |
| 557 | assembly_subdir += '/netstandard1.5/win7-x64' |
Jan Tattermusch | 38ed2cf | 2016-04-09 16:24:16 -0700 | [diff] [blame] | 558 | runtime_cmd = [] |
Jan Tattermusch | b00aa67 | 2015-06-01 15:48:03 -0700 | [diff] [blame] | 559 | else: |
Jan Tattermusch | bc98af1 | 2016-06-17 18:38:27 -0700 | [diff] [blame] | 560 | nunit_args += ['--noresult', '--workers=1'] |
| 561 | if self.platform == 'windows': |
| 562 | runtime_cmd = [] |
| 563 | else: |
| 564 | runtime_cmd = ['mono'] |
Jan Tattermusch | bf3b153 | 2015-10-26 10:24:42 -0700 | [diff] [blame] | 565 | |
Jan Tattermusch | 38ed2cf | 2016-04-09 16:24:16 -0700 | [diff] [blame] | 566 | specs = [] |
| 567 | for assembly in tests_by_assembly.iterkeys(): |
Jan Tattermusch | 76511a5 | 2016-06-17 14:00:57 -0700 | [diff] [blame] | 568 | assembly_file = 'src/csharp/%s/%s/%s%s' % (assembly, |
| 569 | assembly_subdir, |
| 570 | assembly, |
| 571 | assembly_extension) |
Jan Tattermusch | a5f1f12 | 2016-04-11 15:49:56 -0700 | [diff] [blame] | 572 | if self.config.build_config != 'gcov' or self.platform != 'windows': |
Jan Tattermusch | 38ed2cf | 2016-04-09 16:24:16 -0700 | [diff] [blame] | 573 | # normally, run each test as a separate process |
| 574 | for test in tests_by_assembly[assembly]: |
| 575 | cmdline = runtime_cmd + [assembly_file, '--test=%s' % test] + nunit_args |
| 576 | specs.append(self.config.job_spec(cmdline, |
| 577 | None, |
| 578 | shortname='csharp.%s' % test, |
| 579 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)) |
| 580 | else: |
Jan Tattermusch | a5f1f12 | 2016-04-11 15:49:56 -0700 | [diff] [blame] | 581 | # For C# test coverage, run all tests from the same assembly at once |
| 582 | # using OpenCover.Console (only works on Windows). |
| 583 | cmdline = ['src\\csharp\\packages\\OpenCover.4.6.519\\tools\\OpenCover.Console.exe', |
| 584 | '-target:%s' % assembly_file, |
| 585 | '-targetdir:src\\csharp', |
| 586 | '-targetargs:%s' % ' '.join(nunit_args), |
| 587 | '-filter:+[Grpc.Core]*', |
| 588 | '-register:user', |
| 589 | '-output:src\\csharp\\coverage_csharp_%s.xml' % assembly] |
Jan Tattermusch | 38ed2cf | 2016-04-09 16:24:16 -0700 | [diff] [blame] | 590 | |
Jan Tattermusch | a5f1f12 | 2016-04-11 15:49:56 -0700 | [diff] [blame] | 591 | # set really high cpu_cost to make sure instances of OpenCover.Console run exclusively |
| 592 | # to prevent problems with registering the profiler. |
| 593 | run_exclusive = 1000000 |
Jan Tattermusch | 35e608f | 2016-04-09 16:35:06 -0700 | [diff] [blame] | 594 | specs.append(self.config.job_spec(cmdline, |
| 595 | None, |
Jan Tattermusch | 38ed2cf | 2016-04-09 16:24:16 -0700 | [diff] [blame] | 596 | shortname='csharp.coverage.%s' % assembly, |
Jan Tattermusch | a5f1f12 | 2016-04-11 15:49:56 -0700 | [diff] [blame] | 597 | cpu_cost=run_exclusive, |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 598 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)) |
Jan Tattermusch | 38ed2cf | 2016-04-09 16:24:16 -0700 | [diff] [blame] | 599 | return specs |
Jan Tattermusch | 1970a5b | 2015-03-03 15:17:25 -0800 | [diff] [blame] | 600 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 601 | def pre_build_steps(self): |
Jan Tattermusch | 48423fc | 2015-10-07 18:59:16 -0700 | [diff] [blame] | 602 | if self.platform == 'windows': |
Jan Tattermusch | 874aec0 | 2015-10-07 19:26:19 -0700 | [diff] [blame] | 603 | return [['tools\\run_tests\\pre_build_csharp.bat']] |
Jan Tattermusch | 48423fc | 2015-10-07 18:59:16 -0700 | [diff] [blame] | 604 | else: |
| 605 | return [['tools/run_tests/pre_build_csharp.sh']] |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 606 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 607 | def make_targets(self): |
Jan Tattermusch | 6d28d35 | 2016-03-25 15:07:22 -0700 | [diff] [blame] | 608 | return ['grpc_csharp_ext'] |
Jan Tattermusch | 1970a5b | 2015-03-03 15:17:25 -0800 | [diff] [blame] | 609 | |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 610 | def make_options(self): |
Jan Tattermusch | 6d28d35 | 2016-03-25 15:07:22 -0700 | [diff] [blame] | 611 | return self._make_options; |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 612 | |
Jan Tattermusch | 1970a5b | 2015-03-03 15:17:25 -0800 | [diff] [blame] | 613 | def build_steps(self): |
Jan Tattermusch | 76511a5 | 2016-06-17 14:00:57 -0700 | [diff] [blame] | 614 | if self.args.compiler == 'coreclr': |
Jan Tattermusch | bc98af1 | 2016-06-17 18:38:27 -0700 | [diff] [blame] | 615 | if self.platform == 'windows': |
| 616 | return [['tools\\run_tests\\build_csharp_coreclr.bat']] |
| 617 | else: |
| 618 | return [['tools/run_tests/build_csharp_coreclr.sh']] |
Jan Tattermusch | b00aa67 | 2015-06-01 15:48:03 -0700 | [diff] [blame] | 619 | else: |
Jan Tattermusch | 76511a5 | 2016-06-17 14:00:57 -0700 | [diff] [blame] | 620 | if self.platform == 'windows': |
| 621 | return [[_windows_build_bat(self.args.compiler), |
| 622 | 'src/csharp/Grpc.sln', |
| 623 | '/p:Configuration=%s' % _MSBUILD_CONFIG[self.config.build_config]]] |
| 624 | else: |
| 625 | return [['tools/run_tests/build_csharp.sh']] |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 626 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 627 | def post_tests_steps(self): |
Jan Tattermusch | 38ed2cf | 2016-04-09 16:24:16 -0700 | [diff] [blame] | 628 | if self.platform == 'windows': |
| 629 | return [['tools\\run_tests\\post_tests_csharp.bat']] |
| 630 | else: |
| 631 | return [['tools/run_tests/post_tests_csharp.sh']] |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 632 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 633 | def makefile_name(self): |
| 634 | return 'Makefile' |
| 635 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 636 | def dockerfile_dir(self): |
Jan Tattermusch | 76511a5 | 2016-06-17 14:00:57 -0700 | [diff] [blame] | 637 | return 'tools/dockerfile/test/csharp_%s_%s' % (self._docker_distro, |
| 638 | _docker_arch_suffix(self.args.arch)) |
Jan Tattermusch | 788ee23 | 2016-01-26 12:19:44 -0800 | [diff] [blame] | 639 | |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 640 | def __str__(self): |
| 641 | return 'csharp' |
| 642 | |
Craig Tiller | d625d81 | 2015-04-08 15:52:35 -0700 | [diff] [blame] | 643 | |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 644 | class ObjCLanguage(object): |
| 645 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 646 | def configure(self, config, args): |
| 647 | self.config = config |
| 648 | self.args = args |
| 649 | _check_compiler(self.args.compiler, ['default']) |
| 650 | |
| 651 | def test_specs(self): |
Jorge Canizales | 6ec3b53 | 2016-07-01 11:34:32 -0700 | [diff] [blame] | 652 | return [self.config.job_spec(['src/objective-c/tests/run_tests.sh'], |
| 653 | timeout_seconds=None, |
| 654 | shortname='objc-tests', |
| 655 | environ=_FORCE_ENVIRON_FOR_WRAPPERS), |
Yuchen Zeng | f95a489 | 2016-06-21 23:27:46 -0700 | [diff] [blame] | 656 | self.config.job_spec(['src/objective-c/tests/build_example_test.sh'], |
Jorge Canizales | 6ec3b53 | 2016-07-01 11:34:32 -0700 | [diff] [blame] | 657 | timeout_seconds=15*60, |
| 658 | shortname='objc-examples-build', |
Yuchen Zeng | c0668c8 | 2016-06-22 01:30:47 -0700 | [diff] [blame] | 659 | environ=_FORCE_ENVIRON_FOR_WRAPPERS)] |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 660 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 661 | def pre_build_steps(self): |
| 662 | return [] |
| 663 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 664 | def make_targets(self): |
Jorge Canizales | d0b32e9 | 2015-07-30 23:08:43 -0700 | [diff] [blame] | 665 | return ['grpc_objective_c_plugin', 'interop_server'] |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 666 | |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 667 | def make_options(self): |
| 668 | return [] |
| 669 | |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 670 | def build_steps(self): |
Jorge Canizales | d0b32e9 | 2015-07-30 23:08:43 -0700 | [diff] [blame] | 671 | return [['src/objective-c/tests/build_tests.sh']] |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 672 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 673 | def post_tests_steps(self): |
| 674 | return [] |
| 675 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 676 | def makefile_name(self): |
| 677 | return 'Makefile' |
| 678 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 679 | def dockerfile_dir(self): |
Jan Tattermusch | 788ee23 | 2016-01-26 12:19:44 -0800 | [diff] [blame] | 680 | return None |
| 681 | |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 682 | def __str__(self): |
| 683 | return 'objc' |
| 684 | |
| 685 | |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 686 | class Sanity(object): |
| 687 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 688 | def configure(self, config, args): |
| 689 | self.config = config |
| 690 | self.args = args |
| 691 | _check_compiler(self.args.compiler, ['default']) |
| 692 | |
| 693 | def test_specs(self): |
Craig Tiller | 94d04a5 | 2016-01-20 10:58:23 -0800 | [diff] [blame] | 694 | import yaml |
Jan Tattermusch | 788ee23 | 2016-01-26 12:19:44 -0800 | [diff] [blame] | 695 | with open('tools/run_tests/sanity/sanity_tests.yaml', 'r') as f: |
Craig Tiller | 34226af | 2016-06-24 16:46:25 -0700 | [diff] [blame] | 696 | return [self.config.job_spec(cmd['script'].split(), |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 697 | timeout_seconds=None, environ={'TEST': 'true'}, |
| 698 | cpu_cost=cmd.get('cpu_cost', 1)) |
Craig Tiller | 94d04a5 | 2016-01-20 10:58:23 -0800 | [diff] [blame] | 699 | for cmd in yaml.load(f)] |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 700 | |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 701 | def pre_build_steps(self): |
| 702 | return [] |
| 703 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 704 | def make_targets(self): |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 705 | return ['run_dep_checks'] |
| 706 | |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 707 | def make_options(self): |
| 708 | return [] |
| 709 | |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 710 | def build_steps(self): |
| 711 | return [] |
| 712 | |
Nicolas "Pixel" Noble | 87879b3 | 2015-10-12 23:28:53 +0200 | [diff] [blame] | 713 | def post_tests_steps(self): |
| 714 | return [] |
| 715 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 716 | def makefile_name(self): |
| 717 | return 'Makefile' |
| 718 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 719 | def dockerfile_dir(self): |
Jan Tattermusch | e70b3c5 | 2016-02-07 20:21:02 -0800 | [diff] [blame] | 720 | return 'tools/dockerfile/test/sanity' |
Jan Tattermusch | 788ee23 | 2016-01-26 12:19:44 -0800 | [diff] [blame] | 721 | |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 722 | def __str__(self): |
| 723 | return 'sanity' |
| 724 | |
Nicolas "Pixel" Noble | e55cd7f | 2015-04-14 17:59:13 +0200 | [diff] [blame] | 725 | |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 726 | # different configurations we can run under |
Craig Tiller | a0f8517 | 2016-01-20 15:56:06 -0800 | [diff] [blame] | 727 | with open('tools/run_tests/configs.json') as f: |
Craig Tiller | 1dce906 | 2016-01-20 17:01:56 -0800 | [diff] [blame] | 728 | _CONFIGS = dict((cfg['config'], Config(**cfg)) for cfg in ast.literal_eval(f.read())) |
Craig Tiller | 738c334 | 2015-01-12 14:28:33 -0800 | [diff] [blame] | 729 | |
| 730 | |
Craig Tiller | c744916 | 2015-01-16 14:42:10 -0800 | [diff] [blame] | 731 | _LANGUAGES = { |
Craig Tiller | e9c959d | 2015-01-18 10:23:26 -0800 | [diff] [blame] | 732 | 'c++': CLanguage('cxx', 'c++'), |
| 733 | 'c': CLanguage('c', 'c'), |
murgatroid99 | 2c8d516 | 2015-01-26 10:41:21 -0800 | [diff] [blame] | 734 | 'node': NodeLanguage(), |
Nathaniel Manista | 840615e | 2015-01-22 20:31:47 +0000 | [diff] [blame] | 735 | 'php': PhpLanguage(), |
| 736 | 'python': PythonLanguage(), |
Jan Tattermusch | 1970a5b | 2015-03-03 15:17:25 -0800 | [diff] [blame] | 737 | 'ruby': RubyLanguage(), |
Nicolas "Pixel" Noble | 9f72864 | 2015-03-24 18:50:30 +0100 | [diff] [blame] | 738 | 'csharp': CSharpLanguage(), |
Jorge Canizales | a0b3bfa | 2015-07-30 19:25:52 -0700 | [diff] [blame] | 739 | 'objc' : ObjCLanguage(), |
Jan Tattermusch | 70a57e4 | 2016-02-20 18:50:27 -0800 | [diff] [blame] | 740 | 'sanity': Sanity() |
Craig Tiller | eb272bc | 2015-01-30 13:13:14 -0800 | [diff] [blame] | 741 | } |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 742 | |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 743 | |
Jan Tattermusch | a2d964c | 2016-02-22 17:33:09 -0800 | [diff] [blame] | 744 | _MSBUILD_CONFIG = { |
Craig Tiller | 7bb3efd | 2015-09-01 08:04:03 -0700 | [diff] [blame] | 745 | 'dbg': 'Debug', |
| 746 | 'opt': 'Release', |
Jan Tattermusch | e4a6918 | 2015-12-15 09:53:01 -0800 | [diff] [blame] | 747 | 'gcov': 'Debug', |
Craig Tiller | 7bb3efd | 2015-09-01 08:04:03 -0700 | [diff] [blame] | 748 | } |
| 749 | |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 750 | |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 751 | def _windows_arch_option(arch): |
| 752 | """Returns msbuild cmdline option for selected architecture.""" |
Jan Tattermusch | 9be594f | 2016-01-25 18:08:47 -0800 | [diff] [blame] | 753 | if arch == 'default' or arch == 'x86': |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 754 | return '/p:Platform=Win32' |
Jan Tattermusch | 9be594f | 2016-01-25 18:08:47 -0800 | [diff] [blame] | 755 | elif arch == 'x64': |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 756 | return '/p:Platform=x64' |
| 757 | else: |
Jan Tattermusch | 9be594f | 2016-01-25 18:08:47 -0800 | [diff] [blame] | 758 | print 'Architecture %s not supported.' % arch |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 759 | sys.exit(1) |
Jan Tattermusch | 788ee23 | 2016-01-26 12:19:44 -0800 | [diff] [blame] | 760 | |
Jan Tattermusch | f08018a | 2016-01-26 08:22:09 -0800 | [diff] [blame] | 761 | |
| 762 | def _check_arch_option(arch): |
| 763 | """Checks that architecture option is valid.""" |
| 764 | if platform_string() == 'windows': |
| 765 | _windows_arch_option(arch) |
| 766 | elif platform_string() == 'linux': |
| 767 | # On linux, we need to be running under docker with the right architecture. |
Jan Tattermusch | 07fb042 | 2016-01-26 10:46:56 -0800 | [diff] [blame] | 768 | runtime_arch = platform.architecture()[0] |
Jan Tattermusch | f08018a | 2016-01-26 08:22:09 -0800 | [diff] [blame] | 769 | if arch == 'default': |
| 770 | return |
| 771 | elif runtime_arch == '64bit' and arch == 'x64': |
| 772 | return |
| 773 | elif runtime_arch == '32bit' and arch == 'x86': |
| 774 | return |
| 775 | else: |
| 776 | print 'Architecture %s does not match current runtime architecture.' % arch |
| 777 | sys.exit(1) |
| 778 | else: |
| 779 | if args.arch != 'default': |
| 780 | print 'Architecture %s not supported on current platform.' % args.arch |
| 781 | sys.exit(1) |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 782 | |
Jan Tattermusch | 4dc9e72 | 2016-01-25 17:00:54 -0800 | [diff] [blame] | 783 | |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 784 | def _windows_build_bat(compiler): |
| 785 | """Returns name of build.bat for selected compiler.""" |
Jan Tattermusch | bc98af1 | 2016-06-17 18:38:27 -0700 | [diff] [blame] | 786 | # For CoreCLR, fall back to the default compiler for C core |
| 787 | if compiler == 'default' or compiler == 'vs2013' or compiler == 'coreclr': |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 788 | return 'vsprojects\\build_vs2013.bat' |
| 789 | elif compiler == 'vs2015': |
| 790 | return 'vsprojects\\build_vs2015.bat' |
| 791 | elif compiler == 'vs2010': |
| 792 | return 'vsprojects\\build_vs2010.bat' |
| 793 | else: |
| 794 | print 'Compiler %s not supported.' % compiler |
| 795 | sys.exit(1) |
Jan Tattermusch | 4dc9e72 | 2016-01-25 17:00:54 -0800 | [diff] [blame] | 796 | |
| 797 | |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 798 | def _windows_toolset_option(compiler): |
| 799 | """Returns msbuild PlatformToolset for selected compiler.""" |
Jan Tattermusch | bc98af1 | 2016-06-17 18:38:27 -0700 | [diff] [blame] | 800 | # For CoreCLR, fall back to the default compiler for C core |
| 801 | if compiler == 'default' or compiler == 'vs2013' or compiler == 'coreclr': |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 802 | return '/p:PlatformToolset=v120' |
| 803 | elif compiler == 'vs2015': |
| 804 | return '/p:PlatformToolset=v140' |
| 805 | elif compiler == 'vs2010': |
| 806 | return '/p:PlatformToolset=v100' |
| 807 | else: |
| 808 | print 'Compiler %s not supported.' % compiler |
| 809 | sys.exit(1) |
Jan Tattermusch | 4dc9e72 | 2016-01-25 17:00:54 -0800 | [diff] [blame] | 810 | |
| 811 | |
Jan Tattermusch | e70b3c5 | 2016-02-07 20:21:02 -0800 | [diff] [blame] | 812 | def _docker_arch_suffix(arch): |
| 813 | """Returns suffix to dockerfile dir to use.""" |
| 814 | if arch == 'default' or arch == 'x64': |
| 815 | return 'x64' |
| 816 | elif arch == 'x86': |
| 817 | return 'x86' |
| 818 | else: |
| 819 | print 'Architecture %s not supported with current settings.' % arch |
| 820 | sys.exit(1) |
| 821 | |
| 822 | |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 823 | def runs_per_test_type(arg_str): |
| 824 | """Auxilary function to parse the "runs_per_test" flag. |
| 825 | |
| 826 | Returns: |
| 827 | A positive integer or 0, the latter indicating an infinite number of |
| 828 | runs. |
| 829 | |
| 830 | Raises: |
| 831 | argparse.ArgumentTypeError: Upon invalid input. |
| 832 | """ |
| 833 | if arg_str == 'inf': |
| 834 | return 0 |
| 835 | try: |
| 836 | n = int(arg_str) |
| 837 | if n <= 0: raise ValueError |
Craig Tiller | 50e53e2 | 2015-06-01 20:18:21 -0700 | [diff] [blame] | 838 | return n |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 839 | except: |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 840 | msg = '\'{}\' is not a positive integer or \'inf\''.format(arg_str) |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 841 | raise argparse.ArgumentTypeError(msg) |
Jan Tattermusch | c95eead | 2015-09-18 13:03:50 -0700 | [diff] [blame] | 842 | |
| 843 | # parse command line |
| 844 | argp = argparse.ArgumentParser(description='Run grpc tests.') |
| 845 | argp.add_argument('-c', '--config', |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 846 | choices=sorted(_CONFIGS.keys()), |
| 847 | default='opt') |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 848 | argp.add_argument('-n', '--runs_per_test', default=1, type=runs_per_test_type, |
| 849 | help='A positive integer or "inf". If "inf", all tests will run in an ' |
| 850 | 'infinite loop. Especially useful in combination with "-f"') |
Craig Tiller | fe406ec | 2015-02-24 13:55:12 -0800 | [diff] [blame] | 851 | argp.add_argument('-r', '--regex', default='.*', type=str) |
Vijay Pai | 488fd0e | 2016-06-13 12:37:12 -0700 | [diff] [blame] | 852 | argp.add_argument('--regex_exclude', default='', type=str) |
Craig Tiller | 5f735a6 | 2016-01-20 09:31:15 -0800 | [diff] [blame] | 853 | argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int) |
Craig Tiller | 8451e87 | 2015-02-27 09:25:51 -0800 | [diff] [blame] | 854 | argp.add_argument('-s', '--slowdown', default=1.0, type=float) |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 855 | argp.add_argument('-f', '--forever', |
| 856 | default=False, |
| 857 | action='store_const', |
| 858 | const=True) |
Nicolas "Pixel" Noble | a7df3f9 | 2015-02-26 22:07:04 +0100 | [diff] [blame] | 859 | argp.add_argument('-t', '--travis', |
| 860 | default=False, |
| 861 | action='store_const', |
| 862 | const=True) |
Nicolas Noble | 044db74 | 2015-01-14 16:57:24 -0800 | [diff] [blame] | 863 | argp.add_argument('--newline_on_success', |
| 864 | default=False, |
| 865 | action='store_const', |
| 866 | const=True) |
Craig Tiller | 686fb26 | 2015-01-15 07:39:09 -0800 | [diff] [blame] | 867 | argp.add_argument('-l', '--language', |
Craig Tiller | 60f15e6 | 2015-05-13 09:05:17 -0700 | [diff] [blame] | 868 | choices=['all'] + sorted(_LANGUAGES.keys()), |
Craig Tiller | 686fb26 | 2015-01-15 07:39:09 -0800 | [diff] [blame] | 869 | nargs='+', |
Craig Tiller | 60f15e6 | 2015-05-13 09:05:17 -0700 | [diff] [blame] | 870 | default=['all']) |
Craig Tiller | cd43da8 | 2015-05-29 08:41:29 -0700 | [diff] [blame] | 871 | argp.add_argument('-S', '--stop_on_failure', |
| 872 | default=False, |
| 873 | action='store_const', |
| 874 | const=True) |
Jan Tattermusch | c95eead | 2015-09-18 13:03:50 -0700 | [diff] [blame] | 875 | argp.add_argument('--use_docker', |
| 876 | default=False, |
| 877 | action='store_const', |
| 878 | const=True, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 879 | help='Run all the tests under docker. That provides ' + |
| 880 | 'additional isolation and prevents the need to install ' + |
| 881 | 'language specific prerequisites. Only available on Linux.') |
Craig Tiller | d4509a1 | 2015-09-28 09:18:40 -0700 | [diff] [blame] | 882 | argp.add_argument('--allow_flakes', |
| 883 | default=False, |
| 884 | action='store_const', |
| 885 | const=True, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 886 | help='Allow flaky tests to show as passing (re-runs failed tests up to five times)') |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 887 | argp.add_argument('--arch', |
Jan Tattermusch | 9be594f | 2016-01-25 18:08:47 -0800 | [diff] [blame] | 888 | choices=['default', 'x86', 'x64'], |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 889 | default='default', |
| 890 | help='Selects architecture to target. For some platforms "default" is the only supported choice.') |
| 891 | argp.add_argument('--compiler', |
Jan Tattermusch | c4cbe39 | 2016-02-22 19:29:38 -0800 | [diff] [blame] | 892 | choices=['default', |
Jan Tattermusch | 6d258c5 | 2016-06-10 09:36:51 -0700 | [diff] [blame] | 893 | 'gcc4.4', 'gcc4.6', 'gcc4.9', 'gcc5.3', |
| 894 | 'clang3.4', 'clang3.5', 'clang3.6', 'clang3.7', |
Jan Tattermusch | 825471c | 2016-04-25 16:52:25 -0700 | [diff] [blame] | 895 | 'vs2010', 'vs2013', 'vs2015', |
murgatroid99 | 9fab438 | 2016-04-29 15:05:00 -0700 | [diff] [blame] | 896 | 'python2.7', 'python3.4', |
Jan Tattermusch | 76511a5 | 2016-06-17 14:00:57 -0700 | [diff] [blame] | 897 | 'node0.12', 'node4', 'node5', |
| 898 | 'coreclr'], |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 899 | default='default', |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 900 | help='Selects compiler to use. Allowed values depend on the platform and language.') |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 901 | argp.add_argument('--build_only', |
| 902 | default=False, |
| 903 | action='store_const', |
| 904 | const=True, |
| 905 | help='Perform all the build steps but dont run any tests.') |
Craig Tiller | 5f735a6 | 2016-01-20 09:31:15 -0800 | [diff] [blame] | 906 | argp.add_argument('--measure_cpu_costs', default=False, action='store_const', const=True, |
| 907 | help='Measure the cpu costs of tests') |
Craig Tiller | 1676f91 | 2016-01-05 10:49:44 -0800 | [diff] [blame] | 908 | argp.add_argument('--update_submodules', default=[], nargs='*', |
| 909 | help='Update some submodules before building. If any are updated, also run generate_projects. ' + |
| 910 | 'Submodules are specified as SUBMODULE_NAME:BRANCH; if BRANCH is omitted, master is assumed.') |
Craig Tiller | 234b6e7 | 2015-05-23 10:12:40 -0700 | [diff] [blame] | 911 | argp.add_argument('-a', '--antagonists', default=0, type=int) |
Nicolas "Pixel" Noble | 5937b5b | 2015-06-26 02:04:12 +0200 | [diff] [blame] | 912 | argp.add_argument('-x', '--xml_report', default=None, type=str, |
| 913 | help='Generates a JUnit-compatible XML report') |
Craig Tiller | 123f137 | 2016-06-15 15:06:14 -0700 | [diff] [blame] | 914 | argp.add_argument('--force_default_poller', default=False, action='store_const', const=True, |
| 915 | help='Dont try to iterate over many polling strategies when they exist') |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 916 | args = argp.parse_args() |
| 917 | |
Craig Tiller | 123f137 | 2016-06-15 15:06:14 -0700 | [diff] [blame] | 918 | if args.force_default_poller: |
| 919 | _POLLING_STRATEGIES = {} |
| 920 | |
Craig Tiller | 5f735a6 | 2016-01-20 09:31:15 -0800 | [diff] [blame] | 921 | jobset.measure_cpu_costs = args.measure_cpu_costs |
| 922 | |
Craig Tiller | 1676f91 | 2016-01-05 10:49:44 -0800 | [diff] [blame] | 923 | # update submodules if necessary |
Craig Tiller | b361b4e | 2016-01-06 11:44:17 -0800 | [diff] [blame] | 924 | need_to_regenerate_projects = False |
| 925 | for spec in args.update_submodules: |
| 926 | spec = spec.split(':', 1) |
| 927 | if len(spec) == 1: |
| 928 | submodule = spec[0] |
| 929 | branch = 'master' |
| 930 | elif len(spec) == 2: |
| 931 | submodule = spec[0] |
| 932 | branch = spec[1] |
| 933 | cwd = 'third_party/%s' % submodule |
| 934 | def git(cmd, cwd=cwd): |
| 935 | print 'in %s: git %s' % (cwd, cmd) |
| 936 | subprocess.check_call('git %s' % cmd, cwd=cwd, shell=True) |
| 937 | git('fetch') |
| 938 | git('checkout %s' % branch) |
| 939 | git('pull origin %s' % branch) |
| 940 | if os.path.exists('src/%s/gen_build_yaml.py' % submodule): |
| 941 | need_to_regenerate_projects = True |
| 942 | if need_to_regenerate_projects: |
| 943 | if jobset.platform_string() == 'linux': |
| 944 | subprocess.check_call('tools/buildgen/generate_projects.sh', shell=True) |
| 945 | else: |
| 946 | print 'WARNING: may need to regenerate projects, but since we are not on' |
| 947 | print ' Linux this step is being skipped. Compilation MAY fail.' |
Craig Tiller | 1676f91 | 2016-01-05 10:49:44 -0800 | [diff] [blame] | 948 | |
| 949 | |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 950 | # grab config |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 951 | run_config = _CONFIGS[args.config] |
| 952 | build_config = run_config.build_config |
Craig Tiller | f1973b0 | 2015-01-16 12:32:13 -0800 | [diff] [blame] | 953 | |
Craig Tiller | 0680527 | 2015-06-11 14:46:47 -0700 | [diff] [blame] | 954 | if args.travis: |
murgatroid99 | d3b5b7f | 2015-10-06 17:02:03 -0700 | [diff] [blame] | 955 | _FORCE_ENVIRON_FOR_WRAPPERS = {'GRPC_TRACE': 'api'} |
Craig Tiller | 0680527 | 2015-06-11 14:46:47 -0700 | [diff] [blame] | 956 | |
Adele Zhou | 6b9527c | 2015-11-20 15:56:35 -0800 | [diff] [blame] | 957 | if 'all' in args.language: |
Craig Tiller | 1676f91 | 2016-01-05 10:49:44 -0800 | [diff] [blame] | 958 | lang_list = _LANGUAGES.keys() |
Adele Zhou | 6b9527c | 2015-11-20 15:56:35 -0800 | [diff] [blame] | 959 | else: |
| 960 | lang_list = args.language |
Craig Tiller | 1690066 | 2016-01-07 19:30:54 -0800 | [diff] [blame] | 961 | # We don't support code coverage on some languages |
| 962 | if 'gcov' in args.config: |
Jan Tattermusch | 3b5121b | 2016-02-22 17:41:05 -0800 | [diff] [blame] | 963 | for bad in ['objc', 'sanity']: |
Craig Tiller | 1690066 | 2016-01-07 19:30:54 -0800 | [diff] [blame] | 964 | if bad in lang_list: |
| 965 | lang_list.remove(bad) |
Adele Zhou | 6b9527c | 2015-11-20 15:56:35 -0800 | [diff] [blame] | 966 | |
| 967 | languages = set(_LANGUAGES[l] for l in lang_list) |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 968 | for l in languages: |
| 969 | l.configure(run_config, args) |
murgatroid99 | 132ce6a | 2015-03-04 17:29:14 -0800 | [diff] [blame] | 970 | |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 971 | language_make_options=[] |
| 972 | if any(language.make_options() for language in languages): |
Adele Zhou | 3b6ab81 | 2016-05-18 17:04:20 -0700 | [diff] [blame] | 973 | if not 'gcov' in args.config and len(languages) != 1: |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 974 | print 'languages with custom make options cannot be built simultaneously with other languages' |
| 975 | sys.exit(1) |
| 976 | else: |
| 977 | language_make_options = next(iter(languages)).make_options() |
| 978 | |
Jan Tattermusch | 4dc9e72 | 2016-01-25 17:00:54 -0800 | [diff] [blame] | 979 | if args.use_docker: |
| 980 | if not args.travis: |
| 981 | print 'Seen --use_docker flag, will run tests under docker.' |
| 982 | print |
| 983 | print 'IMPORTANT: The changes you are testing need to be locally committed' |
| 984 | print 'because only the committed changes in the current branch will be' |
| 985 | print 'copied to the docker environment.' |
| 986 | time.sleep(5) |
| 987 | |
Jan Tattermusch | 3b5121b | 2016-02-22 17:41:05 -0800 | [diff] [blame] | 988 | dockerfile_dirs = set([l.dockerfile_dir() for l in languages]) |
| 989 | if len(dockerfile_dirs) > 1: |
Adele Zhou | 9506ef2 | 2016-03-02 13:53:34 -0800 | [diff] [blame] | 990 | if 'gcov' in args.config: |
| 991 | dockerfile_dir = 'tools/dockerfile/test/multilang_jessie_x64' |
| 992 | print ('Using multilang_jessie_x64 docker image for code coverage for ' |
| 993 | 'all languages.') |
| 994 | else: |
| 995 | print ('Languages to be tested require running under different docker ' |
| 996 | 'images.') |
| 997 | sys.exit(1) |
| 998 | else: |
| 999 | dockerfile_dir = next(iter(dockerfile_dirs)) |
Craig Tiller | de7edf8 | 2016-03-20 09:12:16 -0700 | [diff] [blame] | 1000 | |
Jan Tattermusch | 4dc9e72 | 2016-01-25 17:00:54 -0800 | [diff] [blame] | 1001 | child_argv = [ arg for arg in sys.argv if not arg == '--use_docker' ] |
Jan Tattermusch | ed342b1 | 2016-01-26 14:40:31 -0800 | [diff] [blame] | 1002 | run_tests_cmd = 'python tools/run_tests/run_tests.py %s' % ' '.join(child_argv[1:]) |
Jan Tattermusch | 4dc9e72 | 2016-01-25 17:00:54 -0800 | [diff] [blame] | 1003 | |
Jan Tattermusch | 4dc9e72 | 2016-01-25 17:00:54 -0800 | [diff] [blame] | 1004 | env = os.environ.copy() |
| 1005 | env['RUN_TESTS_COMMAND'] = run_tests_cmd |
Jan Tattermusch | 3b5121b | 2016-02-22 17:41:05 -0800 | [diff] [blame] | 1006 | env['DOCKERFILE_DIR'] = dockerfile_dir |
Jan Tattermusch | 9835d4b | 2016-04-29 15:05:05 -0700 | [diff] [blame] | 1007 | env['DOCKER_RUN_SCRIPT'] = 'tools/run_tests/dockerize/docker_run_tests.sh' |
Jan Tattermusch | 4dc9e72 | 2016-01-25 17:00:54 -0800 | [diff] [blame] | 1008 | if args.xml_report: |
| 1009 | env['XML_REPORT'] = args.xml_report |
| 1010 | if not args.travis: |
| 1011 | env['TTY_FLAG'] = '-t' # enables Ctrl-C when not on Jenkins. |
| 1012 | |
Jan Tattermusch | 9835d4b | 2016-04-29 15:05:05 -0700 | [diff] [blame] | 1013 | subprocess.check_call(['tools/run_tests/dockerize/build_docker_and_run_tests.sh'], |
Jan Tattermusch | 4dc9e72 | 2016-01-25 17:00:54 -0800 | [diff] [blame] | 1014 | shell=True, |
| 1015 | env=env) |
| 1016 | sys.exit(0) |
Jan Tattermusch | 788ee23 | 2016-01-26 12:19:44 -0800 | [diff] [blame] | 1017 | |
Jan Tattermusch | f08018a | 2016-01-26 08:22:09 -0800 | [diff] [blame] | 1018 | _check_arch_option(args.arch) |
Jan Tattermusch | 4dc9e72 | 2016-01-25 17:00:54 -0800 | [diff] [blame] | 1019 | |
Jan Tattermusch | fba6530 | 2016-01-25 18:21:14 -0800 | [diff] [blame] | 1020 | def make_jobspec(cfg, targets, makefile='Makefile'): |
| 1021 | if platform_string() == 'windows': |
Craig Tiller | fc3c0c4 | 2015-09-01 16:47:54 -0700 | [diff] [blame] | 1022 | extra_args = [] |
Craig Tiller | b5391e1 | 2015-09-03 14:35:18 -0700 | [diff] [blame] | 1023 | # better do parallel compilation |
Jan Tattermusch | 47eeb2b | 2015-10-07 14:09:18 -0700 | [diff] [blame] | 1024 | # empirically /m:2 gives the best performance/price and should prevent |
| 1025 | # overloading the windows workers. |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 1026 | extra_args.extend(['/m:2']) |
Craig Tiller | b5391e1 | 2015-09-03 14:35:18 -0700 | [diff] [blame] | 1027 | # disable PDB generation: it's broken, and we don't need it during CI |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 1028 | extra_args.extend(['/p:Jenkins=true']) |
Craig Tiller | 6fd2384 | 2015-09-01 07:36:31 -0700 | [diff] [blame] | 1029 | return [ |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 1030 | jobset.JobSpec([_windows_build_bat(args.compiler), |
murgatroid99 | cf08daf | 2015-09-21 15:33:16 -0700 | [diff] [blame] | 1031 | 'vsprojects\\%s.sln' % target, |
Jan Tattermusch | a2d964c | 2016-02-22 17:33:09 -0800 | [diff] [blame] | 1032 | '/p:Configuration=%s' % _MSBUILD_CONFIG[cfg]] + |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 1033 | extra_args + |
| 1034 | language_make_options, |
Craig Tiller | 590105a | 2016-01-19 13:03:46 -0800 | [diff] [blame] | 1035 | shell=True, timeout_seconds=None) |
Craig Tiller | 6fd2384 | 2015-09-01 07:36:31 -0700 | [diff] [blame] | 1036 | for target in targets] |
Jan Tattermusch | fba6530 | 2016-01-25 18:21:14 -0800 | [diff] [blame] | 1037 | else: |
murgatroid99 | 8ae409f | 2015-10-26 16:39:00 -0700 | [diff] [blame] | 1038 | if targets: |
| 1039 | return [jobset.JobSpec([os.getenv('MAKE', 'make'), |
| 1040 | '-f', makefile, |
Craig Tiller | dd6f7ed | 2016-01-21 12:54:42 -0800 | [diff] [blame] | 1041 | '-j', '%d' % args.jobs, |
Craig Tiller | 71a8604 | 2016-01-15 14:59:58 -0800 | [diff] [blame] | 1042 | 'EXTRA_DEFINES=GRPC_TEST_SLOWDOWN_MACHINE_FACTOR=%f' % args.slowdown, |
| 1043 | 'CONFIG=%s' % cfg] + |
Jan Tattermusch | c895fe0 | 2016-01-20 09:13:09 -0800 | [diff] [blame] | 1044 | language_make_options + |
Craig Tiller | 71a8604 | 2016-01-15 14:59:58 -0800 | [diff] [blame] | 1045 | ([] if not args.travis else ['JENKINS_BUILD=1']) + |
| 1046 | targets, |
Craig Tiller | 590105a | 2016-01-19 13:03:46 -0800 | [diff] [blame] | 1047 | timeout_seconds=None)] |
murgatroid99 | 8ae409f | 2015-10-26 16:39:00 -0700 | [diff] [blame] | 1048 | else: |
| 1049 | return [] |
Jan Tattermusch | fba6530 | 2016-01-25 18:21:14 -0800 | [diff] [blame] | 1050 | |
murgatroid99 | a3e244f | 2015-09-22 11:25:53 -0700 | [diff] [blame] | 1051 | make_targets = {} |
| 1052 | for l in languages: |
| 1053 | makefile = l.makefile_name() |
| 1054 | make_targets[makefile] = make_targets.get(makefile, set()).union( |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 1055 | set(l.make_targets())) |
Craig Tiller | 5058c69 | 2015-04-08 09:42:04 -0700 | [diff] [blame] | 1056 | |
Jan Tattermusch | e4a6918 | 2015-12-15 09:53:01 -0800 | [diff] [blame] | 1057 | def build_step_environ(cfg): |
| 1058 | environ = {'CONFIG': cfg} |
Jan Tattermusch | a2d964c | 2016-02-22 17:33:09 -0800 | [diff] [blame] | 1059 | msbuild_cfg = _MSBUILD_CONFIG.get(cfg) |
Jan Tattermusch | e4a6918 | 2015-12-15 09:53:01 -0800 | [diff] [blame] | 1060 | if msbuild_cfg: |
| 1061 | environ['MSBUILD_CONFIG'] = msbuild_cfg |
| 1062 | return environ |
| 1063 | |
murgatroid99 | fddac96 | 2015-09-22 09:20:11 -0700 | [diff] [blame] | 1064 | build_steps = list(set( |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 1065 | jobset.JobSpec(cmdline, environ=build_step_environ(build_config), flake_retries=5) |
murgatroid99 | 256d3df | 2015-09-21 16:58:02 -0700 | [diff] [blame] | 1066 | for l in languages |
| 1067 | for cmdline in l.pre_build_steps())) |
Craig Tiller | bd4e378 | 2015-09-01 06:48:55 -0700 | [diff] [blame] | 1068 | if make_targets: |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 1069 | make_commands = itertools.chain.from_iterable(make_jobspec(build_config, list(targets), makefile) for (makefile, targets) in make_targets.iteritems()) |
Craig Tiller | 6fd2384 | 2015-09-01 07:36:31 -0700 | [diff] [blame] | 1070 | build_steps.extend(set(make_commands)) |
Craig Tiller | 5058c69 | 2015-04-08 09:42:04 -0700 | [diff] [blame] | 1071 | build_steps.extend(set( |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 1072 | jobset.JobSpec(cmdline, environ=build_step_environ(build_config), timeout_seconds=None) |
Craig Tiller | 547db2b | 2015-01-30 14:08:39 -0800 | [diff] [blame] | 1073 | for l in languages |
Craig Tiller | 533b1a2 | 2015-05-29 08:41:29 -0700 | [diff] [blame] | 1074 | for cmdline in l.build_steps())) |
Craig Tiller | f1973b0 | 2015-01-16 12:32:13 -0800 | [diff] [blame] | 1075 | |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 1076 | post_tests_steps = list(set( |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 1077 | jobset.JobSpec(cmdline, environ=build_step_environ(build_config)) |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 1078 | for l in languages |
| 1079 | for cmdline in l.post_tests_steps())) |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 1080 | runs_per_test = args.runs_per_test |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1081 | forever = args.forever |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 1082 | |
Nicolas Noble | ddef246 | 2015-01-06 18:08:25 -0800 | [diff] [blame] | 1083 | |
Ken Payson | fa51de5 | 2016-06-30 23:50:48 -0700 | [diff] [blame] | 1084 | def _shut_down_legacy_server(legacy_server_port): |
| 1085 | try: |
| 1086 | version = int(urllib2.urlopen( |
| 1087 | 'http://localhost:%d/version_number' % legacy_server_port, |
| 1088 | timeout=10).read()) |
| 1089 | except: |
| 1090 | pass |
| 1091 | else: |
| 1092 | urllib2.urlopen( |
| 1093 | 'http://localhost:%d/quitquitquit' % legacy_server_port).read() |
| 1094 | |
| 1095 | |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1096 | def _start_port_server(port_server_port): |
Ken Payson | fa51de5 | 2016-06-30 23:50:48 -0700 | [diff] [blame] | 1097 | # Temporary patch to switch the port_server port |
| 1098 | # see https://github.com/grpc/grpc/issues/7145 |
| 1099 | _shut_down_legacy_server(32767) |
| 1100 | |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1101 | # check if a compatible port server is running |
| 1102 | # if incompatible (version mismatch) ==> start a new one |
| 1103 | # if not running ==> start a new one |
| 1104 | # otherwise, leave it up |
| 1105 | try: |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 1106 | version = int(urllib2.urlopen( |
| 1107 | 'http://localhost:%d/version_number' % port_server_port, |
Jan Tattermusch | 292d010 | 2016-06-28 10:29:41 -0700 | [diff] [blame] | 1108 | timeout=10).read()) |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 1109 | print 'detected port server running version %d' % version |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1110 | running = True |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 1111 | except Exception as e: |
Craig Tiller | 0d6499e | 2015-10-05 14:00:47 -0700 | [diff] [blame] | 1112 | print 'failed to detect port server: %s' % sys.exc_info()[0] |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 1113 | print e.strerror |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1114 | running = False |
| 1115 | if running: |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 1116 | current_version = int(subprocess.check_output( |
Jan Tattermusch | 3bd0827 | 2015-11-04 19:24:37 -0800 | [diff] [blame] | 1117 | [sys.executable, os.path.abspath('tools/run_tests/port_server.py'), |
| 1118 | 'dump_version'])) |
Craig Tiller | fe4939f | 2015-10-06 12:55:36 -0700 | [diff] [blame] | 1119 | print 'my port server is version %d' % current_version |
| 1120 | running = (version >= current_version) |
| 1121 | if not running: |
| 1122 | print 'port_server version mismatch: killing the old one' |
| 1123 | urllib2.urlopen('http://localhost:%d/quitquitquit' % port_server_port).read() |
| 1124 | time.sleep(1) |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1125 | if not running: |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 1126 | fd, logfile = tempfile.mkstemp() |
| 1127 | os.close(fd) |
| 1128 | print 'starting port_server, with log file %s' % logfile |
Jan Tattermusch | 3bd0827 | 2015-11-04 19:24:37 -0800 | [diff] [blame] | 1129 | args = [sys.executable, os.path.abspath('tools/run_tests/port_server.py'), |
| 1130 | '-p', '%d' % port_server_port, '-l', logfile] |
Craig Tiller | 367d41d | 2015-10-12 13:00:22 -0700 | [diff] [blame] | 1131 | env = dict(os.environ) |
| 1132 | env['BUILD_ID'] = 'pleaseDontKillMeJenkins' |
Nicolas "Pixel" Noble | f72d7b5 | 2015-12-03 03:07:43 +0100 | [diff] [blame] | 1133 | if platform_string() == 'windows': |
Jan Tattermusch | 3bd0827 | 2015-11-04 19:24:37 -0800 | [diff] [blame] | 1134 | # Working directory of port server needs to be outside of Jenkins |
| 1135 | # workspace to prevent file lock issues. |
| 1136 | tempdir = tempfile.mkdtemp() |
Craig Tiller | d2c3971 | 2015-10-12 11:08:49 -0700 | [diff] [blame] | 1137 | port_server = subprocess.Popen( |
Craig Tiller | 367d41d | 2015-10-12 13:00:22 -0700 | [diff] [blame] | 1138 | args, |
| 1139 | env=env, |
Jan Tattermusch | 3bd0827 | 2015-11-04 19:24:37 -0800 | [diff] [blame] | 1140 | cwd=tempdir, |
Craig Tiller | 367d41d | 2015-10-12 13:00:22 -0700 | [diff] [blame] | 1141 | creationflags = 0x00000008, # detached process |
| 1142 | close_fds=True) |
Craig Tiller | d2c3971 | 2015-10-12 11:08:49 -0700 | [diff] [blame] | 1143 | else: |
| 1144 | port_server = subprocess.Popen( |
| 1145 | args, |
Craig Tiller | 367d41d | 2015-10-12 13:00:22 -0700 | [diff] [blame] | 1146 | env=env, |
Craig Tiller | d2c3971 | 2015-10-12 11:08:49 -0700 | [diff] [blame] | 1147 | preexec_fn=os.setsid, |
| 1148 | close_fds=True) |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 1149 | time.sleep(1) |
Craig Tiller | 8b5f4dc | 2015-08-26 08:02:01 -0700 | [diff] [blame] | 1150 | # ensure port server is up |
Craig Tiller | abd37fd | 2015-08-26 07:54:01 -0700 | [diff] [blame] | 1151 | waits = 0 |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1152 | while True: |
Craig Tiller | abd37fd | 2015-08-26 07:54:01 -0700 | [diff] [blame] | 1153 | if waits > 10: |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 1154 | print 'killing port server due to excessive start up waits' |
Craig Tiller | abd37fd | 2015-08-26 07:54:01 -0700 | [diff] [blame] | 1155 | port_server.kill() |
Craig Tiller | a2f38b0 | 2015-09-24 11:19:17 -0700 | [diff] [blame] | 1156 | if port_server.poll() is not None: |
Craig Tiller | 0d6499e | 2015-10-05 14:00:47 -0700 | [diff] [blame] | 1157 | print 'port_server failed to start' |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 1158 | # try one final time: maybe another build managed to start one |
| 1159 | time.sleep(1) |
| 1160 | try: |
| 1161 | urllib2.urlopen('http://localhost:%d/get' % port_server_port, |
| 1162 | timeout=1).read() |
| 1163 | print 'last ditch attempt to contact port server succeeded' |
| 1164 | break |
| 1165 | except: |
Jan Tattermusch | 3b5121b | 2016-02-22 17:41:05 -0800 | [diff] [blame] | 1166 | traceback.print_exc() |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 1167 | port_log = open(logfile, 'r').read() |
| 1168 | print port_log |
| 1169 | sys.exit(1) |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1170 | try: |
Craig Tiller | abd37fd | 2015-08-26 07:54:01 -0700 | [diff] [blame] | 1171 | urllib2.urlopen('http://localhost:%d/get' % port_server_port, |
| 1172 | timeout=1).read() |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 1173 | print 'port server is up and ready' |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1174 | break |
Craig Tiller | 31fdaa4 | 2015-09-25 13:09:59 -0700 | [diff] [blame] | 1175 | except socket.timeout: |
Craig Tiller | 0d6499e | 2015-10-05 14:00:47 -0700 | [diff] [blame] | 1176 | print 'waiting for port_server: timeout' |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 1177 | traceback.print_exc(); |
| 1178 | time.sleep(1) |
Craig Tiller | 31fdaa4 | 2015-09-25 13:09:59 -0700 | [diff] [blame] | 1179 | waits += 1 |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1180 | except urllib2.URLError: |
Craig Tiller | 0d6499e | 2015-10-05 14:00:47 -0700 | [diff] [blame] | 1181 | print 'waiting for port_server: urlerror' |
Craig Tiller | f0a293e | 2015-10-12 10:05:50 -0700 | [diff] [blame] | 1182 | traceback.print_exc(); |
| 1183 | time.sleep(1) |
Craig Tiller | abd37fd | 2015-08-26 07:54:01 -0700 | [diff] [blame] | 1184 | waits += 1 |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1185 | except: |
Jan Tattermusch | 3b5121b | 2016-02-22 17:41:05 -0800 | [diff] [blame] | 1186 | traceback.print_exc() |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1187 | port_server.kill() |
| 1188 | raise |
| 1189 | |
| 1190 | |
Adele Zhou | d5fffa5 | 2015-10-23 15:51:42 -0700 | [diff] [blame] | 1191 | def _calculate_num_runs_failures(list_of_results): |
| 1192 | """Caculate number of runs and failures for a particular test. |
| 1193 | |
| 1194 | Args: |
| 1195 | list_of_results: (List) of JobResult object. |
| 1196 | Returns: |
| 1197 | A tuple of total number of runs and failures. |
| 1198 | """ |
| 1199 | num_runs = len(list_of_results) # By default, there is 1 run per JobResult. |
| 1200 | num_failures = 0 |
| 1201 | for jobresult in list_of_results: |
| 1202 | if jobresult.retries > 0: |
| 1203 | num_runs += jobresult.retries |
| 1204 | if jobresult.num_failures > 0: |
| 1205 | num_failures += jobresult.num_failures |
| 1206 | return num_runs, num_failures |
| 1207 | |
Adele Zhou | 6b9527c | 2015-11-20 15:56:35 -0800 | [diff] [blame] | 1208 | |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1209 | # _build_and_run results |
| 1210 | class BuildAndRunError(object): |
| 1211 | |
| 1212 | BUILD = object() |
| 1213 | TEST = object() |
| 1214 | POST_TEST = object() |
| 1215 | |
| 1216 | |
| 1217 | # returns a list of things that failed (or an empty list on success) |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1218 | def _build_and_run( |
Craig Tiller | 74189cd | 2016-06-23 15:39:06 -0700 | [diff] [blame] | 1219 | check_cancelled, newline_on_success, xml_report=None, build_only=False): |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1220 | """Do one pass of building & running tests.""" |
murgatroid99 | 666450e | 2015-01-26 13:03:31 -0800 | [diff] [blame] | 1221 | # build latest sequentially |
Jan Tattermusch | aab1e51 | 2016-01-28 09:30:44 -0800 | [diff] [blame] | 1222 | num_failures, resultset = jobset.run( |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 1223 | build_steps, maxjobs=1, stop_on_failure=True, |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 1224 | newline_on_success=newline_on_success, travis=args.travis) |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 1225 | if num_failures: |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1226 | return [BuildAndRunError.BUILD] |
Craig Tiller | b361b4e | 2016-01-06 11:44:17 -0800 | [diff] [blame] | 1227 | |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 1228 | if build_only: |
Jan Tattermusch | aab1e51 | 2016-01-28 09:30:44 -0800 | [diff] [blame] | 1229 | if xml_report: |
| 1230 | report_utils.render_junit_xml_report(resultset, xml_report) |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1231 | return [] |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1232 | |
Craig Tiller | 234b6e7 | 2015-05-23 10:12:40 -0700 | [diff] [blame] | 1233 | # start antagonists |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 1234 | antagonists = [subprocess.Popen(['tools/run_tests/antagonist.py']) |
Craig Tiller | 234b6e7 | 2015-05-23 10:12:40 -0700 | [diff] [blame] | 1235 | for _ in range(0, args.antagonists)] |
Ken Payson | fa51de5 | 2016-06-30 23:50:48 -0700 | [diff] [blame] | 1236 | port_server_port = 32766 |
Craig Tiller | f53d9c8 | 2015-08-04 14:19:43 -0700 | [diff] [blame] | 1237 | _start_port_server(port_server_port) |
Adele Zhou | 7cf7211 | 2015-11-04 11:18:43 -0800 | [diff] [blame] | 1238 | resultset = None |
Adele Zhou | 803af15 | 2015-11-30 15:16:16 -0800 | [diff] [blame] | 1239 | num_test_failures = 0 |
Craig Tiller | 234b6e7 | 2015-05-23 10:12:40 -0700 | [diff] [blame] | 1240 | try: |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 1241 | infinite_runs = runs_per_test == 0 |
yang-g | 6c1fdc6 | 2015-08-18 11:57:42 -0700 | [diff] [blame] | 1242 | one_run = set( |
| 1243 | spec |
yang-g | 6c1fdc6 | 2015-08-18 11:57:42 -0700 | [diff] [blame] | 1244 | for language in languages |
Jan Tattermusch | 77db432 | 2016-02-20 20:19:35 -0800 | [diff] [blame] | 1245 | for spec in language.test_specs() |
Vijay Pai | 488fd0e | 2016-06-13 12:37:12 -0700 | [diff] [blame] | 1246 | if (re.search(args.regex, spec.shortname) and |
| 1247 | (args.regex_exclude == '' or |
| 1248 | not re.search(args.regex_exclude, spec.shortname)))) |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 1249 | # When running on travis, we want out test runs to be as similar as possible |
| 1250 | # for reproducibility purposes. |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 1251 | if args.travis: |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 1252 | massaged_one_run = sorted(one_run, key=lambda x: x.shortname) |
| 1253 | else: |
| 1254 | # whereas otherwise, we want to shuffle things up to give all tests a |
| 1255 | # chance to run. |
| 1256 | massaged_one_run = list(one_run) # random.shuffle needs an indexable seq. |
| 1257 | random.shuffle(massaged_one_run) # which it modifies in-place. |
Craig Tiller | f7b7c89 | 2015-06-22 14:33:25 -0700 | [diff] [blame] | 1258 | if infinite_runs: |
| 1259 | assert len(massaged_one_run) > 0, 'Must have at least one test for a -n inf run' |
David Garcia Quintas | 79e389f | 2015-06-02 17:49:42 -0700 | [diff] [blame] | 1260 | runs_sequence = (itertools.repeat(massaged_one_run) if infinite_runs |
| 1261 | else itertools.repeat(massaged_one_run, runs_per_test)) |
David Garcia Quintas | e90cd37 | 2015-05-31 18:15:26 -0700 | [diff] [blame] | 1262 | all_runs = itertools.chain.from_iterable(runs_sequence) |
Nicolas "Pixel" Noble | 5937b5b | 2015-06-26 02:04:12 +0200 | [diff] [blame] | 1263 | |
Adele Zhou | 803af15 | 2015-11-30 15:16:16 -0800 | [diff] [blame] | 1264 | num_test_failures, resultset = jobset.run( |
Adele Zhou | 2271ab5 | 2015-10-28 13:59:14 -0700 | [diff] [blame] | 1265 | all_runs, check_cancelled, newline_on_success=newline_on_success, |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 1266 | travis=args.travis, infinite_runs=infinite_runs, maxjobs=args.jobs, |
murgatroid99 | 8ae409f | 2015-10-26 16:39:00 -0700 | [diff] [blame] | 1267 | stop_on_failure=args.stop_on_failure, |
Adele Zhou | f2ca7bc | 2015-10-23 15:38:00 -0700 | [diff] [blame] | 1268 | add_env={'GRPC_TEST_PORT_SERVER': 'localhost:%d' % port_server_port}) |
Adele Zhou | d5fffa5 | 2015-10-23 15:51:42 -0700 | [diff] [blame] | 1269 | if resultset: |
Craig Tiller | 2b59dbc | 2016-05-13 15:59:09 -0700 | [diff] [blame] | 1270 | for k, v in sorted(resultset.items()): |
Adele Zhou | d5fffa5 | 2015-10-23 15:51:42 -0700 | [diff] [blame] | 1271 | num_runs, num_failures = _calculate_num_runs_failures(v) |
| 1272 | if num_failures == num_runs: # what about infinite_runs??? |
| 1273 | jobset.message('FAILED', k, do_newline=True) |
| 1274 | elif num_failures > 0: |
| 1275 | jobset.message( |
| 1276 | 'FLAKE', '%s [%d/%d runs flaked]' % (k, num_failures, num_runs), |
| 1277 | do_newline=True) |
| 1278 | else: |
| 1279 | jobset.message('PASSED', k, do_newline=True) |
Craig Tiller | 234b6e7 | 2015-05-23 10:12:40 -0700 | [diff] [blame] | 1280 | finally: |
| 1281 | for antagonist in antagonists: |
| 1282 | antagonist.kill() |
Adele Zhou | 7cf7211 | 2015-11-04 11:18:43 -0800 | [diff] [blame] | 1283 | if xml_report and resultset: |
Adele Zhou | 3bc7ba4 | 2015-11-05 10:21:58 -0800 | [diff] [blame] | 1284 | report_utils.render_junit_xml_report(resultset, xml_report) |
Craig Tiller | d86a394 | 2015-01-14 12:48:54 -0800 | [diff] [blame] | 1285 | |
Adele Zhou | f2ca7bc | 2015-10-23 15:38:00 -0700 | [diff] [blame] | 1286 | number_failures, _ = jobset.run( |
| 1287 | post_tests_steps, maxjobs=1, stop_on_failure=True, |
Craig Tiller | 883064c | 2015-11-04 10:06:10 -0800 | [diff] [blame] | 1288 | newline_on_success=newline_on_success, travis=args.travis) |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1289 | |
| 1290 | out = [] |
| 1291 | if number_failures: |
| 1292 | out.append(BuildAndRunError.POST_TEST) |
| 1293 | if num_test_failures: |
| 1294 | out.append(BuildAndRunError.TEST) |
Nicolas "Pixel" Noble | 3fcd3bf | 2015-10-10 02:30:38 +0200 | [diff] [blame] | 1295 | |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1296 | return out |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1297 | |
| 1298 | |
| 1299 | if forever: |
Nicolas Noble | 044db74 | 2015-01-14 16:57:24 -0800 | [diff] [blame] | 1300 | success = True |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1301 | while True: |
Craig Tiller | 42bc87c | 2015-02-23 08:50:19 -0800 | [diff] [blame] | 1302 | dw = watch_dirs.DirWatcher(['src', 'include', 'test', 'examples']) |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1303 | initial_time = dw.most_recent_change() |
| 1304 | have_files_changed = lambda: dw.most_recent_change() != initial_time |
Nicolas Noble | 044db74 | 2015-01-14 16:57:24 -0800 | [diff] [blame] | 1305 | previous_success = success |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1306 | errors = _build_and_run(check_cancelled=have_files_changed, |
| 1307 | newline_on_success=False, |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1308 | build_only=args.build_only) == 0 |
| 1309 | if not previous_success and not errors: |
Nicolas Noble | b09078f | 2015-01-14 18:06:05 -0800 | [diff] [blame] | 1310 | jobset.message('SUCCESS', |
| 1311 | 'All tests are now passing properly', |
| 1312 | do_newline=True) |
Nicolas Noble | 044db74 | 2015-01-14 16:57:24 -0800 | [diff] [blame] | 1313 | jobset.message('IDLE', 'No change detected') |
ctiller | 3040cb7 | 2015-01-07 12:13:17 -0800 | [diff] [blame] | 1314 | while not have_files_changed(): |
| 1315 | time.sleep(1) |
| 1316 | else: |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1317 | errors = _build_and_run(check_cancelled=lambda: False, |
Craig Tiller | 7173518 | 2015-01-15 17:07:13 -0800 | [diff] [blame] | 1318 | newline_on_success=args.newline_on_success, |
Jan Tattermusch | 2dd156e | 2015-12-04 18:26:17 -0800 | [diff] [blame] | 1319 | xml_report=args.xml_report, |
| 1320 | build_only=args.build_only) |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1321 | if not errors: |
Nicolas Noble | b09078f | 2015-01-14 18:06:05 -0800 | [diff] [blame] | 1322 | jobset.message('SUCCESS', 'All tests passed', do_newline=True) |
| 1323 | else: |
| 1324 | jobset.message('FAILED', 'Some tests failed', do_newline=True) |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1325 | exit_code = 0 |
| 1326 | if BuildAndRunError.BUILD in errors: |
| 1327 | exit_code |= 1 |
Craig Tiller | 4f2be36 | 2016-01-08 08:59:20 -0800 | [diff] [blame] | 1328 | if BuildAndRunError.TEST in errors and not args.travis: |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1329 | exit_code |= 2 |
Craig Tiller | 4f2be36 | 2016-01-08 08:59:20 -0800 | [diff] [blame] | 1330 | if BuildAndRunError.POST_TEST in errors: |
| 1331 | exit_code |= 4 |
Craig Tiller | eb9de8b | 2016-01-08 08:57:41 -0800 | [diff] [blame] | 1332 | sys.exit(exit_code) |