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 | |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 64 | def client_args(self): |
| 65 | return ['bins/opt/interop_client'] |
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 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 70 | def server_args(self): |
Jan Tattermusch | 28bf559 | 2015-10-02 13:50:24 -0700 | [diff] [blame] | 71 | return ['bins/opt/interop_server', '--use_tls=true'] |
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 | |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 90 | def client_args(self): |
| 91 | return ['mono', 'Grpc.IntegrationTesting.Client.exe'] |
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 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 96 | def server_args(self): |
Jan Tattermusch | 7828e81 | 2015-10-07 17:27:48 -0700 | [diff] [blame] | 97 | return ['mono', 'Grpc.IntegrationTesting.Server.exe', '--use_tls=true'] |
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 | |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 116 | def client_args(self): |
| 117 | return ['./run-test-client.sh'] |
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 | |
| 122 | def server_args(self): |
| 123 | return ['./run-test-server.sh', '--use_tls=true'] |
| 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 | |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 143 | def client_args(self): |
| 144 | return ['go', 'run', 'client.go'] |
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 | |
| 149 | def server_args(self): |
| 150 | return ['go', 'run', 'server.go', '--use_tls=true'] |
| 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 | |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 194 | def client_args(self): |
| 195 | return ['node', 'src/node/interop/interop_client.js'] |
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 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 200 | def server_args(self): |
| 201 | return ['node', 'src/node/interop/interop_server.js', '--use_tls=true'] |
| 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 | |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 219 | def client_args(self): |
| 220 | return ['src/php/bin/interop_client.sh'] |
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 | |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 242 | def client_args(self): |
| 243 | return ['ruby', 'src/ruby/bin/interop/interop_client.rb'] |
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 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 248 | def server_args(self): |
Jan Tattermusch | 73b3eea | 2015-10-15 17:52:06 -0700 | [diff] [blame] | 249 | return ['ruby', 'src/ruby/bin/interop/interop_server.rb', '--use_tls=true'] |
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 | |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 268 | def client_args(self): |
| 269 | return ['python2.7_virtual_environment/bin/python', '-m', 'grpc_interop.client'] |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 270 | |
| 271 | def cloud_to_prod_env(self): |
| 272 | return _SSL_CERT_ENV |
| 273 | |
| 274 | def server_args(self): |
Jan Tattermusch | 785efd4 | 2015-10-15 17:20:22 -0700 | [diff] [blame] | 275 | return ['python2.7_virtual_environment/bin/python', '-m', 'grpc_interop.server', '--use_tls=true'] |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 276 | |
| 277 | def global_env(self): |
| 278 | return {'LD_LIBRARY_PATH': 'libs/opt'} |
| 279 | |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 280 | def unimplemented_test_cases(self): |
| 281 | return ['jwt_token_creds', 'per_rpc_creds'] |
| 282 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 283 | def __str__(self): |
| 284 | return 'python' |
| 285 | |
| 286 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 287 | _LANGUAGES = { |
| 288 | 'c++' : CXXLanguage(), |
| 289 | 'csharp' : CSharpLanguage(), |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 290 | 'go' : GoLanguage(), |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 291 | 'java' : JavaLanguage(), |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 292 | 'node' : NodeLanguage(), |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 293 | 'php' : PHPLanguage(), |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 294 | 'ruby' : RubyLanguage(), |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 295 | 'python' : PythonLanguage(), |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 296 | } |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 297 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 298 | # languages supported as cloud_to_cloud servers |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 299 | _SERVERS = ['c++', 'node', 'csharp', 'java', 'go', 'ruby', 'python'] |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 300 | |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 301 | _TEST_CASES = ['large_unary', 'empty_unary', 'ping_pong', |
Jan Tattermusch | 1f1c5c5 | 2015-10-09 14:36:28 -0700 | [diff] [blame] | 302 | 'empty_stream', 'client_streaming', 'server_streaming', |
Jan Tattermusch | 13bf36a | 2015-10-14 17:01:00 -0700 | [diff] [blame] | 303 | 'cancel_after_begin', 'cancel_after_first_response', |
| 304 | 'timeout_on_sleeping_server'] |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 305 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 306 | _AUTH_TEST_CASES = ['compute_engine_creds', 'jwt_token_creds', |
| 307 | 'oauth2_auth_token', 'per_rpc_creds'] |
| 308 | |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 309 | _HTTP2_TEST_CASES = ["tls"] |
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 | def docker_run_cmdline(cmdline, image, docker_args=[], cwd=None, environ=None): |
| 312 | """Wraps given cmdline array to create 'docker run' cmdline from it.""" |
| 313 | docker_cmdline = ['docker', 'run', '-i', '--rm=true'] |
| 314 | |
| 315 | # turn environ into -e docker args |
| 316 | if environ: |
| 317 | for k,v in environ.iteritems(): |
| 318 | docker_cmdline += ['-e', '%s=%s' % (k,v)] |
| 319 | |
| 320 | # set working directory |
| 321 | workdir = '/var/local/git/grpc' |
| 322 | if cwd: |
| 323 | workdir = os.path.join(workdir, cwd) |
| 324 | docker_cmdline += ['-w', workdir] |
| 325 | |
| 326 | docker_cmdline += docker_args + [image] + cmdline |
| 327 | return docker_cmdline |
| 328 | |
| 329 | |
| 330 | def bash_login_cmdline(cmdline): |
| 331 | """Creates bash -l -c cmdline from args list.""" |
| 332 | # Use login shell: |
| 333 | # * rvm and nvm require it |
| 334 | # * makes error messages clearer if executables are missing |
| 335 | return ['bash', '-l', '-c', ' '.join(cmdline)] |
| 336 | |
| 337 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 338 | def add_auth_options(language, test_case, cmdline, env): |
| 339 | """Returns (cmdline, env) tuple with cloud_to_prod_auth test options.""" |
| 340 | |
| 341 | language = str(language) |
| 342 | cmdline = list(cmdline) |
| 343 | env = env.copy() |
| 344 | |
| 345 | # TODO(jtattermusch): this file path only works inside docker |
| 346 | key_filepath = '/root/service_account/stubbyCloudTestingTest-ee3fce360ac5.json' |
| 347 | oauth_scope_arg = '--oauth_scope=https://www.googleapis.com/auth/xapi.zoo' |
| 348 | key_file_arg = '--service_account_key_file=%s' % key_filepath |
| 349 | default_account_arg = '--default_service_account=830293263384-compute@developer.gserviceaccount.com' |
| 350 | |
| 351 | 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] | 352 | if language in ['csharp', 'node', 'php', 'python', 'ruby']: |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 353 | env['GOOGLE_APPLICATION_CREDENTIALS'] = key_filepath |
| 354 | else: |
| 355 | cmdline += [key_file_arg] |
| 356 | |
| 357 | if test_case in ['per_rpc_creds', 'oauth2_auth_token']: |
| 358 | cmdline += [oauth_scope_arg] |
| 359 | |
Jan Tattermusch | 64d7c24 | 2015-10-08 08:02:27 -0700 | [diff] [blame] | 360 | if test_case == 'oauth2_auth_token' and language == 'c++': |
| 361 | # C++ oauth2 test uses GCE creds and thus needs to know the default account |
| 362 | cmdline += [default_account_arg] |
| 363 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 364 | if test_case == 'compute_engine_creds': |
| 365 | cmdline += [oauth_scope_arg, default_account_arg] |
| 366 | |
| 367 | return (cmdline, env) |
| 368 | |
| 369 | |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 370 | def _job_kill_handler(job): |
| 371 | if job._spec.container_name: |
| 372 | dockerjob.docker_kill(job._spec.container_name) |
Jan Tattermusch | 39e3cb3 | 2015-10-22 18:21:08 -0700 | [diff] [blame] | 373 | # When the job times out and we decide to kill it, |
| 374 | # we need to wait a before restarting the job |
| 375 | # to prevent "container name already in use" error. |
| 376 | # TODO(jtattermusch): figure out a cleaner way to to this. |
| 377 | time.sleep(2) |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 378 | |
| 379 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 380 | 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] | 381 | """Creates jobspec for cloud-to-prod interop test""" |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 382 | cmdline = language.client_args() + [ |
| 383 | '--server_host_override=grpc-test.sandbox.google.com', |
| 384 | '--server_host=grpc-test.sandbox.google.com', |
| 385 | '--server_port=443', |
| 386 | '--use_tls=true', |
| 387 | '--test_case=%s' % test_case] |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 388 | cwd = language.client_cwd |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 389 | environ = dict(language.cloud_to_prod_env(), **language.global_env()) |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 390 | container_name = None |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 391 | if auth: |
| 392 | cmdline, environ = add_auth_options(language, test_case, cmdline, environ) |
| 393 | cmdline = bash_login_cmdline(cmdline) |
| 394 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 395 | if docker_image: |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 396 | container_name = dockerjob.random_name('interop_client_%s' % language.safename) |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 397 | cmdline = docker_run_cmdline(cmdline, |
| 398 | image=docker_image, |
| 399 | cwd=cwd, |
| 400 | environ=environ, |
| 401 | docker_args=['--net=host', |
| 402 | '--name', container_name]) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 403 | cwd = None |
| 404 | environ = None |
| 405 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 406 | suite_name='cloud_to_prod_auth' if auth else 'cloud_to_prod' |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 407 | test_job = jobset.JobSpec( |
| 408 | cmdline=cmdline, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 409 | cwd=cwd, |
| 410 | environ=environ, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 411 | shortname='%s:%s:%s' % (suite_name, language, test_case), |
Jan Tattermusch | 29fd005 | 2015-10-22 18:58:57 -0700 | [diff] [blame] | 412 | timeout_seconds=90, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 413 | flake_retries=5 if args.allow_flakes else 0, |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 414 | timeout_retries=2 if args.allow_flakes else 0, |
| 415 | kill_handler=_job_kill_handler) |
| 416 | test_job.container_name = container_name |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 417 | return test_job |
| 418 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 419 | |
| 420 | def cloud_to_cloud_jobspec(language, test_case, server_name, server_host, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 421 | server_port, docker_image=None): |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 422 | """Creates jobspec for cloud-to-cloud interop test""" |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 423 | cmdline = bash_login_cmdline(language.client_args() + |
| 424 | ['--server_host_override=foo.test.google.fr', |
| 425 | '--use_tls=true', |
| 426 | '--use_test_ca=true', |
| 427 | '--test_case=%s' % test_case, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 428 | '--server_host=%s' % server_host, |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 429 | '--server_port=%s' % server_port]) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 430 | cwd = language.client_cwd |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 431 | environ = language.global_env() |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 432 | if docker_image: |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 433 | container_name = dockerjob.random_name('interop_client_%s' % language.safename) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 434 | cmdline = docker_run_cmdline(cmdline, |
| 435 | image=docker_image, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 436 | environ=environ, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 437 | cwd=cwd, |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 438 | docker_args=['--net=host', |
| 439 | '--name', container_name]) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 440 | cwd = None |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 441 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 442 | test_job = jobset.JobSpec( |
| 443 | cmdline=cmdline, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 444 | cwd=cwd, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 445 | environ=environ, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 446 | shortname='cloud_to_cloud:%s:%s_server:%s' % (language, server_name, |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 447 | test_case), |
Jan Tattermusch | 29fd005 | 2015-10-22 18:58:57 -0700 | [diff] [blame] | 448 | timeout_seconds=90, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 449 | flake_retries=5 if args.allow_flakes else 0, |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 450 | timeout_retries=2 if args.allow_flakes else 0, |
| 451 | kill_handler=_job_kill_handler) |
| 452 | test_job.container_name = container_name |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 453 | return test_job |
| 454 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 455 | |
| 456 | def server_jobspec(language, docker_image): |
| 457 | """Create jobspec for running a server""" |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 458 | container_name = dockerjob.random_name('interop_server_%s' % language.safename) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 459 | cmdline = bash_login_cmdline(language.server_args() + |
| 460 | ['--port=%s' % _DEFAULT_SERVER_PORT]) |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 461 | environ = language.global_env() |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 462 | docker_cmdline = docker_run_cmdline(cmdline, |
| 463 | image=docker_image, |
| 464 | cwd=language.server_cwd, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 465 | environ=environ, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 466 | docker_args=['-p', str(_DEFAULT_SERVER_PORT), |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 467 | '--name', container_name]) |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 468 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 469 | server_job = jobset.JobSpec( |
| 470 | cmdline=docker_cmdline, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 471 | environ=environ, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 472 | shortname='interop_server_%s' % language, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 473 | timeout_seconds=30*60) |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 474 | server_job.container_name = container_name |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 475 | return server_job |
| 476 | |
| 477 | |
| 478 | def build_interop_image_jobspec(language, tag=None): |
| 479 | """Creates jobspec for building interop docker image for a language""" |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 480 | if not tag: |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 481 | tag = 'grpc_interop_%s:%s' % (language.safename, uuid.uuid4()) |
Stanley Cheung | 22b6bed | 2015-10-15 16:54:52 -0700 | [diff] [blame] | 482 | env = {'INTEROP_IMAGE': tag, |
| 483 | 'BASE_NAME': 'grpc_interop_%s' % language.safename} |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 484 | if not args.travis: |
Stanley Cheung | 22b6bed | 2015-10-15 16:54:52 -0700 | [diff] [blame] | 485 | env['TTY_FLAG'] = '-t' |
| 486 | # This env variable is used to get around the github rate limit |
| 487 | # error when running the PHP `composer install` command |
| 488 | # TODO(stanleycheung): find a more elegant way to do this |
Stanley Cheung | f565dfb | 2015-10-15 17:57:09 -0700 | [diff] [blame] | 489 | 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] | 490 | env['BUILD_INTEROP_DOCKER_EXTRA_ARGS'] = \ |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 491 | '-v /var/local/.composer/auth.json:/root/.composer/auth.json:ro' |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 492 | build_job = jobset.JobSpec( |
| 493 | cmdline=['tools/jenkins/build_interop_image.sh'], |
Stanley Cheung | 22b6bed | 2015-10-15 16:54:52 -0700 | [diff] [blame] | 494 | environ=env, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 495 | shortname='build_docker_%s' % (language), |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 496 | timeout_seconds=30*60) |
| 497 | build_job.tag = tag |
| 498 | return build_job |
| 499 | |
| 500 | |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 501 | argp = argparse.ArgumentParser(description='Run interop tests.') |
| 502 | argp.add_argument('-l', '--language', |
| 503 | choices=['all'] + sorted(_LANGUAGES), |
| 504 | nargs='+', |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 505 | default=['all'], |
| 506 | help='Clients to run.') |
Jan Tattermusch | 210a0ea | 2015-10-02 15:05:36 -0700 | [diff] [blame] | 507 | argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 508 | argp.add_argument('--cloud_to_prod', |
| 509 | default=False, |
| 510 | action='store_const', |
| 511 | const=True, |
| 512 | help='Run cloud_to_prod tests.') |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 513 | argp.add_argument('--cloud_to_prod_auth', |
| 514 | default=False, |
| 515 | action='store_const', |
| 516 | const=True, |
| 517 | help='Run cloud_to_prod_auth tests.') |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 518 | argp.add_argument('-s', '--server', |
| 519 | choices=['all'] + sorted(_SERVERS), |
| 520 | action='append', |
| 521 | help='Run cloud_to_cloud servers in a separate docker ' + |
| 522 | 'image. Servers can only be started automatically if ' + |
| 523 | '--use_docker option is enabled.', |
| 524 | default=[]) |
| 525 | argp.add_argument('--override_server', |
| 526 | action='append', |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 527 | type=lambda kv: kv.split('='), |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 528 | help='Use servername=HOST:PORT to explicitly specify a server. E.g. csharp=localhost:50000', |
| 529 | default=[]) |
| 530 | argp.add_argument('-t', '--travis', |
| 531 | default=False, |
| 532 | action='store_const', |
| 533 | const=True) |
| 534 | argp.add_argument('--use_docker', |
| 535 | default=False, |
| 536 | action='store_const', |
| 537 | const=True, |
| 538 | help='Run all the interop tests under docker. That provides ' + |
| 539 | 'additional isolation and prevents the need to install ' + |
| 540 | 'language specific prerequisites. Only available on Linux.') |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 541 | argp.add_argument('--allow_flakes', |
| 542 | default=False, |
| 543 | action='store_const', |
| 544 | const=True, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 545 | 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] | 546 | argp.add_argument('--http2_interop', |
| 547 | default=False, |
| 548 | action='store_const', |
| 549 | const=True, |
| 550 | help='Enable HTTP/2 interop tests') |
| 551 | |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 552 | args = argp.parse_args() |
| 553 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 554 | servers = set(s for s in itertools.chain.from_iterable(_SERVERS |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 555 | if x == 'all' else [x] |
| 556 | for x in args.server)) |
| 557 | |
| 558 | if args.use_docker: |
| 559 | if not args.travis: |
| 560 | print 'Seen --use_docker flag, will run interop tests under docker.' |
| 561 | print |
| 562 | print 'IMPORTANT: The changes you are testing need to be locally committed' |
| 563 | print 'because only the committed changes in the current branch will be' |
| 564 | print 'copied to the docker environment.' |
| 565 | time.sleep(5) |
| 566 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 567 | if not args.use_docker and servers: |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 568 | print 'Running interop servers is only supported with --use_docker option enabled.' |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 569 | sys.exit(1) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 570 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 571 | languages = set(_LANGUAGES[l] |
| 572 | for l in itertools.chain.from_iterable( |
| 573 | _LANGUAGES.iterkeys() if x == 'all' else [x] |
| 574 | for x in args.language)) |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 575 | |
| 576 | http2Interop = Http2Client() if args.http2_interop else None |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 577 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 578 | docker_images={} |
| 579 | if args.use_docker: |
| 580 | # languages for which to build docker images |
| 581 | languages_to_build = set(_LANGUAGES[k] for k in set([str(l) for l in languages] + |
| 582 | [s for s in servers])) |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 583 | if args.http2_interop: |
| 584 | languages_to_build.add(http2Interop) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 585 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 586 | build_jobs = [] |
| 587 | for l in languages_to_build: |
| 588 | job = build_interop_image_jobspec(l) |
| 589 | docker_images[str(l)] = job.tag |
| 590 | build_jobs.append(job) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 591 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 592 | if build_jobs: |
| 593 | jobset.message('START', 'Building interop docker images.', do_newline=True) |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 594 | num_failures, _ = jobset.run( |
| 595 | build_jobs, newline_on_success=True, maxjobs=args.jobs) |
| 596 | if num_failures == 0: |
| 597 | jobset.message('SUCCESS', 'All docker images built successfully.', |
| 598 | do_newline=True) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 599 | else: |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 600 | jobset.message('FAILED', 'Failed to build interop docker images.', |
| 601 | do_newline=True) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 602 | for image in docker_images.itervalues(): |
| 603 | dockerjob.remove_image(image, skip_nonexistent=True) |
Carl Mastrangelo | 7a17140 | 2015-10-26 14:01:03 -0700 | [diff] [blame] | 604 | sys.exit(1) |
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 | # Start interop servers. |
| 607 | server_jobs={} |
| 608 | server_addresses={} |
| 609 | try: |
| 610 | for s in servers: |
| 611 | lang = str(s) |
| 612 | spec = server_jobspec(_LANGUAGES[lang], docker_images.get(lang)) |
| 613 | job = dockerjob.DockerJob(spec) |
| 614 | server_jobs[lang] = job |
| 615 | server_addresses[lang] = ('localhost', job.mapped_port(_DEFAULT_SERVER_PORT)) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 616 | |
Jan Tattermusch | 210a0ea | 2015-10-02 15:05:36 -0700 | [diff] [blame] | 617 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 618 | jobs = [] |
| 619 | if args.cloud_to_prod: |
| 620 | for language in languages: |
| 621 | for test_case in _TEST_CASES: |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 622 | if not test_case in language.unimplemented_test_cases(): |
| 623 | test_job = cloud_to_prod_jobspec(language, test_case, |
| 624 | docker_image=docker_images.get(str(language))) |
| 625 | jobs.append(test_job) |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 626 | |
Carl Mastrangelo | 3b2e1bd | 2015-11-06 14:31:55 -0800 | [diff] [blame^] | 627 | # TODO(carl-mastrangelo): Currently prod TLS terminators aren't spec compliant. Reenable |
| 628 | # this once a better solution is in place. |
| 629 | if args.http2_interop and False: |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 630 | for test_case in _HTTP2_TEST_CASES: |
| 631 | test_job = cloud_to_prod_jobspec(http2Interop, test_case, |
| 632 | docker_image=docker_images.get(str(http2Interop))) |
| 633 | jobs.append(test_job) |
| 634 | |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 635 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 636 | if args.cloud_to_prod_auth: |
| 637 | for language in languages: |
| 638 | for test_case in _AUTH_TEST_CASES: |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 639 | if not test_case in language.unimplemented_test_cases(): |
| 640 | test_job = cloud_to_prod_jobspec(language, test_case, |
| 641 | docker_image=docker_images.get(str(language)), |
| 642 | auth=True) |
| 643 | jobs.append(test_job) |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 644 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 645 | for server in args.override_server: |
| 646 | server_name = server[0] |
| 647 | (server_host, server_port) = server[1].split(':') |
| 648 | server_addresses[server_name] = (server_host, server_port) |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 649 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 650 | for server_name, server_address in server_addresses.iteritems(): |
| 651 | (server_host, server_port) = server_address |
| 652 | for language in languages: |
| 653 | for test_case in _TEST_CASES: |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 654 | if not test_case in language.unimplemented_test_cases(): |
| 655 | test_job = cloud_to_cloud_jobspec(language, |
| 656 | test_case, |
| 657 | server_name, |
| 658 | server_host, |
| 659 | server_port, |
| 660 | docker_image=docker_images.get(str(language))) |
| 661 | jobs.append(test_job) |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 662 | |
| 663 | if args.http2_interop: |
| 664 | for test_case in _HTTP2_TEST_CASES: |
Carl Mastrangelo | 3b2e1bd | 2015-11-06 14:31:55 -0800 | [diff] [blame^] | 665 | if server_name == "go": |
| 666 | # TODO(carl-mastrangelo): Reenable after https://github.com/grpc/grpc-go/issues/434 |
| 667 | continue |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 668 | test_job = cloud_to_cloud_jobspec(http2Interop, |
| 669 | test_case, |
| 670 | server_name, |
| 671 | server_host, |
| 672 | server_port, |
| 673 | docker_image=docker_images.get(str(http2Interop))) |
| 674 | jobs.append(test_job) |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 675 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 676 | if not jobs: |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 677 | print 'No jobs to run.' |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 678 | for image in docker_images.itervalues(): |
| 679 | dockerjob.remove_image(image, skip_nonexistent=True) |
| 680 | sys.exit(1) |
| 681 | |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 682 | num_failures, resultset = jobset.run(jobs, newline_on_success=True, |
Adele Zhou | 2271ab5 | 2015-10-28 13:59:14 -0700 | [diff] [blame] | 683 | maxjobs=args.jobs) |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 684 | if num_failures: |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 685 | jobset.message('FAILED', 'Some tests failed', do_newline=True) |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 686 | else: |
| 687 | jobset.message('SUCCESS', 'All tests passed', do_newline=True) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 688 | |
Adele Zhou | a30f829 | 2015-11-02 13:15:46 -0800 | [diff] [blame] | 689 | report_utils.render_xml_report(resultset, 'report.xml') |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 690 | |
Adele Zhou | a30f829 | 2015-11-02 13:15:46 -0800 | [diff] [blame] | 691 | report_utils.render_html_report( |
Adele Zhou | 2271ab5 | 2015-10-28 13:59:14 -0700 | [diff] [blame] | 692 | 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] | 693 | _HTTP2_TEST_CASES, resultset, num_failures, |
| 694 | 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] | 695 | |
| 696 | finally: |
| 697 | # Check if servers are still running. |
| 698 | for server, job in server_jobs.iteritems(): |
| 699 | if not job.is_running(): |
| 700 | print 'Server "%s" has exited prematurely.' % server |
| 701 | |
| 702 | dockerjob.finish_jobs([j for j in server_jobs.itervalues()]) |
| 703 | |
| 704 | for image in docker_images.itervalues(): |
| 705 | print 'Removing docker image %s' % image |
| 706 | dockerjob.remove_image(image) |