Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2015, Google Inc. |
| 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 | |
| 31 | """Run interop (cross-language) tests in parallel.""" |
| 32 | |
| 33 | import argparse |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 34 | import dockerjob |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 35 | import itertools |
| 36 | import xml.etree.cElementTree as ET |
| 37 | import jobset |
Jan Tattermusch | 210a0ea | 2015-10-02 15:05:36 -0700 | [diff] [blame] | 38 | import multiprocessing |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 39 | import os |
| 40 | import subprocess |
| 41 | import sys |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 42 | import tempfile |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 43 | import time |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 44 | import uuid |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 45 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 46 | ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..')) |
| 47 | os.chdir(ROOT) |
| 48 | |
| 49 | _DEFAULT_SERVER_PORT=8080 |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 50 | |
| 51 | _CLOUD_TO_PROD_BASE_ARGS = [ |
| 52 | '--server_host_override=grpc-test.sandbox.google.com', |
| 53 | '--server_host=grpc-test.sandbox.google.com', |
| 54 | '--server_port=443'] |
| 55 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 56 | _CLOUD_TO_CLOUD_BASE_ARGS = [ |
| 57 | '--server_host_override=foo.test.google.fr'] |
| 58 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 59 | # TOOD(jtattermusch) wrapped languages use this variable for location |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 60 | # of roots.pem. We might want to use GRPC_DEFAULT_SSL_ROOTS_FILE_PATH |
| 61 | # supported by C core SslCredentials instead. |
| 62 | _SSL_CERT_ENV = { 'SSL_CERT_FILE':'/usr/local/share/grpc/roots.pem' } |
| 63 | |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 64 | # TODO(jtattermusch) unify usage of --use_tls and --use_tls=true |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 65 | # TODO(jtattermusch) go uses --tls_ca_file instead of --use_test_ca |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 66 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 67 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 68 | class CXXLanguage: |
| 69 | |
| 70 | def __init__(self): |
| 71 | self.client_cmdline_base = ['bins/opt/interop_client'] |
| 72 | self.client_cwd = None |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 73 | self.server_cwd = None |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 74 | self.safename = 'cxx' |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 75 | |
| 76 | def cloud_to_prod_args(self): |
| 77 | return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + |
yang-g | a006b5f | 2015-10-07 13:14:35 -0700 | [diff] [blame] | 78 | ['--use_tls=true']) |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 79 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 80 | def cloud_to_cloud_args(self): |
| 81 | return (self.client_cmdline_base + _CLOUD_TO_CLOUD_BASE_ARGS + |
yang-g | a006b5f | 2015-10-07 13:14:35 -0700 | [diff] [blame] | 82 | ['--use_tls=true', '--use_test_ca=true']) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 83 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 84 | def cloud_to_prod_env(self): |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 85 | return {} |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 86 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 87 | def server_args(self): |
Jan Tattermusch | 28bf559 | 2015-10-02 13:50:24 -0700 | [diff] [blame] | 88 | return ['bins/opt/interop_server', '--use_tls=true'] |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 89 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 90 | def global_env(self): |
| 91 | return {} |
| 92 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 93 | def __str__(self): |
| 94 | return 'c++' |
| 95 | |
| 96 | |
| 97 | class CSharpLanguage: |
| 98 | |
| 99 | def __init__(self): |
| 100 | self.client_cmdline_base = ['mono', 'Grpc.IntegrationTesting.Client.exe'] |
| 101 | self.client_cwd = 'src/csharp/Grpc.IntegrationTesting.Client/bin/Debug' |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 102 | self.server_cwd = 'src/csharp/Grpc.IntegrationTesting.Server/bin/Debug' |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 103 | self.safename = str(self) |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 104 | |
| 105 | def cloud_to_prod_args(self): |
| 106 | return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + |
Jan Tattermusch | 7828e81 | 2015-10-07 17:27:48 -0700 | [diff] [blame] | 107 | ['--use_tls=true']) |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 108 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 109 | def cloud_to_cloud_args(self): |
| 110 | return (self.client_cmdline_base + _CLOUD_TO_CLOUD_BASE_ARGS + |
Jan Tattermusch | 7828e81 | 2015-10-07 17:27:48 -0700 | [diff] [blame] | 111 | ['--use_tls=true', '--use_test_ca=true']) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 112 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 113 | def cloud_to_prod_env(self): |
| 114 | return _SSL_CERT_ENV |
| 115 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 116 | def server_args(self): |
Jan Tattermusch | 7828e81 | 2015-10-07 17:27:48 -0700 | [diff] [blame] | 117 | return ['mono', 'Grpc.IntegrationTesting.Server.exe', '--use_tls=true'] |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 118 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 119 | def global_env(self): |
| 120 | return {} |
| 121 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 122 | def __str__(self): |
| 123 | return 'csharp' |
| 124 | |
| 125 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 126 | class JavaLanguage: |
| 127 | |
| 128 | def __init__(self): |
| 129 | self.client_cmdline_base = ['./run-test-client.sh'] |
| 130 | self.client_cwd = '../grpc-java' |
| 131 | self.server_cwd = '../grpc-java' |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 132 | self.safename = str(self) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 133 | |
| 134 | def cloud_to_prod_args(self): |
| 135 | return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + |
| 136 | ['--use_tls=true']) |
| 137 | |
| 138 | def cloud_to_cloud_args(self): |
| 139 | return (self.client_cmdline_base + _CLOUD_TO_CLOUD_BASE_ARGS + |
| 140 | ['--use_tls=true', '--use_test_ca=true']) |
| 141 | |
| 142 | def cloud_to_prod_env(self): |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 143 | return {} |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 144 | |
| 145 | def server_args(self): |
| 146 | return ['./run-test-server.sh', '--use_tls=true'] |
| 147 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 148 | def global_env(self): |
| 149 | return {} |
| 150 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 151 | def __str__(self): |
| 152 | return 'java' |
| 153 | |
| 154 | |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 155 | class GoLanguage: |
| 156 | |
| 157 | def __init__(self): |
| 158 | self.client_cmdline_base = ['go', 'run', 'client.go'] |
| 159 | # TODO: this relies on running inside docker |
| 160 | self.client_cwd = '/go/src/google.golang.org/grpc/interop/client' |
| 161 | self.server_cwd = '/go/src/google.golang.org/grpc/interop/server' |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 162 | self.safename = str(self) |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 163 | |
| 164 | def cloud_to_prod_args(self): |
| 165 | return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + |
| 166 | ['--use_tls=true', '--tls_ca_file=""']) |
| 167 | |
| 168 | def cloud_to_cloud_args(self): |
| 169 | return (self.client_cmdline_base + _CLOUD_TO_CLOUD_BASE_ARGS + |
| 170 | ['--use_tls=true']) |
| 171 | |
| 172 | def cloud_to_prod_env(self): |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 173 | return {} |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 174 | |
| 175 | def server_args(self): |
| 176 | return ['go', 'run', 'server.go', '--use_tls=true'] |
| 177 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 178 | def global_env(self): |
| 179 | return {} |
| 180 | |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 181 | def __str__(self): |
| 182 | return 'go' |
| 183 | |
| 184 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 185 | class NodeLanguage: |
| 186 | |
| 187 | def __init__(self): |
| 188 | self.client_cmdline_base = ['node', 'src/node/interop/interop_client.js'] |
| 189 | self.client_cwd = None |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 190 | self.server_cwd = None |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 191 | self.safename = str(self) |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 192 | |
| 193 | def cloud_to_prod_args(self): |
| 194 | return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + |
| 195 | ['--use_tls=true']) |
| 196 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 197 | def cloud_to_cloud_args(self): |
| 198 | return (self.client_cmdline_base + _CLOUD_TO_CLOUD_BASE_ARGS + |
| 199 | ['--use_tls=true', '--use_test_ca=true']) |
| 200 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 201 | def cloud_to_prod_env(self): |
| 202 | return _SSL_CERT_ENV |
| 203 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 204 | def server_args(self): |
| 205 | return ['node', 'src/node/interop/interop_server.js', '--use_tls=true'] |
| 206 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 207 | def global_env(self): |
| 208 | return {} |
| 209 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 210 | def __str__(self): |
| 211 | return 'node' |
| 212 | |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 213 | |
| 214 | class PHPLanguage: |
| 215 | |
| 216 | def __init__(self): |
| 217 | self.client_cmdline_base = ['src/php/bin/interop_client.sh'] |
| 218 | self.client_cwd = None |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 219 | self.safename = str(self) |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 220 | |
| 221 | def cloud_to_prod_args(self): |
| 222 | return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + |
| 223 | ['--use_tls']) |
| 224 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 225 | def cloud_to_cloud_args(self): |
| 226 | return (self.client_cmdline_base + _CLOUD_TO_CLOUD_BASE_ARGS + |
| 227 | ['--use_tls', '--use_test_ca']) |
| 228 | |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 229 | def cloud_to_prod_env(self): |
| 230 | return _SSL_CERT_ENV |
| 231 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 232 | def global_env(self): |
| 233 | return {} |
| 234 | |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 235 | def __str__(self): |
| 236 | return 'php' |
| 237 | |
| 238 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 239 | class RubyLanguage: |
| 240 | |
| 241 | def __init__(self): |
| 242 | self.client_cmdline_base = ['ruby', 'src/ruby/bin/interop/interop_client.rb'] |
| 243 | self.client_cwd = None |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 244 | self.server_cwd = None |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 245 | self.safename = str(self) |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 246 | |
| 247 | def cloud_to_prod_args(self): |
| 248 | return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + |
| 249 | ['--use_tls']) |
| 250 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 251 | def cloud_to_cloud_args(self): |
| 252 | return (self.client_cmdline_base + _CLOUD_TO_CLOUD_BASE_ARGS + |
| 253 | ['--use_tls', '--use_test_ca']) |
| 254 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 255 | def cloud_to_prod_env(self): |
| 256 | return _SSL_CERT_ENV |
| 257 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 258 | def server_args(self): |
| 259 | return ['ruby', 'src/ruby/bin/interop/interop_server.rb', '--use_tls'] |
| 260 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 261 | def global_env(self): |
| 262 | return {} |
| 263 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 264 | def __str__(self): |
| 265 | return 'ruby' |
| 266 | |
| 267 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 268 | class PythonLanguage: |
| 269 | |
| 270 | def __init__(self): |
| 271 | self.client_cmdline_base = ['python2.7_virtual_environment/bin/python', '-m', 'grpc_interop.client'] |
| 272 | self.client_cwd = None |
| 273 | self.server_cwd = None |
| 274 | self.safename = str(self) |
| 275 | |
| 276 | def cloud_to_prod_args(self): |
| 277 | return (self.client_cmdline_base + _CLOUD_TO_PROD_BASE_ARGS + |
| 278 | ['--use_tls']) |
| 279 | |
| 280 | def cloud_to_cloud_args(self): |
| 281 | return (self.client_cmdline_base + _CLOUD_TO_CLOUD_BASE_ARGS + |
| 282 | ['--use_tls', '--use_test_ca']) |
| 283 | |
| 284 | def cloud_to_prod_env(self): |
| 285 | return _SSL_CERT_ENV |
| 286 | |
| 287 | def server_args(self): |
| 288 | return ['python2.7_virtual_environment/bin/python', '-m', 'grpc_interop.server', '--use_tls'] |
| 289 | |
| 290 | def global_env(self): |
| 291 | return {'LD_LIBRARY_PATH': 'libs/opt'} |
| 292 | |
| 293 | def __str__(self): |
| 294 | return 'python' |
| 295 | |
| 296 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 297 | _LANGUAGES = { |
| 298 | 'c++' : CXXLanguage(), |
| 299 | 'csharp' : CSharpLanguage(), |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 300 | 'go' : GoLanguage(), |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 301 | 'java' : JavaLanguage(), |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 302 | 'node' : NodeLanguage(), |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 303 | 'php' : PHPLanguage(), |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 304 | 'ruby' : RubyLanguage(), |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 305 | 'python' : PythonLanguage(), |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 306 | } |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 307 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 308 | # languages supported as cloud_to_cloud servers |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 309 | _SERVERS = ['c++', 'node', 'csharp', 'java', 'go', 'ruby', 'python'] |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 310 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 311 | # TODO(jtattermusch): add timeout_on_sleeping_server once java starts supporting it. |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 312 | _TEST_CASES = ['large_unary', 'empty_unary', 'ping_pong', |
Jan Tattermusch | 1f1c5c5 | 2015-10-09 14:36:28 -0700 | [diff] [blame] | 313 | 'empty_stream', 'client_streaming', 'server_streaming', |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 314 | 'cancel_after_begin', 'cancel_after_first_response'] |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 315 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 316 | _AUTH_TEST_CASES = ['compute_engine_creds', 'jwt_token_creds', |
| 317 | 'oauth2_auth_token', 'per_rpc_creds'] |
| 318 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 319 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 320 | def docker_run_cmdline(cmdline, image, docker_args=[], cwd=None, environ=None): |
| 321 | """Wraps given cmdline array to create 'docker run' cmdline from it.""" |
| 322 | docker_cmdline = ['docker', 'run', '-i', '--rm=true'] |
| 323 | |
| 324 | # turn environ into -e docker args |
| 325 | if environ: |
| 326 | for k,v in environ.iteritems(): |
| 327 | docker_cmdline += ['-e', '%s=%s' % (k,v)] |
| 328 | |
| 329 | # set working directory |
| 330 | workdir = '/var/local/git/grpc' |
| 331 | if cwd: |
| 332 | workdir = os.path.join(workdir, cwd) |
| 333 | docker_cmdline += ['-w', workdir] |
| 334 | |
| 335 | docker_cmdline += docker_args + [image] + cmdline |
| 336 | return docker_cmdline |
| 337 | |
| 338 | |
| 339 | def bash_login_cmdline(cmdline): |
| 340 | """Creates bash -l -c cmdline from args list.""" |
| 341 | # Use login shell: |
| 342 | # * rvm and nvm require it |
| 343 | # * makes error messages clearer if executables are missing |
| 344 | return ['bash', '-l', '-c', ' '.join(cmdline)] |
| 345 | |
| 346 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 347 | def add_auth_options(language, test_case, cmdline, env): |
| 348 | """Returns (cmdline, env) tuple with cloud_to_prod_auth test options.""" |
| 349 | |
| 350 | language = str(language) |
| 351 | cmdline = list(cmdline) |
| 352 | env = env.copy() |
| 353 | |
| 354 | # TODO(jtattermusch): this file path only works inside docker |
| 355 | key_filepath = '/root/service_account/stubbyCloudTestingTest-ee3fce360ac5.json' |
| 356 | oauth_scope_arg = '--oauth_scope=https://www.googleapis.com/auth/xapi.zoo' |
| 357 | key_file_arg = '--service_account_key_file=%s' % key_filepath |
| 358 | default_account_arg = '--default_service_account=830293263384-compute@developer.gserviceaccount.com' |
| 359 | |
| 360 | if test_case in ['jwt_token_creds', 'per_rpc_creds', 'oauth2_auth_token']: |
| 361 | if language in ['csharp', 'node', 'php', 'ruby']: |
| 362 | env['GOOGLE_APPLICATION_CREDENTIALS'] = key_filepath |
| 363 | else: |
| 364 | cmdline += [key_file_arg] |
| 365 | |
| 366 | if test_case in ['per_rpc_creds', 'oauth2_auth_token']: |
| 367 | cmdline += [oauth_scope_arg] |
| 368 | |
Jan Tattermusch | 64d7c24 | 2015-10-08 08:02:27 -0700 | [diff] [blame] | 369 | if test_case == 'oauth2_auth_token' and language == 'c++': |
| 370 | # C++ oauth2 test uses GCE creds and thus needs to know the default account |
| 371 | cmdline += [default_account_arg] |
| 372 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 373 | if test_case == 'compute_engine_creds': |
| 374 | cmdline += [oauth_scope_arg, default_account_arg] |
| 375 | |
| 376 | return (cmdline, env) |
| 377 | |
| 378 | |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 379 | def _job_kill_handler(job): |
| 380 | if job._spec.container_name: |
| 381 | dockerjob.docker_kill(job._spec.container_name) |
| 382 | |
| 383 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 384 | def cloud_to_prod_jobspec(language, test_case, docker_image=None, auth=False): |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 385 | """Creates jobspec for cloud-to-prod interop test""" |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 386 | cmdline = language.cloud_to_prod_args() + ['--test_case=%s' % test_case] |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 387 | cwd = language.client_cwd |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 388 | environ = dict(language.cloud_to_prod_env(), **language.global_env()) |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 389 | container_name = None |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 390 | if auth: |
| 391 | cmdline, environ = add_auth_options(language, test_case, cmdline, environ) |
| 392 | cmdline = bash_login_cmdline(cmdline) |
| 393 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 394 | if docker_image: |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 395 | container_name = dockerjob.random_name('interop_client_%s' % language.safename) |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 396 | cmdline = docker_run_cmdline(cmdline, |
| 397 | image=docker_image, |
| 398 | cwd=cwd, |
| 399 | environ=environ, |
| 400 | docker_args=['--net=host', |
| 401 | '--name', container_name]) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 402 | cwd = None |
| 403 | environ = None |
| 404 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 405 | suite_name='cloud_to_prod_auth' if auth else 'cloud_to_prod' |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 406 | test_job = jobset.JobSpec( |
| 407 | cmdline=cmdline, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 408 | cwd=cwd, |
| 409 | environ=environ, |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 410 | shortname="%s:%s:%s" % (suite_name, language, test_case), |
Jan Tattermusch | 210a0ea | 2015-10-02 15:05:36 -0700 | [diff] [blame] | 411 | timeout_seconds=2*60, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 412 | flake_retries=5 if args.allow_flakes else 0, |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 413 | timeout_retries=2 if args.allow_flakes else 0, |
| 414 | kill_handler=_job_kill_handler) |
| 415 | test_job.container_name = container_name |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 416 | return test_job |
| 417 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 418 | |
| 419 | def cloud_to_cloud_jobspec(language, test_case, server_name, server_host, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 420 | server_port, docker_image=None): |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 421 | """Creates jobspec for cloud-to-cloud interop test""" |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 422 | cmdline = bash_login_cmdline(language.cloud_to_cloud_args() + |
| 423 | ['--test_case=%s' % test_case, |
| 424 | '--server_host=%s' % server_host, |
| 425 | '--server_port=%s' % server_port ]) |
| 426 | cwd = language.client_cwd |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 427 | environ = language.global_env() |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 428 | if docker_image: |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 429 | container_name = dockerjob.random_name('interop_client_%s' % language.safename) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 430 | cmdline = docker_run_cmdline(cmdline, |
| 431 | image=docker_image, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 432 | environ=environ, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 433 | cwd=cwd, |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 434 | docker_args=['--net=host', |
| 435 | '--name', container_name]) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 436 | cwd = None |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 437 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 438 | test_job = jobset.JobSpec( |
| 439 | cmdline=cmdline, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 440 | cwd=cwd, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 441 | environ=environ, |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 442 | shortname="cloud_to_cloud:%s:%s_server:%s" % (language, server_name, |
| 443 | test_case), |
Jan Tattermusch | 210a0ea | 2015-10-02 15:05:36 -0700 | [diff] [blame] | 444 | timeout_seconds=2*60, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 445 | flake_retries=5 if args.allow_flakes else 0, |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 446 | timeout_retries=2 if args.allow_flakes else 0, |
| 447 | kill_handler=_job_kill_handler) |
| 448 | test_job.container_name = container_name |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 449 | return test_job |
| 450 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 451 | |
| 452 | def server_jobspec(language, docker_image): |
| 453 | """Create jobspec for running a server""" |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 454 | container_name = dockerjob.random_name('interop_server_%s' % language.safename) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 455 | cmdline = bash_login_cmdline(language.server_args() + |
| 456 | ['--port=%s' % _DEFAULT_SERVER_PORT]) |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 457 | environ = language.global_env() |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 458 | docker_cmdline = docker_run_cmdline(cmdline, |
| 459 | image=docker_image, |
| 460 | cwd=language.server_cwd, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 461 | environ=environ, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 462 | docker_args=['-p', str(_DEFAULT_SERVER_PORT), |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 463 | '--name', container_name]) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 464 | server_job = jobset.JobSpec( |
| 465 | cmdline=docker_cmdline, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame^] | 466 | environ=environ, |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 467 | shortname="interop_server_%s" % language, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 468 | timeout_seconds=30*60) |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 469 | server_job.container_name = container_name |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 470 | return server_job |
| 471 | |
| 472 | |
| 473 | def build_interop_image_jobspec(language, tag=None): |
| 474 | """Creates jobspec for building interop docker image for a language""" |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 475 | if not tag: |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 476 | tag = 'grpc_interop_%s:%s' % (language.safename, uuid.uuid4()) |
| 477 | env = {'INTEROP_IMAGE': tag, |
| 478 | 'BASE_NAME': 'grpc_interop_%s' % language.safename} |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 479 | if not args.travis: |
| 480 | env['TTY_FLAG'] = '-t' |
| 481 | build_job = jobset.JobSpec( |
| 482 | cmdline=['tools/jenkins/build_interop_image.sh'], |
| 483 | environ=env, |
| 484 | shortname="build_docker_%s" % (language), |
| 485 | timeout_seconds=30*60) |
| 486 | build_job.tag = tag |
| 487 | return build_job |
| 488 | |
| 489 | |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 490 | argp = argparse.ArgumentParser(description='Run interop tests.') |
| 491 | argp.add_argument('-l', '--language', |
| 492 | choices=['all'] + sorted(_LANGUAGES), |
| 493 | nargs='+', |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 494 | default=['all'], |
| 495 | help='Clients to run.') |
Jan Tattermusch | 210a0ea | 2015-10-02 15:05:36 -0700 | [diff] [blame] | 496 | argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 497 | argp.add_argument('--cloud_to_prod', |
| 498 | default=False, |
| 499 | action='store_const', |
| 500 | const=True, |
| 501 | help='Run cloud_to_prod tests.') |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 502 | argp.add_argument('--cloud_to_prod_auth', |
| 503 | default=False, |
| 504 | action='store_const', |
| 505 | const=True, |
| 506 | help='Run cloud_to_prod_auth tests.') |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 507 | argp.add_argument('-s', '--server', |
| 508 | choices=['all'] + sorted(_SERVERS), |
| 509 | action='append', |
| 510 | help='Run cloud_to_cloud servers in a separate docker ' + |
| 511 | 'image. Servers can only be started automatically if ' + |
| 512 | '--use_docker option is enabled.', |
| 513 | default=[]) |
| 514 | argp.add_argument('--override_server', |
| 515 | action='append', |
| 516 | type=lambda kv: kv.split("="), |
| 517 | help='Use servername=HOST:PORT to explicitly specify a server. E.g. csharp=localhost:50000', |
| 518 | default=[]) |
| 519 | argp.add_argument('-t', '--travis', |
| 520 | default=False, |
| 521 | action='store_const', |
| 522 | const=True) |
| 523 | argp.add_argument('--use_docker', |
| 524 | default=False, |
| 525 | action='store_const', |
| 526 | const=True, |
| 527 | help='Run all the interop tests under docker. That provides ' + |
| 528 | 'additional isolation and prevents the need to install ' + |
| 529 | 'language specific prerequisites. Only available on Linux.') |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 530 | argp.add_argument('--allow_flakes', |
| 531 | default=False, |
| 532 | action='store_const', |
| 533 | const=True, |
| 534 | help="Allow flaky tests to show as passing (re-runs failed tests up to five times)") |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 535 | args = argp.parse_args() |
| 536 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 537 | servers = set(s for s in itertools.chain.from_iterable(_SERVERS |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 538 | if x == 'all' else [x] |
| 539 | for x in args.server)) |
| 540 | |
| 541 | if args.use_docker: |
| 542 | if not args.travis: |
| 543 | print 'Seen --use_docker flag, will run interop tests under docker.' |
| 544 | print |
| 545 | print 'IMPORTANT: The changes you are testing need to be locally committed' |
| 546 | print 'because only the committed changes in the current branch will be' |
| 547 | print 'copied to the docker environment.' |
| 548 | time.sleep(5) |
| 549 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 550 | if not args.use_docker and servers: |
| 551 | print "Running interop servers is only supported with --use_docker option enabled." |
| 552 | sys.exit(1) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 553 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 554 | languages = set(_LANGUAGES[l] |
| 555 | for l in itertools.chain.from_iterable( |
| 556 | _LANGUAGES.iterkeys() if x == 'all' else [x] |
| 557 | for x in args.language)) |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 558 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 559 | docker_images={} |
| 560 | if args.use_docker: |
| 561 | # languages for which to build docker images |
| 562 | languages_to_build = set(_LANGUAGES[k] for k in set([str(l) for l in languages] + |
| 563 | [s for s in servers])) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 564 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 565 | build_jobs = [] |
| 566 | for l in languages_to_build: |
| 567 | job = build_interop_image_jobspec(l) |
| 568 | docker_images[str(l)] = job.tag |
| 569 | build_jobs.append(job) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 570 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 571 | if build_jobs: |
| 572 | jobset.message('START', 'Building interop docker images.', do_newline=True) |
| 573 | if jobset.run(build_jobs, newline_on_success=True, maxjobs=args.jobs): |
| 574 | jobset.message('SUCCESS', 'All docker images built successfully.', do_newline=True) |
| 575 | else: |
| 576 | jobset.message('FAILED', 'Failed to build interop docker images.', do_newline=True) |
| 577 | for image in docker_images.itervalues(): |
| 578 | dockerjob.remove_image(image, skip_nonexistent=True) |
| 579 | exit(1); |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 580 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 581 | # Start interop servers. |
| 582 | server_jobs={} |
| 583 | server_addresses={} |
| 584 | try: |
| 585 | for s in servers: |
| 586 | lang = str(s) |
| 587 | spec = server_jobspec(_LANGUAGES[lang], docker_images.get(lang)) |
| 588 | job = dockerjob.DockerJob(spec) |
| 589 | server_jobs[lang] = job |
| 590 | server_addresses[lang] = ('localhost', job.mapped_port(_DEFAULT_SERVER_PORT)) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 591 | |
Jan Tattermusch | 210a0ea | 2015-10-02 15:05:36 -0700 | [diff] [blame] | 592 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 593 | jobs = [] |
| 594 | if args.cloud_to_prod: |
| 595 | for language in languages: |
| 596 | for test_case in _TEST_CASES: |
| 597 | test_job = cloud_to_prod_jobspec(language, test_case, |
| 598 | docker_image=docker_images.get(str(language))) |
| 599 | jobs.append(test_job) |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 600 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 601 | if args.cloud_to_prod_auth: |
| 602 | for language in languages: |
| 603 | for test_case in _AUTH_TEST_CASES: |
| 604 | test_job = cloud_to_prod_jobspec(language, test_case, |
| 605 | docker_image=docker_images.get(str(language)), |
| 606 | auth=True) |
| 607 | jobs.append(test_job) |
| 608 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 609 | for server in args.override_server: |
| 610 | server_name = server[0] |
| 611 | (server_host, server_port) = server[1].split(':') |
| 612 | server_addresses[server_name] = (server_host, server_port) |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 613 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 614 | for server_name, server_address in server_addresses.iteritems(): |
| 615 | (server_host, server_port) = server_address |
| 616 | for language in languages: |
| 617 | for test_case in _TEST_CASES: |
| 618 | test_job = cloud_to_cloud_jobspec(language, |
| 619 | test_case, |
| 620 | server_name, |
| 621 | server_host, |
| 622 | server_port, |
| 623 | docker_image=docker_images.get(str(language))) |
| 624 | jobs.append(test_job) |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 625 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 626 | if not jobs: |
| 627 | print "No jobs to run." |
| 628 | for image in docker_images.itervalues(): |
| 629 | dockerjob.remove_image(image, skip_nonexistent=True) |
| 630 | sys.exit(1) |
| 631 | |
| 632 | root = ET.Element('testsuites') |
| 633 | testsuite = ET.SubElement(root, 'testsuite', id='1', package='grpc', name='tests') |
| 634 | |
| 635 | if jobset.run(jobs, newline_on_success=True, maxjobs=args.jobs, xml_report=testsuite): |
| 636 | jobset.message('SUCCESS', 'All tests passed', do_newline=True) |
| 637 | else: |
| 638 | jobset.message('FAILED', 'Some tests failed', do_newline=True) |
| 639 | |
| 640 | tree = ET.ElementTree(root) |
| 641 | tree.write('report.xml', encoding='UTF-8') |
| 642 | |
| 643 | finally: |
| 644 | # Check if servers are still running. |
| 645 | for server, job in server_jobs.iteritems(): |
| 646 | if not job.is_running(): |
| 647 | print 'Server "%s" has exited prematurely.' % server |
| 648 | |
| 649 | dockerjob.finish_jobs([j for j in server_jobs.itervalues()]) |
| 650 | |
| 651 | for image in docker_images.itervalues(): |
| 652 | print 'Removing docker image %s' % image |
| 653 | dockerjob.remove_image(image) |