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