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