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