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