Nathaniel Manista | cbf21da | 2016-02-02 22:17:44 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python2.7 |
Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 2 | # Copyright 2015, Google Inc. |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 3 | # All rights reserved. |
| 4 | # |
| 5 | # Redistribution and use in source and binary forms, with or without |
| 6 | # modification, are permitted provided that the following conditions are |
| 7 | # met: |
| 8 | # |
| 9 | # * Redistributions of source code must retain the above copyright |
| 10 | # notice, this list of conditions and the following disclaimer. |
| 11 | # * Redistributions in binary form must reproduce the above |
| 12 | # copyright notice, this list of conditions and the following disclaimer |
| 13 | # in the documentation and/or other materials provided with the |
| 14 | # distribution. |
| 15 | # * Neither the name of Google Inc. nor the names of its |
| 16 | # contributors may be used to endorse or promote products derived from |
| 17 | # this software without specific prior written permission. |
| 18 | # |
| 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
| 31 | """Run interop (cross-language) tests in parallel.""" |
| 32 | |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 33 | from __future__ import print_function |
| 34 | |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 35 | import argparse |
Carl Mastrangelo | e7f8e8e | 2015-12-08 17:22:44 -0800 | [diff] [blame] | 36 | import atexit |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 37 | import itertools |
Carl Mastrangelo | e7f8e8e | 2015-12-08 17:22:44 -0800 | [diff] [blame] | 38 | import json |
Jan Tattermusch | 210a0ea | 2015-10-02 15:05:36 -0700 | [diff] [blame] | 39 | import multiprocessing |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 40 | import os |
Carl Mastrangelo | e7f8e8e | 2015-12-08 17:22:44 -0800 | [diff] [blame] | 41 | import re |
Carl Mastrangelo | e7f8e8e | 2015-12-08 17:22:44 -0800 | [diff] [blame] | 42 | import subprocess |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 43 | import sys |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 44 | import tempfile |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 45 | import time |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 46 | import uuid |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 47 | |
Jan Tattermusch | 5c79a31 | 2016-12-20 11:02:50 +0100 | [diff] [blame] | 48 | import python_utils.dockerjob as dockerjob |
| 49 | import python_utils.jobset as jobset |
| 50 | import python_utils.report_utils as report_utils |
| 51 | |
Carl Mastrangelo | e7f8e8e | 2015-12-08 17:22:44 -0800 | [diff] [blame] | 52 | # Docker doesn't clean up after itself, so we do it on exit. |
| 53 | atexit.register(lambda: subprocess.call(['stty', 'echo'])) |
| 54 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 55 | ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..')) |
| 56 | os.chdir(ROOT) |
| 57 | |
| 58 | _DEFAULT_SERVER_PORT=8080 |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 59 | |
Jan Tattermusch | 9fc079f | 2016-06-21 19:53:31 -0700 | [diff] [blame] | 60 | _SKIP_CLIENT_COMPRESSION = ['client_compressed_unary', |
| 61 | 'client_compressed_streaming'] |
| 62 | |
| 63 | _SKIP_SERVER_COMPRESSION = ['server_compressed_unary', |
| 64 | 'server_compressed_streaming'] |
| 65 | |
| 66 | _SKIP_COMPRESSION = _SKIP_CLIENT_COMPRESSION + _SKIP_SERVER_COMPRESSION |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 67 | |
Noah Eisen | 794afb3 | 2016-11-11 14:42:52 -0800 | [diff] [blame] | 68 | _SKIP_ADVANCED = ['status_code_and_message', |
| 69 | 'custom_metadata', |
| 70 | 'unimplemented_method', |
| 71 | 'unimplemented_service'] |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 72 | |
Jan Tattermusch | 19f703d | 2016-03-03 15:33:29 -0800 | [diff] [blame] | 73 | _TEST_TIMEOUT = 3*60 |
| 74 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 75 | class CXXLanguage: |
| 76 | |
| 77 | def __init__(self): |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 78 | self.client_cwd = None |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 79 | self.server_cwd = None |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 80 | self.safename = 'cxx' |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 81 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 82 | def client_cmd(self, args): |
| 83 | return ['bins/opt/interop_client'] + args |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 84 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 85 | def cloud_to_prod_env(self): |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 86 | return {} |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 87 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 88 | def server_cmd(self, args): |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 89 | return ['bins/opt/interop_server'] + args |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 90 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 91 | def global_env(self): |
| 92 | return {} |
| 93 | |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 94 | def unimplemented_test_cases(self): |
Noah Eisen | 88477fd | 2016-10-18 12:25:25 -0700 | [diff] [blame] | 95 | return [] |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 96 | |
| 97 | def unimplemented_test_cases_server(self): |
Noah Eisen | 88477fd | 2016-10-18 12:25:25 -0700 | [diff] [blame] | 98 | return [] |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 99 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 100 | def __str__(self): |
| 101 | return 'c++' |
| 102 | |
| 103 | |
| 104 | class CSharpLanguage: |
| 105 | |
| 106 | def __init__(self): |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 107 | self.client_cwd = 'src/csharp/Grpc.IntegrationTesting.Client/bin/Debug' |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 108 | self.server_cwd = 'src/csharp/Grpc.IntegrationTesting.Server/bin/Debug' |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 109 | self.safename = str(self) |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 110 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 111 | def client_cmd(self, args): |
| 112 | return ['mono', 'Grpc.IntegrationTesting.Client.exe'] + args |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 113 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 114 | def cloud_to_prod_env(self): |
Jan Tattermusch | a6b2c4c | 2015-12-10 16:41:11 -0800 | [diff] [blame] | 115 | return {} |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 116 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 117 | def server_cmd(self, args): |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 118 | return ['mono', 'Grpc.IntegrationTesting.Server.exe'] + args |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 119 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 120 | def global_env(self): |
| 121 | return {} |
| 122 | |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 123 | def unimplemented_test_cases(self): |
Jan Tattermusch | 9fc079f | 2016-06-21 19:53:31 -0700 | [diff] [blame] | 124 | return _SKIP_SERVER_COMPRESSION |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 125 | |
| 126 | def unimplemented_test_cases_server(self): |
| 127 | return _SKIP_COMPRESSION |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 128 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 129 | def __str__(self): |
| 130 | return 'csharp' |
| 131 | |
| 132 | |
Jan Tattermusch | a98a2ad | 2016-09-09 12:42:32 +0200 | [diff] [blame] | 133 | class CSharpCoreCLRLanguage: |
| 134 | |
| 135 | def __init__(self): |
| 136 | self.client_cwd = 'src/csharp/Grpc.IntegrationTesting.Client/bin/Debug/netcoreapp1.0' |
| 137 | self.server_cwd = 'src/csharp/Grpc.IntegrationTesting.Server/bin/Debug/netcoreapp1.0' |
| 138 | self.safename = str(self) |
| 139 | |
| 140 | def client_cmd(self, args): |
| 141 | return ['dotnet', 'exec', 'Grpc.IntegrationTesting.Client.dll'] + args |
| 142 | |
| 143 | def cloud_to_prod_env(self): |
| 144 | return {} |
| 145 | |
| 146 | def server_cmd(self, args): |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 147 | return ['dotnet', 'exec', 'Grpc.IntegrationTesting.Server.dll'] + args |
Jan Tattermusch | a98a2ad | 2016-09-09 12:42:32 +0200 | [diff] [blame] | 148 | |
| 149 | def global_env(self): |
| 150 | return {} |
| 151 | |
| 152 | def unimplemented_test_cases(self): |
| 153 | return _SKIP_SERVER_COMPRESSION |
| 154 | |
| 155 | def unimplemented_test_cases_server(self): |
| 156 | return _SKIP_COMPRESSION |
| 157 | |
| 158 | def __str__(self): |
| 159 | return 'csharpcoreclr' |
| 160 | |
| 161 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 162 | class JavaLanguage: |
| 163 | |
| 164 | def __init__(self): |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 165 | self.client_cwd = '../grpc-java' |
| 166 | self.server_cwd = '../grpc-java' |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 167 | self.safename = str(self) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 168 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 169 | def client_cmd(self, args): |
| 170 | return ['./run-test-client.sh'] + args |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 171 | |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 172 | def client_cmd_http2interop(self, args): |
Eric Gribkoff | 4e51140 | 2017-01-20 11:07:59 -0800 | [diff] [blame^] | 173 | return ['./interop-testing/build/install/grpc-interop-testing/bin/http2-client'] + args |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 174 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 175 | def cloud_to_prod_env(self): |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 176 | return {} |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 177 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 178 | def server_cmd(self, args): |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 179 | return ['./run-test-server.sh'] + args |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 180 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 181 | def global_env(self): |
| 182 | return {} |
| 183 | |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 184 | def unimplemented_test_cases(self): |
Eric Gribkoff | ced8702 | 2017-01-06 09:16:29 -0800 | [diff] [blame] | 185 | return _SKIP_COMPRESSION |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 186 | |
| 187 | def unimplemented_test_cases_server(self): |
Eric Gribkoff | ced8702 | 2017-01-06 09:16:29 -0800 | [diff] [blame] | 188 | return _SKIP_COMPRESSION |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 189 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 190 | def __str__(self): |
| 191 | return 'java' |
| 192 | |
| 193 | |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 194 | class GoLanguage: |
| 195 | |
| 196 | def __init__(self): |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 197 | # TODO: this relies on running inside docker |
| 198 | self.client_cwd = '/go/src/google.golang.org/grpc/interop/client' |
| 199 | self.server_cwd = '/go/src/google.golang.org/grpc/interop/server' |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 200 | self.safename = str(self) |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 201 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 202 | def client_cmd(self, args): |
| 203 | return ['go', 'run', 'client.go'] + args |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 204 | |
| 205 | def cloud_to_prod_env(self): |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 206 | return {} |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 207 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 208 | def server_cmd(self, args): |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 209 | return ['go', 'run', 'server.go'] + args |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 210 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 211 | def global_env(self): |
| 212 | return {} |
| 213 | |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 214 | def unimplemented_test_cases(self): |
Noah Eisen | 794afb3 | 2016-11-11 14:42:52 -0800 | [diff] [blame] | 215 | return _SKIP_COMPRESSION |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 216 | |
| 217 | def unimplemented_test_cases_server(self): |
Noah Eisen | 794afb3 | 2016-11-11 14:42:52 -0800 | [diff] [blame] | 218 | return _SKIP_COMPRESSION |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 219 | |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 220 | def __str__(self): |
| 221 | return 'go' |
| 222 | |
Makarand Dharmapurikar | 078e421 | 2017-01-10 15:09:21 -0800 | [diff] [blame] | 223 | class Http2Server: |
| 224 | """Represents the HTTP/2 Interop Test server |
| 225 | |
| 226 | This pretends to be a language in order to be built and run, but really it |
| 227 | isn't. |
| 228 | """ |
| 229 | def __init__(self): |
| 230 | self.server_cwd = None |
| 231 | self.safename = str(self) |
| 232 | |
| 233 | def server_cmd(self, args): |
| 234 | return ['python test/http2_test/http2_test_server.py'] |
| 235 | |
| 236 | def cloud_to_prod_env(self): |
| 237 | return {} |
| 238 | |
| 239 | def global_env(self): |
| 240 | return {} |
| 241 | |
| 242 | def unimplemented_test_cases(self): |
| 243 | return _TEST_CASES |
| 244 | |
| 245 | def unimplemented_test_cases_server(self): |
| 246 | return _TEST_CASES |
| 247 | |
| 248 | def __str__(self): |
| 249 | return 'http2' |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 250 | |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 251 | class Http2Client: |
| 252 | """Represents the HTTP/2 Interop Test |
| 253 | |
| 254 | This pretends to be a language in order to be built and run, but really it |
| 255 | isn't. |
| 256 | """ |
| 257 | def __init__(self): |
| 258 | self.client_cwd = None |
| 259 | self.safename = str(self) |
| 260 | |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 261 | def client_cmd(self, args): |
| 262 | return ['tools/http2_interop/http2_interop.test', '-test.v'] + args |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 263 | |
| 264 | def cloud_to_prod_env(self): |
| 265 | return {} |
| 266 | |
| 267 | def global_env(self): |
| 268 | return {} |
| 269 | |
| 270 | def unimplemented_test_cases(self): |
| 271 | return _TEST_CASES |
| 272 | |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 273 | def unimplemented_test_cases_server(self): |
| 274 | return [] |
| 275 | |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 276 | def __str__(self): |
| 277 | return 'http2' |
| 278 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 279 | class NodeLanguage: |
| 280 | |
| 281 | def __init__(self): |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 282 | self.client_cwd = None |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 283 | self.server_cwd = None |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 284 | self.safename = str(self) |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 285 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 286 | def client_cmd(self, args): |
Jan Tattermusch | 6d4dba9 | 2016-11-18 10:36:35 +0100 | [diff] [blame] | 287 | return ['tools/run_tests/interop/with_nvm.sh', |
| 288 | 'node', 'src/node/interop/interop_client.js'] + args |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 289 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 290 | def cloud_to_prod_env(self): |
Jan Tattermusch | a6b2c4c | 2015-12-10 16:41:11 -0800 | [diff] [blame] | 291 | return {} |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 292 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 293 | def server_cmd(self, args): |
Jan Tattermusch | 6d4dba9 | 2016-11-18 10:36:35 +0100 | [diff] [blame] | 294 | return ['tools/run_tests/interop/with_nvm.sh', |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 295 | 'node', 'src/node/interop/interop_server.js'] + args |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 296 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 297 | def global_env(self): |
| 298 | return {} |
| 299 | |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 300 | def unimplemented_test_cases(self): |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 301 | return _SKIP_COMPRESSION |
| 302 | |
| 303 | def unimplemented_test_cases_server(self): |
| 304 | return _SKIP_COMPRESSION |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 305 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 306 | def __str__(self): |
| 307 | return 'node' |
| 308 | |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 309 | |
| 310 | class PHPLanguage: |
| 311 | |
| 312 | def __init__(self): |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 313 | self.client_cwd = None |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 314 | self.safename = str(self) |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 315 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 316 | def client_cmd(self, args): |
| 317 | return ['src/php/bin/interop_client.sh'] + args |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 318 | |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 319 | def cloud_to_prod_env(self): |
Jan Tattermusch | a6b2c4c | 2015-12-10 16:41:11 -0800 | [diff] [blame] | 320 | return {} |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 321 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 322 | def global_env(self): |
Stanley Cheung | 22b6bed | 2015-10-15 16:54:52 -0700 | [diff] [blame] | 323 | return {} |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 324 | |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 325 | def unimplemented_test_cases(self): |
Stanley Cheung | 83d8e37 | 2016-06-17 11:53:33 -0700 | [diff] [blame] | 326 | return _SKIP_COMPRESSION |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 327 | |
| 328 | def unimplemented_test_cases_server(self): |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 329 | return [] |
| 330 | |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 331 | def __str__(self): |
| 332 | return 'php' |
| 333 | |
| 334 | |
Stanley Cheung | 2e2cdff | 2016-07-23 19:07:36 -0700 | [diff] [blame] | 335 | class PHP7Language: |
| 336 | |
| 337 | def __init__(self): |
| 338 | self.client_cwd = None |
| 339 | self.safename = str(self) |
| 340 | |
| 341 | def client_cmd(self, args): |
| 342 | return ['src/php/bin/interop_client.sh'] + args |
| 343 | |
| 344 | def cloud_to_prod_env(self): |
| 345 | return {} |
| 346 | |
| 347 | def global_env(self): |
| 348 | return {} |
| 349 | |
| 350 | def unimplemented_test_cases(self): |
| 351 | return _SKIP_COMPRESSION |
| 352 | |
| 353 | def unimplemented_test_cases_server(self): |
| 354 | return [] |
| 355 | |
| 356 | def __str__(self): |
| 357 | return 'php7' |
| 358 | |
| 359 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 360 | class RubyLanguage: |
| 361 | |
| 362 | def __init__(self): |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 363 | self.client_cwd = None |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 364 | self.server_cwd = None |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 365 | self.safename = str(self) |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 366 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 367 | def client_cmd(self, args): |
Jan Tattermusch | 34e8b91 | 2016-11-18 10:44:28 +0100 | [diff] [blame] | 368 | return ['tools/run_tests/interop/with_rvm.sh', |
| 369 | 'ruby', 'src/ruby/pb/test/client.rb'] + args |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 370 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 371 | def cloud_to_prod_env(self): |
Jan Tattermusch | a6b2c4c | 2015-12-10 16:41:11 -0800 | [diff] [blame] | 372 | return {} |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 373 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 374 | def server_cmd(self, args): |
Jan Tattermusch | 34e8b91 | 2016-11-18 10:44:28 +0100 | [diff] [blame] | 375 | return ['tools/run_tests/interop/with_rvm.sh', |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 376 | 'ruby', 'src/ruby/pb/test/server.rb'] + args |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 377 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 378 | def global_env(self): |
| 379 | return {} |
| 380 | |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 381 | def unimplemented_test_cases(self): |
ncteisen | 9d1cc8c | 2017-01-10 13:57:25 -0800 | [diff] [blame] | 382 | return _SKIP_SERVER_COMPRESSION |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 383 | |
| 384 | def unimplemented_test_cases_server(self): |
ncteisen | 9d1cc8c | 2017-01-10 13:57:25 -0800 | [diff] [blame] | 385 | return _SKIP_COMPRESSION |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 386 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 387 | def __str__(self): |
| 388 | return 'ruby' |
| 389 | |
| 390 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 391 | class PythonLanguage: |
| 392 | |
| 393 | def __init__(self): |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 394 | self.client_cwd = None |
| 395 | self.server_cwd = None |
| 396 | self.safename = str(self) |
| 397 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 398 | def client_cmd(self, args): |
| 399 | return [ |
Masood Malekghassemi | 3b5b206 | 2016-06-02 20:27:20 -0700 | [diff] [blame] | 400 | 'py27/bin/python', |
| 401 | 'src/python/grpcio_tests/setup.py', |
| 402 | 'run_interop', |
| 403 | '--client', |
| 404 | '--args="{}"'.format(' '.join(args)) |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 405 | ] |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 406 | |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 407 | def client_cmd_http2interop(self, args): |
| 408 | return [ 'py27/bin/python', |
| 409 | 'src/python/grpcio_tests/tests/http2/_negative_http2_client.py', |
| 410 | ] + args |
| 411 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 412 | def cloud_to_prod_env(self): |
Jan Tattermusch | a6b2c4c | 2015-12-10 16:41:11 -0800 | [diff] [blame] | 413 | return {} |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 414 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 415 | def server_cmd(self, args): |
| 416 | return [ |
Masood Malekghassemi | 3b5b206 | 2016-06-02 20:27:20 -0700 | [diff] [blame] | 417 | 'py27/bin/python', |
| 418 | 'src/python/grpcio_tests/setup.py', |
| 419 | 'run_interop', |
| 420 | '--server', |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 421 | '--args="{}"'.format(' '.join(args)) |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 422 | ] |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 423 | |
| 424 | def global_env(self): |
Ken Payson | 707c9e2 | 2016-04-20 09:42:19 -0700 | [diff] [blame] | 425 | return {'LD_LIBRARY_PATH': '{}/libs/opt'.format(DOCKER_WORKDIR_ROOT), |
| 426 | 'PYTHONPATH': '{}/src/python/gens'.format(DOCKER_WORKDIR_ROOT)} |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 427 | |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 428 | def unimplemented_test_cases(self): |
Noah Eisen | 9785c8f | 2016-10-25 12:04:24 -0700 | [diff] [blame] | 429 | return _SKIP_COMPRESSION |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 430 | |
| 431 | def unimplemented_test_cases_server(self): |
Noah Eisen | 9785c8f | 2016-10-25 12:04:24 -0700 | [diff] [blame] | 432 | return _SKIP_COMPRESSION |
Jan Tattermusch | 289b7b9 | 2015-10-21 18:09:59 -0700 | [diff] [blame] | 433 | |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 434 | def __str__(self): |
| 435 | return 'python' |
| 436 | |
| 437 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 438 | _LANGUAGES = { |
| 439 | 'c++' : CXXLanguage(), |
| 440 | 'csharp' : CSharpLanguage(), |
Jan Tattermusch | a98a2ad | 2016-09-09 12:42:32 +0200 | [diff] [blame] | 441 | 'csharpcoreclr' : CSharpCoreCLRLanguage(), |
Jan Tattermusch | cc1bde7 | 2015-10-05 12:47:45 -0700 | [diff] [blame] | 442 | 'go' : GoLanguage(), |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 443 | 'java' : JavaLanguage(), |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 444 | 'node' : NodeLanguage(), |
Jan Tattermusch | f88f3e2 | 2015-09-16 17:50:45 -0700 | [diff] [blame] | 445 | 'php' : PHPLanguage(), |
Stanley Cheung | 2e2cdff | 2016-07-23 19:07:36 -0700 | [diff] [blame] | 446 | 'php7' : PHP7Language(), |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 447 | 'ruby' : RubyLanguage(), |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 448 | 'python' : PythonLanguage(), |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 449 | } |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 450 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 451 | # languages supported as cloud_to_cloud servers |
Jan Tattermusch | a98a2ad | 2016-09-09 12:42:32 +0200 | [diff] [blame] | 452 | _SERVERS = ['c++', 'node', 'csharp', 'csharpcoreclr', 'java', 'go', 'ruby', 'python'] |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 453 | |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 454 | _TEST_CASES = ['large_unary', 'empty_unary', 'ping_pong', |
Jan Tattermusch | 1f1c5c5 | 2015-10-09 14:36:28 -0700 | [diff] [blame] | 455 | 'empty_stream', 'client_streaming', 'server_streaming', |
Jan Tattermusch | 13bf36a | 2015-10-14 17:01:00 -0700 | [diff] [blame] | 456 | 'cancel_after_begin', 'cancel_after_first_response', |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 457 | 'timeout_on_sleeping_server', 'custom_metadata', |
| 458 | 'status_code_and_message', 'unimplemented_method', |
David Garcia Quintas | ff32a86 | 2016-06-21 17:07:20 -0700 | [diff] [blame] | 459 | 'client_compressed_unary', 'server_compressed_unary', |
Noah Eisen | 7fc1d4e | 2016-10-27 18:17:03 -0700 | [diff] [blame] | 460 | 'client_compressed_streaming', 'server_compressed_streaming', |
| 461 | 'unimplemented_service'] |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 462 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 463 | _AUTH_TEST_CASES = ['compute_engine_creds', 'jwt_token_creds', |
| 464 | 'oauth2_auth_token', 'per_rpc_creds'] |
| 465 | |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 466 | _HTTP2_TEST_CASES = ['tls', 'framing'] |
| 467 | |
| 468 | _HTTP2_BADSERVER_TEST_CASES = ['rst_after_header', 'rst_after_data', 'rst_during_data', |
| 469 | 'goaway', 'ping', 'max_streams'] |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 470 | |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 471 | DOCKER_WORKDIR_ROOT = '/var/local/git/grpc' |
| 472 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 473 | def docker_run_cmdline(cmdline, image, docker_args=[], cwd=None, environ=None): |
| 474 | """Wraps given cmdline array to create 'docker run' cmdline from it.""" |
| 475 | docker_cmdline = ['docker', 'run', '-i', '--rm=true'] |
| 476 | |
| 477 | # turn environ into -e docker args |
| 478 | if environ: |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 479 | for k,v in environ.items(): |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 480 | docker_cmdline += ['-e', '%s=%s' % (k,v)] |
| 481 | |
| 482 | # set working directory |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 483 | workdir = DOCKER_WORKDIR_ROOT |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 484 | if cwd: |
| 485 | workdir = os.path.join(workdir, cwd) |
| 486 | docker_cmdline += ['-w', workdir] |
| 487 | |
| 488 | docker_cmdline += docker_args + [image] + cmdline |
| 489 | return docker_cmdline |
| 490 | |
| 491 | |
Jan Tattermusch | 03b7612 | 2016-11-17 15:28:57 +0100 | [diff] [blame] | 492 | def bash_cmdline(cmdline): |
| 493 | """Creates bash -c cmdline from args list.""" |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 494 | # Use login shell: |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 495 | # * makes error messages clearer if executables are missing |
Jan Tattermusch | 03b7612 | 2016-11-17 15:28:57 +0100 | [diff] [blame] | 496 | return ['bash', '-c', ' '.join(cmdline)] |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 497 | |
| 498 | |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 499 | def auth_options(language, test_case): |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 500 | """Returns (cmdline, env) tuple with cloud_to_prod_auth test options.""" |
| 501 | |
| 502 | language = str(language) |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 503 | cmdargs = [] |
| 504 | env = {} |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 505 | |
| 506 | # TODO(jtattermusch): this file path only works inside docker |
| 507 | key_filepath = '/root/service_account/stubbyCloudTestingTest-ee3fce360ac5.json' |
| 508 | oauth_scope_arg = '--oauth_scope=https://www.googleapis.com/auth/xapi.zoo' |
| 509 | key_file_arg = '--service_account_key_file=%s' % key_filepath |
| 510 | default_account_arg = '--default_service_account=830293263384-compute@developer.gserviceaccount.com' |
| 511 | |
| 512 | if test_case in ['jwt_token_creds', 'per_rpc_creds', 'oauth2_auth_token']: |
Jan Tattermusch | a98a2ad | 2016-09-09 12:42:32 +0200 | [diff] [blame] | 513 | if language in ['csharp', 'csharpcoreclr', 'node', 'php', 'php7', 'python', 'ruby']: |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 514 | env['GOOGLE_APPLICATION_CREDENTIALS'] = key_filepath |
| 515 | else: |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 516 | cmdargs += [key_file_arg] |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 517 | |
| 518 | if test_case in ['per_rpc_creds', 'oauth2_auth_token']: |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 519 | cmdargs += [oauth_scope_arg] |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 520 | |
Jan Tattermusch | 64d7c24 | 2015-10-08 08:02:27 -0700 | [diff] [blame] | 521 | if test_case == 'oauth2_auth_token' and language == 'c++': |
| 522 | # C++ oauth2 test uses GCE creds and thus needs to know the default account |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 523 | cmdargs += [default_account_arg] |
Jan Tattermusch | 64d7c24 | 2015-10-08 08:02:27 -0700 | [diff] [blame] | 524 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 525 | if test_case == 'compute_engine_creds': |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 526 | cmdargs += [oauth_scope_arg, default_account_arg] |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 527 | |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 528 | return (cmdargs, env) |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 529 | |
| 530 | |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 531 | def _job_kill_handler(job): |
| 532 | if job._spec.container_name: |
| 533 | dockerjob.docker_kill(job._spec.container_name) |
Jan Tattermusch | 39e3cb3 | 2015-10-22 18:21:08 -0700 | [diff] [blame] | 534 | # When the job times out and we decide to kill it, |
| 535 | # we need to wait a before restarting the job |
| 536 | # to prevent "container name already in use" error. |
| 537 | # TODO(jtattermusch): figure out a cleaner way to to this. |
| 538 | time.sleep(2) |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 539 | |
| 540 | |
murgatroid99 | 090a251 | 2016-02-19 11:32:31 -0800 | [diff] [blame] | 541 | def cloud_to_prod_jobspec(language, test_case, server_host_name, |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 542 | server_host_detail, docker_image=None, auth=False): |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 543 | """Creates jobspec for cloud-to-prod interop test""" |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 544 | container_name = None |
| 545 | cmdargs = [ |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 546 | '--server_host=%s' % server_host_detail[0], |
| 547 | '--server_host_override=%s' % server_host_detail[1], |
Jan Tattermusch | c8b9441 | 2015-10-21 17:57:28 -0700 | [diff] [blame] | 548 | '--server_port=443', |
| 549 | '--use_tls=true', |
| 550 | '--test_case=%s' % test_case] |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 551 | environ = dict(language.cloud_to_prod_env(), **language.global_env()) |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 552 | if auth: |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 553 | auth_cmdargs, auth_env = auth_options(language, test_case) |
| 554 | cmdargs += auth_cmdargs |
| 555 | environ.update(auth_env) |
Jan Tattermusch | 03b7612 | 2016-11-17 15:28:57 +0100 | [diff] [blame] | 556 | cmdline = bash_cmdline(language.client_cmd(cmdargs)) |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 557 | cwd = language.client_cwd |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 558 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 559 | if docker_image: |
murgatroid99 | 090a251 | 2016-02-19 11:32:31 -0800 | [diff] [blame] | 560 | container_name = dockerjob.random_name('interop_client_%s' % |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 561 | language.safename) |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 562 | cmdline = docker_run_cmdline(cmdline, |
| 563 | image=docker_image, |
| 564 | cwd=cwd, |
| 565 | environ=environ, |
| 566 | docker_args=['--net=host', |
| 567 | '--name', container_name]) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 568 | cwd = None |
| 569 | environ = None |
| 570 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 571 | suite_name='cloud_to_prod_auth' if auth else 'cloud_to_prod' |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 572 | test_job = jobset.JobSpec( |
| 573 | cmdline=cmdline, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 574 | cwd=cwd, |
| 575 | environ=environ, |
murgatroid99 | 090a251 | 2016-02-19 11:32:31 -0800 | [diff] [blame] | 576 | shortname='%s:%s:%s:%s' % (suite_name, server_host_name, language, |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 577 | test_case), |
Jan Tattermusch | 19f703d | 2016-03-03 15:33:29 -0800 | [diff] [blame] | 578 | timeout_seconds=_TEST_TIMEOUT, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 579 | flake_retries=5 if args.allow_flakes else 0, |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 580 | timeout_retries=2 if args.allow_flakes else 0, |
| 581 | kill_handler=_job_kill_handler) |
murgatroid99 | 0146756 | 2016-06-27 15:48:08 -0700 | [diff] [blame] | 582 | if docker_image: |
| 583 | test_job.container_name = container_name |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 584 | return test_job |
| 585 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 586 | |
| 587 | def cloud_to_cloud_jobspec(language, test_case, server_name, server_host, |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 588 | server_port, docker_image=None, insecure=False): |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 589 | """Creates jobspec for cloud-to-cloud interop test""" |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 590 | interop_only_options = [ |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 591 | '--server_host_override=foo.test.google.fr', |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 592 | '--use_tls=%s' % ('false' if insecure else 'true'), |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 593 | '--use_test_ca=true', |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 594 | ] |
| 595 | common_options = [ |
Masood Malekghassemi | 7566c9a | 2015-10-21 20:29:23 -0700 | [diff] [blame] | 596 | '--test_case=%s' % test_case, |
| 597 | '--server_host=%s' % server_host, |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 598 | ] |
Makarand Dharmapurikar | 078e421 | 2017-01-10 15:09:21 -0800 | [diff] [blame] | 599 | if test_case in _HTTP2_BADSERVER_TEST_CASES: |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 600 | # We are running the http2_badserver_interop test. Adjust command line accordingly. |
| 601 | offset = sorted(_HTTP2_BADSERVER_TEST_CASES).index(test_case) |
| 602 | client_options = common_options + ['--server_port=%s' % |
| 603 | (int(server_port)+offset)] |
| 604 | cmdline = bash_cmdline(language.client_cmd_http2interop(client_options)) |
| 605 | else: |
| 606 | client_options = interop_only_options + common_options + ['--server_port=%s' % server_port] |
| 607 | cmdline = bash_cmdline(language.client_cmd(client_options)) |
| 608 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 609 | cwd = language.client_cwd |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 610 | environ = language.global_env() |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 611 | if docker_image: |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 612 | container_name = dockerjob.random_name('interop_client_%s' % language.safename) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 613 | cmdline = docker_run_cmdline(cmdline, |
| 614 | image=docker_image, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 615 | environ=environ, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 616 | cwd=cwd, |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 617 | docker_args=['--net=host', |
| 618 | '--name', container_name]) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 619 | cwd = None |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 620 | |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 621 | test_job = jobset.JobSpec( |
| 622 | cmdline=cmdline, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 623 | cwd=cwd, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 624 | environ=environ, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 625 | shortname='cloud_to_cloud:%s:%s_server:%s' % (language, server_name, |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 626 | test_case), |
Jan Tattermusch | 19f703d | 2016-03-03 15:33:29 -0800 | [diff] [blame] | 627 | timeout_seconds=_TEST_TIMEOUT, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 628 | flake_retries=5 if args.allow_flakes else 0, |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 629 | timeout_retries=2 if args.allow_flakes else 0, |
| 630 | kill_handler=_job_kill_handler) |
murgatroid99 | 0146756 | 2016-06-27 15:48:08 -0700 | [diff] [blame] | 631 | if docker_image: |
| 632 | test_job.container_name = container_name |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 633 | return test_job |
| 634 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 635 | |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 636 | def server_jobspec(language, docker_image, insecure=False): |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 637 | """Create jobspec for running a server""" |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 638 | container_name = dockerjob.random_name('interop_server_%s' % language.safename) |
Jan Tattermusch | 03b7612 | 2016-11-17 15:28:57 +0100 | [diff] [blame] | 639 | cmdline = bash_cmdline( |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 640 | language.server_cmd(['--port=%s' % _DEFAULT_SERVER_PORT, |
| 641 | '--use_tls=%s' % ('false' if insecure else 'true')])) |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 642 | environ = language.global_env() |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 643 | if language.safename == 'http2': |
| 644 | # we are running the http2 interop server. Open next N ports beginning |
| 645 | # with the server port. These ports are used for http2 interop test |
| 646 | # (one test case per port). We also attach the docker container running |
| 647 | # the server to local network, so we don't have to mess with port mapping |
| 648 | port_args = [ |
| 649 | '-p', str(_DEFAULT_SERVER_PORT+0), |
| 650 | '-p', str(_DEFAULT_SERVER_PORT+1), |
| 651 | '-p', str(_DEFAULT_SERVER_PORT+2), |
| 652 | '-p', str(_DEFAULT_SERVER_PORT+3), |
| 653 | '-p', str(_DEFAULT_SERVER_PORT+4), |
| 654 | '-p', str(_DEFAULT_SERVER_PORT+5), |
| 655 | '-p', str(_DEFAULT_SERVER_PORT+6), |
| 656 | '--net=host', |
| 657 | ] |
| 658 | else: |
| 659 | port_args = ['-p', str(_DEFAULT_SERVER_PORT)] |
| 660 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 661 | docker_cmdline = docker_run_cmdline(cmdline, |
| 662 | image=docker_image, |
| 663 | cwd=language.server_cwd, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 664 | environ=environ, |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 665 | docker_args=port_args + |
| 666 | ['--name', container_name]) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 667 | server_job = jobset.JobSpec( |
| 668 | cmdline=docker_cmdline, |
Masood Malekghassemi | 18cc842 | 2015-10-09 17:55:45 -0700 | [diff] [blame] | 669 | environ=environ, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 670 | shortname='interop_server_%s' % language, |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 671 | timeout_seconds=30*60) |
Jan Tattermusch | e268628 | 2015-10-08 16:27:07 -0700 | [diff] [blame] | 672 | server_job.container_name = container_name |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 673 | return server_job |
| 674 | |
| 675 | |
| 676 | def build_interop_image_jobspec(language, tag=None): |
| 677 | """Creates jobspec for building interop docker image for a language""" |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 678 | if not tag: |
Jan Tattermusch | 0a14f62 | 2015-10-09 14:34:29 -0700 | [diff] [blame] | 679 | tag = 'grpc_interop_%s:%s' % (language.safename, uuid.uuid4()) |
Stanley Cheung | 22b6bed | 2015-10-15 16:54:52 -0700 | [diff] [blame] | 680 | env = {'INTEROP_IMAGE': tag, |
| 681 | 'BASE_NAME': 'grpc_interop_%s' % language.safename} |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 682 | if not args.travis: |
Stanley Cheung | 22b6bed | 2015-10-15 16:54:52 -0700 | [diff] [blame] | 683 | env['TTY_FLAG'] = '-t' |
| 684 | # This env variable is used to get around the github rate limit |
| 685 | # error when running the PHP `composer install` command |
Stanley Cheung | d82efd8 | 2016-02-10 10:36:20 -0800 | [diff] [blame] | 686 | host_file = '%s/.composer/auth.json' % os.environ['HOME'] |
| 687 | if language.safename == 'php' and os.path.exists(host_file): |
Stanley Cheung | 22b6bed | 2015-10-15 16:54:52 -0700 | [diff] [blame] | 688 | env['BUILD_INTEROP_DOCKER_EXTRA_ARGS'] = \ |
Stanley Cheung | d82efd8 | 2016-02-10 10:36:20 -0800 | [diff] [blame] | 689 | '-v %s:/root/.composer/auth.json:ro' % host_file |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 690 | build_job = jobset.JobSpec( |
Jan Tattermusch | 9835d4b | 2016-04-29 15:05:05 -0700 | [diff] [blame] | 691 | cmdline=['tools/run_tests/dockerize/build_interop_image.sh'], |
Stanley Cheung | 22b6bed | 2015-10-15 16:54:52 -0700 | [diff] [blame] | 692 | environ=env, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 693 | shortname='build_docker_%s' % (language), |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 694 | timeout_seconds=30*60) |
| 695 | build_job.tag = tag |
| 696 | return build_job |
| 697 | |
| 698 | |
Carl Mastrangelo | e7f8e8e | 2015-12-08 17:22:44 -0800 | [diff] [blame] | 699 | def aggregate_http2_results(stdout): |
| 700 | match = re.search(r'\{"cases[^\]]*\]\}', stdout) |
| 701 | if not match: |
| 702 | return None |
murgatroid99 | c3910ca | 2016-01-06 13:14:23 -0800 | [diff] [blame] | 703 | |
Carl Mastrangelo | e7f8e8e | 2015-12-08 17:22:44 -0800 | [diff] [blame] | 704 | results = json.loads(match.group(0)) |
| 705 | skipped = 0 |
| 706 | passed = 0 |
| 707 | failed = 0 |
| 708 | failed_cases = [] |
| 709 | for case in results['cases']: |
| 710 | if case.get('skipped', False): |
| 711 | skipped += 1 |
| 712 | else: |
| 713 | if case.get('passed', False): |
| 714 | passed += 1 |
| 715 | else: |
| 716 | failed += 1 |
| 717 | failed_cases.append(case.get('name', "NONAME")) |
| 718 | return { |
| 719 | 'passed': passed, |
| 720 | 'failed': failed, |
| 721 | 'skipped': skipped, |
| 722 | 'failed_cases': ', '.join(failed_cases), |
| 723 | 'percent': 1.0 * passed / (passed + failed) |
| 724 | } |
| 725 | |
murgatroid99 | 090a251 | 2016-02-19 11:32:31 -0800 | [diff] [blame] | 726 | # A dictionary of prod servers to test. |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 727 | # Format: server_name: (server_host, server_host_override, errors_allowed) |
| 728 | # TODO(adelez): implement logic for errors_allowed where if the indicated tests |
| 729 | # fail, they don't impact the overall test result. |
| 730 | prod_servers = { |
Adele Zhou | c4b61e2 | 2016-08-25 16:32:06 -0700 | [diff] [blame] | 731 | 'default': ('216.239.32.254', |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 732 | 'grpc-test.sandbox.googleapis.com', False), |
Adele Zhou | c4b61e2 | 2016-08-25 16:32:06 -0700 | [diff] [blame] | 733 | 'gateway_v2': ('216.239.32.254', |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 734 | 'grpc-test2.sandbox.googleapis.com', True), |
murgatroid99 | 090a251 | 2016-02-19 11:32:31 -0800 | [diff] [blame] | 735 | 'cloud_gateway': ('216.239.32.255', 'grpc-test.sandbox.googleapis.com', |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 736 | False), |
murgatroid99 | 090a251 | 2016-02-19 11:32:31 -0800 | [diff] [blame] | 737 | 'cloud_gateway_v2': ('216.239.32.255', 'grpc-test2.sandbox.googleapis.com', |
Adele Zhou | 2480f98 | 2016-02-26 14:18:46 -0800 | [diff] [blame] | 738 | True), |
Adele Zhou | c4b61e2 | 2016-08-25 16:32:06 -0700 | [diff] [blame] | 739 | 'gateway_v4': ('216.239.32.254', |
murgatroid99 | e621f13 | 2016-04-21 14:28:00 -0700 | [diff] [blame] | 740 | 'grpc-test4.sandbox.googleapis.com', True), |
Adele Zhou | 2480f98 | 2016-02-26 14:18:46 -0800 | [diff] [blame] | 741 | 'cloud_gateway_v4': ('216.239.32.255', 'grpc-test4.sandbox.googleapis.com', |
| 742 | True), |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 743 | } |
| 744 | |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 745 | argp = argparse.ArgumentParser(description='Run interop tests.') |
| 746 | argp.add_argument('-l', '--language', |
| 747 | choices=['all'] + sorted(_LANGUAGES), |
| 748 | nargs='+', |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 749 | default=['all'], |
| 750 | help='Clients to run.') |
Jan Tattermusch | 210a0ea | 2015-10-02 15:05:36 -0700 | [diff] [blame] | 751 | argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 752 | argp.add_argument('--cloud_to_prod', |
| 753 | default=False, |
| 754 | action='store_const', |
| 755 | const=True, |
| 756 | help='Run cloud_to_prod tests.') |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 757 | argp.add_argument('--cloud_to_prod_auth', |
| 758 | default=False, |
| 759 | action='store_const', |
| 760 | const=True, |
| 761 | help='Run cloud_to_prod_auth tests.') |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 762 | argp.add_argument('--prod_servers', |
| 763 | choices=prod_servers.keys(), |
| 764 | default=['default'], |
| 765 | nargs='+', |
| 766 | help=('The servers to run cloud_to_prod and ' |
| 767 | 'cloud_to_prod_auth tests against.')) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 768 | argp.add_argument('-s', '--server', |
| 769 | choices=['all'] + sorted(_SERVERS), |
Adele Zhou | 9088d59 | 2016-08-16 17:48:42 -0700 | [diff] [blame] | 770 | nargs='+', |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 771 | help='Run cloud_to_cloud servers in a separate docker ' + |
| 772 | 'image. Servers can only be started automatically if ' + |
| 773 | '--use_docker option is enabled.', |
| 774 | default=[]) |
| 775 | argp.add_argument('--override_server', |
| 776 | action='append', |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 777 | type=lambda kv: kv.split('='), |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 778 | help='Use servername=HOST:PORT to explicitly specify a server. E.g. csharp=localhost:50000', |
| 779 | default=[]) |
| 780 | argp.add_argument('-t', '--travis', |
| 781 | default=False, |
| 782 | action='store_const', |
| 783 | const=True) |
| 784 | argp.add_argument('--use_docker', |
| 785 | default=False, |
| 786 | action='store_const', |
| 787 | const=True, |
| 788 | help='Run all the interop tests under docker. That provides ' + |
| 789 | 'additional isolation and prevents the need to install ' + |
| 790 | 'language specific prerequisites. Only available on Linux.') |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 791 | argp.add_argument('--allow_flakes', |
| 792 | default=False, |
| 793 | action='store_const', |
| 794 | const=True, |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 795 | 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] | 796 | argp.add_argument('--http2_interop', |
| 797 | default=False, |
| 798 | action='store_const', |
| 799 | const=True, |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 800 | help='Enable HTTP/2 client edge case testing. (Bad client, good server)') |
| 801 | argp.add_argument('--http2_badserver_interop', |
| 802 | default=False, |
| 803 | action='store_const', |
| 804 | const=True, |
| 805 | help='Enable HTTP/2 server edge case testing. (Good client, bad server)') |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 806 | argp.add_argument('--insecure', |
| 807 | default=False, |
| 808 | action='store_const', |
| 809 | const=True, |
| 810 | help='Whether to use secure channel.') |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 811 | |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 812 | args = argp.parse_args() |
| 813 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 814 | servers = set(s for s in itertools.chain.from_iterable(_SERVERS |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 815 | if x == 'all' else [x] |
| 816 | for x in args.server)) |
| 817 | |
| 818 | if args.use_docker: |
| 819 | if not args.travis: |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 820 | print('Seen --use_docker flag, will run interop tests under docker.') |
| 821 | print('') |
| 822 | print('IMPORTANT: The changes you are testing need to be locally committed') |
| 823 | print('because only the committed changes in the current branch will be') |
| 824 | print('copied to the docker environment.') |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 825 | time.sleep(5) |
| 826 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 827 | if not args.use_docker and servers: |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 828 | print('Running interop servers is only supported with --use_docker option enabled.') |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 829 | sys.exit(1) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 830 | |
Jan Tattermusch | f49936a | 2015-09-16 15:44:26 -0700 | [diff] [blame] | 831 | languages = set(_LANGUAGES[l] |
| 832 | for l in itertools.chain.from_iterable( |
| 833 | _LANGUAGES.iterkeys() if x == 'all' else [x] |
| 834 | for x in args.language)) |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 835 | |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 836 | http2Interop = Http2Client() if args.http2_interop else None |
Makarand Dharmapurikar | 078e421 | 2017-01-10 15:09:21 -0800 | [diff] [blame] | 837 | http2InteropServer = Http2Server() if args.http2_badserver_interop else None |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 838 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 839 | docker_images={} |
| 840 | if args.use_docker: |
| 841 | # languages for which to build docker images |
| 842 | languages_to_build = set(_LANGUAGES[k] for k in set([str(l) for l in languages] + |
| 843 | [s for s in servers])) |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 844 | if args.http2_interop: |
| 845 | languages_to_build.add(http2Interop) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 846 | |
Makarand Dharmapurikar | 078e421 | 2017-01-10 15:09:21 -0800 | [diff] [blame] | 847 | if args.http2_badserver_interop: |
| 848 | languages_to_build.add(http2InteropServer) |
| 849 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 850 | build_jobs = [] |
| 851 | for l in languages_to_build: |
| 852 | job = build_interop_image_jobspec(l) |
| 853 | docker_images[str(l)] = job.tag |
| 854 | build_jobs.append(job) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 855 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 856 | if build_jobs: |
| 857 | jobset.message('START', 'Building interop docker images.', do_newline=True) |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 858 | num_failures, _ = jobset.run( |
| 859 | build_jobs, newline_on_success=True, maxjobs=args.jobs) |
| 860 | if num_failures == 0: |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 861 | jobset.message('SUCCESS', 'All docker images built successfully.', |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 862 | do_newline=True) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 863 | else: |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 864 | jobset.message('FAILED', 'Failed to build interop docker images.', |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 865 | do_newline=True) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 866 | for image in docker_images.itervalues(): |
| 867 | dockerjob.remove_image(image, skip_nonexistent=True) |
Carl Mastrangelo | 7a17140 | 2015-10-26 14:01:03 -0700 | [diff] [blame] | 868 | sys.exit(1) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 869 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 870 | # Start interop servers. |
| 871 | server_jobs={} |
| 872 | server_addresses={} |
| 873 | try: |
| 874 | for s in servers: |
| 875 | lang = str(s) |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 876 | spec = server_jobspec(_LANGUAGES[lang], docker_images.get(lang), |
| 877 | args.insecure) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 878 | job = dockerjob.DockerJob(spec) |
| 879 | server_jobs[lang] = job |
| 880 | server_addresses[lang] = ('localhost', job.mapped_port(_DEFAULT_SERVER_PORT)) |
Jan Tattermusch | 8266c67 | 2015-09-17 09:18:03 -0700 | [diff] [blame] | 881 | |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 882 | if args.http2_badserver_interop: |
| 883 | # launch a HTTP2 server emulator that creates edge cases |
Makarand Dharmapurikar | 078e421 | 2017-01-10 15:09:21 -0800 | [diff] [blame] | 884 | lang = str(http2InteropServer) |
Makarand Dharmapurikar | 6bbd95e | 2017-01-11 09:35:09 -0800 | [diff] [blame] | 885 | spec = server_jobspec(http2InteropServer, docker_images.get(lang)) |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 886 | job = dockerjob.DockerJob(spec) |
| 887 | server_jobs[lang] = job |
| 888 | server_addresses[lang] = ('localhost', _DEFAULT_SERVER_PORT) |
| 889 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 890 | jobs = [] |
| 891 | if args.cloud_to_prod: |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 892 | if args.insecure: |
| 893 | print('TLS is always enabled for cloud_to_prod scenarios.') |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 894 | for server_host_name in args.prod_servers: |
| 895 | for language in languages: |
| 896 | for test_case in _TEST_CASES: |
| 897 | if not test_case in language.unimplemented_test_cases(): |
| 898 | if not test_case in _SKIP_ADVANCED + _SKIP_COMPRESSION: |
| 899 | test_job = cloud_to_prod_jobspec( |
murgatroid99 | 090a251 | 2016-02-19 11:32:31 -0800 | [diff] [blame] | 900 | language, test_case, server_host_name, |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 901 | prod_servers[server_host_name], |
| 902 | docker_image=docker_images.get(str(language))) |
| 903 | jobs.append(test_job) |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 904 | |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 905 | if args.http2_interop: |
| 906 | for test_case in _HTTP2_TEST_CASES: |
| 907 | test_job = cloud_to_prod_jobspec( |
murgatroid99 | 090a251 | 2016-02-19 11:32:31 -0800 | [diff] [blame] | 908 | http2Interop, test_case, server_host_name, |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 909 | prod_servers[server_host_name], |
| 910 | docker_image=docker_images.get(str(http2Interop))) |
| 911 | jobs.append(test_job) |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 912 | |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 913 | if args.cloud_to_prod_auth: |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 914 | if args.insecure: |
| 915 | print('TLS is always enabled for cloud_to_prod scenarios.') |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 916 | for server_host_name in args.prod_servers: |
| 917 | for language in languages: |
| 918 | for test_case in _AUTH_TEST_CASES: |
| 919 | if not test_case in language.unimplemented_test_cases(): |
| 920 | test_job = cloud_to_prod_jobspec( |
murgatroid99 | 090a251 | 2016-02-19 11:32:31 -0800 | [diff] [blame] | 921 | language, test_case, server_host_name, |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 922 | prod_servers[server_host_name], |
| 923 | docker_image=docker_images.get(str(language)), auth=True) |
| 924 | jobs.append(test_job) |
Jan Tattermusch | fb8c77d | 2015-10-06 09:33:37 -0700 | [diff] [blame] | 925 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 926 | for server in args.override_server: |
| 927 | server_name = server[0] |
| 928 | (server_host, server_port) = server[1].split(':') |
| 929 | server_addresses[server_name] = (server_host, server_port) |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 930 | |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 931 | for server_name, server_address in server_addresses.items(): |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 932 | (server_host, server_port) = server_address |
Jan Tattermusch | 5c7a1c8 | 2015-12-09 19:56:51 -0800 | [diff] [blame] | 933 | server_language = _LANGUAGES.get(server_name, None) |
| 934 | skip_server = [] # test cases unimplemented by server |
| 935 | if server_language: |
| 936 | skip_server = server_language.unimplemented_test_cases_server() |
Makarand Dharmapurikar | 078e421 | 2017-01-10 15:09:21 -0800 | [diff] [blame] | 937 | if not args.http2_badserver_interop: |
| 938 | for language in languages: |
| 939 | for test_case in _TEST_CASES: |
| 940 | if not test_case in language.unimplemented_test_cases(): |
| 941 | if not test_case in skip_server: |
| 942 | test_job = cloud_to_cloud_jobspec(language, |
| 943 | test_case, |
| 944 | server_name, |
| 945 | server_host, |
| 946 | server_port, |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 947 | docker_image=docker_images.get(str(language)), |
| 948 | insecure=args.insecure) |
Makarand Dharmapurikar | 078e421 | 2017-01-10 15:09:21 -0800 | [diff] [blame] | 949 | jobs.append(test_job) |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 950 | |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 951 | if args.http2_interop: |
| 952 | for test_case in _HTTP2_TEST_CASES: |
Carl Mastrangelo | 3b2e1bd | 2015-11-06 14:31:55 -0800 | [diff] [blame] | 953 | if server_name == "go": |
| 954 | # TODO(carl-mastrangelo): Reenable after https://github.com/grpc/grpc-go/issues/434 |
murgatroid99 | c3910ca | 2016-01-06 13:14:23 -0800 | [diff] [blame] | 955 | continue |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 956 | test_job = cloud_to_cloud_jobspec(http2Interop, |
| 957 | test_case, |
| 958 | server_name, |
| 959 | server_host, |
| 960 | server_port, |
Adele Zhou | 57b02fc | 2017-01-17 14:18:41 -0800 | [diff] [blame] | 961 | docker_image=docker_images.get(str(http2Interop)), |
| 962 | insecure=args.insecure) |
Carl Mastrangelo | de44910 | 2015-10-28 11:05:49 -0700 | [diff] [blame] | 963 | jobs.append(test_job) |
Jan Tattermusch | 320bd61 | 2015-09-15 12:44:35 -0700 | [diff] [blame] | 964 | |
Makarand Dharmapurikar | d383e4a | 2017-01-10 13:58:07 -0800 | [diff] [blame] | 965 | if args.http2_badserver_interop: |
| 966 | for language in languages: |
| 967 | for test_case in _HTTP2_BADSERVER_TEST_CASES: |
| 968 | test_job = cloud_to_cloud_jobspec(language, |
| 969 | test_case, |
| 970 | server_name, |
| 971 | server_host, |
| 972 | server_port, |
| 973 | docker_image=docker_images.get(str(language))) |
| 974 | jobs.append(test_job) |
| 975 | |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 976 | if not jobs: |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 977 | print('No jobs to run.') |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 978 | for image in docker_images.itervalues(): |
| 979 | dockerjob.remove_image(image, skip_nonexistent=True) |
| 980 | sys.exit(1) |
| 981 | |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 982 | num_failures, resultset = jobset.run(jobs, newline_on_success=True, |
Adele Zhou | 2271ab5 | 2015-10-28 13:59:14 -0700 | [diff] [blame] | 983 | maxjobs=args.jobs) |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 984 | if num_failures: |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 985 | jobset.message('FAILED', 'Some tests failed', do_newline=True) |
Adele Zhou | e4c3561 | 2015-10-16 15:34:23 -0700 | [diff] [blame] | 986 | else: |
| 987 | jobset.message('SUCCESS', 'All tests passed', do_newline=True) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 988 | |
Adele Zhou | 3bc7ba4 | 2015-11-05 10:21:58 -0800 | [diff] [blame] | 989 | report_utils.render_junit_xml_report(resultset, 'report.xml') |
Masood Malekghassemi | 0a9cc3c | 2015-11-09 12:24:05 -0800 | [diff] [blame] | 990 | |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 991 | for name, job in resultset.items(): |
Carl Mastrangelo | e7f8e8e | 2015-12-08 17:22:44 -0800 | [diff] [blame] | 992 | if "http2" in name: |
| 993 | job[0].http2results = aggregate_http2_results(job[0].message) |
| 994 | |
Adele Zhou | 3bc7ba4 | 2015-11-05 10:21:58 -0800 | [diff] [blame] | 995 | report_utils.render_interop_html_report( |
murgatroid99 | c3910ca | 2016-01-06 13:14:23 -0800 | [diff] [blame] | 996 | 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] | 997 | _HTTP2_TEST_CASES, resultset, num_failures, |
murgatroid99 | 090a251 | 2016-02-19 11:32:31 -0800 | [diff] [blame] | 998 | args.cloud_to_prod_auth or args.cloud_to_prod, args.prod_servers, |
Adele Zhou | b9e66cc | 2016-02-03 13:12:23 -0800 | [diff] [blame] | 999 | args.http2_interop) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 1000 | |
| 1001 | finally: |
| 1002 | # Check if servers are still running. |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 1003 | for server, job in server_jobs.items(): |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 1004 | if not job.is_running(): |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 1005 | print('Server "%s" has exited prematurely.' % server) |
Jan Tattermusch | 91ad018 | 2015-10-01 09:22:03 -0700 | [diff] [blame] | 1006 | |
| 1007 | dockerjob.finish_jobs([j for j in server_jobs.itervalues()]) |
| 1008 | |
| 1009 | for image in docker_images.itervalues(): |
siddharthshukla | 0589e53 | 2016-07-07 16:08:01 +0200 | [diff] [blame] | 1010 | print('Removing docker image %s' % image) |
David Garcia Quintas | 2bf574f | 2016-01-14 15:27:08 -0800 | [diff] [blame] | 1011 | dockerjob.remove_image(image) |