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