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