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