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