aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2015-12-07 17:57:19 -0800
committerGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2015-12-07 17:57:19 -0800
commit56bab33bbfbb374d2262c58d03c5bb0e9523b497 (patch)
tree03f8c1069467433d9bf216f54fc28a276590837c /src
parent21265256888dea5d4f0c16d50b1f26bfa9830979 (diff)
parentb91c7068200895d7d0b9752a5e9520b2df6c04bd (diff)
Merge pull request #4306 from jcanizales/merge-release
Merge release-0.12 into master
Diffstat (limited to 'src')
-rw-r--r--src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs6
-rw-r--r--src/csharp/Grpc.Core/AsyncAuthInterceptor.cs84
-rw-r--r--src/csharp/Grpc.Core/CallCredentials.cs8
-rw-r--r--src/csharp/Grpc.Core/Grpc.Core.csproj7
-rw-r--r--src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs13
-rw-r--r--src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs2
-rw-r--r--src/csharp/ext/grpc_csharp_ext.c7
-rw-r--r--src/node/ext/call.cc5
-rw-r--r--src/node/src/credentials.js5
-rw-r--r--src/objective-c/BoringSSL.podspec1428
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.h43
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCRequestHeaders.h13
-rw-r--r--src/objective-c/GRPCClient/private/GRPCRequestHeaders.m43
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.h2
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.m2
-rw-r--r--src/objective-c/examples/Sample/Podfile1
-rw-r--r--src/objective-c/examples/SwiftSample/Podfile1
-rw-r--r--src/objective-c/tests/Podfile1
-rw-r--r--src/python/grpcio/.gitignore7
-rw-r--r--src/python/grpcio/MANIFEST.in1
-rw-r--r--src/python/grpcio/commands.py127
-rw-r--r--src/python/grpcio/grpc/beta/_server.py175
-rw-r--r--src/python/grpcio/grpc/beta/_stub.py124
-rw-r--r--src/python/grpcio/grpc/framework/core/_end.py60
-rw-r--r--src/python/grpcio/requirements.txt1
-rw-r--r--src/python/grpcio/setup.cfg6
-rw-r--r--src/python/grpcio/setup.py120
-rw-r--r--src/python/grpcio/tests/__init__.py (renamed from src/python/grpcio_test/setup.py)68
-rw-r--r--src/python/grpcio/tests/_loader.py119
-rw-r--r--src/python/grpcio/tests/_result.py451
-rw-r--r--src/python/grpcio/tests/_runner.py224
-rw-r--r--src/python/grpcio/tests/interop/__init__.py (renamed from src/python/grpcio_test/grpc_interop/__init__.py)0
-rw-r--r--src/python/grpcio/tests/interop/_insecure_interop_test.py (renamed from src/python/grpcio_test/grpc_interop/_insecure_interop_test.py)8
-rw-r--r--src/python/grpcio/tests/interop/_interop_test_case.py (renamed from src/python/grpcio_test/grpc_interop/_interop_test_case.py)2
-rw-r--r--src/python/grpcio/tests/interop/_secure_interop_test.py (renamed from src/python/grpcio_test/grpc_interop/_secure_interop_test.py)10
-rw-r--r--src/python/grpcio/tests/interop/client.py (renamed from src/python/grpcio_test/grpc_interop/client.py)13
-rw-r--r--src/python/grpcio/tests/interop/credentials/README (renamed from src/python/grpcio_test/grpc_interop/credentials/README)0
-rwxr-xr-xsrc/python/grpcio/tests/interop/credentials/ca.pem (renamed from src/python/grpcio_test/grpc_interop/credentials/ca.pem)0
-rwxr-xr-xsrc/python/grpcio/tests/interop/credentials/server1.key (renamed from src/python/grpcio_test/grpc_interop/credentials/server1.key)0
-rwxr-xr-xsrc/python/grpcio/tests/interop/credentials/server1.pem (renamed from src/python/grpcio_test/grpc_interop/credentials/server1.pem)0
-rw-r--r--src/python/grpcio/tests/interop/empty.proto (renamed from src/python/grpcio_test/grpc_interop/empty.proto)0
-rw-r--r--src/python/grpcio/tests/interop/messages.proto (renamed from src/python/grpcio_test/grpc_interop/messages.proto)0
-rw-r--r--src/python/grpcio/tests/interop/methods.py (renamed from src/python/grpcio_test/grpc_interop/methods.py)6
-rw-r--r--src/python/grpcio/tests/interop/resources.py (renamed from src/python/grpcio_test/grpc_interop/resources.py)0
-rw-r--r--src/python/grpcio/tests/interop/server.py (renamed from src/python/grpcio_test/grpc_interop/server.py)8
-rw-r--r--src/python/grpcio/tests/interop/test.proto (renamed from src/python/grpcio_test/grpc_interop/test.proto)4
-rw-r--r--src/python/grpcio/tests/protoc_plugin/__init__.py (renamed from src/python/grpcio_test/grpc_protoc_plugin/__init__.py)0
-rw-r--r--src/python/grpcio/tests/protoc_plugin/beta_python_plugin_test.py (renamed from src/python/grpcio_test/grpc_protoc_plugin/beta_python_plugin_test.py)73
-rw-r--r--src/python/grpcio/tests/protoc_plugin/protoc_plugin_test.proto (renamed from src/python/grpcio_test/grpc_protoc_plugin/test.proto)0
-rw-r--r--src/python/grpcio/tests/unit/__init__.py (renamed from src/python/grpcio_test/grpc_test/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/_adapter/.gitignore (renamed from src/python/grpcio_test/grpc_test/_adapter/.gitignore)0
-rw-r--r--src/python/grpcio/tests/unit/_adapter/__init__.py (renamed from src/python/grpcio_test/grpc_test/_adapter/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/_adapter/_c_test.py (renamed from src/python/grpcio_test/grpc_test/_adapter/_c_test.py)0
-rw-r--r--src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py (renamed from src/python/grpcio_test/grpc_test/_adapter/_intermediary_low_test.py)0
-rw-r--r--src/python/grpcio/tests/unit/_adapter/_low_test.py (renamed from src/python/grpcio_test/grpc_test/_adapter/_low_test.py)2
-rw-r--r--src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py (renamed from src/python/grpcio_test/grpc_test/_adapter/_proto_scenarios.py)2
-rw-r--r--src/python/grpcio/tests/unit/_core_over_links_base_interface_test.py (renamed from src/python/grpcio_test/grpc_test/_core_over_links_base_interface_test.py)8
-rw-r--r--src/python/grpcio/tests/unit/_crust_over_core_over_links_face_interface_test.py (renamed from src/python/grpcio_test/grpc_test/_crust_over_core_over_links_face_interface_test.py)8
-rw-r--r--src/python/grpcio/tests/unit/_cython/.gitignore (renamed from src/python/grpcio_test/grpc_test/_cython/.gitignore)0
-rw-r--r--src/python/grpcio/tests/unit/_cython/__init__.py (renamed from src/python/grpcio_test/grpc_test/_cython/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/_cython/adapter_low_test.py (renamed from src/python/grpcio_test/grpc_test/_cython/adapter_low_test.py)0
-rw-r--r--src/python/grpcio/tests/unit/_cython/cygrpc_test.py (renamed from src/python/grpcio_test/grpc_test/_cython/cygrpc_test.py)4
-rw-r--r--src/python/grpcio/tests/unit/_cython/test_utilities.py (renamed from src/python/grpcio_test/grpc_test/_cython/test_utilities.py)0
-rw-r--r--src/python/grpcio/tests/unit/_junkdrawer/__init__.py (renamed from src/python/grpcio_test/grpc_test/_junkdrawer/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/_junkdrawer/math_pb2.py (renamed from src/python/grpcio_test/grpc_test/_junkdrawer/math_pb2.py)0
-rw-r--r--src/python/grpcio/tests/unit/_junkdrawer/stock_pb2.py (renamed from src/python/grpcio_test/grpc_test/_junkdrawer/stock_pb2.py)0
-rw-r--r--src/python/grpcio/tests/unit/_links/__init__.py (renamed from src/python/grpcio_test/grpc_test/_links/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/_links/_lonely_invocation_link_test.py (renamed from src/python/grpcio_test/grpc_test/_links/_lonely_invocation_link_test.py)6
-rw-r--r--src/python/grpcio/tests/unit/_links/_proto_scenarios.py (renamed from src/python/grpcio_test/grpc_test/_links/_proto_scenarios.py)4
-rw-r--r--src/python/grpcio/tests/unit/_links/_transmission_test.py (renamed from src/python/grpcio_test/grpc_test/_links/_transmission_test.py)10
-rw-r--r--src/python/grpcio/tests/unit/beta/__init__.py (renamed from src/python/grpcio_test/grpc_test/beta/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/beta/_beta_features_test.py (renamed from src/python/grpcio_test/grpc_test/beta/_beta_features_test.py)79
-rw-r--r--src/python/grpcio/tests/unit/beta/_connectivity_channel_test.py (renamed from src/python/grpcio_test/grpc_test/beta/_connectivity_channel_test.py)2
-rw-r--r--src/python/grpcio/tests/unit/beta/_face_interface_test.py (renamed from src/python/grpcio_test/grpc_test/beta/_face_interface_test.py)12
-rw-r--r--src/python/grpcio/tests/unit/beta/_not_found_test.py (renamed from src/python/grpcio_test/grpc_test/beta/_not_found_test.py)2
-rw-r--r--src/python/grpcio/tests/unit/beta/_utilities_test.py (renamed from src/python/grpcio_test/grpc_test/beta/_utilities_test.py)2
-rw-r--r--src/python/grpcio/tests/unit/beta/test_utilities.py (renamed from src/python/grpcio_test/grpc_test/beta/test_utilities.py)0
-rw-r--r--src/python/grpcio/tests/unit/credentials/README (renamed from src/python/grpcio_test/grpc_test/credentials/README)0
-rwxr-xr-xsrc/python/grpcio/tests/unit/credentials/ca.pem (renamed from src/python/grpcio_test/grpc_test/credentials/ca.pem)0
-rwxr-xr-xsrc/python/grpcio/tests/unit/credentials/server1.key (renamed from src/python/grpcio_test/grpc_test/credentials/server1.key)0
-rwxr-xr-xsrc/python/grpcio/tests/unit/credentials/server1.pem (renamed from src/python/grpcio_test/grpc_test/credentials/server1.pem)0
-rw-r--r--src/python/grpcio/tests/unit/framework/__init__.py (renamed from src/python/grpcio_test/grpc_test/framework/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/_crust_over_core_face_interface_test.py (renamed from src/python/grpcio_test/grpc_test/framework/_crust_over_core_face_interface_test.py)8
-rw-r--r--src/python/grpcio/tests/unit/framework/common/__init__.py (renamed from src/python/grpcio_test/grpc_test/framework/common/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/common/test_constants.py (renamed from src/python/grpcio_test/grpc_test/framework/common/test_constants.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/common/test_control.py (renamed from src/python/grpcio_test/grpc_test/framework/common/test_control.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/common/test_coverage.py (renamed from src/python/grpcio_test/grpc_test/framework/common/test_coverage.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/core/__init__.py (renamed from src/python/grpcio_test/grpc_test/framework/core/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/core/_base_interface_test.py (renamed from src/python/grpcio_test/grpc_test/framework/core/_base_interface_test.py)6
-rw-r--r--src/python/grpcio/tests/unit/framework/face/__init__.py (renamed from src/python/grpcio_test/grpc_test/framework/face/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/__init__.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/base_util.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/base_util.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/blocking_invocation_inline_service_test_case.py)12
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/callback.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/callback.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/control.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/control.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/coverage.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/coverage.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/digest.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/digest.py)6
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/event_invocation_synchronous_event_service_test_case.py)14
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py)12
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/interfaces.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/interfaces.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/service.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/service.py)2
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/stock_service.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/stock_service.py)4
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/test_case.py (renamed from src/python/grpcio_test/grpc_test/framework/face/testing/test_case.py)2
-rw-r--r--src/python/grpcio/tests/unit/framework/foundation/__init__.py (renamed from src/python/grpcio_test/grpc_test/framework/foundation/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/foundation/_later_test.py (renamed from src/python/grpcio_test/grpc_test/framework/foundation/_later_test.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/foundation/_logging_pool_test.py (renamed from src/python/grpcio_test/grpc_test/framework/foundation/_logging_pool_test.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/foundation/stream_testing.py (renamed from src/python/grpcio_test/grpc_test/framework/foundation/stream_testing.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/__init__.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/__init__.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/base/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/_control.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/base/_control.py)8
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/_sequence.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/base/_sequence.py)2
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/_state.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/base/_state.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/test_cases.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/base/test_cases.py)7
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/base/test_interfaces.py)2
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_3069_test_constant.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/_3069_test_constant.py)2
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/__init__.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/_blocking_invocation_inline_service.py)14
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/_digest.py)6
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_event_invocation_synchronous_event_service.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/_event_invocation_synchronous_event_service.py)16
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/_future_invocation_asynchronous_event_service.py)14
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/_invocation.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/_receiver.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_service.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/_service.py)2
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_stock_service.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/_stock_service.py)6
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/test_cases.py)14
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/face/test_interfaces.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/links/__init__.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/links/__init__.py)0
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/links/test_cases.py)4
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/links/test_utilities.py (renamed from src/python/grpcio_test/grpc_test/framework/interfaces/links/test_utilities.py)0
-rw-r--r--src/python/grpcio/tests/unit/resources.py (renamed from src/python/grpcio_test/grpc_test/resources.py)0
-rw-r--r--src/python/grpcio/tests/unit/test_common.py (renamed from src/python/grpcio_test/grpc_test/test_common.py)0
-rw-r--r--src/python/grpcio/tox.ini19
-rw-r--r--src/python/grpcio_test/.gitignore12
-rw-r--r--src/python/grpcio_test/MANIFEST.in4
-rw-r--r--src/python/grpcio_test/commands.py106
-rw-r--r--src/python/grpcio_test/grpc_test/conftest.py60
-rw-r--r--src/python/grpcio_test/requirements.txt6
-rw-r--r--src/python/grpcio_test/setup.cfg2
139 files changed, 3136 insertions, 657 deletions
diff --git a/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs b/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs
index 1c14c5bb5b..f77e9c6573 100644
--- a/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs
+++ b/src/csharp/Grpc.Auth/GoogleAuthInterceptors.cs
@@ -57,9 +57,9 @@ namespace Grpc.Auth
/// <returns>The interceptor.</returns>
public static AsyncAuthInterceptor FromCredential(ITokenAccess credential)
{
- return new AsyncAuthInterceptor(async (authUri, metadata) =>
+ return new AsyncAuthInterceptor(async (context, metadata) =>
{
- var accessToken = await credential.GetAccessTokenForRequestAsync(authUri, CancellationToken.None).ConfigureAwait(false);
+ var accessToken = await credential.GetAccessTokenForRequestAsync(context.ServiceUrl, CancellationToken.None).ConfigureAwait(false);
metadata.Add(CreateBearerTokenHeader(accessToken));
});
}
@@ -72,7 +72,7 @@ namespace Grpc.Auth
public static AsyncAuthInterceptor FromAccessToken(string accessToken)
{
Preconditions.CheckNotNull(accessToken);
- return new AsyncAuthInterceptor(async (authUri, metadata) =>
+ return new AsyncAuthInterceptor(async (context, metadata) =>
{
metadata.Add(CreateBearerTokenHeader(accessToken));
});
diff --git a/src/csharp/Grpc.Core/AsyncAuthInterceptor.cs b/src/csharp/Grpc.Core/AsyncAuthInterceptor.cs
new file mode 100644
index 0000000000..5c9ab04812
--- /dev/null
+++ b/src/csharp/Grpc.Core/AsyncAuthInterceptor.cs
@@ -0,0 +1,84 @@
+#region Copyright notice and license
+
+// Copyright 2015, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+using Grpc.Core.Internal;
+using Grpc.Core.Utils;
+
+namespace Grpc.Core
+{
+ /// <summary>
+ /// Asynchronous authentication interceptor for <see cref="CallCredentials"/>.
+ /// </summary>
+ /// <param name="context">The interceptor context.</param>
+ /// <param name="metadata">Metadata to populate with entries that will be added to outgoing call's headers.</param>
+ /// <returns></returns>
+ public delegate Task AsyncAuthInterceptor(AuthInterceptorContext context, Metadata metadata);
+
+ /// <summary>
+ /// Context for an RPC being intercepted by <see cref="AsyncAuthInterceptor"/>.
+ /// </summary>
+ public class AuthInterceptorContext
+ {
+ readonly string serviceUrl;
+ readonly string methodName;
+
+ /// <summary>
+ /// Initializes a new instance of <c>AuthInterceptorContext</c>.
+ /// </summary>
+ public AuthInterceptorContext(string serviceUrl, string methodName)
+ {
+ this.serviceUrl = Preconditions.CheckNotNull(serviceUrl);
+ this.methodName = Preconditions.CheckNotNull(methodName);
+ }
+
+ /// <summary>
+ /// The fully qualified service URL for the RPC being called.
+ /// </summary>
+ public string ServiceUrl
+ {
+ get { return serviceUrl; }
+ }
+
+ /// <summary>
+ /// The method name of the RPC being called.
+ /// </summary>
+ public string MethodName
+ {
+ get { return methodName; }
+ }
+ }
+}
diff --git a/src/csharp/Grpc.Core/CallCredentials.cs b/src/csharp/Grpc.Core/CallCredentials.cs
index 5ea179dfea..a71c8904fe 100644
--- a/src/csharp/Grpc.Core/CallCredentials.cs
+++ b/src/csharp/Grpc.Core/CallCredentials.cs
@@ -41,14 +41,6 @@ using Grpc.Core.Utils;
namespace Grpc.Core
{
/// <summary>
- /// Asynchronous authentication interceptor for <see cref="CallCredentials"/>.
- /// </summary>
- /// <param name="authUri">URL of a service to which current remote call needs to authenticate</param>
- /// <param name="metadata">Metadata to populate with entries that will be added to outgoing call's headers.</param>
- /// <returns></returns>
- public delegate Task AsyncAuthInterceptor(string authUri, Metadata metadata);
-
- /// <summary>
/// Client-side call credentials. Provide authorization with per-call granularity.
/// </summary>
public abstract class CallCredentials
diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj
index 56a06f4a9b..5b3da7c6c9 100644
--- a/src/csharp/Grpc.Core/Grpc.Core.csproj
+++ b/src/csharp/Grpc.Core/Grpc.Core.csproj
@@ -46,6 +46,7 @@
<ItemGroup>
<Compile Include="AsyncDuplexStreamingCall.cs" />
<Compile Include="AsyncServerStreamingCall.cs" />
+ <Compile Include="AsyncAuthInterceptor.cs" />
<Compile Include="CallCredentials.cs" />
<Compile Include="IClientStreamWriter.cs" />
<Compile Include="Internal\NativeMetadataCredentialsPlugin.cs" />
@@ -148,8 +149,8 @@
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets'))" />
</Target>
- <ItemGroup />
- <ItemGroup />
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" />
-</Project> \ No newline at end of file
+ <ItemGroup />
+ <ItemGroup />
+</Project>
diff --git a/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs b/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs
index 4c086048d2..8bb646d303 100644
--- a/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs
+++ b/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs
@@ -38,7 +38,7 @@ using Grpc.Core.Utils;
namespace Grpc.Core.Internal
{
- internal delegate void NativeMetadataInterceptor(IntPtr statePtr, IntPtr serviceUrlPtr, IntPtr callbackPtr, IntPtr userDataPtr, bool isDestroy);
+ internal delegate void NativeMetadataInterceptor(IntPtr statePtr, IntPtr serviceUrlPtr, IntPtr methodNamePtr, IntPtr callbackPtr, IntPtr userDataPtr, bool isDestroy);
internal class NativeMetadataCredentialsPlugin
{
@@ -71,7 +71,7 @@ namespace Grpc.Core.Internal
get { return credentials; }
}
- private void NativeMetadataInterceptorHandler(IntPtr statePtr, IntPtr serviceUrlPtr, IntPtr callbackPtr, IntPtr userDataPtr, bool isDestroy)
+ private void NativeMetadataInterceptorHandler(IntPtr statePtr, IntPtr serviceUrlPtr, IntPtr methodNamePtr, IntPtr callbackPtr, IntPtr userDataPtr, bool isDestroy)
{
if (isDestroy)
{
@@ -81,8 +81,9 @@ namespace Grpc.Core.Internal
try
{
- string serviceUrl = Marshal.PtrToStringAnsi(serviceUrlPtr);
- StartGetMetadata(serviceUrl, callbackPtr, userDataPtr);
+ var context = new AuthInterceptorContext(Marshal.PtrToStringAnsi(serviceUrlPtr),
+ Marshal.PtrToStringAnsi(methodNamePtr));
+ StartGetMetadata(context, callbackPtr, userDataPtr);
}
catch (Exception e)
{
@@ -91,12 +92,12 @@ namespace Grpc.Core.Internal
}
}
- private async void StartGetMetadata(string serviceUrl, IntPtr callbackPtr, IntPtr userDataPtr)
+ private async void StartGetMetadata(AuthInterceptorContext context, IntPtr callbackPtr, IntPtr userDataPtr)
{
try
{
var metadata = new Metadata();
- await interceptor(serviceUrl, metadata).ConfigureAwait(false);
+ await interceptor(context, metadata).ConfigureAwait(false);
using (var metadataArray = MetadataArraySafeHandle.Create(metadata))
{
diff --git a/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs b/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
index 3d56678b99..35230f48c1 100644
--- a/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
+++ b/src/csharp/Grpc.IntegrationTesting/MetadataCredentialsTest.cs
@@ -67,7 +67,7 @@ namespace Grpc.IntegrationTesting
new ChannelOption(ChannelOptions.SslTargetNameOverride, TestCredentials.DefaultHostOverride)
};
- var asyncAuthInterceptor = new AsyncAuthInterceptor(async (authUri, metadata) =>
+ var asyncAuthInterceptor = new AsyncAuthInterceptor(async (context, metadata) =>
{
await Task.Delay(100); // make sure the operation is asynchronous.
metadata.Add("authorization", "SECRET_TOKEN");
diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c
index b8705c49d3..0ef9be33a6 100644
--- a/src/csharp/ext/grpc_csharp_ext.c
+++ b/src/csharp/ext/grpc_csharp_ext.c
@@ -927,7 +927,8 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_metadata_credentials_notify_from_plugin(
}
typedef void(GPR_CALLTYPE *grpcsharp_metadata_interceptor_func)(
- void *state, const char *service_url, grpc_credentials_plugin_metadata_cb cb,
+ void *state, const char *service_url, const char *method_name,
+ grpc_credentials_plugin_metadata_cb cb,
void *user_data, gpr_int32 is_destroy);
static void grpcsharp_get_metadata_handler(
@@ -935,13 +936,13 @@ static void grpcsharp_get_metadata_handler(
grpc_credentials_plugin_metadata_cb cb, void *user_data) {
grpcsharp_metadata_interceptor_func interceptor =
(grpcsharp_metadata_interceptor_func)(gpr_intptr)state;
- interceptor(state, context.service_url, cb, user_data, 0);
+ interceptor(state, context.service_url, context.method_name, cb, user_data, 0);
}
static void grpcsharp_metadata_credentials_destroy_handler(void *state) {
grpcsharp_metadata_interceptor_func interceptor =
(grpcsharp_metadata_interceptor_func)(gpr_intptr)state;
- interceptor(state, NULL, NULL, NULL, 1);
+ interceptor(state, NULL, NULL, NULL, NULL, 1);
}
GPR_EXPORT grpc_call_credentials *GPR_CALLTYPE grpcsharp_metadata_credentials_create_from_plugin(
diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc
index 1b2ab21dfe..c0e2b0f0e8 100644
--- a/src/node/ext/call.cc
+++ b/src/node/ext/call.cc
@@ -234,7 +234,9 @@ class SendMetadataOp : public Op {
class SendMessageOp : public Op {
public:
- SendMessageOp() { send_message = NULL; }
+ SendMessageOp() {
+ send_message = NULL;
+ }
~SendMessageOp() {
if (send_message != NULL) {
grpc_byte_buffer_destroy(send_message);
@@ -269,7 +271,6 @@ class SendMessageOp : public Op {
std::string GetTypeString() const {
return "send_message";
}
-
private:
grpc_byte_buffer *send_message;
};
diff --git a/src/node/src/credentials.js b/src/node/src/credentials.js
index ff10a22e6a..dcbfac18f4 100644
--- a/src/node/src/credentials.js
+++ b/src/node/src/credentials.js
@@ -91,7 +91,7 @@ exports.createSsl = ChannelCredentials.createSsl;
*/
exports.createFromMetadataGenerator = function(metadata_generator) {
return CallCredentials.createFromPlugin(function(service_url, callback) {
- metadata_generator(service_url, function(error, metadata) {
+ metadata_generator({service_url: service_url}, function(error, metadata) {
var code = grpc.status.OK;
var message = '';
if (error) {
@@ -114,7 +114,8 @@ exports.createFromMetadataGenerator = function(metadata_generator) {
* @return {CallCredentials} The resulting credentials object
*/
exports.createFromGoogleCredential = function(google_credential) {
- return exports.createFromMetadataGenerator(function(service_url, callback) {
+ return exports.createFromMetadataGenerator(function(auth_context, callback) {
+ var service_url = auth_context.service_url;
google_credential.getRequestMetadata(service_url, function(err, header) {
if (err) {
callback(err);
diff --git a/src/objective-c/BoringSSL.podspec b/src/objective-c/BoringSSL.podspec
new file mode 100644
index 0000000000..f5b738203d
--- /dev/null
+++ b/src/objective-c/BoringSSL.podspec
@@ -0,0 +1,1428 @@
+# BoringSSL CocoaPods podspec
+
+# Copyright 2015, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Pod::Spec.new do |s|
+ s.name = 'BoringSSL'
+ s.version = '1.0'
+ s.summary = 'BoringSSL is a fork of OpenSSL that is designed to meet Google’s needs.'
+ # Adapted from the homepage:
+ s.description = <<-DESC
+ BoringSSL is a fork of OpenSSL that is designed to meet Google’s needs.
+
+ Although BoringSSL is an open source project, it is not intended for general use, as OpenSSL is.
+ We don’t recommend that third parties depend upon it. Doing so is likely to be frustrating
+ because there are no guarantees of API stability. Only the latest version of this pod is
+ supported, and every new version is a new major version.
+
+ We update Google libraries and programs that use BoringSSL as needed when deciding to make API
+ changes. This allows us to mostly avoid compromises in the name of compatibility. It works for
+ us, but it may not work for you.
+
+ As a Cocoapods pod, it has the advantage over OpenSSL's pods that the library doesn't need to
+ be precompiled. This eliminates the 10 - 20 minutes of wait the first time a user does "pod
+ install", lets it be used as a dynamic framework (pending solution of Cocoapods' issue #4605),
+ and works with bitcode automatically. It's also thought to be smaller than OpenSSL (which takes
+ 1MB - 2MB per ARM architecture), but we don't have specific numbers yet.
+
+ BoringSSL arose because Google used OpenSSL for many years in various ways and, over time, built
+ up a large number of patches that were maintained while tracking upstream OpenSSL. As Google’s
+ product portfolio became more complex, more copies of OpenSSL sprung up and the effort involved
+ in maintaining all these patches in multiple places was growing steadily.
+
+ Currently BoringSSL is the SSL library in Chrome/Chromium, Android (but it’s not part of the
+ NDK) and a number of other apps/programs.
+ DESC
+ s.homepage = 'https://boringssl.googlesource.com/boringssl/'
+ s.documentation_url = 'https://commondatastorage.googleapis.com/chromium-boringssl-docs/headers.html'
+ s.license = { :type => 'Mixed', :file => 'LICENSE' }
+ # "The name and email addresses of the library maintainers, not the Podspec maintainer."
+ s.authors = 'Adam Langley', 'David Benjamin', 'Matt Braithwaite'
+
+ s.source = { :git => 'https://boringssl.googlesource.com/boringssl',
+ :tag => 'version_for_cocoapods_1.0' }
+
+ s.source_files = 'ssl/*.{h,c}',
+ 'ssl/**/*.{h,c}',
+ '*.{h,c}',
+ 'crypto/*.{h,c}',
+ 'crypto/**/*.{h,c}',
+ 'include/openssl/*.h'
+
+ s.public_header_files = 'include/openssl/*.h'
+ s.header_mappings_dir = 'include'
+
+ s.exclude_files = "**/*_test.*"
+
+ # We don't need to inhibit all warnings; only -Wno-shorten-64-to-32. But Cocoapods' linter doesn't
+ # want that for some reason.
+ s.compiler_flags = '-DOPENSSL_NO_ASM', '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
+ s.requires_arc = false
+
+ s.prepare_command = <<-END_OF_COMMAND
+ # Replace "const BIGNUM *I" in rsa.h with a lowercase i, as the former fails when including
+ # OpenSSL in a Swift bridging header (complex.h defines "I", and it's as if the compiler
+ # included it in every bridged header).
+ sed -E -i '.back' 's/\\*I,/*i,/g' include/openssl/rsa.h
+
+ # This is a bit ridiculous, but requiring people to install Go in order to build is slightly
+ # more ridiculous IMO. To save you from scrolling, this is the last part of the podspec.
+ # TODO(jcanizales): Translate err_data_generate.go into a Bash or Ruby script.
+ cat > err_data.c <<EOF
+ /* Copyright (c) 2015, Google Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+
+ /* This file was generated by err_data_generate.go. */
+
+ #include <openssl/base.h>
+ #include <openssl/err.h>
+ #include <openssl/type_check.h>
+
+
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_NONE == 1, library_values_changed_1);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_SYS == 2, library_values_changed_2);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_BN == 3, library_values_changed_3);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_RSA == 4, library_values_changed_4);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_DH == 5, library_values_changed_5);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_EVP == 6, library_values_changed_6);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_BUF == 7, library_values_changed_7);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_OBJ == 8, library_values_changed_8);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_PEM == 9, library_values_changed_9);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_DSA == 10, library_values_changed_10);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_X509 == 11, library_values_changed_11);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_ASN1 == 12, library_values_changed_12);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_CONF == 13, library_values_changed_13);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_CRYPTO == 14, library_values_changed_14);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_EC == 15, library_values_changed_15);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_SSL == 16, library_values_changed_16);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_BIO == 17, library_values_changed_17);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_PKCS7 == 18, library_values_changed_18);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_PKCS8 == 19, library_values_changed_19);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_X509V3 == 20, library_values_changed_20);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_RAND == 21, library_values_changed_21);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_ENGINE == 22, library_values_changed_22);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_OCSP == 23, library_values_changed_23);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_UI == 24, library_values_changed_24);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_COMP == 25, library_values_changed_25);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_ECDSA == 26, library_values_changed_26);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_ECDH == 27, library_values_changed_27);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_HMAC == 28, library_values_changed_28);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_DIGEST == 29, library_values_changed_29);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_CIPHER == 30, library_values_changed_30);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_HKDF == 31, library_values_changed_31);
+ OPENSSL_COMPILE_ASSERT(ERR_LIB_USER == 32, library_values_changed_32);
+ OPENSSL_COMPILE_ASSERT(ERR_NUM_LIBS == 33, library_values_changed_num);
+
+ const uint32_t kOpenSSLReasonValues[] = {
+ 0xc3207ba,
+ 0xc3287d4,
+ 0xc3307e3,
+ 0xc3387f3,
+ 0xc340802,
+ 0xc34881b,
+ 0xc350827,
+ 0xc358844,
+ 0xc360856,
+ 0xc368864,
+ 0xc370874,
+ 0xc378881,
+ 0xc380891,
+ 0xc38889c,
+ 0xc3908b2,
+ 0xc3988c1,
+ 0xc3a08d5,
+ 0xc3a87c7,
+ 0xc3b00b0,
+ 0x10321478,
+ 0x10329484,
+ 0x1033149d,
+ 0x103394b0,
+ 0x10340de1,
+ 0x103494cf,
+ 0x103514e4,
+ 0x10359516,
+ 0x1036152f,
+ 0x10369544,
+ 0x10371562,
+ 0x10379571,
+ 0x1038158d,
+ 0x103895a8,
+ 0x103915b7,
+ 0x103995d3,
+ 0x103a15ee,
+ 0x103a9605,
+ 0x103b1616,
+ 0x103b962a,
+ 0x103c1649,
+ 0x103c9658,
+ 0x103d166f,
+ 0x103d9682,
+ 0x103e0b6c,
+ 0x103e96b3,
+ 0x103f16c6,
+ 0x103f96e0,
+ 0x104016f0,
+ 0x10409704,
+ 0x1041171a,
+ 0x10419732,
+ 0x10421747,
+ 0x1042975b,
+ 0x1043176d,
+ 0x104385d0,
+ 0x104408c1,
+ 0x10449782,
+ 0x10451799,
+ 0x104597ae,
+ 0x104617bc,
+ 0x10469695,
+ 0x104714f7,
+ 0x104787c7,
+ 0x104800b0,
+ 0x104894c3,
+ 0x14320b4f,
+ 0x14328b5d,
+ 0x14330b6c,
+ 0x14338b7e,
+ 0x18320083,
+ 0x18328e47,
+ 0x18340e75,
+ 0x18348e89,
+ 0x18358ec0,
+ 0x18368eed,
+ 0x18370f00,
+ 0x18378f14,
+ 0x18380f38,
+ 0x18388f46,
+ 0x18390f5c,
+ 0x18398f70,
+ 0x183a0f80,
+ 0x183b0f90,
+ 0x183b8fa5,
+ 0x183c8fd0,
+ 0x183d0fe4,
+ 0x183d8ff4,
+ 0x183e0b9b,
+ 0x183e9001,
+ 0x183f1013,
+ 0x183f901e,
+ 0x1840102e,
+ 0x1840903f,
+ 0x18411050,
+ 0x18419062,
+ 0x1842108b,
+ 0x184290bd,
+ 0x184310cc,
+ 0x18451135,
+ 0x1845914b,
+ 0x18461166,
+ 0x18468ed8,
+ 0x184709d9,
+ 0x18478094,
+ 0x18480fbc,
+ 0x18489101,
+ 0x18490e5d,
+ 0x18498e9e,
+ 0x184a119c,
+ 0x184a9119,
+ 0x184b10e0,
+ 0x184b8e37,
+ 0x184c10a4,
+ 0x184c866b,
+ 0x184d1181,
+ 0x203211c3,
+ 0x243211cf,
+ 0x24328907,
+ 0x243311e1,
+ 0x243391ee,
+ 0x243411fb,
+ 0x2434920d,
+ 0x2435121c,
+ 0x24359239,
+ 0x24361246,
+ 0x24369254,
+ 0x24371262,
+ 0x24379270,
+ 0x24381279,
+ 0x24389286,
+ 0x24391299,
+ 0x28320b8f,
+ 0x28328b9b,
+ 0x28330b6c,
+ 0x28338bae,
+ 0x2c322c0b,
+ 0x2c32ac19,
+ 0x2c332c2b,
+ 0x2c33ac3d,
+ 0x2c342c51,
+ 0x2c34ac63,
+ 0x2c352c7e,
+ 0x2c35ac90,
+ 0x2c362ca3,
+ 0x2c3682f3,
+ 0x2c372cb0,
+ 0x2c37acc2,
+ 0x2c382cd5,
+ 0x2c38ace3,
+ 0x2c392cf3,
+ 0x2c39ad05,
+ 0x2c3a2d19,
+ 0x2c3aad2a,
+ 0x2c3b1359,
+ 0x2c3bad3b,
+ 0x2c3c2d4f,
+ 0x2c3cad65,
+ 0x2c3d2d7e,
+ 0x2c3dadac,
+ 0x2c3e2dba,
+ 0x2c3eadd2,
+ 0x2c3f2dea,
+ 0x2c3fadf7,
+ 0x2c402e1a,
+ 0x2c40ae39,
+ 0x2c4111c3,
+ 0x2c41ae4a,
+ 0x2c422e5d,
+ 0x2c429135,
+ 0x2c432e6e,
+ 0x2c4386a2,
+ 0x2c442d9b,
+ 0x30320000,
+ 0x30328015,
+ 0x3033001f,
+ 0x30338038,
+ 0x3034004a,
+ 0x30348064,
+ 0x3035006b,
+ 0x30358083,
+ 0x30360094,
+ 0x303680a1,
+ 0x303700b0,
+ 0x303780bd,
+ 0x303800d0,
+ 0x303880eb,
+ 0x30390100,
+ 0x30398114,
+ 0x303a0128,
+ 0x303a8139,
+ 0x303b0152,
+ 0x303b816f,
+ 0x303c017d,
+ 0x303c8191,
+ 0x303d01a1,
+ 0x303d81ba,
+ 0x303e01ca,
+ 0x303e81dd,
+ 0x303f01ec,
+ 0x303f81f8,
+ 0x3040020d,
+ 0x3040821d,
+ 0x30410234,
+ 0x30418241,
+ 0x30420254,
+ 0x30428263,
+ 0x30430278,
+ 0x30438299,
+ 0x304402ac,
+ 0x304482bf,
+ 0x304502d8,
+ 0x304582f3,
+ 0x30460310,
+ 0x30468329,
+ 0x30470337,
+ 0x30478348,
+ 0x30480357,
+ 0x3048836f,
+ 0x30490381,
+ 0x30498395,
+ 0x304a03b4,
+ 0x304a83c7,
+ 0x304b03d2,
+ 0x304b83e1,
+ 0x304c03f2,
+ 0x304c83fe,
+ 0x304d0414,
+ 0x304d8422,
+ 0x304e0438,
+ 0x304e844a,
+ 0x304f045c,
+ 0x304f846f,
+ 0x30500482,
+ 0x30508493,
+ 0x305104a3,
+ 0x305184bb,
+ 0x305204d0,
+ 0x305284e8,
+ 0x305304fc,
+ 0x30538514,
+ 0x3054052d,
+ 0x30548546,
+ 0x30550563,
+ 0x3055856e,
+ 0x30560586,
+ 0x30568596,
+ 0x305705a7,
+ 0x305785ba,
+ 0x305805d0,
+ 0x305885d9,
+ 0x305905ee,
+ 0x30598601,
+ 0x305a0610,
+ 0x305a8630,
+ 0x305b063f,
+ 0x305b864b,
+ 0x305c066b,
+ 0x305c8687,
+ 0x305d0698,
+ 0x305d86a2,
+ 0x34320ac9,
+ 0x34328add,
+ 0x34330afa,
+ 0x34338b0d,
+ 0x34340b1c,
+ 0x34348b39,
+ 0x3c320083,
+ 0x3c328bd8,
+ 0x3c330bf1,
+ 0x3c338c0c,
+ 0x3c340c29,
+ 0x3c348c44,
+ 0x3c350c5f,
+ 0x3c358c74,
+ 0x3c360c8d,
+ 0x3c368ca5,
+ 0x3c370cb6,
+ 0x3c378cc4,
+ 0x3c380cd1,
+ 0x3c388ce5,
+ 0x3c390b9b,
+ 0x3c398cf9,
+ 0x3c3a0d0d,
+ 0x3c3a8881,
+ 0x3c3b0d1d,
+ 0x3c3b8d38,
+ 0x3c3c0d4a,
+ 0x3c3c8d60,
+ 0x3c3d0d6a,
+ 0x3c3d8d7e,
+ 0x3c3e0d8c,
+ 0x3c3e8db1,
+ 0x3c3f0bc4,
+ 0x3c3f8d9a,
+ 0x403217d3,
+ 0x403297e9,
+ 0x40331817,
+ 0x40339821,
+ 0x40341838,
+ 0x40349856,
+ 0x40351866,
+ 0x40359878,
+ 0x40361885,
+ 0x40369891,
+ 0x403718a6,
+ 0x403798bb,
+ 0x403818cd,
+ 0x403898d8,
+ 0x403918ea,
+ 0x40398de1,
+ 0x403a18fa,
+ 0x403a990d,
+ 0x403b192e,
+ 0x403b993f,
+ 0x403c194f,
+ 0x403c8064,
+ 0x403d195b,
+ 0x403d9977,
+ 0x403e198d,
+ 0x403e999c,
+ 0x403f19af,
+ 0x403f99c9,
+ 0x404019d7,
+ 0x404099ec,
+ 0x40411a00,
+ 0x40419a1d,
+ 0x40421a36,
+ 0x40429a51,
+ 0x40431a6a,
+ 0x40439a7d,
+ 0x40441a91,
+ 0x40449aa9,
+ 0x40451af4,
+ 0x40459b02,
+ 0x40461b20,
+ 0x40468094,
+ 0x40471b35,
+ 0x40479b47,
+ 0x40481b6b,
+ 0x40489b99,
+ 0x40491bad,
+ 0x40499bc2,
+ 0x404a1bdb,
+ 0x404a9c15,
+ 0x404b1c46,
+ 0x404b9c7c,
+ 0x404c1c97,
+ 0x404c9cb1,
+ 0x404d1cc8,
+ 0x404d9cf0,
+ 0x404e1d07,
+ 0x404e9d23,
+ 0x404f1d3f,
+ 0x404f9d60,
+ 0x40501d82,
+ 0x40509d9e,
+ 0x40511db2,
+ 0x40519dbf,
+ 0x40521dd6,
+ 0x40529de6,
+ 0x40531df6,
+ 0x40539e0a,
+ 0x40541e25,
+ 0x40549e35,
+ 0x40551e4c,
+ 0x40559e5b,
+ 0x40561e88,
+ 0x40569ea0,
+ 0x40571ebc,
+ 0x40579ed5,
+ 0x40581ee8,
+ 0x40589efd,
+ 0x40591f20,
+ 0x40599f4b,
+ 0x405a1f58,
+ 0x405a9f71,
+ 0x405b1f89,
+ 0x405b9f9c,
+ 0x405c1fb1,
+ 0x405c9fc3,
+ 0x405d1fd8,
+ 0x405d9fe8,
+ 0x405e2001,
+ 0x405ea015,
+ 0x405f2025,
+ 0x405fa03d,
+ 0x4060204e,
+ 0x4060a061,
+ 0x40612072,
+ 0x4061a090,
+ 0x406220a1,
+ 0x4062a0ae,
+ 0x406320c5,
+ 0x4063a106,
+ 0x4064211d,
+ 0x4064a12a,
+ 0x40652138,
+ 0x4065a15a,
+ 0x40662182,
+ 0x4066a197,
+ 0x406721ae,
+ 0x4067a1bf,
+ 0x406821d0,
+ 0x4068a1e1,
+ 0x406921f6,
+ 0x4069a20d,
+ 0x406a221e,
+ 0x406aa237,
+ 0x406b2252,
+ 0x406ba269,
+ 0x406c22d6,
+ 0x406ca2f7,
+ 0x406d230a,
+ 0x406da32b,
+ 0x406e2346,
+ 0x406ea38f,
+ 0x406f23b0,
+ 0x406fa3d6,
+ 0x407023f6,
+ 0x4070a412,
+ 0x4071259f,
+ 0x4071a5c2,
+ 0x407225d8,
+ 0x4072a5f7,
+ 0x4073260f,
+ 0x4073a62f,
+ 0x40742859,
+ 0x4074a87e,
+ 0x40752899,
+ 0x4075a8b8,
+ 0x407628e7,
+ 0x4076a90f,
+ 0x40772940,
+ 0x4077a95f,
+ 0x40782999,
+ 0x4078a9b0,
+ 0x407929c3,
+ 0x4079a9e0,
+ 0x407a0782,
+ 0x407aa9f2,
+ 0x407b2a05,
+ 0x407baa1e,
+ 0x407c2a36,
+ 0x407c90bd,
+ 0x407d2a4a,
+ 0x407daa64,
+ 0x407e2a75,
+ 0x407eaa89,
+ 0x407f2a97,
+ 0x407faab2,
+ 0x40801286,
+ 0x4080aad7,
+ 0x40812af9,
+ 0x4081ab14,
+ 0x40822b29,
+ 0x4082ab41,
+ 0x40832b59,
+ 0x4083ab70,
+ 0x40842b86,
+ 0x4084ab92,
+ 0x40852ba5,
+ 0x4085abba,
+ 0x40862bcc,
+ 0x4086abe1,
+ 0x40872bea,
+ 0x40879cde,
+ 0x40880083,
+ 0x4088a0e5,
+ 0x40890a17,
+ 0x4089a281,
+ 0x408a1bfe,
+ 0x408aa2ab,
+ 0x408b2928,
+ 0x408ba984,
+ 0x408c2361,
+ 0x408c9c2f,
+ 0x408d1c64,
+ 0x408d9e76,
+ 0x408e1ab9,
+ 0x408e9add,
+ 0x408f1f2e,
+ 0x408f9b8b,
+ 0x41f424ca,
+ 0x41f9255c,
+ 0x41fe244f,
+ 0x41fea680,
+ 0x41ff2771,
+ 0x420324e3,
+ 0x42082505,
+ 0x4208a541,
+ 0x42092433,
+ 0x4209a57b,
+ 0x420a248a,
+ 0x420aa46a,
+ 0x420b24aa,
+ 0x420ba523,
+ 0x420c278d,
+ 0x420ca64d,
+ 0x420d2667,
+ 0x420da69e,
+ 0x421226b8,
+ 0x42172754,
+ 0x4217a6fa,
+ 0x421c271c,
+ 0x421f26d7,
+ 0x422127a4,
+ 0x42262737,
+ 0x422b283d,
+ 0x422ba806,
+ 0x422c2825,
+ 0x422ca7e0,
+ 0x422d27bf,
+ 0x443206ad,
+ 0x443286bc,
+ 0x443306c8,
+ 0x443386d6,
+ 0x443406e9,
+ 0x443486fa,
+ 0x44350701,
+ 0x4435870b,
+ 0x4436071e,
+ 0x44368734,
+ 0x44370746,
+ 0x44378753,
+ 0x44380762,
+ 0x4438876a,
+ 0x44390782,
+ 0x44398790,
+ 0x443a07a3,
+ 0x4c3212b0,
+ 0x4c3292c0,
+ 0x4c3312d3,
+ 0x4c3392f3,
+ 0x4c340094,
+ 0x4c3480b0,
+ 0x4c3512ff,
+ 0x4c35930d,
+ 0x4c361329,
+ 0x4c36933c,
+ 0x4c37134b,
+ 0x4c379359,
+ 0x4c38136e,
+ 0x4c38937a,
+ 0x4c39139a,
+ 0x4c3993c4,
+ 0x4c3a13dd,
+ 0x4c3a93f6,
+ 0x4c3b05d0,
+ 0x4c3b940f,
+ 0x4c3c1421,
+ 0x4c3c9430,
+ 0x4c3d10bd,
+ 0x4c3d9449,
+ 0x4c3e1456,
+ 0x50322e80,
+ 0x5032ae8f,
+ 0x50332e9a,
+ 0x5033aeaa,
+ 0x50342ec3,
+ 0x5034aedd,
+ 0x50352eeb,
+ 0x5035af01,
+ 0x50362f13,
+ 0x5036af29,
+ 0x50372f42,
+ 0x5037af55,
+ 0x50382f6d,
+ 0x5038af7e,
+ 0x50392f93,
+ 0x5039afa7,
+ 0x503a2fc7,
+ 0x503aafdd,
+ 0x503b2ff5,
+ 0x503bb007,
+ 0x503c3023,
+ 0x503cb03a,
+ 0x503d3053,
+ 0x503db069,
+ 0x503e3076,
+ 0x503eb08c,
+ 0x503f309e,
+ 0x503f8348,
+ 0x504030b1,
+ 0x5040b0c1,
+ 0x504130db,
+ 0x5041b0ea,
+ 0x50423104,
+ 0x5042b121,
+ 0x50433131,
+ 0x5043b141,
+ 0x50443150,
+ 0x50448414,
+ 0x50453164,
+ 0x5045b182,
+ 0x50463195,
+ 0x5046b1ab,
+ 0x504731bd,
+ 0x5047b1d2,
+ 0x504831f8,
+ 0x5048b206,
+ 0x50493219,
+ 0x5049b22e,
+ 0x504a3244,
+ 0x504ab254,
+ 0x504b3274,
+ 0x504bb287,
+ 0x504c32aa,
+ 0x504cb2d8,
+ 0x504d32ea,
+ 0x504db307,
+ 0x504e3322,
+ 0x504eb33e,
+ 0x504f3350,
+ 0x504fb367,
+ 0x50503376,
+ 0x50508687,
+ 0x50513389,
+ 0x58320e1f,
+ 0x68320de1,
+ 0x68328b9b,
+ 0x68330bae,
+ 0x68338def,
+ 0x68340dff,
+ 0x683480b0,
+ 0x6c320dbd,
+ 0x6c328b7e,
+ 0x6c330dc8,
+ 0x7432098d,
+ 0x783208f2,
+ 0x78328907,
+ 0x78330913,
+ 0x78338083,
+ 0x78340922,
+ 0x78348937,
+ 0x78350956,
+ 0x78358978,
+ 0x7836098d,
+ 0x783689a3,
+ 0x783709b3,
+ 0x783789c6,
+ 0x783809d9,
+ 0x783889eb,
+ 0x783909f8,
+ 0x78398a17,
+ 0x783a0a2c,
+ 0x783a8a3a,
+ 0x783b0a44,
+ 0x783b8a58,
+ 0x783c0a6f,
+ 0x783c8a84,
+ 0x783d0a9b,
+ 0x783d8ab0,
+ 0x783e0a06,
+ 0x7c3211b2,
+ };
+
+ const size_t kOpenSSLReasonValuesLen = sizeof(kOpenSSLReasonValues) / sizeof(kOpenSSLReasonValues[0]);
+
+ const char kOpenSSLReasonStringData[] =
+ "ASN1_LENGTH_MISMATCH\\0"
+ "AUX_ERROR\\0"
+ "BAD_GET_ASN1_OBJECT_CALL\\0"
+ "BAD_OBJECT_HEADER\\0"
+ "BMPSTRING_IS_WRONG_LENGTH\\0"
+ "BN_LIB\\0"
+ "BOOLEAN_IS_WRONG_LENGTH\\0"
+ "BUFFER_TOO_SMALL\\0"
+ "DECODE_ERROR\\0"
+ "DEPTH_EXCEEDED\\0"
+ "ENCODE_ERROR\\0"
+ "ERROR_GETTING_TIME\\0"
+ "EXPECTING_AN_ASN1_SEQUENCE\\0"
+ "EXPECTING_AN_INTEGER\\0"
+ "EXPECTING_AN_OBJECT\\0"
+ "EXPECTING_A_BOOLEAN\\0"
+ "EXPECTING_A_TIME\\0"
+ "EXPLICIT_LENGTH_MISMATCH\\0"
+ "EXPLICIT_TAG_NOT_CONSTRUCTED\\0"
+ "FIELD_MISSING\\0"
+ "FIRST_NUM_TOO_LARGE\\0"
+ "HEADER_TOO_LONG\\0"
+ "ILLEGAL_BITSTRING_FORMAT\\0"
+ "ILLEGAL_BOOLEAN\\0"
+ "ILLEGAL_CHARACTERS\\0"
+ "ILLEGAL_FORMAT\\0"
+ "ILLEGAL_HEX\\0"
+ "ILLEGAL_IMPLICIT_TAG\\0"
+ "ILLEGAL_INTEGER\\0"
+ "ILLEGAL_NESTED_TAGGING\\0"
+ "ILLEGAL_NULL\\0"
+ "ILLEGAL_NULL_VALUE\\0"
+ "ILLEGAL_OBJECT\\0"
+ "ILLEGAL_OPTIONAL_ANY\\0"
+ "ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE\\0"
+ "ILLEGAL_TAGGED_ANY\\0"
+ "ILLEGAL_TIME_VALUE\\0"
+ "INTEGER_NOT_ASCII_FORMAT\\0"
+ "INTEGER_TOO_LARGE_FOR_LONG\\0"
+ "INVALID_BIT_STRING_BITS_LEFT\\0"
+ "INVALID_BMPSTRING_LENGTH\\0"
+ "INVALID_DIGIT\\0"
+ "INVALID_MODIFIER\\0"
+ "INVALID_NUMBER\\0"
+ "INVALID_OBJECT_ENCODING\\0"
+ "INVALID_SEPARATOR\\0"
+ "INVALID_TIME_FORMAT\\0"
+ "INVALID_UNIVERSALSTRING_LENGTH\\0"
+ "INVALID_UTF8STRING\\0"
+ "LIST_ERROR\\0"
+ "MALLOC_FAILURE\\0"
+ "MISSING_ASN1_EOS\\0"
+ "MISSING_EOC\\0"
+ "MISSING_SECOND_NUMBER\\0"
+ "MISSING_VALUE\\0"
+ "MSTRING_NOT_UNIVERSAL\\0"
+ "MSTRING_WRONG_TAG\\0"
+ "NESTED_ASN1_ERROR\\0"
+ "NESTED_ASN1_STRING\\0"
+ "NON_HEX_CHARACTERS\\0"
+ "NOT_ASCII_FORMAT\\0"
+ "NOT_ENOUGH_DATA\\0"
+ "NO_MATCHING_CHOICE_TYPE\\0"
+ "NULL_IS_WRONG_LENGTH\\0"
+ "OBJECT_NOT_ASCII_FORMAT\\0"
+ "ODD_NUMBER_OF_CHARS\\0"
+ "SECOND_NUMBER_TOO_LARGE\\0"
+ "SEQUENCE_LENGTH_MISMATCH\\0"
+ "SEQUENCE_NOT_CONSTRUCTED\\0"
+ "SEQUENCE_OR_SET_NEEDS_CONFIG\\0"
+ "SHORT_LINE\\0"
+ "STREAMING_NOT_SUPPORTED\\0"
+ "STRING_TOO_LONG\\0"
+ "STRING_TOO_SHORT\\0"
+ "TAG_VALUE_TOO_HIGH\\0"
+ "TIME_NOT_ASCII_FORMAT\\0"
+ "TOO_LONG\\0"
+ "TYPE_NOT_CONSTRUCTED\\0"
+ "TYPE_NOT_PRIMITIVE\\0"
+ "UNEXPECTED_EOC\\0"
+ "UNIVERSALSTRING_IS_WRONG_LENGTH\\0"
+ "UNKNOWN_FORMAT\\0"
+ "UNKNOWN_TAG\\0"
+ "UNSUPPORTED_ANY_DEFINED_BY_TYPE\\0"
+ "UNSUPPORTED_PUBLIC_KEY_TYPE\\0"
+ "UNSUPPORTED_TYPE\\0"
+ "WRONG_TAG\\0"
+ "WRONG_TYPE\\0"
+ "BAD_FOPEN_MODE\\0"
+ "BROKEN_PIPE\\0"
+ "CONNECT_ERROR\\0"
+ "ERROR_SETTING_NBIO\\0"
+ "INVALID_ARGUMENT\\0"
+ "IN_USE\\0"
+ "KEEPALIVE\\0"
+ "NBIO_CONNECT_ERROR\\0"
+ "NO_HOSTNAME_SPECIFIED\\0"
+ "NO_PORT_SPECIFIED\\0"
+ "NO_SUCH_FILE\\0"
+ "NULL_PARAMETER\\0"
+ "SYS_LIB\\0"
+ "UNABLE_TO_CREATE_SOCKET\\0"
+ "UNINITIALIZED\\0"
+ "UNSUPPORTED_METHOD\\0"
+ "WRITE_TO_READ_ONLY_BIO\\0"
+ "ARG2_LT_ARG3\\0"
+ "BAD_ENCODING\\0"
+ "BAD_RECIPROCAL\\0"
+ "BIGNUM_TOO_LONG\\0"
+ "BITS_TOO_SMALL\\0"
+ "CALLED_WITH_EVEN_MODULUS\\0"
+ "DIV_BY_ZERO\\0"
+ "EXPAND_ON_STATIC_BIGNUM_DATA\\0"
+ "INPUT_NOT_REDUCED\\0"
+ "INVALID_RANGE\\0"
+ "NEGATIVE_NUMBER\\0"
+ "NOT_A_SQUARE\\0"
+ "NOT_INITIALIZED\\0"
+ "NO_INVERSE\\0"
+ "PRIVATE_KEY_TOO_LARGE\\0"
+ "P_IS_NOT_PRIME\\0"
+ "TOO_MANY_ITERATIONS\\0"
+ "TOO_MANY_TEMPORARY_VARIABLES\\0"
+ "AES_KEY_SETUP_FAILED\\0"
+ "BAD_DECRYPT\\0"
+ "BAD_KEY_LENGTH\\0"
+ "CTRL_NOT_IMPLEMENTED\\0"
+ "CTRL_OPERATION_NOT_IMPLEMENTED\\0"
+ "DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH\\0"
+ "INITIALIZATION_ERROR\\0"
+ "INPUT_NOT_INITIALIZED\\0"
+ "INVALID_AD_SIZE\\0"
+ "INVALID_KEY_LENGTH\\0"
+ "INVALID_NONCE_SIZE\\0"
+ "INVALID_OPERATION\\0"
+ "IV_TOO_LARGE\\0"
+ "NO_CIPHER_SET\\0"
+ "NO_DIRECTION_SET\\0"
+ "OUTPUT_ALIASES_INPUT\\0"
+ "TAG_TOO_LARGE\\0"
+ "TOO_LARGE\\0"
+ "UNSUPPORTED_AD_SIZE\\0"
+ "UNSUPPORTED_INPUT_SIZE\\0"
+ "UNSUPPORTED_KEY_SIZE\\0"
+ "UNSUPPORTED_NONCE_SIZE\\0"
+ "UNSUPPORTED_TAG_SIZE\\0"
+ "WRONG_FINAL_BLOCK_LENGTH\\0"
+ "LIST_CANNOT_BE_NULL\\0"
+ "MISSING_CLOSE_SQUARE_BRACKET\\0"
+ "MISSING_EQUAL_SIGN\\0"
+ "NO_CLOSE_BRACE\\0"
+ "UNABLE_TO_CREATE_NEW_SECTION\\0"
+ "VARIABLE_HAS_NO_VALUE\\0"
+ "BAD_GENERATOR\\0"
+ "INVALID_PUBKEY\\0"
+ "MODULUS_TOO_LARGE\\0"
+ "NO_PRIVATE_VALUE\\0"
+ "BAD_Q_VALUE\\0"
+ "MISSING_PARAMETERS\\0"
+ "NEED_NEW_SETUP_VALUES\\0"
+ "BIGNUM_OUT_OF_RANGE\\0"
+ "COORDINATES_OUT_OF_RANGE\\0"
+ "D2I_ECPKPARAMETERS_FAILURE\\0"
+ "EC_GROUP_NEW_BY_NAME_FAILURE\\0"
+ "GROUP2PKPARAMETERS_FAILURE\\0"
+ "I2D_ECPKPARAMETERS_FAILURE\\0"
+ "INCOMPATIBLE_OBJECTS\\0"
+ "INVALID_COMPRESSED_POINT\\0"
+ "INVALID_COMPRESSION_BIT\\0"
+ "INVALID_ENCODING\\0"
+ "INVALID_FIELD\\0"
+ "INVALID_FORM\\0"
+ "INVALID_GROUP_ORDER\\0"
+ "INVALID_PRIVATE_KEY\\0"
+ "MISSING_PRIVATE_KEY\\0"
+ "NON_NAMED_CURVE\\0"
+ "PKPARAMETERS2GROUP_FAILURE\\0"
+ "POINT_AT_INFINITY\\0"
+ "POINT_IS_NOT_ON_CURVE\\0"
+ "SLOT_FULL\\0"
+ "UNDEFINED_GENERATOR\\0"
+ "UNKNOWN_GROUP\\0"
+ "UNKNOWN_ORDER\\0"
+ "WRONG_CURVE_PARAMETERS\\0"
+ "WRONG_ORDER\\0"
+ "KDF_FAILED\\0"
+ "POINT_ARITHMETIC_FAILURE\\0"
+ "BAD_SIGNATURE\\0"
+ "NOT_IMPLEMENTED\\0"
+ "RANDOM_NUMBER_GENERATION_FAILED\\0"
+ "OPERATION_NOT_SUPPORTED\\0"
+ "BN_DECODE_ERROR\\0"
+ "COMMAND_NOT_SUPPORTED\\0"
+ "CONTEXT_NOT_INITIALISED\\0"
+ "DIFFERENT_KEY_TYPES\\0"
+ "DIFFERENT_PARAMETERS\\0"
+ "DIGEST_AND_KEY_TYPE_NOT_SUPPORTED\\0"
+ "EXPECTING_AN_EC_KEY_KEY\\0"
+ "EXPECTING_AN_RSA_KEY\\0"
+ "EXPECTING_A_DH_KEY\\0"
+ "EXPECTING_A_DSA_KEY\\0"
+ "ILLEGAL_OR_UNSUPPORTED_PADDING_MODE\\0"
+ "INVALID_CURVE\\0"
+ "INVALID_DIGEST_LENGTH\\0"
+ "INVALID_DIGEST_TYPE\\0"
+ "INVALID_KEYBITS\\0"
+ "INVALID_MGF1_MD\\0"
+ "INVALID_PADDING_MODE\\0"
+ "INVALID_PSS_PARAMETERS\\0"
+ "INVALID_PSS_SALTLEN\\0"
+ "INVALID_SALT_LENGTH\\0"
+ "INVALID_TRAILER\\0"
+ "KEYS_NOT_SET\\0"
+ "NO_DEFAULT_DIGEST\\0"
+ "NO_KEY_SET\\0"
+ "NO_MDC2_SUPPORT\\0"
+ "NO_NID_FOR_CURVE\\0"
+ "NO_OPERATION_SET\\0"
+ "NO_PARAMETERS_SET\\0"
+ "OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE\\0"
+ "OPERATON_NOT_INITIALIZED\\0"
+ "PARAMETER_ENCODING_ERROR\\0"
+ "UNKNOWN_DIGEST\\0"
+ "UNKNOWN_MASK_DIGEST\\0"
+ "UNKNOWN_MESSAGE_DIGEST_ALGORITHM\\0"
+ "UNKNOWN_PUBLIC_KEY_TYPE\\0"
+ "UNKNOWN_SIGNATURE_ALGORITHM\\0"
+ "UNSUPPORTED_ALGORITHM\\0"
+ "UNSUPPORTED_MASK_ALGORITHM\\0"
+ "UNSUPPORTED_MASK_PARAMETER\\0"
+ "UNSUPPORTED_SIGNATURE_TYPE\\0"
+ "WRONG_PUBLIC_KEY_TYPE\\0"
+ "OUTPUT_TOO_LARGE\\0"
+ "UNKNOWN_NID\\0"
+ "BAD_BASE64_DECODE\\0"
+ "BAD_END_LINE\\0"
+ "BAD_IV_CHARS\\0"
+ "BAD_PASSWORD_READ\\0"
+ "CIPHER_IS_NULL\\0"
+ "ERROR_CONVERTING_PRIVATE_KEY\\0"
+ "NOT_DEK_INFO\\0"
+ "NOT_ENCRYPTED\\0"
+ "NOT_PROC_TYPE\\0"
+ "NO_START_LINE\\0"
+ "READ_KEY\\0"
+ "SHORT_HEADER\\0"
+ "UNSUPPORTED_CIPHER\\0"
+ "UNSUPPORTED_ENCRYPTION\\0"
+ "BAD_PKCS12_DATA\\0"
+ "BAD_PKCS12_VERSION\\0"
+ "CIPHER_HAS_NO_OBJECT_IDENTIFIER\\0"
+ "CRYPT_ERROR\\0"
+ "ENCRYPT_ERROR\\0"
+ "ERROR_SETTING_CIPHER_PARAMS\\0"
+ "INCORRECT_PASSWORD\\0"
+ "KEYGEN_FAILURE\\0"
+ "KEY_GEN_ERROR\\0"
+ "METHOD_NOT_SUPPORTED\\0"
+ "MISSING_MAC\\0"
+ "MULTIPLE_PRIVATE_KEYS_IN_PKCS12\\0"
+ "PKCS12_PUBLIC_KEY_INTEGRITY_NOT_SUPPORTED\\0"
+ "PKCS12_TOO_DEEPLY_NESTED\\0"
+ "PRIVATE_KEY_DECODE_ERROR\\0"
+ "PRIVATE_KEY_ENCODE_ERROR\\0"
+ "UNKNOWN_ALGORITHM\\0"
+ "UNKNOWN_CIPHER\\0"
+ "UNKNOWN_CIPHER_ALGORITHM\\0"
+ "UNKNOWN_HASH\\0"
+ "UNSUPPORTED_PRIVATE_KEY_ALGORITHM\\0"
+ "BAD_E_VALUE\\0"
+ "BAD_FIXED_HEADER_DECRYPT\\0"
+ "BAD_PAD_BYTE_COUNT\\0"
+ "BAD_RSA_PARAMETERS\\0"
+ "BAD_VERSION\\0"
+ "BLOCK_TYPE_IS_NOT_01\\0"
+ "BN_NOT_INITIALIZED\\0"
+ "CANNOT_RECOVER_MULTI_PRIME_KEY\\0"
+ "CRT_PARAMS_ALREADY_GIVEN\\0"
+ "CRT_VALUES_INCORRECT\\0"
+ "DATA_LEN_NOT_EQUAL_TO_MOD_LEN\\0"
+ "DATA_TOO_LARGE\\0"
+ "DATA_TOO_LARGE_FOR_KEY_SIZE\\0"
+ "DATA_TOO_LARGE_FOR_MODULUS\\0"
+ "DATA_TOO_SMALL\\0"
+ "DATA_TOO_SMALL_FOR_KEY_SIZE\\0"
+ "DIGEST_TOO_BIG_FOR_RSA_KEY\\0"
+ "D_E_NOT_CONGRUENT_TO_1\\0"
+ "EMPTY_PUBLIC_KEY\\0"
+ "FIRST_OCTET_INVALID\\0"
+ "INCONSISTENT_SET_OF_CRT_VALUES\\0"
+ "INTERNAL_ERROR\\0"
+ "INVALID_MESSAGE_LENGTH\\0"
+ "KEY_SIZE_TOO_SMALL\\0"
+ "LAST_OCTET_INVALID\\0"
+ "MUST_HAVE_AT_LEAST_TWO_PRIMES\\0"
+ "NO_PUBLIC_EXPONENT\\0"
+ "NULL_BEFORE_BLOCK_MISSING\\0"
+ "N_NOT_EQUAL_P_Q\\0"
+ "OAEP_DECODING_ERROR\\0"
+ "ONLY_ONE_OF_P_Q_GIVEN\\0"
+ "OUTPUT_BUFFER_TOO_SMALL\\0"
+ "PADDING_CHECK_FAILED\\0"
+ "PKCS_DECODING_ERROR\\0"
+ "SLEN_CHECK_FAILED\\0"
+ "SLEN_RECOVERY_FAILED\\0"
+ "UNKNOWN_ALGORITHM_TYPE\\0"
+ "UNKNOWN_PADDING_TYPE\\0"
+ "VALUE_MISSING\\0"
+ "WRONG_SIGNATURE_LENGTH\\0"
+ "APP_DATA_IN_HANDSHAKE\\0"
+ "ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT\\0"
+ "BAD_ALERT\\0"
+ "BAD_CHANGE_CIPHER_SPEC\\0"
+ "BAD_DATA_RETURNED_BY_CALLBACK\\0"
+ "BAD_DH_P_LENGTH\\0"
+ "BAD_DIGEST_LENGTH\\0"
+ "BAD_ECC_CERT\\0"
+ "BAD_ECPOINT\\0"
+ "BAD_HANDSHAKE_LENGTH\\0"
+ "BAD_HANDSHAKE_RECORD\\0"
+ "BAD_HELLO_REQUEST\\0"
+ "BAD_LENGTH\\0"
+ "BAD_PACKET_LENGTH\\0"
+ "BAD_RSA_ENCRYPT\\0"
+ "BAD_SRTP_MKI_VALUE\\0"
+ "BAD_SRTP_PROTECTION_PROFILE_LIST\\0"
+ "BAD_SSL_FILETYPE\\0"
+ "BAD_WRITE_RETRY\\0"
+ "BIO_NOT_SET\\0"
+ "CANNOT_SERIALIZE_PUBLIC_KEY\\0"
+ "CA_DN_LENGTH_MISMATCH\\0"
+ "CA_DN_TOO_LONG\\0"
+ "CCS_RECEIVED_EARLY\\0"
+ "CERTIFICATE_VERIFY_FAILED\\0"
+ "CERT_CB_ERROR\\0"
+ "CERT_LENGTH_MISMATCH\\0"
+ "CHANNEL_ID_NOT_P256\\0"
+ "CHANNEL_ID_SIGNATURE_INVALID\\0"
+ "CIPHER_CODE_WRONG_LENGTH\\0"
+ "CIPHER_OR_HASH_UNAVAILABLE\\0"
+ "CLIENTHELLO_PARSE_FAILED\\0"
+ "CLIENTHELLO_TLSEXT\\0"
+ "CONNECTION_REJECTED\\0"
+ "CONNECTION_TYPE_NOT_SET\\0"
+ "COOKIE_MISMATCH\\0"
+ "CUSTOM_EXTENSION_CONTENTS_TOO_LARGE\\0"
+ "CUSTOM_EXTENSION_ERROR\\0"
+ "D2I_ECDSA_SIG\\0"
+ "DATA_BETWEEN_CCS_AND_FINISHED\\0"
+ "DATA_LENGTH_TOO_LONG\\0"
+ "DECRYPTION_FAILED\\0"
+ "DECRYPTION_FAILED_OR_BAD_RECORD_MAC\\0"
+ "DH_PUBLIC_VALUE_LENGTH_IS_WRONG\\0"
+ "DH_P_TOO_LONG\\0"
+ "DIGEST_CHECK_FAILED\\0"
+ "DTLS_MESSAGE_TOO_BIG\\0"
+ "ECC_CERT_NOT_FOR_SIGNING\\0"
+ "EMPTY_SRTP_PROTECTION_PROFILE_LIST\\0"
+ "EMS_STATE_INCONSISTENT\\0"
+ "ENCRYPTED_LENGTH_TOO_LONG\\0"
+ "ERROR_ADDING_EXTENSION\\0"
+ "ERROR_IN_RECEIVED_CIPHER_LIST\\0"
+ "ERROR_PARSING_EXTENSION\\0"
+ "EVP_DIGESTSIGNFINAL_FAILED\\0"
+ "EVP_DIGESTSIGNINIT_FAILED\\0"
+ "EXCESSIVE_MESSAGE_SIZE\\0"
+ "EXTRA_DATA_IN_MESSAGE\\0"
+ "FRAGMENT_MISMATCH\\0"
+ "GOT_A_FIN_BEFORE_A_CCS\\0"
+ "GOT_CHANNEL_ID_BEFORE_A_CCS\\0"
+ "GOT_NEXT_PROTO_BEFORE_A_CCS\\0"
+ "GOT_NEXT_PROTO_WITHOUT_EXTENSION\\0"
+ "HANDSHAKE_FAILURE_ON_CLIENT_HELLO\\0"
+ "HANDSHAKE_RECORD_BEFORE_CCS\\0"
+ "HTTPS_PROXY_REQUEST\\0"
+ "HTTP_REQUEST\\0"
+ "INAPPROPRIATE_FALLBACK\\0"
+ "INVALID_COMMAND\\0"
+ "INVALID_MESSAGE\\0"
+ "INVALID_SSL_SESSION\\0"
+ "INVALID_TICKET_KEYS_LENGTH\\0"
+ "LENGTH_MISMATCH\\0"
+ "LIBRARY_HAS_NO_CIPHERS\\0"
+ "MISSING_DH_KEY\\0"
+ "MISSING_ECDSA_SIGNING_CERT\\0"
+ "MISSING_EXTENSION\\0"
+ "MISSING_RSA_CERTIFICATE\\0"
+ "MISSING_RSA_ENCRYPTING_CERT\\0"
+ "MISSING_RSA_SIGNING_CERT\\0"
+ "MISSING_TMP_DH_KEY\\0"
+ "MISSING_TMP_ECDH_KEY\\0"
+ "MIXED_SPECIAL_OPERATOR_WITH_GROUPS\\0"
+ "MTU_TOO_SMALL\\0"
+ "NEGOTIATED_BOTH_NPN_AND_ALPN\\0"
+ "NESTED_GROUP\\0"
+ "NO_CERTIFICATES_RETURNED\\0"
+ "NO_CERTIFICATE_ASSIGNED\\0"
+ "NO_CERTIFICATE_SET\\0"
+ "NO_CIPHERS_AVAILABLE\\0"
+ "NO_CIPHERS_PASSED\\0"
+ "NO_CIPHERS_SPECIFIED\\0"
+ "NO_CIPHER_MATCH\\0"
+ "NO_COMPRESSION_SPECIFIED\\0"
+ "NO_METHOD_SPECIFIED\\0"
+ "NO_P256_SUPPORT\\0"
+ "NO_PRIVATE_KEY_ASSIGNED\\0"
+ "NO_RENEGOTIATION\\0"
+ "NO_REQUIRED_DIGEST\\0"
+ "NO_SHARED_CIPHER\\0"
+ "NO_SHARED_SIGATURE_ALGORITHMS\\0"
+ "NO_SRTP_PROFILES\\0"
+ "NULL_SSL_CTX\\0"
+ "NULL_SSL_METHOD_PASSED\\0"
+ "OLD_SESSION_CIPHER_NOT_RETURNED\\0"
+ "OLD_SESSION_VERSION_NOT_RETURNED\\0"
+ "PACKET_LENGTH_TOO_LONG\\0"
+ "PARSE_TLSEXT\\0"
+ "PATH_TOO_LONG\\0"
+ "PEER_DID_NOT_RETURN_A_CERTIFICATE\\0"
+ "PEER_ERROR_UNSUPPORTED_CERTIFICATE_TYPE\\0"
+ "PROTOCOL_IS_SHUTDOWN\\0"
+ "PSK_IDENTITY_NOT_FOUND\\0"
+ "PSK_NO_CLIENT_CB\\0"
+ "PSK_NO_SERVER_CB\\0"
+ "READ_BIO_NOT_SET\\0"
+ "READ_TIMEOUT_EXPIRED\\0"
+ "RECORD_LENGTH_MISMATCH\\0"
+ "RECORD_TOO_LARGE\\0"
+ "RENEGOTIATE_EXT_TOO_LONG\\0"
+ "RENEGOTIATION_ENCODING_ERR\\0"
+ "RENEGOTIATION_MISMATCH\\0"
+ "REQUIRED_CIPHER_MISSING\\0"
+ "RESUMED_EMS_SESSION_WITHOUT_EMS_EXTENSION\\0"
+ "RESUMED_NON_EMS_SESSION_WITH_EMS_EXTENSION\\0"
+ "SCSV_RECEIVED_WHEN_RENEGOTIATING\\0"
+ "SERVERHELLO_TLSEXT\\0"
+ "SESSION_ID_CONTEXT_UNINITIALIZED\\0"
+ "SESSION_MAY_NOT_BE_CREATED\\0"
+ "SIGNATURE_ALGORITHMS_ERROR\\0"
+ "SIGNATURE_ALGORITHMS_EXTENSION_SENT_BY_SERVER\\0"
+ "SRTP_COULD_NOT_ALLOCATE_PROFILES\\0"
+ "SRTP_PROTECTION_PROFILE_LIST_TOO_LONG\\0"
+ "SRTP_UNKNOWN_PROTECTION_PROFILE\\0"
+ "SSL3_EXT_INVALID_SERVERNAME\\0"
+ "SSL3_EXT_INVALID_SERVERNAME_TYPE\\0"
+ "SSLV3_ALERT_BAD_CERTIFICATE\\0"
+ "SSLV3_ALERT_BAD_RECORD_MAC\\0"
+ "SSLV3_ALERT_CERTIFICATE_EXPIRED\\0"
+ "SSLV3_ALERT_CERTIFICATE_REVOKED\\0"
+ "SSLV3_ALERT_CERTIFICATE_UNKNOWN\\0"
+ "SSLV3_ALERT_CLOSE_NOTIFY\\0"
+ "SSLV3_ALERT_DECOMPRESSION_FAILURE\\0"
+ "SSLV3_ALERT_HANDSHAKE_FAILURE\\0"
+ "SSLV3_ALERT_ILLEGAL_PARAMETER\\0"
+ "SSLV3_ALERT_NO_CERTIFICATE\\0"
+ "SSLV3_ALERT_UNEXPECTED_MESSAGE\\0"
+ "SSLV3_ALERT_UNSUPPORTED_CERTIFICATE\\0"
+ "SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION\\0"
+ "SSL_HANDSHAKE_FAILURE\\0"
+ "SSL_SESSION_ID_CALLBACK_FAILED\\0"
+ "SSL_SESSION_ID_CONFLICT\\0"
+ "SSL_SESSION_ID_CONTEXT_TOO_LONG\\0"
+ "SSL_SESSION_ID_HAS_BAD_LENGTH\\0"
+ "TLSV1_ALERT_ACCESS_DENIED\\0"
+ "TLSV1_ALERT_DECODE_ERROR\\0"
+ "TLSV1_ALERT_DECRYPTION_FAILED\\0"
+ "TLSV1_ALERT_DECRYPT_ERROR\\0"
+ "TLSV1_ALERT_EXPORT_RESTRICTION\\0"
+ "TLSV1_ALERT_INAPPROPRIATE_FALLBACK\\0"
+ "TLSV1_ALERT_INSUFFICIENT_SECURITY\\0"
+ "TLSV1_ALERT_INTERNAL_ERROR\\0"
+ "TLSV1_ALERT_NO_RENEGOTIATION\\0"
+ "TLSV1_ALERT_PROTOCOL_VERSION\\0"
+ "TLSV1_ALERT_RECORD_OVERFLOW\\0"
+ "TLSV1_ALERT_UNKNOWN_CA\\0"
+ "TLSV1_ALERT_USER_CANCELLED\\0"
+ "TLSV1_BAD_CERTIFICATE_HASH_VALUE\\0"
+ "TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE\\0"
+ "TLSV1_CERTIFICATE_UNOBTAINABLE\\0"
+ "TLSV1_UNRECOGNIZED_NAME\\0"
+ "TLSV1_UNSUPPORTED_EXTENSION\\0"
+ "TLS_CLIENT_CERT_REQ_WITH_ANON_CIPHER\\0"
+ "TLS_ILLEGAL_EXPORTER_LABEL\\0"
+ "TLS_INVALID_ECPOINTFORMAT_LIST\\0"
+ "TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST\\0"
+ "TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG\\0"
+ "TOO_MANY_EMPTY_FRAGMENTS\\0"
+ "TOO_MANY_WARNING_ALERTS\\0"
+ "UNABLE_TO_FIND_ECDH_PARAMETERS\\0"
+ "UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS\\0"
+ "UNEXPECTED_EXTENSION\\0"
+ "UNEXPECTED_GROUP_CLOSE\\0"
+ "UNEXPECTED_MESSAGE\\0"
+ "UNEXPECTED_OPERATOR_IN_GROUP\\0"
+ "UNEXPECTED_RECORD\\0"
+ "UNKNOWN_ALERT_TYPE\\0"
+ "UNKNOWN_CERTIFICATE_TYPE\\0"
+ "UNKNOWN_CIPHER_RETURNED\\0"
+ "UNKNOWN_CIPHER_TYPE\\0"
+ "UNKNOWN_KEY_EXCHANGE_TYPE\\0"
+ "UNKNOWN_PROTOCOL\\0"
+ "UNKNOWN_SSL_VERSION\\0"
+ "UNKNOWN_STATE\\0"
+ "UNPROCESSED_HANDSHAKE_DATA\\0"
+ "UNSAFE_LEGACY_RENEGOTIATION_DISABLED\\0"
+ "UNSUPPORTED_COMPRESSION_ALGORITHM\\0"
+ "UNSUPPORTED_ELLIPTIC_CURVE\\0"
+ "UNSUPPORTED_PROTOCOL\\0"
+ "UNSUPPORTED_SSL_VERSION\\0"
+ "USE_SRTP_NOT_NEGOTIATED\\0"
+ "WRONG_CERTIFICATE_TYPE\\0"
+ "WRONG_CIPHER_RETURNED\\0"
+ "WRONG_CURVE\\0"
+ "WRONG_MESSAGE_TYPE\\0"
+ "WRONG_SIGNATURE_TYPE\\0"
+ "WRONG_SSL_VERSION\\0"
+ "WRONG_VERSION_NUMBER\\0"
+ "X509_LIB\\0"
+ "X509_VERIFICATION_SETUP_PROBLEMS\\0"
+ "AKID_MISMATCH\\0"
+ "BAD_PKCS7_VERSION\\0"
+ "BAD_X509_FILETYPE\\0"
+ "BASE64_DECODE_ERROR\\0"
+ "CANT_CHECK_DH_KEY\\0"
+ "CERT_ALREADY_IN_HASH_TABLE\\0"
+ "CRL_ALREADY_DELTA\\0"
+ "CRL_VERIFY_FAILURE\\0"
+ "IDP_MISMATCH\\0"
+ "INVALID_DIRECTORY\\0"
+ "INVALID_FIELD_NAME\\0"
+ "INVALID_TRUST\\0"
+ "ISSUER_MISMATCH\\0"
+ "KEY_TYPE_MISMATCH\\0"
+ "KEY_VALUES_MISMATCH\\0"
+ "LOADING_CERT_DIR\\0"
+ "LOADING_DEFAULTS\\0"
+ "NEWER_CRL_NOT_NEWER\\0"
+ "NOT_PKCS7_SIGNED_DATA\\0"
+ "NO_CERTIFICATES_INCLUDED\\0"
+ "NO_CERT_SET_FOR_US_TO_VERIFY\\0"
+ "NO_CRLS_INCLUDED\\0"
+ "NO_CRL_NUMBER\\0"
+ "PUBLIC_KEY_DECODE_ERROR\\0"
+ "PUBLIC_KEY_ENCODE_ERROR\\0"
+ "SHOULD_RETRY\\0"
+ "UNABLE_TO_FIND_PARAMETERS_IN_CHAIN\\0"
+ "UNABLE_TO_GET_CERTS_PUBLIC_KEY\\0"
+ "UNKNOWN_KEY_TYPE\\0"
+ "UNKNOWN_PURPOSE_ID\\0"
+ "UNKNOWN_TRUST_ID\\0"
+ "WRONG_LOOKUP_TYPE\\0"
+ "BAD_IP_ADDRESS\\0"
+ "BAD_OBJECT\\0"
+ "BN_DEC2BN_ERROR\\0"
+ "BN_TO_ASN1_INTEGER_ERROR\\0"
+ "CANNOT_FIND_FREE_FUNCTION\\0"
+ "DIRNAME_ERROR\\0"
+ "DISTPOINT_ALREADY_SET\\0"
+ "DUPLICATE_ZONE_ID\\0"
+ "ERROR_CONVERTING_ZONE\\0"
+ "ERROR_CREATING_EXTENSION\\0"
+ "ERROR_IN_EXTENSION\\0"
+ "EXPECTED_A_SECTION_NAME\\0"
+ "EXTENSION_EXISTS\\0"
+ "EXTENSION_NAME_ERROR\\0"
+ "EXTENSION_NOT_FOUND\\0"
+ "EXTENSION_SETTING_NOT_SUPPORTED\\0"
+ "EXTENSION_VALUE_ERROR\\0"
+ "ILLEGAL_EMPTY_EXTENSION\\0"
+ "ILLEGAL_HEX_DIGIT\\0"
+ "INCORRECT_POLICY_SYNTAX_TAG\\0"
+ "INVALID_BOOLEAN_STRING\\0"
+ "INVALID_EXTENSION_STRING\\0"
+ "INVALID_MULTIPLE_RDNS\\0"
+ "INVALID_NAME\\0"
+ "INVALID_NULL_ARGUMENT\\0"
+ "INVALID_NULL_NAME\\0"
+ "INVALID_NULL_VALUE\\0"
+ "INVALID_NUMBERS\\0"
+ "INVALID_OBJECT_IDENTIFIER\\0"
+ "INVALID_OPTION\\0"
+ "INVALID_POLICY_IDENTIFIER\\0"
+ "INVALID_PROXY_POLICY_SETTING\\0"
+ "INVALID_PURPOSE\\0"
+ "INVALID_SECTION\\0"
+ "INVALID_SYNTAX\\0"
+ "ISSUER_DECODE_ERROR\\0"
+ "NEED_ORGANIZATION_AND_NUMBERS\\0"
+ "NO_CONFIG_DATABASE\\0"
+ "NO_ISSUER_CERTIFICATE\\0"
+ "NO_ISSUER_DETAILS\\0"
+ "NO_POLICY_IDENTIFIER\\0"
+ "NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED\\0"
+ "NO_PUBLIC_KEY\\0"
+ "NO_SUBJECT_DETAILS\\0"
+ "ODD_NUMBER_OF_DIGITS\\0"
+ "OPERATION_NOT_DEFINED\\0"
+ "OTHERNAME_ERROR\\0"
+ "POLICY_LANGUAGE_ALREADY_DEFINED\\0"
+ "POLICY_PATH_LENGTH\\0"
+ "POLICY_PATH_LENGTH_ALREADY_DEFINED\\0"
+ "POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY\\0"
+ "SECTION_NOT_FOUND\\0"
+ "UNABLE_TO_GET_ISSUER_DETAILS\\0"
+ "UNABLE_TO_GET_ISSUER_KEYID\\0"
+ "UNKNOWN_BIT_STRING_ARGUMENT\\0"
+ "UNKNOWN_EXTENSION\\0"
+ "UNKNOWN_EXTENSION_NAME\\0"
+ "UNKNOWN_OPTION\\0"
+ "UNSUPPORTED_OPTION\\0"
+ "USER_TOO_LONG\\0"
+ "";
+ EOF
+ END_OF_COMMAND
+end
diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h
index 5918f8857a..c9fda42855 100644
--- a/src/objective-c/GRPCClient/GRPCCall.h
+++ b/src/objective-c/GRPCClient/GRPCCall.h
@@ -50,6 +50,8 @@
#import <Foundation/Foundation.h>
#import <RxLibrary/GRXWriter.h>
+#include <AvailabilityMacros.h>
+
#pragma mark gRPC errors
/** Domain of NSError objects produced by gRPC. */
@@ -161,6 +163,9 @@ extern id const kGRPCTrailersKey;
#pragma mark GRPCCall
+/** Represents a single gRPC remote call. */
+@interface GRPCCall : GRXWriter
+
/**
* The container of the request headers of an RPC conforms to this protocol, which is a subset of
* NSMutableDictionary's interface. It will become a NSMutableDictionary later on.
@@ -170,21 +175,6 @@ extern id const kGRPCTrailersKey;
* A header value is a NSString object (with only ASCII characters), unless the header name has the
* suffix "-bin", in which case the value has to be a NSData object.
*/
-@protocol GRPCRequestHeaders <NSObject>
-
-@property(nonatomic, readonly) NSUInteger count;
-
-- (id)objectForKeyedSubscript:(NSString *)key;
-- (void)setObject:(id)obj forKeyedSubscript:(NSString *)key;
-
-- (void)removeAllObjects;
-- (void)removeObjectForKey:(NSString *)key;
-
-@end
-
-/** Represents a single gRPC remote call. */
-@interface GRPCCall : GRXWriter
-
/**
* These HTTP headers will be passed to the server as part of this call. Each HTTP header is a
* name-value pair with string names and either string or binary values.
@@ -200,7 +190,7 @@ extern id const kGRPCTrailersKey;
*
* The property is initialized to an empty NSMutableDictionary.
*/
-@property(atomic, readonly) id<GRPCRequestHeaders> requestHeaders;
+@property(atomic, readonly) NSMutableDictionary *requestHeaders;
/**
* This dictionary is populated with the HTTP headers received from the server. This happens before
@@ -243,3 +233,24 @@ extern id const kGRPCTrailersKey;
// TODO(jcanizales): Let specify a deadline. As a category of GRXWriter?
@end
+
+#pragma mark Backwards compatibiity
+
+/** This protocol is kept for backwards compatibility with existing code. */
+DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.")
+@protocol GRPCRequestHeaders <NSObject>
+@property(nonatomic, readonly) NSUInteger count;
+
+- (id)objectForKeyedSubscript:(NSString *)key;
+- (void)setObject:(id)obj forKeyedSubscript:(NSString *)key;
+
+- (void)removeAllObjects;
+- (void)removeObjectForKey:(NSString *)key;
+@end
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated"
+/** This is only needed for backwards-compatibility. */
+@interface NSMutableDictionary (GRPCRequestHeaders) <GRPCRequestHeaders>
+@end
+#pragma clang diagnostic pop
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index b6986bf59c..f79b7d0bc0 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -221,7 +221,7 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
#pragma mark Send headers
-- (void)sendHeaders:(id<GRPCRequestHeaders>)headers {
+- (void)sendHeaders:(NSDictionary *)headers {
// TODO(jcanizales): Add error handlers for async failures
[_wrappedCall startBatchWithOperations:@[[[GRPCOpSendMetadata alloc] initWithMetadata:headers
handler:nil]]];
diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h
index cf5a1be9d6..b580f19406 100644
--- a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h
+++ b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.h
@@ -32,21 +32,14 @@
*/
#import <Foundation/Foundation.h>
-#include <grpc/grpc.h>
#import "../GRPCCall.h"
-@interface GRPCRequestHeaders : NSObject<GRPCRequestHeaders>
-
-@property(nonatomic, readonly) NSUInteger count;
-@property(nonatomic, readonly) grpc_metadata *grpc_metadataArray;
+@interface GRPCRequestHeaders : NSMutableDictionary
- (instancetype)initWithCall:(GRPCCall *)call;
-- (id)objectForKeyedSubscript:(NSString *)key;
-- (void)setObject:(id)obj forKeyedSubscript:(NSString *)key;
-
-- (void)removeAllObjects;
-- (void)removeObjectForKey:(NSString *)key;
+- (instancetype)initWithCall:(GRPCCall *)call
+ storage:(NSMutableDictionary *)storage NS_DESIGNATED_INITIALIZER;
@end
diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
index d23f21c0f9..c6a03c145e 100644
--- a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
+++ b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
@@ -68,17 +68,44 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
@implementation GRPCRequestHeaders {
__weak GRPCCall *_call;
+ // The NSMutableDictionary superclass doesn't hold any storage (so that people can implement their
+ // own in subclasses). As that's not the reason we're subclassing, we just delegate storage to the
+ // default NSMutableDictionary subclass returned by the cluster (e.g. __NSDictionaryM on iOS 9).
NSMutableDictionary *_delegate;
}
+- (instancetype)init {
+ return [self initWithCall:nil];
+}
+
+- (instancetype)initWithCapacity:(NSUInteger)numItems {
+ return [self init];
+}
+
+- (instancetype)initWithCoder:(NSCoder *)aDecoder {
+ return [self init];
+}
+
- (instancetype)initWithCall:(GRPCCall *)call {
+ return [self initWithCall:call storage:[NSMutableDictionary dictionary]];
+}
+
+// Designated initializer
+- (instancetype)initWithCall:(GRPCCall *)call storage:(NSMutableDictionary *)storage {
+ // TODO(jcanizales): Throw if call or storage are nil.
if ((self = [super init])) {
_call = call;
- _delegate = [NSMutableDictionary dictionary];
+ _delegate = storage;
}
return self;
}
+- (instancetype)initWithObjects:(const id _Nonnull __unsafe_unretained *)objects
+ forKeys:(const id<NSCopying> _Nonnull __unsafe_unretained *)keys
+ count:(NSUInteger)cnt {
+ return [self init];
+}
+
- (void)checkCallIsNotStarted {
if (_call.state != GRXWriterStateNotStarted) {
[NSException raise:@"Invalid modification"
@@ -86,11 +113,11 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
}
}
-- (id)objectForKeyedSubscript:(NSString *)key {
+- (id)objectForKey:(NSString *)key {
return _delegate[key.lowercaseString];
}
-- (void)setObject:(id)obj forKeyedSubscript:(NSString *)key {
+- (void)setObject:(id)obj forKey:(NSString *)key {
[self checkCallIsNotStarted];
CheckIsNonNilASCII(@"Header name", key);
key = key.lowercaseString;
@@ -103,16 +130,12 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
[_delegate removeObjectForKey:key.lowercaseString];
}
-- (void)removeAllObjects {
- [self checkCallIsNotStarted];
- [_delegate removeAllObjects];
-}
-
- (NSUInteger)count {
return _delegate.count;
}
-- (grpc_metadata *)grpc_metadataArray {
- return _delegate.grpc_metadataArray;
+- (NSEnumerator * _Nonnull)keyEnumerator {
+ return [_delegate keyEnumerator];
}
+
@end
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
index 7747aa53ef..71e7e0e54e 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
@@ -45,7 +45,7 @@
@interface GRPCOpSendMetadata : GRPCOperation
-- (instancetype)initWithMetadata:(GRPCRequestHeaders *)metadata
+- (instancetype)initWithMetadata:(NSDictionary *)metadata
handler:(void(^)())handler NS_DESIGNATED_INITIALIZER;
@end
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
index cea7c479e0..fe3d51da53 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
@@ -65,7 +65,7 @@
return [self initWithMetadata:nil handler:nil];
}
-- (instancetype)initWithMetadata:(GRPCRequestHeaders *)metadata handler:(void (^)())handler {
+- (instancetype)initWithMetadata:(NSDictionary *)metadata handler:(void (^)())handler {
if (self = [super init]) {
_op.op = GRPC_OP_SEND_INITIAL_METADATA;
_op.data.send_initial_metadata.count = metadata.count;
diff --git a/src/objective-c/examples/Sample/Podfile b/src/objective-c/examples/Sample/Podfile
index 3b2f412569..93859fb734 100644
--- a/src/objective-c/examples/Sample/Podfile
+++ b/src/objective-c/examples/Sample/Podfile
@@ -2,6 +2,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
pod 'Protobuf', :path => "../../../../third_party/protobuf"
+pod 'BoringSSL', :podspec => "../.."
pod 'gRPC', :path => "../../../.."
pod 'RemoteTest', :path => "../RemoteTestClient"
diff --git a/src/objective-c/examples/SwiftSample/Podfile b/src/objective-c/examples/SwiftSample/Podfile
index 3611b00863..f2df4a34a3 100644
--- a/src/objective-c/examples/SwiftSample/Podfile
+++ b/src/objective-c/examples/SwiftSample/Podfile
@@ -2,6 +2,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
pod 'Protobuf', :path => "../../../../third_party/protobuf"
+pod 'BoringSSL', :podspec => "../.."
pod 'gRPC', :path => "../../../.."
pod 'RemoteTest', :path => "../RemoteTestClient"
diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile
index cab608d37f..7ec7a25898 100644
--- a/src/objective-c/tests/Podfile
+++ b/src/objective-c/tests/Podfile
@@ -2,6 +2,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
pod 'Protobuf', :path => "../../../third_party/protobuf"
+pod 'BoringSSL', :podspec => ".."
pod 'gRPC', :path => "../../.."
pod 'RemoteTest', :path => "RemoteTestClient"
diff --git a/src/python/grpcio/.gitignore b/src/python/grpcio/.gitignore
index 4c02b8d14d..95b96f7c1e 100644
--- a/src/python/grpcio/.gitignore
+++ b/src/python/grpcio/.gitignore
@@ -5,5 +5,12 @@ dist/
*.egg
*.egg/
*.eggs/
+*_pb2.py
+.coverage
+.coverage.*
+.cache/
+.tox/
+nosetests.xml
doc/
_grpcio_metadata.py
+htmlcov/
diff --git a/src/python/grpcio/MANIFEST.in b/src/python/grpcio/MANIFEST.in
index 9583dc7768..407eeabc17 100644
--- a/src/python/grpcio/MANIFEST.in
+++ b/src/python/grpcio/MANIFEST.in
@@ -1,3 +1,4 @@
graft grpc
+graft tests
include commands.py
include requirements.txt
diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py
index 8a2f2d6283..d9fd023b21 100644
--- a/src/python/grpcio/commands.py
+++ b/src/python/grpcio/commands.py
@@ -29,14 +29,18 @@
"""Provides distutils command classes for the GRPC Python setup process."""
+import distutils
import os
import os.path
+import re
+import subprocess
import sys
import setuptools
from setuptools.command import build_py
+from setuptools.command import test
-_CONF_PY_ADDENDUM = """
+CONF_PY_ADDENDUM = """
extensions.append('sphinx.ext.napoleon')
napoleon_google_docstring = True
napoleon_numpy_docstring = True
@@ -48,7 +52,7 @@ html_theme = 'sphinx_rtd_theme'
class SphinxDocumentation(setuptools.Command):
"""Command to generate documentation via sphinx."""
- description = ''
+ description = 'generate sphinx documentation'
user_options = []
def initialize_options(self):
@@ -72,14 +76,61 @@ class SphinxDocumentation(setuptools.Command):
'-o', os.path.join('doc', 'src'), src_dir])
conf_filepath = os.path.join('doc', 'src', 'conf.py')
with open(conf_filepath, 'a') as conf_file:
- conf_file.write(_CONF_PY_ADDENDUM)
+ conf_file.write(CONF_PY_ADDENDUM)
sphinx.main(['', os.path.join('doc', 'src'), os.path.join('doc', 'build')])
+class BuildProtoModules(setuptools.Command):
+ """Command to generate project *_pb2.py modules from proto files."""
+
+ description = 'build protobuf modules'
+ user_options = [
+ ('include=', None, 'path patterns to include in protobuf generation'),
+ ('exclude=', None, 'path patterns to exclude from protobuf generation')
+ ]
+
+ def initialize_options(self):
+ self.exclude = None
+ self.include = r'.*\.proto$'
+ self.protoc_command = None
+ self.grpc_python_plugin_command = None
+
+ def finalize_options(self):
+ self.protoc_command = distutils.spawn.find_executable('protoc')
+ self.grpc_python_plugin_command = distutils.spawn.find_executable(
+ 'grpc_python_plugin')
+
+ def run(self):
+ include_regex = re.compile(self.include)
+ exclude_regex = re.compile(self.exclude) if self.exclude else None
+ paths = []
+ root_directory = os.getcwd()
+ for walk_root, directories, filenames in os.walk(root_directory):
+ for filename in filenames:
+ path = os.path.join(walk_root, filename)
+ if include_regex.match(path) and not (
+ exclude_regex and exclude_regex.match(path)):
+ paths.append(path)
+ command = [
+ self.protoc_command,
+ '--plugin=protoc-gen-python-grpc={}'.format(
+ self.grpc_python_plugin_command),
+ '-I {}'.format(root_directory),
+ '--python_out={}'.format(root_directory),
+ '--python-grpc_out={}'.format(root_directory),
+ ] + paths
+ try:
+ subprocess.check_output(' '.join(command), cwd=root_directory, shell=True,
+ stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise Exception('Command:\n{}\nMessage:\n{}\nOutput:\n{}'.format(
+ command, e.message, e.output))
+
+
class BuildProjectMetadata(setuptools.Command):
"""Command to generate project metadata in a module."""
- description = ''
+ description = 'build grpcio project metadata files'
user_options = []
def initialize_options(self):
@@ -98,5 +149,73 @@ class BuildPy(build_py.build_py):
"""Custom project build command."""
def run(self):
+ self.run_command('build_proto_modules')
self.run_command('build_project_metadata')
build_py.build_py.run(self)
+
+
+class Gather(setuptools.Command):
+ """Command to gather project dependencies."""
+
+ description = 'gather dependencies for grpcio'
+ user_options = [
+ ('test', 't', 'flag indicating to gather test dependencies'),
+ ('install', 'i', 'flag indicating to gather install dependencies')
+ ]
+
+ def initialize_options(self):
+ self.test = False
+ self.install = False
+
+ def finalize_options(self):
+ # distutils requires this override.
+ pass
+
+ def run(self):
+ if self.install and self.distribution.install_requires:
+ self.distribution.fetch_build_eggs(self.distribution.install_requires)
+ if self.test and self.distribution.tests_require:
+ self.distribution.fetch_build_eggs(self.distribution.tests_require)
+
+
+class RunInterop(test.test):
+
+ description = 'run interop test client/server'
+ user_options = [
+ ('args=', 'a', 'pass-thru arguments for the client/server'),
+ ('client', 'c', 'flag indicating to run the client'),
+ ('server', 's', 'flag indicating to run the server')
+ ]
+
+ def initialize_options(self):
+ self.args = ''
+ self.client = False
+ self.server = False
+
+ def finalize_options(self):
+ if self.client and self.server:
+ raise DistutilsOptionError('you may only specify one of client or server')
+
+ def run(self):
+ if self.distribution.install_requires:
+ self.distribution.fetch_build_eggs(self.distribution.install_requires)
+ if self.distribution.tests_require:
+ self.distribution.fetch_build_eggs(self.distribution.tests_require)
+ if self.client:
+ self.run_client()
+ elif self.server:
+ self.run_server()
+
+ def run_server(self):
+ # We import here to ensure that our setuptools parent has had a chance to
+ # edit the Python system path.
+ from tests.interop import server
+ sys.argv[1:] = self.args.split()
+ server.serve()
+
+ def run_client(self):
+ # We import here to ensure that our setuptools parent has had a chance to
+ # edit the Python system path.
+ from tests.interop import client
+ sys.argv[1:] = self.args.split()
+ client.test_interoperability()
diff --git a/src/python/grpcio/grpc/beta/_server.py b/src/python/grpcio/grpc/beta/_server.py
index 05b954d186..4f454437c0 100644
--- a/src/python/grpcio/grpc/beta/_server.py
+++ b/src/python/grpcio/grpc/beta/_server.py
@@ -44,6 +44,12 @@ _DEFAULT_TIMEOUT = 300
_MAXIMUM_TIMEOUT = 24 * 60 * 60
+def _set_event():
+ event = threading.Event()
+ event.set()
+ return event
+
+
class _GRPCServicer(base.Servicer):
def __init__(self, delegate):
@@ -61,86 +67,143 @@ class _GRPCServicer(base.Servicer):
raise
-def _disassemble(grpc_link, end_link, pool, event, grace):
- grpc_link.begin_stop()
- end_link.stop(grace).wait()
- grpc_link.end_stop()
- grpc_link.join_link(utilities.NULL_LINK)
- end_link.join_link(utilities.NULL_LINK)
- if pool is not None:
- pool.shutdown(wait=True)
- event.set()
+class _Server(interfaces.Server):
+ def __init__(
+ self, implementations, multi_implementation, pool, pool_size,
+ default_timeout, maximum_timeout, grpc_link):
+ self._lock = threading.Lock()
+ self._implementations = implementations
+ self._multi_implementation = multi_implementation
+ self._customer_pool = pool
+ self._pool_size = pool_size
+ self._default_timeout = default_timeout
+ self._maximum_timeout = maximum_timeout
+ self._grpc_link = grpc_link
-class Server(interfaces.Server):
+ self._end_link = None
+ self._stop_events = None
+ self._pool = None
- def __init__(self, grpc_link, end_link, pool):
- self._grpc_link = grpc_link
- self._end_link = end_link
- self._pool = pool
+ def _start(self):
+ with self._lock:
+ if self._end_link is not None:
+ raise ValueError('Cannot start already-started server!')
+
+ if self._customer_pool is None:
+ self._pool = logging_pool.pool(self._pool_size)
+ assembly_pool = self._pool
+ else:
+ assembly_pool = self._customer_pool
+
+ servicer = _GRPCServicer(
+ _crust_implementations.servicer(
+ self._implementations, self._multi_implementation, assembly_pool))
+
+ self._end_link = _core_implementations.service_end_link(
+ servicer, self._default_timeout, self._maximum_timeout)
+
+ self._grpc_link.join_link(self._end_link)
+ self._end_link.join_link(self._grpc_link)
+ self._grpc_link.start()
+ self._end_link.start()
+
+ def _dissociate_links_and_shut_down_pool(self):
+ self._grpc_link.end_stop()
+ self._grpc_link.join_link(utilities.NULL_LINK)
+ self._end_link.join_link(utilities.NULL_LINK)
+ self._end_link = None
+ if self._pool is not None:
+ self._pool.shutdown(wait=True)
+ self._pool = None
+
+ def _stop_stopping(self):
+ self._dissociate_links_and_shut_down_pool()
+ for stop_event in self._stop_events:
+ stop_event.set()
+ self._stop_events = None
+
+ def _stop_started(self):
+ self._grpc_link.begin_stop()
+ self._end_link.stop(0).wait()
+ self._dissociate_links_and_shut_down_pool()
+
+ def _foreign_thread_stop(self, end_stop_event, stop_events):
+ end_stop_event.wait()
+ with self._lock:
+ if self._stop_events is stop_events:
+ self._stop_stopping()
+
+ def _schedule_stop(self, grace):
+ with self._lock:
+ if self._end_link is None:
+ return _set_event()
+ server_stop_event = threading.Event()
+ if self._stop_events is None:
+ self._stop_events = [server_stop_event]
+ self._grpc_link.begin_stop()
+ else:
+ self._stop_events.append(server_stop_event)
+ end_stop_event = self._end_link.stop(grace)
+ end_stop_thread = threading.Thread(
+ target=self._foreign_thread_stop,
+ args=(end_stop_event, self._stop_events))
+ end_stop_thread.start()
+ return server_stop_event
+
+ def _stop_now(self):
+ with self._lock:
+ if self._end_link is not None:
+ if self._stop_events is None:
+ self._stop_started()
+ else:
+ self._stop_stopping()
def add_insecure_port(self, address):
- return self._grpc_link.add_port(address, None)
+ with self._lock:
+ if self._end_link is None:
+ return self._grpc_link.add_port(address, None)
+ else:
+ raise ValueError('Can\'t add port to serving server!')
def add_secure_port(self, address, server_credentials):
- return self._grpc_link.add_port(
- address, server_credentials._intermediary_low_credentials) # pylint: disable=protected-access
-
- def _start(self):
- self._grpc_link.join_link(self._end_link)
- self._end_link.join_link(self._grpc_link)
- self._grpc_link.start()
- self._end_link.start()
-
- def _stop(self, grace):
- stop_event = threading.Event()
- if 0 < grace:
- disassembly_thread = threading.Thread(
- target=_disassemble,
- args=(
- self._grpc_link, self._end_link, self._pool, stop_event, grace,))
- disassembly_thread.start()
- return stop_event
- else:
- _disassemble(self._grpc_link, self._end_link, self._pool, stop_event, 0)
- return stop_event
+ with self._lock:
+ if self._end_link is None:
+ return self._grpc_link.add_port(
+ address, server_credentials._intermediary_low_credentials) # pylint: disable=protected-access
+ else:
+ raise ValueError('Can\'t add port to serving server!')
def start(self):
self._start()
def stop(self, grace):
- return self._stop(grace)
+ if 0 < grace:
+ return self._schedule_stop(grace)
+ else:
+ self._stop_now()
+ return _set_event()
def __enter__(self):
self._start()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
- self._stop(0).wait()
+ self._stop_now()
return False
+ def __del__(self):
+ self._stop_now()
+
def server(
implementations, multi_implementation, request_deserializers,
response_serializers, thread_pool, thread_pool_size, default_timeout,
maximum_timeout):
- if thread_pool is None:
- service_thread_pool = logging_pool.pool(
- _DEFAULT_POOL_SIZE if thread_pool_size is None else thread_pool_size)
- assembly_thread_pool = service_thread_pool
- else:
- service_thread_pool = thread_pool
- assembly_thread_pool = None
-
- servicer = _GRPCServicer(
- _crust_implementations.servicer(
- implementations, multi_implementation, service_thread_pool))
-
grpc_link = service.service_link(request_deserializers, response_serializers)
-
- end_link = _core_implementations.service_end_link(
- servicer,
+ return _Server(
+ implementations, multi_implementation, thread_pool,
+ _DEFAULT_POOL_SIZE if thread_pool_size is None else thread_pool_size,
_DEFAULT_TIMEOUT if default_timeout is None else default_timeout,
- _MAXIMUM_TIMEOUT if maximum_timeout is None else maximum_timeout)
-
- return Server(grpc_link, end_link, assembly_thread_pool)
+ _MAXIMUM_TIMEOUT if maximum_timeout is None else maximum_timeout,
+ grpc_link)
diff --git a/src/python/grpcio/grpc/beta/_stub.py b/src/python/grpcio/grpc/beta/_stub.py
index 11dab889cd..2af019309a 100644
--- a/src/python/grpcio/grpc/beta/_stub.py
+++ b/src/python/grpcio/grpc/beta/_stub.py
@@ -42,76 +42,114 @@ _DEFAULT_POOL_SIZE = 6
class _AutoIntermediary(object):
- def __init__(self, delegate, on_deletion):
+ def __init__(self, up, down, delegate):
+ self._lock = threading.Lock()
+ self._up = up
+ self._down = down
+ self._in_context = False
self._delegate = delegate
- self._on_deletion = on_deletion
def __getattr__(self, attr):
- return getattr(self._delegate, attr)
+ with self._lock:
+ if self._delegate is None:
+ raise AttributeError('No useful attributes out of context!')
+ else:
+ return getattr(self._delegate, attr)
def __enter__(self):
- return self
+ with self._lock:
+ if self._in_context:
+ raise ValueError('Already in context!')
+ elif self._delegate is None:
+ self._delegate = self._up()
+ self._in_context = True
+ return self
def __exit__(self, exc_type, exc_val, exc_tb):
- return False
+ with self._lock:
+ if not self._in_context:
+ raise ValueError('Not in context!')
+ self._down()
+ self._in_context = False
+ self._delegate = None
+ return False
def __del__(self):
- self._on_deletion()
+ with self._lock:
+ if self._delegate is not None:
+ self._down()
+ self._delegate = None
+
+
+class _StubAssemblyManager(object):
+
+ def __init__(
+ self, thread_pool, thread_pool_size, end_link, grpc_link, stub_creator):
+ self._thread_pool = thread_pool
+ self._pool_size = thread_pool_size
+ self._end_link = end_link
+ self._grpc_link = grpc_link
+ self._stub_creator = stub_creator
+ self._own_pool = None
+
+ def up(self):
+ if self._thread_pool is None:
+ self._own_pool = logging_pool.pool(
+ _DEFAULT_POOL_SIZE if self._pool_size is None else self._pool_size)
+ assembly_pool = self._own_pool
+ else:
+ assembly_pool = self._thread_pool
+ self._end_link.join_link(self._grpc_link)
+ self._grpc_link.join_link(self._end_link)
+ self._end_link.start()
+ self._grpc_link.start()
+ return self._stub_creator(self._end_link, assembly_pool)
+
+ def down(self):
+ self._end_link.stop(0).wait()
+ self._grpc_link.stop()
+ self._end_link.join_link(utilities.NULL_LINK)
+ self._grpc_link.join_link(utilities.NULL_LINK)
+ if self._own_pool is not None:
+ self._own_pool.shutdown(wait=True)
+ self._own_pool = None
def _assemble(
channel, host, metadata_transformer, request_serializers,
- response_deserializers, thread_pool, thread_pool_size):
+ response_deserializers, thread_pool, thread_pool_size, stub_creator):
end_link = _core_implementations.invocation_end_link()
grpc_link = invocation.invocation_link(
channel, host, metadata_transformer, request_serializers,
response_deserializers)
- if thread_pool is None:
- invocation_pool = logging_pool.pool(
- _DEFAULT_POOL_SIZE if thread_pool_size is None else thread_pool_size)
- assembly_pool = invocation_pool
- else:
- invocation_pool = thread_pool
- assembly_pool = None
- end_link.join_link(grpc_link)
- grpc_link.join_link(end_link)
- end_link.start()
- grpc_link.start()
- return end_link, grpc_link, invocation_pool, assembly_pool
-
-
-def _disassemble(end_link, grpc_link, pool):
- end_link.stop(24 * 60 * 60).wait()
- grpc_link.stop()
- end_link.join_link(utilities.NULL_LINK)
- grpc_link.join_link(utilities.NULL_LINK)
- if pool is not None:
- pool.shutdown(wait=True)
-
-
-def _wrap_assembly(stub, end_link, grpc_link, assembly_pool):
- disassembly_thread = threading.Thread(
- target=_disassemble, args=(end_link, grpc_link, assembly_pool))
- return _AutoIntermediary(stub, disassembly_thread.start)
+ stub_assembly_manager = _StubAssemblyManager(
+ thread_pool, thread_pool_size, end_link, grpc_link, stub_creator)
+ stub = stub_assembly_manager.up()
+ return _AutoIntermediary(
+ stub_assembly_manager.up, stub_assembly_manager.down, stub)
+
+
+def _dynamic_stub_creator(service, cardinalities):
+ def create_dynamic_stub(end_link, invocation_pool):
+ return _crust_implementations.dynamic_stub(
+ end_link, service, cardinalities, invocation_pool)
+ return create_dynamic_stub
def generic_stub(
channel, host, metadata_transformer, request_serializers,
response_deserializers, thread_pool, thread_pool_size):
- end_link, grpc_link, invocation_pool, assembly_pool = _assemble(
+ return _assemble(
channel, host, metadata_transformer, request_serializers,
- response_deserializers, thread_pool, thread_pool_size)
- stub = _crust_implementations.generic_stub(end_link, invocation_pool)
- return _wrap_assembly(stub, end_link, grpc_link, assembly_pool)
+ response_deserializers, thread_pool, thread_pool_size,
+ _crust_implementations.generic_stub)
def dynamic_stub(
channel, host, service, cardinalities, metadata_transformer,
request_serializers, response_deserializers, thread_pool,
thread_pool_size):
- end_link, grpc_link, invocation_pool, assembly_pool = _assemble(
+ return _assemble(
channel, host, metadata_transformer, request_serializers,
- response_deserializers, thread_pool, thread_pool_size)
- stub = _crust_implementations.dynamic_stub(
- end_link, service, cardinalities, invocation_pool)
- return _wrap_assembly(stub, end_link, grpc_link, assembly_pool)
+ response_deserializers, thread_pool, thread_pool_size,
+ _dynamic_stub_creator(service, cardinalities))
diff --git a/src/python/grpcio/grpc/framework/core/_end.py b/src/python/grpcio/grpc/framework/core/_end.py
index 8e07d9061e..9c615672aa 100644
--- a/src/python/grpcio/grpc/framework/core/_end.py
+++ b/src/python/grpcio/grpc/framework/core/_end.py
@@ -85,35 +85,6 @@ def _future_shutdown(lock, cycle, event):
return in_future
-def _termination_action(lock, stats, operation_id, cycle):
- """Constructs the termination action for a single operation.
-
- Args:
- lock: A lock to hold during the termination action.
- stats: A mapping from base.Outcome.Kind values to integers to increment
- with the outcome kind given to the termination action.
- operation_id: The operation ID for the termination action.
- cycle: A _Cycle value to be updated during the termination action.
-
- Returns:
- A callable that takes an operation outcome kind as its sole parameter and
- that should be used as the termination action for the operation
- associated with the given operation ID.
- """
- def termination_action(outcome_kind):
- with lock:
- stats[outcome_kind] += 1
- cycle.operations.pop(operation_id, None)
- if not cycle.operations:
- for action in cycle.idle_actions:
- cycle.pool.submit(action)
- cycle.idle_actions = []
- if cycle.grace:
- _cancel_futures(cycle.futures)
- cycle.pool.shutdown(wait=False)
- return termination_action
-
-
class _End(End):
"""An End implementation."""
@@ -133,6 +104,31 @@ class _End(End):
self._cycle = None
+ def _termination_action(self, operation_id):
+ """Constructs the termination action for a single operation.
+
+ Args:
+ operation_id: The operation ID for the termination action.
+
+ Returns:
+ A callable that takes an operation outcome kind as its sole parameter and
+ that should be used as the termination action for the operation
+ associated with the given operation ID.
+ """
+ def termination_action(outcome_kind):
+ with self._lock:
+ self._stats[outcome_kind] += 1
+ self._cycle.operations.pop(operation_id, None)
+ if not self._cycle.operations:
+ for action in self._cycle.idle_actions:
+ self._cycle.pool.submit(action)
+ self._cycle.idle_actions = []
+ if self._cycle.grace:
+ _cancel_futures(self._cycle.futures)
+ self._cycle.pool.shutdown(wait=False)
+ self._cycle = None
+ return termination_action
+
def start(self):
"""See base.End.start for specification."""
with self._lock:
@@ -174,8 +170,7 @@ class _End(End):
with self._lock:
if self._cycle is None or self._cycle.grace:
raise ValueError('Can\'t operate on stopped or stopping End!')
- termination_action = _termination_action(
- self._lock, self._stats, operation_id, self._cycle)
+ termination_action = self._termination_action(operation_id)
operation = _operation.invocation_operate(
operation_id, group, method, subscription, timeout, protocol_options,
initial_metadata, payload, completion, self._mate.accept_ticket,
@@ -208,8 +203,7 @@ class _End(End):
if operation is not None:
operation.handle_ticket(ticket)
elif self._servicer_package is not None and not self._cycle.grace:
- termination_action = _termination_action(
- self._lock, self._stats, ticket.operation_id, self._cycle)
+ termination_action = self._termination_action(ticket.operation_id)
operation = _operation.service_operate(
self._servicer_package, ticket, self._mate.accept_ticket,
termination_action, self._cycle.pool)
diff --git a/src/python/grpcio/requirements.txt b/src/python/grpcio/requirements.txt
index ee8568120b..06516ee0d7 100644
--- a/src/python/grpcio/requirements.txt
+++ b/src/python/grpcio/requirements.txt
@@ -1,3 +1,4 @@
enum34>=1.0.4
futures>=2.2.0
cython>=0.23
+coverage>=4.0
diff --git a/src/python/grpcio/setup.cfg b/src/python/grpcio/setup.cfg
index 8f69613632..52b6b50900 100644
--- a/src/python/grpcio/setup.cfg
+++ b/src/python/grpcio/setup.cfg
@@ -1,2 +1,8 @@
+[coverage:run]
+plugins = Cython.Coverage
+
[build_ext]
inplace=1
+
+[build_proto_modules]
+exclude=.*protoc_plugin/protoc_plugin_test\.proto$
diff --git a/src/python/grpcio/setup.py b/src/python/grpcio/setup.py
index ec68eb6755..8ac185bd6b 100644
--- a/src/python/grpcio/setup.py
+++ b/src/python/grpcio/setup.py
@@ -43,12 +43,21 @@ os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Break import-style to ensure we can actually find our commands module.
import commands
-# Use environment variables to determine whether or not the Cython extension
-# should *use* Cython or use the generated C files. Note that this requires the
-# C files to have been generated by building first *with* Cython support.
-_BUILD_WITH_CYTHON = os.environ.get('GRPC_PYTHON_BUILD_WITH_CYTHON', False)
+# Environment variable to determine whether or not the Cython extension should
+# *use* Cython or use the generated C files. Note that this requires the C files
+# to have been generated by building first *with* Cython support.
+BUILD_WITH_CYTHON = os.environ.get('GRPC_PYTHON_BUILD_WITH_CYTHON', False)
-_C_EXTENSION_SOURCES = (
+# Environment variable to determine whether or not to enable coverage analysis
+# in Cython modules.
+ENABLE_CYTHON_TRACING = os.environ.get(
+ 'GRPC_PYTHON_ENABLE_CYTHON_TRACING', False)
+
+# Environment variable to determine whether or not to include the test files in
+# the installation.
+INSTALL_TESTS = os.environ.get('GRPC_PYTHON_INSTALL_TESTS', False)
+
+C_EXTENSION_SOURCES = (
'grpc/_adapter/_c/module.c',
'grpc/_adapter/_c/types.c',
'grpc/_adapter/_c/utility.c',
@@ -61,9 +70,9 @@ _C_EXTENSION_SOURCES = (
'grpc/_adapter/_c/types/server.c',
)
-_CYTHON_EXTENSION_PACKAGE_NAMES = ()
+CYTHON_EXTENSION_PACKAGE_NAMES = ()
-_CYTHON_EXTENSION_MODULE_NAMES = (
+CYTHON_EXTENSION_MODULE_NAMES = (
'grpc._cython.cygrpc',
'grpc._cython._cygrpc.call',
'grpc._cython._cygrpc.channel',
@@ -73,24 +82,24 @@ _CYTHON_EXTENSION_MODULE_NAMES = (
'grpc._cython._cygrpc.server',
)
-_EXTENSION_INCLUDE_DIRECTORIES = (
+EXTENSION_INCLUDE_DIRECTORIES = (
'.',
)
-_EXTENSION_LIBRARIES = (
+EXTENSION_LIBRARIES = (
'grpc',
'gpr',
)
if not "darwin" in sys.platform:
- _EXTENSION_LIBRARIES += ('rt',)
+ EXTENSION_LIBRARIES += ('rt',)
-_C_EXTENSION_MODULE = _core.Extension(
- 'grpc._adapter._c', sources=list(_C_EXTENSION_SOURCES),
- include_dirs=list(_EXTENSION_INCLUDE_DIRECTORIES),
- libraries=list(_EXTENSION_LIBRARIES),
+C_EXTENSION_MODULE = _core.Extension(
+ 'grpc._adapter._c', sources=list(C_EXTENSION_SOURCES),
+ include_dirs=list(EXTENSION_INCLUDE_DIRECTORIES),
+ libraries=list(EXTENSION_LIBRARIES)
)
-_EXTENSION_MODULES = [_C_EXTENSION_MODULE]
+EXTENSION_MODULES = [C_EXTENSION_MODULE]
def cython_extensions(package_names, module_names, include_dirs, libraries,
@@ -101,48 +110,89 @@ def cython_extensions(package_names, module_names, include_dirs, libraries,
extensions = [
_extension.Extension(
name=module_name, sources=[module_file],
- include_dirs=include_dirs, libraries=libraries
+ include_dirs=include_dirs, libraries=libraries,
+ define_macros=[('CYTHON_TRACE_NOGIL', 1)] if ENABLE_CYTHON_TRACING else []
) for (module_name, module_file) in zip(module_names, module_files)
]
if build_with_cython:
import Cython.Build
- return Cython.Build.cythonize(extensions)
+ return Cython.Build.cythonize(
+ extensions,
+ compiler_directives={'linetrace': bool(ENABLE_CYTHON_TRACING)})
else:
return extensions
-_CYTHON_EXTENSION_MODULES = cython_extensions(
- list(_CYTHON_EXTENSION_PACKAGE_NAMES), list(_CYTHON_EXTENSION_MODULE_NAMES),
- list(_EXTENSION_INCLUDE_DIRECTORIES), list(_EXTENSION_LIBRARIES),
- bool(_BUILD_WITH_CYTHON))
+CYTHON_EXTENSION_MODULES = cython_extensions(
+ list(CYTHON_EXTENSION_PACKAGE_NAMES), list(CYTHON_EXTENSION_MODULE_NAMES),
+ list(EXTENSION_INCLUDE_DIRECTORIES), list(EXTENSION_LIBRARIES),
+ bool(BUILD_WITH_CYTHON))
-_PACKAGES = setuptools.find_packages('.')
-
-_PACKAGE_DIRECTORIES = {
+PACKAGE_DIRECTORIES = {
'': '.',
}
-_INSTALL_REQUIRES = (
+INSTALL_REQUIRES = (
'enum34>=1.0.4',
'futures>=2.2.0',
)
-_SETUP_REQUIRES = (
+SETUP_REQUIRES = (
'sphinx>=1.3',
-) + _INSTALL_REQUIRES
+) + INSTALL_REQUIRES
-_COMMAND_CLASS = {
+COMMAND_CLASS = {
'doc': commands.SphinxDocumentation,
+ 'build_proto_modules': commands.BuildProtoModules,
'build_project_metadata': commands.BuildProjectMetadata,
'build_py': commands.BuildPy,
+ 'gather': commands.Gather,
+ 'run_interop': commands.RunInterop,
+}
+
+TEST_PACKAGE_DATA = {
+ 'tests.interop': [
+ 'credentials/ca.pem',
+ 'credentials/server1.key',
+ 'credentials/server1.pem',
+ ],
+ 'tests.protoc_plugin': [
+ 'protoc_plugin_test.proto',
+ ],
+ 'tests.unit': [
+ 'credentials/ca.pem',
+ 'credentials/server1.key',
+ 'credentials/server1.pem',
+ ],
}
+TESTS_REQUIRE = (
+ 'oauth2client>=1.4.7',
+ 'protobuf==3.0.0a3',
+ 'coverage>=4.0',
+) + INSTALL_REQUIRES
+
+TEST_SUITE = 'tests'
+TEST_LOADER = 'tests:Loader'
+TEST_RUNNER = 'tests:Runner'
+
+PACKAGE_DATA = {}
+if INSTALL_TESTS:
+ PACKAGE_DATA = dict(PACKAGE_DATA, **TEST_PACKAGE_DATA)
+ PACKAGES = setuptools.find_packages('.')
+else:
+ PACKAGES = setuptools.find_packages('.', exclude=['tests', 'tests.*'])
+
setuptools.setup(
name='grpcio',
- version='0.11.0b1',
- ext_modules=_EXTENSION_MODULES + _CYTHON_EXTENSION_MODULES,
- packages=list(_PACKAGES),
- package_dir=_PACKAGE_DIRECTORIES,
- install_requires=_INSTALL_REQUIRES,
- setup_requires=_SETUP_REQUIRES,
- cmdclass=_COMMAND_CLASS
+ version='0.11.0b2',
+ ext_modules=EXTENSION_MODULES + CYTHON_EXTENSION_MODULES,
+ packages=list(PACKAGES),
+ package_dir=PACKAGE_DIRECTORIES,
+ install_requires=INSTALL_REQUIRES,
+ setup_requires=SETUP_REQUIRES,
+ cmdclass=COMMAND_CLASS,
+ tests_require=TESTS_REQUIRE,
+ test_suite=TEST_SUITE,
+ test_loader=TEST_LOADER,
+ test_runner=TEST_RUNNER,
)
diff --git a/src/python/grpcio_test/setup.py b/src/python/grpcio/tests/__init__.py
index e9ee45a92a..b76b3985a1 100644
--- a/src/python/grpcio_test/setup.py
+++ b/src/python/grpcio/tests/__init__.py
@@ -27,68 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-"""A setup module for the GRPC Python interop testing package."""
+from tests import _loader
+from tests import _runner
-import os
-import os.path
-
-import setuptools
-
-# Ensure we're in the proper directory whether or not we're being used by pip.
-os.chdir(os.path.dirname(os.path.abspath(__file__)))
-
-# Break import-style to ensure we can actually find our commands module.
-import commands
-
-_PACKAGES = setuptools.find_packages('.')
-
-_PACKAGE_DIRECTORIES = {
- '': '.',
-}
-
-_PACKAGE_DATA = {
- 'grpc_interop': [
- 'credentials/ca.pem',
- 'credentials/server1.key',
- 'credentials/server1.pem',
- ],
- 'grpc_protoc_plugin': [
- 'test.proto',
- ],
- 'grpc_test': [
- 'credentials/ca.pem',
- 'credentials/server1.key',
- 'credentials/server1.pem',
- ],
-}
-
-_SETUP_REQUIRES = (
- 'pytest>=2.6',
- 'pytest-cov>=2.0',
- 'pytest-xdist>=1.11',
- 'pytest-timeout>=0.5',
-)
-
-_INSTALL_REQUIRES = (
- 'oauth2client>=1.4.7',
- 'grpcio>=0.11.0b0',
- # TODO(issue 3321): Unpin protobuf dependency.
- 'protobuf==3.0.0a3',
-)
-
-_COMMAND_CLASS = {
- 'test': commands.RunTests,
- 'build_proto_modules': commands.BuildProtoModules,
- 'build_py': commands.BuildPy,
-}
-
-setuptools.setup(
- name='grpcio_test',
- version='0.11.0b0',
- packages=_PACKAGES,
- package_dir=_PACKAGE_DIRECTORIES,
- package_data=_PACKAGE_DATA,
- install_requires=_INSTALL_REQUIRES + _SETUP_REQUIRES,
- setup_requires=_SETUP_REQUIRES,
- cmdclass=_COMMAND_CLASS,
-)
+Loader = _loader.Loader
+Runner = _runner.Runner
diff --git a/src/python/grpcio/tests/_loader.py b/src/python/grpcio/tests/_loader.py
new file mode 100644
index 0000000000..6992029b5e
--- /dev/null
+++ b/src/python/grpcio/tests/_loader.py
@@ -0,0 +1,119 @@
+# Copyright 2015, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import importlib
+import pkgutil
+import re
+import unittest
+
+import coverage
+
+TEST_MODULE_REGEX = r'^.*_test$'
+
+
+class Loader(object):
+ """Test loader for setuptools test suite support.
+
+ Attributes:
+ suite (unittest.TestSuite): All tests collected by the loader.
+ loader (unittest.TestLoader): Standard Python unittest loader to be ran per
+ module discovered.
+ module_matcher (re.RegexObject): A regular expression object to match
+ against module names and determine whether or not the discovered module
+ contributes to the test suite.
+ """
+
+ def __init__(self):
+ self.suite = unittest.TestSuite()
+ self.loader = unittest.TestLoader()
+ self.module_matcher = re.compile(TEST_MODULE_REGEX)
+
+ def loadTestsFromNames(self, names, module=None):
+ """Function mirroring TestLoader::loadTestsFromNames, as expected by
+ setuptools.setup argument `test_loader`."""
+ # ensure that we capture decorators and definitions (else our coverage
+ # measure unnecessarily suffers)
+ coverage_context = coverage.Coverage(data_suffix=True)
+ coverage_context.start()
+ modules = [importlib.import_module(name) for name in names]
+ for module in modules:
+ self.visit_module(module)
+ for module in modules:
+ try:
+ package_paths = module.__path__
+ except:
+ continue
+ self.walk_packages(package_paths)
+ coverage_context.stop()
+ coverage_context.save()
+ return self.suite
+
+ def walk_packages(self, package_paths):
+ """Walks over the packages, dispatching `visit_module` calls.
+
+ Args:
+ package_paths (list): A list of paths over which to walk through modules
+ along.
+ """
+ for importer, module_name, is_package in (
+ pkgutil.iter_modules(package_paths)):
+ module = importer.find_module(module_name).load_module(module_name)
+ self.visit_module(module)
+ if is_package:
+ self.walk_packages(module.__path__)
+
+ def visit_module(self, module):
+ """Visits the module, adding discovered tests to the test suite.
+
+ Args:
+ module (module): Module to match against self.module_matcher; if matched
+ it has its tests loaded via self.loader into self.suite.
+ """
+ if self.module_matcher.match(module.__name__):
+ module_suite = self.loader.loadTestsFromModule(module)
+ self.suite.addTest(module_suite)
+
+
+def iterate_suite_cases(suite):
+ """Generator over all unittest.TestCases in a unittest.TestSuite.
+
+ Args:
+ suite (unittest.TestSuite): Suite to iterate over in the generator.
+
+ Returns:
+ generator: A generator over all unittest.TestCases in `suite`.
+ """
+ for item in suite:
+ if isinstance(item, unittest.TestSuite):
+ for child_item in iterate_suite_cases(item):
+ yield child_item
+ elif isinstance(item, unittest.TestCase):
+ yield item
+ else:
+ raise ValueError('unexpected suite item of type {}'.format(type(item)))
diff --git a/src/python/grpcio/tests/_result.py b/src/python/grpcio/tests/_result.py
new file mode 100644
index 0000000000..5a570f4279
--- /dev/null
+++ b/src/python/grpcio/tests/_result.py
@@ -0,0 +1,451 @@
+# Copyright 2015, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import cStringIO as StringIO
+import collections
+import itertools
+import traceback
+import unittest
+from xml.etree import ElementTree
+
+import coverage
+
+from tests import _loader
+
+
+class CaseResult(collections.namedtuple('CaseResult', [
+ 'id', 'name', 'kind', 'stdout', 'stderr', 'skip_reason', 'traceback'])):
+ """A serializable result of a single test case.
+
+ Attributes:
+ id (object): Any serializable object used to denote the identity of this
+ test case.
+ name (str or None): A human-readable name of the test case.
+ kind (CaseResult.Kind): The kind of test result.
+ stdout (object or None): Output on stdout, or None if nothing was captured.
+ stderr (object or None): Output on stderr, or None if nothing was captured.
+ skip_reason (object or None): The reason the test was skipped. Must be
+ something if self.kind is CaseResult.Kind.SKIP, else None.
+ traceback (object or None): The traceback of the test. Must be something if
+ self.kind is CaseResult.Kind.{ERROR, FAILURE, EXPECTED_FAILURE}, else
+ None.
+ """
+
+ class Kind:
+ UNTESTED = 'untested'
+ RUNNING = 'running'
+ ERROR = 'error'
+ FAILURE = 'failure'
+ SUCCESS = 'success'
+ SKIP = 'skip'
+ EXPECTED_FAILURE = 'expected failure'
+ UNEXPECTED_SUCCESS = 'unexpected success'
+
+ def __new__(cls, id=None, name=None, kind=None, stdout=None, stderr=None,
+ skip_reason=None, traceback=None):
+ """Helper keyword constructor for the namedtuple.
+
+ See this class' attributes for information on the arguments."""
+ assert id is not None
+ assert name is None or isinstance(name, str)
+ if kind is CaseResult.Kind.UNTESTED:
+ pass
+ elif kind is CaseResult.Kind.RUNNING:
+ pass
+ elif kind is CaseResult.Kind.ERROR:
+ assert traceback is not None
+ elif kind is CaseResult.Kind.FAILURE:
+ assert traceback is not None
+ elif kind is CaseResult.Kind.SUCCESS:
+ pass
+ elif kind is CaseResult.Kind.SKIP:
+ assert skip_reason is not None
+ elif kind is CaseResult.Kind.EXPECTED_FAILURE:
+ assert traceback is not None
+ elif kind is CaseResult.Kind.UNEXPECTED_SUCCESS:
+ pass
+ else:
+ assert False
+ return super(cls, CaseResult).__new__(
+ cls, id, name, kind, stdout, stderr, skip_reason, traceback)
+
+ def updated(self, name=None, kind=None, stdout=None, stderr=None,
+ skip_reason=None, traceback=None):
+ """Get a new validated CaseResult with the fields updated.
+
+ See this class' attributes for information on the arguments."""
+ name = self.name if name is None else name
+ kind = self.kind if kind is None else kind
+ stdout = self.stdout if stdout is None else stdout
+ stderr = self.stderr if stderr is None else stderr
+ skip_reason = self.skip_reason if skip_reason is None else skip_reason
+ traceback = self.traceback if traceback is None else traceback
+ return CaseResult(id=self.id, name=name, kind=kind, stdout=stdout,
+ stderr=stderr, skip_reason=skip_reason,
+ traceback=traceback)
+
+
+class AugmentedResult(unittest.TestResult):
+ """unittest.Result that keeps track of additional information.
+
+ Uses CaseResult objects to store test-case results, providing additional
+ information beyond that of the standard Python unittest library, such as
+ standard output.
+
+ Attributes:
+ id_map (callable): A unary callable mapping unittest.TestCase objects to
+ unique identifiers.
+ cases (dict): A dictionary mapping from the identifiers returned by id_map
+ to CaseResult objects corresponding to those IDs.
+ """
+
+ def __init__(self, id_map):
+ """Initialize the object with an identifier mapping.
+
+ Arguments:
+ id_map (callable): Corresponds to the attribute `id_map`."""
+ super(AugmentedResult, self).__init__()
+ self.id_map = id_map
+ self.cases = None
+
+ def startTestRun(self):
+ """See unittest.TestResult.startTestRun."""
+ super(AugmentedResult, self).startTestRun()
+ self.cases = dict()
+
+ def stopTestRun(self):
+ """See unittest.TestResult.stopTestRun."""
+ super(AugmentedResult, self).stopTestRun()
+
+ def startTest(self, test):
+ """See unittest.TestResult.startTest."""
+ super(AugmentedResult, self).startTest(test)
+ case_id = self.id_map(test)
+ self.cases[case_id] = CaseResult(
+ id=case_id, name=test.id(), kind=CaseResult.Kind.RUNNING)
+
+ def addError(self, test, error):
+ """See unittest.TestResult.addError."""
+ super(AugmentedResult, self).addError(test, error)
+ case_id = self.id_map(test)
+ self.cases[case_id] = self.cases[case_id].updated(
+ kind=CaseResult.Kind.ERROR, traceback=error)
+
+ def addFailure(self, test, error):
+ """See unittest.TestResult.addFailure."""
+ super(AugmentedResult, self).addFailure(test, error)
+ case_id = self.id_map(test)
+ self.cases[case_id] = self.cases[case_id].updated(
+ kind=CaseResult.Kind.FAILURE, traceback=error)
+
+ def addSuccess(self, test):
+ """See unittest.TestResult.addSuccess."""
+ super(AugmentedResult, self).addSuccess(test)
+ case_id = self.id_map(test)
+ self.cases[case_id] = self.cases[case_id].updated(
+ kind=CaseResult.Kind.SUCCESS)
+
+ def addSkip(self, test, reason):
+ """See unittest.TestResult.addSkip."""
+ super(AugmentedResult, self).addSkip(test, reason)
+ case_id = self.id_map(test)
+ self.cases[case_id] = self.cases[case_id].updated(
+ kind=CaseResult.Kind.SKIP, skip_reason=reason)
+
+ def addExpectedFailure(self, test, error):
+ """See unittest.TestResult.addExpectedFailure."""
+ super(AugmentedResult, self).addExpectedFailure(test, error)
+ case_id = self.id_map(test)
+ self.cases[case_id] = self.cases[case_id].updated(
+ kind=CaseResult.Kind.EXPECTED_FAILURE, traceback=error)
+
+ def addUnexpectedSuccess(self, test):
+ """See unittest.TestResult.addUnexpectedSuccess."""
+ super(AugmentedResult, self).addUnexpectedSuccess(test)
+ case_id = self.id_map(test)
+ self.cases[case_id] = self.cases[case_id].updated(
+ kind=CaseResult.Kind.UNEXPECTED_SUCCESS)
+
+ def set_output(self, test, stdout, stderr):
+ """Set the output attributes for the CaseResult corresponding to a test.
+
+ Args:
+ test (unittest.TestCase): The TestCase to set the outputs of.
+ stdout (str): Output from stdout to assign to self.id_map(test).
+ stderr (str): Output from stderr to assign to self.id_map(test).
+ """
+ case_id = self.id_map(test)
+ self.cases[case_id] = self.cases[case_id].updated(
+ stdout=stdout, stderr=stderr)
+
+ def augmented_results(self, filter):
+ """Convenience method to retrieve filtered case results.
+
+ Args:
+ filter (callable): A unary predicate to filter over CaseResult objects.
+ """
+ return (self.cases[case_id] for case_id in self.cases
+ if filter(self.cases[case_id]))
+
+
+class CoverageResult(AugmentedResult):
+ """Extension to AugmentedResult adding coverage.py support per test.\
+
+ Attributes:
+ coverage_context (coverage.Coverage): coverage.py management object.
+ """
+
+ def __init__(self, id_map):
+ """See AugmentedResult.__init__."""
+ super(CoverageResult, self).__init__(id_map=id_map)
+ self.coverage_context = None
+
+ def startTest(self, test):
+ """See unittest.TestResult.startTest.
+
+ Additionally initializes and begins code coverage tracking."""
+ super(CoverageResult, self).startTest(test)
+ self.coverage_context = coverage.Coverage(data_suffix=True)
+ self.coverage_context.start()
+
+ def stopTest(self, test):
+ """See unittest.TestResult.stopTest.
+
+ Additionally stops and deinitializes code coverage tracking."""
+ super(CoverageResult, self).stopTest(test)
+ self.coverage_context.stop()
+ self.coverage_context.save()
+ self.coverage_context = None
+
+ def stopTestRun(self):
+ """See unittest.TestResult.stopTestRun."""
+ super(CoverageResult, self).stopTestRun()
+ # TODO(atash): Dig deeper into why the following line fails to properly
+ # combine coverage data from the Cython plugin.
+ #coverage.Coverage().combine()
+
+
+class _Colors:
+ """Namespaced constants for terminal color magic numbers."""
+ HEADER = '\033[95m'
+ INFO = '\033[94m'
+ OK = '\033[92m'
+ WARN = '\033[93m'
+ FAIL = '\033[91m'
+ BOLD = '\033[1m'
+ UNDERLINE = '\033[4m'
+ END = '\033[0m'
+
+
+class TerminalResult(CoverageResult):
+ """Extension to CoverageResult adding basic terminal reporting."""
+
+ def __init__(self, out, id_map):
+ """Initialize the result object.
+
+ Args:
+ out (file-like): Output file to which terminal-colored live results will
+ be written.
+ id_map (callable): See AugmentedResult.__init__.
+ """
+ super(TerminalResult, self).__init__(id_map=id_map)
+ self.out = out
+
+ def startTestRun(self):
+ """See unittest.TestResult.startTestRun."""
+ super(TerminalResult, self).startTestRun()
+ self.out.write(
+ _Colors.HEADER +
+ 'Testing gRPC Python...\n' +
+ _Colors.END)
+
+ def stopTestRun(self):
+ """See unittest.TestResult.stopTestRun."""
+ super(TerminalResult, self).stopTestRun()
+ self.out.write(summary(self))
+ self.out.flush()
+
+ def addError(self, test, error):
+ """See unittest.TestResult.addError."""
+ super(TerminalResult, self).addError(test, error)
+ self.out.write(
+ _Colors.FAIL +
+ 'ERROR {}\n'.format(test.id()) +
+ _Colors.END)
+ self.out.flush()
+
+ def addFailure(self, test, error):
+ """See unittest.TestResult.addFailure."""
+ super(TerminalResult, self).addFailure(test, error)
+ self.out.write(
+ _Colors.FAIL +
+ 'FAILURE {}\n'.format(test.id()) +
+ _Colors.END)
+ self.out.flush()
+
+ def addSuccess(self, test):
+ """See unittest.TestResult.addSuccess."""
+ super(TerminalResult, self).addSuccess(test)
+ self.out.write(
+ _Colors.OK +
+ 'SUCCESS {}\n'.format(test.id()) +
+ _Colors.END)
+ self.out.flush()
+
+ def addSkip(self, test, reason):
+ """See unittest.TestResult.addSkip."""
+ super(TerminalResult, self).addSkip(test, reason)
+ self.out.write(
+ _Colors.INFO +
+ 'SKIP {}\n'.format(test.id()) +
+ _Colors.END)
+ self.out.flush()
+
+ def addExpectedFailure(self, test, error):
+ """See unittest.TestResult.addExpectedFailure."""
+ super(TerminalResult, self).addExpectedFailure(test, error)
+ self.out.write(
+ _Colors.INFO +
+ 'FAILURE_OK {}\n'.format(test.id()) +
+ _Colors.END)
+ self.out.flush()
+
+ def addUnexpectedSuccess(self, test):
+ """See unittest.TestResult.addUnexpectedSuccess."""
+ super(TerminalResult, self).addUnexpectedSuccess(test)
+ self.out.write(
+ _Colors.INFO +
+ 'UNEXPECTED_OK {}\n'.format(test.id()) +
+ _Colors.END)
+ self.out.flush()
+
+def _traceback_string(type, value, trace):
+ """Generate a descriptive string of a Python exception traceback.
+
+ Args:
+ type (class): The type of the exception.
+ value (Exception): The value of the exception.
+ trace (traceback): Traceback of the exception.
+
+ Returns:
+ str: Formatted exception descriptive string.
+ """
+ buffer = StringIO.StringIO()
+ traceback.print_exception(type, value, trace, file=buffer)
+ return buffer.getvalue()
+
+def summary(result):
+ """A summary string of a result object.
+
+ Args:
+ result (AugmentedResult): The result object to get the summary of.
+
+ Returns:
+ str: The summary string.
+ """
+ assert isinstance(result, AugmentedResult)
+ untested = list(result.augmented_results(
+ lambda case_result: case_result.kind is CaseResult.Kind.UNTESTED))
+ running = list(result.augmented_results(
+ lambda case_result: case_result.kind is CaseResult.Kind.RUNNING))
+ failures = list(result.augmented_results(
+ lambda case_result: case_result.kind is CaseResult.Kind.FAILURE))
+ errors = list(result.augmented_results(
+ lambda case_result: case_result.kind is CaseResult.Kind.ERROR))
+ successes = list(result.augmented_results(
+ lambda case_result: case_result.kind is CaseResult.Kind.SUCCESS))
+ skips = list(result.augmented_results(
+ lambda case_result: case_result.kind is CaseResult.Kind.SKIP))
+ expected_failures = list(result.augmented_results(
+ lambda case_result: case_result.kind is CaseResult.Kind.EXPECTED_FAILURE))
+ unexpected_successes = list(result.augmented_results(
+ lambda case_result: case_result.kind is CaseResult.Kind.UNEXPECTED_SUCCESS))
+ running_names = [case.name for case in running]
+ finished_count = (len(failures) + len(errors) + len(successes) +
+ len(expected_failures) + len(unexpected_successes))
+ statistics = (
+ '{finished} tests finished:\n'
+ '\t{successful} successful\n'
+ '\t{unsuccessful} unsuccessful\n'
+ '\t{skipped} skipped\n'
+ '\t{expected_fail} expected failures\n'
+ '\t{unexpected_successful} unexpected successes\n'
+ 'Interrupted Tests:\n'
+ '\t{interrupted}\n'
+ .format(finished=finished_count,
+ successful=len(successes),
+ unsuccessful=(len(failures)+len(errors)),
+ skipped=len(skips),
+ expected_fail=len(expected_failures),
+ unexpected_successful=len(unexpected_successes),
+ interrupted=str(running_names)))
+ tracebacks = '\n\n'.join([
+ (_Colors.FAIL + '{test_name}' + _Colors.END + + '\n' +
+ _Colors.BOLD + 'traceback:' + _Colors.END + '\n' +
+ '{traceback}\n' +
+ _Colors.BOLD + 'stdout:' + _Colors.END + '\n' +
+ '{stdout}\n' +
+ _Colors.BOLD + 'stderr:' + _Colors.END + '\n' +
+ '{stderr}\n').format(
+ test_name=result.name,
+ traceback=_traceback_string(*result.traceback),
+ stdout=result.stdout, stderr=result.stderr)
+ for result in itertools.chain(failures, errors)
+ ])
+ notes = 'Unexpected successes: {}\n'.format([
+ result.name for result in unexpected_successes])
+ return statistics + '\nErrors/Failures: \n' + tracebacks + '\n' + notes
+
+
+def jenkins_junit_xml(result):
+ """An XML tree object that when written is recognizable by Jenkins.
+
+ Args:
+ result (AugmentedResult): The result object to get the junit xml output of.
+
+ Returns:
+ ElementTree.ElementTree: The XML tree.
+ """
+ assert isinstance(result, AugmentedResult)
+ root = ElementTree.Element('testsuites')
+ suite = ElementTree.SubElement(root, 'testsuite', {
+ 'name': 'Python gRPC tests',
+ })
+ for case in result.cases.values():
+ if case.kind is CaseResult.Kind.SUCCESS:
+ ElementTree.SubElement(suite, 'testcase', {
+ 'name': case.name,
+ })
+ elif case.kind in (CaseResult.Kind.ERROR, CaseResult.Kind.FAILURE):
+ case_xml = ElementTree.SubElement(suite, 'testcase', {
+ 'name': case.name,
+ })
+ error_xml = ElementTree.SubElement(case_xml, 'error', {})
+ error_xml.text = ''.format(case.stderr, case.traceback)
+ return ElementTree.ElementTree(element=root)
diff --git a/src/python/grpcio/tests/_runner.py b/src/python/grpcio/tests/_runner.py
new file mode 100644
index 0000000000..4f1ddb57fc
--- /dev/null
+++ b/src/python/grpcio/tests/_runner.py
@@ -0,0 +1,224 @@
+# Copyright 2015, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import cStringIO as StringIO
+import collections
+import fcntl
+import multiprocessing
+import os
+import select
+import signal
+import sys
+import threading
+import time
+import unittest
+import uuid
+
+from tests import _loader
+from tests import _result
+
+
+class CapturePipe(object):
+ """A context-manager pipe to redirect output to a byte array.
+
+ Attributes:
+ _redirect_fd (int): File descriptor of file to redirect writes from.
+ _saved_fd (int): A copy of the original value of the redirected file
+ descriptor.
+ _read_thread (threading.Thread or None): Thread upon which reads through the
+ pipe are performed. Only non-None when self is started.
+ _read_fd (int or None): File descriptor of the read end of the redirect
+ pipe. Only non-None when self is started.
+ _write_fd (int or None): File descriptor of the write end of the redirect
+ pipe. Only non-None when self is started.
+ output (bytearray or None): Redirected output from writes to the redirected
+ file descriptor. Only valid during and after self has started.
+ """
+
+ def __init__(self, fd):
+ self._redirect_fd = fd
+ self._saved_fd = os.dup(self._redirect_fd)
+ self._read_thread = None
+ self._read_fd = None
+ self._write_fd = None
+ self.output = None
+
+ def start(self):
+ """Start redirection of writes to the file descriptor."""
+ self._read_fd, self._write_fd = os.pipe()
+ os.dup2(self._write_fd, self._redirect_fd)
+ flags = fcntl.fcntl(self._read_fd, fcntl.F_GETFL)
+ fcntl.fcntl(self._read_fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
+ self._read_thread = threading.Thread(target=self._read)
+ self._read_thread.start()
+
+ def stop(self):
+ """Stop redirection of writes to the file descriptor."""
+ os.close(self._write_fd)
+ os.dup2(self._saved_fd, self._redirect_fd) # auto-close self._redirect_fd
+ self._read_thread.join()
+ self._read_thread = None
+ # we waited for the read thread to finish, so _read_fd has been read and we
+ # can close it.
+ os.close(self._read_fd)
+
+ def _read(self):
+ """Read-thread target for self."""
+ self.output = bytearray()
+ while True:
+ select.select([self._read_fd], [], [])
+ read_bytes = os.read(self._read_fd, 1024)
+ if read_bytes:
+ self.output.extend(read_bytes)
+ else:
+ break
+
+ def write_bypass(self, value):
+ """Bypass the redirection and write directly to the original file.
+
+ Arguments:
+ value (str): What to write to the original file.
+ """
+ if self._saved_fd is None:
+ os.write(self._redirect_fd, value)
+ else:
+ os.write(self._saved_fd, value)
+
+ def __enter__(self):
+ self.start()
+ return self
+
+ def __exit__(self, type, value, traceback):
+ self.stop()
+
+ def close(self):
+ """Close any resources used by self not closed by stop()."""
+ os.close(self._saved_fd)
+
+
+class AugmentedCase(collections.namedtuple('AugmentedCase', [
+ 'case', 'id'])):
+ """A test case with a guaranteed unique externally specified identifier.
+
+ Attributes:
+ case (unittest.TestCase): TestCase we're decorating with an additional
+ identifier.
+ id (object): Any identifier that may be considered 'unique' for testing
+ purposes.
+ """
+
+ def __new__(cls, case, id=None):
+ if id is None:
+ id = uuid.uuid4()
+ return super(cls, AugmentedCase).__new__(cls, case, id)
+
+
+class Runner(object):
+
+ def run(self, suite):
+ """See setuptools' test_runner setup argument for information."""
+ # Ensure that every test case has no collision with any other test case in
+ # the augmented results.
+ augmented_cases = [AugmentedCase(case, uuid.uuid4())
+ for case in _loader.iterate_suite_cases(suite)]
+ case_id_by_case = dict((augmented_case.case, augmented_case.id)
+ for augmented_case in augmented_cases)
+ result_out = StringIO.StringIO()
+ result = _result.TerminalResult(
+ result_out, id_map=lambda case: case_id_by_case[case])
+ stdout_pipe = CapturePipe(sys.stdout.fileno())
+ stderr_pipe = CapturePipe(sys.stderr.fileno())
+ kill_flag = [False]
+
+ def sigint_handler(signal_number, frame):
+ if signal_number == signal.SIGINT:
+ kill_flag[0] = True # Python 2.7 not having 'local'... :-(
+ signal.signal(signal_number, signal.SIG_DFL)
+
+ def fault_handler(signal_number, frame):
+ stdout_pipe.write_bypass(
+ 'Received fault signal {}\nstdout:\n{}\n\nstderr:{}\n'
+ .format(signal_number, stdout_pipe.output, stderr_pipe.output))
+ os._exit(1)
+
+ def check_kill_self():
+ if kill_flag[0]:
+ stdout_pipe.write_bypass('Stopping tests short...')
+ result.stopTestRun()
+ stdout_pipe.write_bypass(result_out.getvalue())
+ stdout_pipe.write_bypass(
+ '\ninterrupted stdout:\n{}\n'.format(stdout_pipe.output))
+ stderr_pipe.write_bypass(
+ '\ninterrupted stderr:\n{}\n'.format(stderr_pipe.output))
+ os._exit(1)
+ signal.signal(signal.SIGINT, sigint_handler)
+ signal.signal(signal.SIGSEGV, fault_handler)
+ signal.signal(signal.SIGBUS, fault_handler)
+ signal.signal(signal.SIGABRT, fault_handler)
+ signal.signal(signal.SIGFPE, fault_handler)
+ signal.signal(signal.SIGILL, fault_handler)
+ # Sometimes output will lag after a test has successfully finished; we
+ # ignore such writes to our pipes.
+ signal.signal(signal.SIGPIPE, signal.SIG_IGN)
+
+ # Run the tests
+ result.startTestRun()
+ for augmented_case in augmented_cases:
+ sys.stdout.write('Running {}\n'.format(augmented_case.case.id()))
+ sys.stdout.flush()
+ case_thread = threading.Thread(
+ target=augmented_case.case.run, args=(result,))
+ try:
+ with stdout_pipe, stderr_pipe:
+ case_thread.start()
+ while case_thread.is_alive():
+ check_kill_self()
+ time.sleep(0)
+ case_thread.join()
+ except:
+ # re-raise the exception after forcing the with-block to end
+ raise
+ result.set_output(
+ augmented_case.case, stdout_pipe.output, stderr_pipe.output)
+ sys.stdout.write(result_out.getvalue())
+ sys.stdout.flush()
+ result_out.truncate(0)
+ check_kill_self()
+ result.stopTestRun()
+ stdout_pipe.close()
+ stderr_pipe.close()
+
+ # Report results
+ sys.stdout.write(result_out.getvalue())
+ sys.stdout.flush()
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
+ with open('report.xml', 'w') as report_xml_file:
+ _result.jenkins_junit_xml(result).write(report_xml_file)
+ return result
+
diff --git a/src/python/grpcio_test/grpc_interop/__init__.py b/src/python/grpcio/tests/interop/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_interop/__init__.py
+++ b/src/python/grpcio/tests/interop/__init__.py
diff --git a/src/python/grpcio_test/grpc_interop/_insecure_interop_test.py b/src/python/grpcio/tests/interop/_insecure_interop_test.py
index 5007be28ff..00b49aba37 100644
--- a/src/python/grpcio_test/grpc_interop/_insecure_interop_test.py
+++ b/src/python/grpcio/tests/interop/_insecure_interop_test.py
@@ -33,10 +33,10 @@ import unittest
from grpc.beta import implementations
-from grpc_interop import _interop_test_case
-from grpc_interop import methods
-from grpc_interop import server
-from grpc_interop import test_pb2
+from tests.interop import _interop_test_case
+from tests.interop import methods
+from tests.interop import server
+from tests.interop import test_pb2
class InsecureInteropTest(
diff --git a/src/python/grpcio_test/grpc_interop/_interop_test_case.py b/src/python/grpcio/tests/interop/_interop_test_case.py
index b6d06b300d..ccea17a66d 100644
--- a/src/python/grpcio_test/grpc_interop/_interop_test_case.py
+++ b/src/python/grpcio/tests/interop/_interop_test_case.py
@@ -29,7 +29,7 @@
"""Common code for unit tests of the interoperability test code."""
-from grpc_interop import methods
+from tests.interop import methods
class InteropTestCase(object):
diff --git a/src/python/grpcio_test/grpc_interop/_secure_interop_test.py b/src/python/grpcio/tests/interop/_secure_interop_test.py
index 108e15b0f9..a0fef1fc20 100644
--- a/src/python/grpcio_test/grpc_interop/_secure_interop_test.py
+++ b/src/python/grpcio/tests/interop/_secure_interop_test.py
@@ -33,12 +33,12 @@ import unittest
from grpc.beta import implementations
-from grpc_test.beta import test_utilities
+from tests.interop import _interop_test_case
+from tests.interop import methods
+from tests.interop import resources
+from tests.interop import test_pb2
-from grpc_interop import _interop_test_case
-from grpc_interop import methods
-from grpc_interop import resources
-from grpc_interop import test_pb2
+from tests.unit.beta import test_utilities
_SERVER_HOST_OVERRIDE = 'foo.test.google.fr'
diff --git a/src/python/grpcio_test/grpc_interop/client.py b/src/python/grpcio/tests/interop/client.py
index b8d5047ca5..9449ff5429 100644
--- a/src/python/grpcio_test/grpc_interop/client.py
+++ b/src/python/grpcio/tests/interop/client.py
@@ -34,11 +34,10 @@ from oauth2client import client as oauth2client_client
from grpc.beta import implementations
-from grpc_test.beta import test_utilities
-
-from grpc_interop import methods
-from grpc_interop import resources
-from grpc_interop import test_pb2
+from tests.interop import methods
+from tests.interop import resources
+from tests.interop import test_pb2
+from tests.unit.beta import test_utilities
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
@@ -114,7 +113,7 @@ def _test_case_from_arg(test_case_arg):
raise ValueError('No test case "%s"!' % test_case_arg)
-def _test_interoperability():
+def test_interoperability():
args = _args()
stub = _stub(args)
test_case = _test_case_from_arg(args.test_case)
@@ -122,4 +121,4 @@ def _test_interoperability():
if __name__ == '__main__':
- _test_interoperability()
+ test_interoperability()
diff --git a/src/python/grpcio_test/grpc_interop/credentials/README b/src/python/grpcio/tests/interop/credentials/README
index cb20dcb49f..cb20dcb49f 100644
--- a/src/python/grpcio_test/grpc_interop/credentials/README
+++ b/src/python/grpcio/tests/interop/credentials/README
diff --git a/src/python/grpcio_test/grpc_interop/credentials/ca.pem b/src/python/grpcio/tests/interop/credentials/ca.pem
index 6c8511a73c..6c8511a73c 100755
--- a/src/python/grpcio_test/grpc_interop/credentials/ca.pem
+++ b/src/python/grpcio/tests/interop/credentials/ca.pem
diff --git a/src/python/grpcio_test/grpc_interop/credentials/server1.key b/src/python/grpcio/tests/interop/credentials/server1.key
index 143a5b8765..143a5b8765 100755
--- a/src/python/grpcio_test/grpc_interop/credentials/server1.key
+++ b/src/python/grpcio/tests/interop/credentials/server1.key
diff --git a/src/python/grpcio_test/grpc_interop/credentials/server1.pem b/src/python/grpcio/tests/interop/credentials/server1.pem
index f3d43fcc5b..f3d43fcc5b 100755
--- a/src/python/grpcio_test/grpc_interop/credentials/server1.pem
+++ b/src/python/grpcio/tests/interop/credentials/server1.pem
diff --git a/src/python/grpcio_test/grpc_interop/empty.proto b/src/python/grpcio/tests/interop/empty.proto
index 6d0eb937d6..6d0eb937d6 100644
--- a/src/python/grpcio_test/grpc_interop/empty.proto
+++ b/src/python/grpcio/tests/interop/empty.proto
diff --git a/src/python/grpcio_test/grpc_interop/messages.proto b/src/python/grpcio/tests/interop/messages.proto
index 193b6c4171..193b6c4171 100644
--- a/src/python/grpcio_test/grpc_interop/messages.proto
+++ b/src/python/grpcio/tests/interop/messages.proto
diff --git a/src/python/grpcio_test/grpc_interop/methods.py b/src/python/grpcio/tests/interop/methods.py
index 3ef8545355..b3591aef7b 100644
--- a/src/python/grpcio_test/grpc_interop/methods.py
+++ b/src/python/grpcio/tests/interop/methods.py
@@ -40,9 +40,9 @@ from oauth2client import client as oauth2client_client
from grpc.framework.common import cardinality
from grpc.framework.interfaces.face import face
-from grpc_interop import empty_pb2
-from grpc_interop import messages_pb2
-from grpc_interop import test_pb2
+from tests.interop import empty_pb2
+from tests.interop import messages_pb2
+from tests.interop import test_pb2
_TIMEOUT = 7
diff --git a/src/python/grpcio_test/grpc_interop/resources.py b/src/python/grpcio/tests/interop/resources.py
index 1122499418..1122499418 100644
--- a/src/python/grpcio_test/grpc_interop/resources.py
+++ b/src/python/grpcio/tests/interop/resources.py
diff --git a/src/python/grpcio_test/grpc_interop/server.py b/src/python/grpcio/tests/interop/server.py
index b541087663..6dd55f008c 100644
--- a/src/python/grpcio_test/grpc_interop/server.py
+++ b/src/python/grpcio/tests/interop/server.py
@@ -35,9 +35,9 @@ import time
from grpc.beta import implementations
-from grpc_interop import methods
-from grpc_interop import resources
-from grpc_interop import test_pb2
+from tests.interop import methods
+from tests.interop import resources
+from tests.interop import test_pb2
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
@@ -68,7 +68,7 @@ def serve():
time.sleep(_ONE_DAY_IN_SECONDS)
except BaseException as e:
logging.info('Caught exception "%s"; stopping server...', e)
- server.stop()
+ server.stop(0)
logging.info('Server stopped; exiting.')
if __name__ == '__main__':
diff --git a/src/python/grpcio_test/grpc_interop/test.proto b/src/python/grpcio/tests/interop/test.proto
index b499813e56..9feecc0278 100644
--- a/src/python/grpcio_test/grpc_interop/test.proto
+++ b/src/python/grpcio/tests/interop/test.proto
@@ -33,8 +33,8 @@
syntax = "proto3";
-import "grpc_interop/empty.proto";
-import "grpc_interop/messages.proto";
+import "tests/interop/empty.proto";
+import "tests/interop/messages.proto";
package grpc.testing;
diff --git a/src/python/grpcio_test/grpc_protoc_plugin/__init__.py b/src/python/grpcio/tests/protoc_plugin/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_protoc_plugin/__init__.py
+++ b/src/python/grpcio/tests/protoc_plugin/__init__.py
diff --git a/src/python/grpcio_test/grpc_protoc_plugin/beta_python_plugin_test.py b/src/python/grpcio/tests/protoc_plugin/beta_python_plugin_test.py
index 259b978de2..ba5b219a88 100644
--- a/src/python/grpcio_test/grpc_protoc_plugin/beta_python_plugin_test.py
+++ b/src/python/grpcio/tests/protoc_plugin/beta_python_plugin_test.py
@@ -45,7 +45,7 @@ import unittest
from grpc.beta import implementations
from grpc.framework.foundation import future
from grpc.framework.interfaces.face import face
-from grpc_test.framework.common import test_constants
+from tests.unit.framework.common import test_constants
# Identifiers of entities we expect to find in the generated module.
SERVICER_IDENTIFIER = 'BetaTestServiceServicer'
@@ -218,7 +218,7 @@ class PythonPluginTest(unittest.TestCase):
protoc_plugin_filename = distutils.spawn.find_executable(
'grpc_python_plugin')
test_proto_filename = pkg_resources.resource_filename(
- 'grpc_protoc_plugin', 'test.proto')
+ 'tests.protoc_plugin', 'protoc_plugin_test.proto')
if not os.path.isfile(protoc_command):
# Assume that if we haven't built protoc that it's on the system.
protoc_command = 'protoc'
@@ -237,7 +237,7 @@ class PythonPluginTest(unittest.TestCase):
]
subprocess.check_call(' '.join(cmd), shell=True, env=os.environ,
cwd=os.path.dirname(test_proto_filename))
- sys.path.append(self.outdir)
+ sys.path.insert(0, self.outdir)
def tearDown(self):
try:
@@ -245,22 +245,26 @@ class PythonPluginTest(unittest.TestCase):
except OSError as exc:
if exc.errno != errno.ENOENT:
raise
+ sys.path.remove(self.outdir)
def testImportAttributes(self):
# check that we can access the generated module and its members.
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
self.assertIsNotNone(getattr(test_pb2, SERVICER_IDENTIFIER, None))
self.assertIsNotNone(getattr(test_pb2, STUB_IDENTIFIER, None))
self.assertIsNotNone(getattr(test_pb2, SERVER_FACTORY_IDENTIFIER, None))
self.assertIsNotNone(getattr(test_pb2, STUB_FACTORY_IDENTIFIER, None))
def testUpDown(self):
- import test_pb2
+ import protoc_plugin_test_pb2 as test_pb2
+ reload(test_pb2)
with _CreateService(test_pb2) as (servicer, stub):
request = test_pb2.SimpleRequest(response_size=13)
def testUnaryCall(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
request = test_pb2.SimpleRequest(response_size=13)
response = stub.UnaryCall(request, test_constants.LONG_TIMEOUT)
@@ -268,7 +272,8 @@ class PythonPluginTest(unittest.TestCase):
self.assertEqual(expected_response, response)
def testUnaryCallFuture(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
request = test_pb2.SimpleRequest(response_size=13)
with _CreateService(test_pb2) as (methods, stub):
# Check that the call does not block waiting for the server to respond.
@@ -280,7 +285,8 @@ class PythonPluginTest(unittest.TestCase):
self.assertEqual(expected_response, response)
def testUnaryCallFutureExpired(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
request = test_pb2.SimpleRequest(response_size=13)
with methods.pause():
@@ -290,7 +296,8 @@ class PythonPluginTest(unittest.TestCase):
response_future.result()
def testUnaryCallFutureCancelled(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
request = test_pb2.SimpleRequest(response_size=13)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
@@ -299,7 +306,8 @@ class PythonPluginTest(unittest.TestCase):
self.assertTrue(response_future.cancelled())
def testUnaryCallFutureFailed(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
request = test_pb2.SimpleRequest(response_size=13)
with _CreateService(test_pb2) as (methods, stub):
with methods.fail():
@@ -308,7 +316,8 @@ class PythonPluginTest(unittest.TestCase):
self.assertIsNotNone(response_future.exception())
def testStreamingOutputCall(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
request = _streaming_output_request(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
responses = stub.StreamingOutputCall(
@@ -320,7 +329,8 @@ class PythonPluginTest(unittest.TestCase):
self.assertEqual(expected_response, response)
def testStreamingOutputCallExpired(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
request = _streaming_output_request(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
@@ -330,7 +340,8 @@ class PythonPluginTest(unittest.TestCase):
list(responses)
def testStreamingOutputCallCancelled(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
request = _streaming_output_request(test_pb2)
with _CreateService(test_pb2) as (unused_methods, stub):
responses = stub.StreamingOutputCall(
@@ -341,7 +352,8 @@ class PythonPluginTest(unittest.TestCase):
next(responses)
def testStreamingOutputCallFailed(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
request = _streaming_output_request(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.fail():
@@ -351,7 +363,8 @@ class PythonPluginTest(unittest.TestCase):
next(responses)
def testStreamingInputCall(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
response = stub.StreamingInputCall(
_streaming_input_request_iterator(test_pb2),
@@ -361,7 +374,8 @@ class PythonPluginTest(unittest.TestCase):
self.assertEqual(expected_response, response)
def testStreamingInputCallFuture(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
response_future = stub.StreamingInputCall.future(
@@ -373,7 +387,8 @@ class PythonPluginTest(unittest.TestCase):
self.assertEqual(expected_response, response)
def testStreamingInputCallFutureExpired(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
response_future = stub.StreamingInputCall.future(
@@ -385,7 +400,8 @@ class PythonPluginTest(unittest.TestCase):
response_future.exception(), face.ExpirationError)
def testStreamingInputCallFutureCancelled(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
response_future = stub.StreamingInputCall.future(
@@ -397,7 +413,8 @@ class PythonPluginTest(unittest.TestCase):
response_future.result()
def testStreamingInputCallFutureFailed(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.fail():
response_future = stub.StreamingInputCall.future(
@@ -406,7 +423,8 @@ class PythonPluginTest(unittest.TestCase):
self.assertIsNotNone(response_future.exception())
def testFullDuplexCall(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
responses = stub.FullDuplexCall(
_full_duplex_request_iterator(test_pb2), test_constants.LONG_TIMEOUT)
@@ -417,7 +435,8 @@ class PythonPluginTest(unittest.TestCase):
self.assertEqual(expected_response, response)
def testFullDuplexCallExpired(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
request_iterator = _full_duplex_request_iterator(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.pause():
@@ -427,7 +446,8 @@ class PythonPluginTest(unittest.TestCase):
list(responses)
def testFullDuplexCallCancelled(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
request_iterator = _full_duplex_request_iterator(test_pb2)
responses = stub.FullDuplexCall(
@@ -438,7 +458,8 @@ class PythonPluginTest(unittest.TestCase):
next(responses)
def testFullDuplexCallFailed(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
request_iterator = _full_duplex_request_iterator(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
with methods.fail():
@@ -449,7 +470,8 @@ class PythonPluginTest(unittest.TestCase):
next(responses)
def testHalfDuplexCall(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
with _CreateService(test_pb2) as (methods, stub):
def half_duplex_request_iterator():
request = test_pb2.StreamingOutputCallRequest()
@@ -468,7 +490,8 @@ class PythonPluginTest(unittest.TestCase):
self.assertEqual(expected_response, response)
def testHalfDuplexCallWedged(self):
- import test_pb2 # pylint: disable=g-import-not-at-top
+ import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
+ reload(test_pb2)
condition = threading.Condition()
wait_cell = [False]
@contextlib.contextmanager
diff --git a/src/python/grpcio_test/grpc_protoc_plugin/test.proto b/src/python/grpcio/tests/protoc_plugin/protoc_plugin_test.proto
index 6762a8e7f3..6762a8e7f3 100644
--- a/src/python/grpcio_test/grpc_protoc_plugin/test.proto
+++ b/src/python/grpcio/tests/protoc_plugin/protoc_plugin_test.proto
diff --git a/src/python/grpcio_test/grpc_test/__init__.py b/src/python/grpcio/tests/unit/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/__init__.py
+++ b/src/python/grpcio/tests/unit/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/_adapter/.gitignore b/src/python/grpcio/tests/unit/_adapter/.gitignore
index a6f96cd6db..a6f96cd6db 100644
--- a/src/python/grpcio_test/grpc_test/_adapter/.gitignore
+++ b/src/python/grpcio/tests/unit/_adapter/.gitignore
diff --git a/src/python/grpcio_test/grpc_test/_adapter/__init__.py b/src/python/grpcio/tests/unit/_adapter/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/_adapter/__init__.py
+++ b/src/python/grpcio/tests/unit/_adapter/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/_adapter/_c_test.py b/src/python/grpcio/tests/unit/_adapter/_c_test.py
index fe020e2a9c..fe020e2a9c 100644
--- a/src/python/grpcio_test/grpc_test/_adapter/_c_test.py
+++ b/src/python/grpcio/tests/unit/_adapter/_c_test.py
diff --git a/src/python/grpcio_test/grpc_test/_adapter/_intermediary_low_test.py b/src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py
index 90ad0b9bcb..90ad0b9bcb 100644
--- a/src/python/grpcio_test/grpc_test/_adapter/_intermediary_low_test.py
+++ b/src/python/grpcio/tests/unit/_adapter/_intermediary_low_test.py
diff --git a/src/python/grpcio_test/grpc_test/_adapter/_low_test.py b/src/python/grpcio/tests/unit/_adapter/_low_test.py
index 8115cd0e83..39b6f247b4 100644
--- a/src/python/grpcio_test/grpc_test/_adapter/_low_test.py
+++ b/src/python/grpcio/tests/unit/_adapter/_low_test.py
@@ -34,7 +34,7 @@ import unittest
from grpc import _grpcio_metadata
from grpc._adapter import _types
from grpc._adapter import _low
-from grpc_test import test_common
+from tests.unit import test_common
def wait_for_events(completion_queues, deadline):
diff --git a/src/python/grpcio_test/grpc_test/_adapter/_proto_scenarios.py b/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
index b3d6ec8607..f55a7a23ea 100644
--- a/src/python/grpcio_test/grpc_test/_adapter/_proto_scenarios.py
+++ b/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
@@ -32,7 +32,7 @@
import abc
import threading
-from grpc_test._junkdrawer import math_pb2
+from tests.unit._junkdrawer import math_pb2
class ProtoScenario(object):
diff --git a/src/python/grpcio_test/grpc_test/_core_over_links_base_interface_test.py b/src/python/grpcio/tests/unit/_core_over_links_base_interface_test.py
index cafb6b6eae..efc990421a 100644
--- a/src/python/grpcio_test/grpc_test/_core_over_links_base_interface_test.py
+++ b/src/python/grpcio/tests/unit/_core_over_links_base_interface_test.py
@@ -41,10 +41,10 @@ from grpc._links import service
from grpc.beta import interfaces as beta_interfaces
from grpc.framework.core import implementations
from grpc.framework.interfaces.base import utilities
-from grpc_test import test_common as grpc_test_common
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.interfaces.base import test_cases
-from grpc_test.framework.interfaces.base import test_interfaces
+from tests.unit import test_common as grpc_test_common
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.interfaces.base import test_cases
+from tests.unit.framework.interfaces.base import test_interfaces
class _SerializationBehaviors(
diff --git a/src/python/grpcio_test/grpc_test/_crust_over_core_over_links_face_interface_test.py b/src/python/grpcio/tests/unit/_crust_over_core_over_links_face_interface_test.py
index a4d4dee38c..4faaaadc2b 100644
--- a/src/python/grpcio_test/grpc_test/_crust_over_core_over_links_face_interface_test.py
+++ b/src/python/grpcio/tests/unit/_crust_over_core_over_links_face_interface_test.py
@@ -40,10 +40,10 @@ from grpc.framework.core import implementations as core_implementations
from grpc.framework.crust import implementations as crust_implementations
from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.links import utilities
-from grpc_test import test_common as grpc_test_common
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.interfaces.face import test_cases
-from grpc_test.framework.interfaces.face import test_interfaces
+from tests.unit import test_common as grpc_test_common
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.interfaces.face import test_cases
+from tests.unit.framework.interfaces.face import test_interfaces
class _SerializationBehaviors(
diff --git a/src/python/grpcio_test/grpc_test/_cython/.gitignore b/src/python/grpcio/tests/unit/_cython/.gitignore
index c315029288..c315029288 100644
--- a/src/python/grpcio_test/grpc_test/_cython/.gitignore
+++ b/src/python/grpcio/tests/unit/_cython/.gitignore
diff --git a/src/python/grpcio_test/grpc_test/_cython/__init__.py b/src/python/grpcio/tests/unit/_cython/__init__.py
index b89398809f..b89398809f 100644
--- a/src/python/grpcio_test/grpc_test/_cython/__init__.py
+++ b/src/python/grpcio/tests/unit/_cython/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/_cython/adapter_low_test.py b/src/python/grpcio/tests/unit/_cython/adapter_low_test.py
index f1bec238cf..f1bec238cf 100644
--- a/src/python/grpcio_test/grpc_test/_cython/adapter_low_test.py
+++ b/src/python/grpcio/tests/unit/_cython/adapter_low_test.py
diff --git a/src/python/grpcio_test/grpc_test/_cython/cygrpc_test.py b/src/python/grpcio/tests/unit/_cython/cygrpc_test.py
index 1307a30ca0..84ee5c9eb5 100644
--- a/src/python/grpcio_test/grpc_test/_cython/cygrpc_test.py
+++ b/src/python/grpcio/tests/unit/_cython/cygrpc_test.py
@@ -31,8 +31,8 @@ import time
import unittest
from grpc._cython import cygrpc
-from grpc_test._cython import test_utilities
-from grpc_test import test_common
+from tests.unit._cython import test_utilities
+from tests.unit import test_common
class TypeSmokeTest(unittest.TestCase):
diff --git a/src/python/grpcio_test/grpc_test/_cython/test_utilities.py b/src/python/grpcio/tests/unit/_cython/test_utilities.py
index 21ea3075b4..21ea3075b4 100644
--- a/src/python/grpcio_test/grpc_test/_cython/test_utilities.py
+++ b/src/python/grpcio/tests/unit/_cython/test_utilities.py
diff --git a/src/python/grpcio_test/grpc_test/_junkdrawer/__init__.py b/src/python/grpcio/tests/unit/_junkdrawer/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/_junkdrawer/__init__.py
+++ b/src/python/grpcio/tests/unit/_junkdrawer/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/_junkdrawer/math_pb2.py b/src/python/grpcio/tests/unit/_junkdrawer/math_pb2.py
index 20165955b4..20165955b4 100644
--- a/src/python/grpcio_test/grpc_test/_junkdrawer/math_pb2.py
+++ b/src/python/grpcio/tests/unit/_junkdrawer/math_pb2.py
diff --git a/src/python/grpcio_test/grpc_test/_junkdrawer/stock_pb2.py b/src/python/grpcio/tests/unit/_junkdrawer/stock_pb2.py
index eef18f82d6..eef18f82d6 100644
--- a/src/python/grpcio_test/grpc_test/_junkdrawer/stock_pb2.py
+++ b/src/python/grpcio/tests/unit/_junkdrawer/stock_pb2.py
diff --git a/src/python/grpcio_test/grpc_test/_links/__init__.py b/src/python/grpcio/tests/unit/_links/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/_links/__init__.py
+++ b/src/python/grpcio/tests/unit/_links/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/_links/_lonely_invocation_link_test.py b/src/python/grpcio/tests/unit/_links/_lonely_invocation_link_test.py
index 8e12e8cc22..890755f81c 100644
--- a/src/python/grpcio_test/grpc_test/_links/_lonely_invocation_link_test.py
+++ b/src/python/grpcio/tests/unit/_links/_lonely_invocation_link_test.py
@@ -34,9 +34,9 @@ import unittest
from grpc._adapter import _intermediary_low
from grpc._links import invocation
from grpc.framework.interfaces.links import links
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.interfaces.links import test_cases
-from grpc_test.framework.interfaces.links import test_utilities
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.interfaces.links import test_cases
+from tests.unit.framework.interfaces.links import test_utilities
_NULL_BEHAVIOR = lambda unused_argument: None
diff --git a/src/python/grpcio_test/grpc_test/_links/_proto_scenarios.py b/src/python/grpcio/tests/unit/_links/_proto_scenarios.py
index 0d74d66297..f69ff51b16 100644
--- a/src/python/grpcio_test/grpc_test/_links/_proto_scenarios.py
+++ b/src/python/grpcio/tests/unit/_links/_proto_scenarios.py
@@ -32,8 +32,8 @@
import abc
import threading
-from grpc_test._junkdrawer import math_pb2
-from grpc_test.framework.common import test_constants
+from tests.unit._junkdrawer import math_pb2
+from tests.unit.framework.common import test_constants
class ProtoScenario(object):
diff --git a/src/python/grpcio_test/grpc_test/_links/_transmission_test.py b/src/python/grpcio/tests/unit/_links/_transmission_test.py
index 77e83d5561..888684d197 100644
--- a/src/python/grpcio_test/grpc_test/_links/_transmission_test.py
+++ b/src/python/grpcio/tests/unit/_links/_transmission_test.py
@@ -36,11 +36,11 @@ from grpc._links import invocation
from grpc._links import service
from grpc.beta import interfaces as beta_interfaces
from grpc.framework.interfaces.links import links
-from grpc_test import test_common
-from grpc_test._links import _proto_scenarios
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.interfaces.links import test_cases
-from grpc_test.framework.interfaces.links import test_utilities
+from tests.unit import test_common
+from tests.unit._links import _proto_scenarios
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.interfaces.links import test_cases
+from tests.unit.framework.interfaces.links import test_utilities
_IDENTITY = lambda x: x
diff --git a/src/python/grpcio_test/grpc_test/beta/__init__.py b/src/python/grpcio/tests/unit/beta/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/beta/__init__.py
+++ b/src/python/grpcio/tests/unit/beta/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/beta/_beta_features_test.py b/src/python/grpcio/tests/unit/beta/_beta_features_test.py
index 5916a9e3ea..5a7492ee9e 100644
--- a/src/python/grpcio_test/grpc_test/beta/_beta_features_test.py
+++ b/src/python/grpcio/tests/unit/beta/_beta_features_test.py
@@ -36,9 +36,9 @@ from grpc.beta import implementations
from grpc.beta import interfaces
from grpc.framework.common import cardinality
from grpc.framework.interfaces.face import utilities
-from grpc_test import resources
-from grpc_test.beta import test_utilities
-from grpc_test.framework.common import test_constants
+from tests.unit import resources
+from tests.unit.beta import test_utilities
+from tests.unit.framework.common import test_constants
_SERVER_HOST_OVERRIDE = 'foo.test.google.fr'
@@ -224,5 +224,78 @@ class BetaFeaturesTest(unittest.TestCase):
self.assertEqual(_RESPONSE, response)
+class ContextManagementAndLifecycleTest(unittest.TestCase):
+
+ def setUp(self):
+ self._servicer = _Servicer()
+ self._method_implementations = {
+ (_GROUP, _UNARY_UNARY):
+ utilities.unary_unary_inline(self._servicer.unary_unary),
+ (_GROUP, _UNARY_STREAM):
+ utilities.unary_stream_inline(self._servicer.unary_stream),
+ (_GROUP, _STREAM_UNARY):
+ utilities.stream_unary_inline(self._servicer.stream_unary),
+ (_GROUP, _STREAM_STREAM):
+ utilities.stream_stream_inline(self._servicer.stream_stream),
+ }
+
+ self._cardinalities = {
+ _UNARY_UNARY: cardinality.Cardinality.UNARY_UNARY,
+ _UNARY_STREAM: cardinality.Cardinality.UNARY_STREAM,
+ _STREAM_UNARY: cardinality.Cardinality.STREAM_UNARY,
+ _STREAM_STREAM: cardinality.Cardinality.STREAM_STREAM,
+ }
+
+ self._server_options = implementations.server_options(
+ thread_pool_size=test_constants.POOL_SIZE)
+ self._server_credentials = implementations.ssl_server_credentials(
+ [(resources.private_key(), resources.certificate_chain(),),])
+ self._client_credentials = implementations.ssl_client_credentials(
+ resources.test_root_certificates(), None, None)
+ self._stub_options = implementations.stub_options(
+ thread_pool_size=test_constants.POOL_SIZE)
+
+ def test_stub_context(self):
+ server = implementations.server(
+ self._method_implementations, options=self._server_options)
+ port = server.add_secure_port('[::]:0', self._server_credentials)
+ server.start()
+
+ channel = test_utilities.not_really_secure_channel(
+ 'localhost', port, self._client_credentials, _SERVER_HOST_OVERRIDE)
+ dynamic_stub = implementations.dynamic_stub(
+ channel, _GROUP, self._cardinalities, options=self._stub_options)
+ for _ in range(100):
+ with dynamic_stub:
+ pass
+ for _ in range(10):
+ with dynamic_stub:
+ call_options = interfaces.grpc_call_options(
+ disable_compression=True)
+ response = getattr(dynamic_stub, _UNARY_UNARY)(
+ _REQUEST, test_constants.LONG_TIMEOUT,
+ protocol_options=call_options)
+ self.assertEqual(_RESPONSE, response)
+ self.assertIsNotNone(self._servicer.peer())
+
+ server.stop(test_constants.SHORT_TIMEOUT).wait()
+
+ def test_server_lifecycle(self):
+ for _ in range(100):
+ server = implementations.server(
+ self._method_implementations, options=self._server_options)
+ port = server.add_secure_port('[::]:0', self._server_credentials)
+ server.start()
+ server.stop(test_constants.SHORT_TIMEOUT).wait()
+ for _ in range(100):
+ server = implementations.server(
+ self._method_implementations, options=self._server_options)
+ server.add_secure_port('[::]:0', self._server_credentials)
+ server.add_insecure_port('[::]:0')
+ with server:
+ server.stop(test_constants.SHORT_TIMEOUT)
+ server.stop(test_constants.SHORT_TIMEOUT)
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/src/python/grpcio_test/grpc_test/beta/_connectivity_channel_test.py b/src/python/grpcio/tests/unit/beta/_connectivity_channel_test.py
index b3c05bdb0c..5dc8720639 100644
--- a/src/python/grpcio_test/grpc_test/beta/_connectivity_channel_test.py
+++ b/src/python/grpcio/tests/unit/beta/_connectivity_channel_test.py
@@ -37,7 +37,7 @@ from grpc._adapter import _low
from grpc._adapter import _types
from grpc.beta import _connectivity_channel
from grpc.beta import interfaces
-from grpc_test.framework.common import test_constants
+from tests.unit.framework.common import test_constants
def _drive_completion_queue(completion_queue):
diff --git a/src/python/grpcio_test/grpc_test/beta/_face_interface_test.py b/src/python/grpcio/tests/unit/beta/_face_interface_test.py
index aa33e1e6f8..55c0d20060 100644
--- a/src/python/grpcio_test/grpc_test/beta/_face_interface_test.py
+++ b/src/python/grpcio/tests/unit/beta/_face_interface_test.py
@@ -34,12 +34,12 @@ import unittest
from grpc.beta import implementations
from grpc.beta import interfaces
-from grpc_test import resources
-from grpc_test import test_common as grpc_test_common
-from grpc_test.beta import test_utilities
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.interfaces.face import test_cases
-from grpc_test.framework.interfaces.face import test_interfaces
+from tests.unit import resources
+from tests.unit import test_common as grpc_test_common
+from tests.unit.beta import test_utilities
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.interfaces.face import test_cases
+from tests.unit.framework.interfaces.face import test_interfaces
_SERVER_HOST_OVERRIDE = 'foo.test.google.fr'
diff --git a/src/python/grpcio_test/grpc_test/beta/_not_found_test.py b/src/python/grpcio/tests/unit/beta/_not_found_test.py
index 5feb997fef..44fcd1e13c 100644
--- a/src/python/grpcio_test/grpc_test/beta/_not_found_test.py
+++ b/src/python/grpcio/tests/unit/beta/_not_found_test.py
@@ -34,7 +34,7 @@ import unittest
from grpc.beta import implementations
from grpc.beta import interfaces
from grpc.framework.interfaces.face import face
-from grpc_test.framework.common import test_constants
+from tests.unit.framework.common import test_constants
class NotFoundTest(unittest.TestCase):
diff --git a/src/python/grpcio_test/grpc_test/beta/_utilities_test.py b/src/python/grpcio/tests/unit/beta/_utilities_test.py
index 996cea9118..08ce98e751 100644
--- a/src/python/grpcio_test/grpc_test/beta/_utilities_test.py
+++ b/src/python/grpcio/tests/unit/beta/_utilities_test.py
@@ -38,7 +38,7 @@ from grpc._adapter import _types
from grpc.beta import implementations
from grpc.beta import utilities
from grpc.framework.foundation import future
-from grpc_test.framework.common import test_constants
+from tests.unit.framework.common import test_constants
def _drive_completion_queue(completion_queue):
diff --git a/src/python/grpcio_test/grpc_test/beta/test_utilities.py b/src/python/grpcio/tests/unit/beta/test_utilities.py
index 24a8600e12..24a8600e12 100644
--- a/src/python/grpcio_test/grpc_test/beta/test_utilities.py
+++ b/src/python/grpcio/tests/unit/beta/test_utilities.py
diff --git a/src/python/grpcio_test/grpc_test/credentials/README b/src/python/grpcio/tests/unit/credentials/README
index cb20dcb49f..cb20dcb49f 100644
--- a/src/python/grpcio_test/grpc_test/credentials/README
+++ b/src/python/grpcio/tests/unit/credentials/README
diff --git a/src/python/grpcio_test/grpc_test/credentials/ca.pem b/src/python/grpcio/tests/unit/credentials/ca.pem
index 6c8511a73c..6c8511a73c 100755
--- a/src/python/grpcio_test/grpc_test/credentials/ca.pem
+++ b/src/python/grpcio/tests/unit/credentials/ca.pem
diff --git a/src/python/grpcio_test/grpc_test/credentials/server1.key b/src/python/grpcio/tests/unit/credentials/server1.key
index 143a5b8765..143a5b8765 100755
--- a/src/python/grpcio_test/grpc_test/credentials/server1.key
+++ b/src/python/grpcio/tests/unit/credentials/server1.key
diff --git a/src/python/grpcio_test/grpc_test/credentials/server1.pem b/src/python/grpcio/tests/unit/credentials/server1.pem
index f3d43fcc5b..f3d43fcc5b 100755
--- a/src/python/grpcio_test/grpc_test/credentials/server1.pem
+++ b/src/python/grpcio/tests/unit/credentials/server1.pem
diff --git a/src/python/grpcio_test/grpc_test/framework/__init__.py b/src/python/grpcio/tests/unit/framework/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/framework/__init__.py
+++ b/src/python/grpcio/tests/unit/framework/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/framework/_crust_over_core_face_interface_test.py b/src/python/grpcio/tests/unit/framework/_crust_over_core_face_interface_test.py
index 30bb85f6c3..360ecc95d5 100644
--- a/src/python/grpcio_test/grpc_test/framework/_crust_over_core_face_interface_test.py
+++ b/src/python/grpcio/tests/unit/framework/_crust_over_core_face_interface_test.py
@@ -36,10 +36,10 @@ from grpc.framework.core import implementations as core_implementations
from grpc.framework.crust import implementations as crust_implementations
from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.links import utilities
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.interfaces.face import test_cases
-from grpc_test.framework.interfaces.face import test_interfaces
-from grpc_test.framework.interfaces.links import test_utilities
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.interfaces.face import test_cases
+from tests.unit.framework.interfaces.face import test_interfaces
+from tests.unit.framework.interfaces.links import test_utilities
class _Implementation(test_interfaces.Implementation):
diff --git a/src/python/grpcio_test/grpc_test/framework/common/__init__.py b/src/python/grpcio/tests/unit/framework/common/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/framework/common/__init__.py
+++ b/src/python/grpcio/tests/unit/framework/common/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/framework/common/test_constants.py b/src/python/grpcio/tests/unit/framework/common/test_constants.py
index e1d3c2709d..e1d3c2709d 100644
--- a/src/python/grpcio_test/grpc_test/framework/common/test_constants.py
+++ b/src/python/grpcio/tests/unit/framework/common/test_constants.py
diff --git a/src/python/grpcio_test/grpc_test/framework/common/test_control.py b/src/python/grpcio/tests/unit/framework/common/test_control.py
index 8d6eba5c2c..8d6eba5c2c 100644
--- a/src/python/grpcio_test/grpc_test/framework/common/test_control.py
+++ b/src/python/grpcio/tests/unit/framework/common/test_control.py
diff --git a/src/python/grpcio_test/grpc_test/framework/common/test_coverage.py b/src/python/grpcio/tests/unit/framework/common/test_coverage.py
index a7ed3582c4..a7ed3582c4 100644
--- a/src/python/grpcio_test/grpc_test/framework/common/test_coverage.py
+++ b/src/python/grpcio/tests/unit/framework/common/test_coverage.py
diff --git a/src/python/grpcio_test/grpc_test/framework/core/__init__.py b/src/python/grpcio/tests/unit/framework/core/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/framework/core/__init__.py
+++ b/src/python/grpcio/tests/unit/framework/core/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/framework/core/_base_interface_test.py b/src/python/grpcio/tests/unit/framework/core/_base_interface_test.py
index 8d72f131d5..1310292306 100644
--- a/src/python/grpcio_test/grpc_test/framework/core/_base_interface_test.py
+++ b/src/python/grpcio/tests/unit/framework/core/_base_interface_test.py
@@ -36,9 +36,9 @@ import unittest
from grpc.framework.core import implementations
from grpc.framework.interfaces.base import utilities
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.interfaces.base import test_cases
-from grpc_test.framework.interfaces.base import test_interfaces
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.interfaces.base import test_cases
+from tests.unit.framework.interfaces.base import test_interfaces
class _Implementation(test_interfaces.Implementation):
diff --git a/src/python/grpcio_test/grpc_test/framework/face/__init__.py b/src/python/grpcio/tests/unit/framework/face/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/__init__.py
+++ b/src/python/grpcio/tests/unit/framework/face/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/__init__.py b/src/python/grpcio/tests/unit/framework/face/testing/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/__init__.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/base_util.py b/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
index 1df1529b27..1df1529b27 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/base_util.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/blocking_invocation_inline_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
index 251e1eb68e..0613516421 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/blocking_invocation_inline_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
@@ -34,12 +34,12 @@ import abc
import unittest # pylint: disable=unused-import
from grpc.framework.face import exceptions
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.face.testing import control
-from grpc_test.framework.face.testing import coverage
-from grpc_test.framework.face.testing import digest
-from grpc_test.framework.face.testing import stock_service
-from grpc_test.framework.face.testing import test_case
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.face.testing import control
+from tests.unit.framework.face.testing import coverage
+from tests.unit.framework.face.testing import digest
+from tests.unit.framework.face.testing import stock_service
+from tests.unit.framework.face.testing import test_case
class BlockingInvocationInlineServiceTestCase(
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/callback.py b/src/python/grpcio/tests/unit/framework/face/testing/callback.py
index d0e63c8c56..d0e63c8c56 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/callback.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/callback.py
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/control.py b/src/python/grpcio/tests/unit/framework/face/testing/control.py
index 3960c4e649..3960c4e649 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/control.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/control.py
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/coverage.py b/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
index f3aca113fe..f3aca113fe 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/coverage.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/digest.py b/src/python/grpcio/tests/unit/framework/face/testing/digest.py
index 54ff21779a..39f28b9657 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/digest.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/digest.py
@@ -40,9 +40,9 @@ from grpc.framework.face import exceptions
from grpc.framework.face import interfaces as face_interfaces
from grpc.framework.foundation import stream
from grpc.framework.foundation import stream_util
-from grpc_test.framework.face.testing import control as testing_control # pylint: disable=unused-import
-from grpc_test.framework.face.testing import interfaces # pylint: disable=unused-import
-from grpc_test.framework.face.testing import service as testing_service # pylint: disable=unused-import
+from tests.unit.framework.face.testing import control as testing_control # pylint: disable=unused-import
+from tests.unit.framework.face.testing import interfaces # pylint: disable=unused-import
+from tests.unit.framework.face.testing import service as testing_service # pylint: disable=unused-import
_IDENTITY = lambda x: x
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/event_invocation_synchronous_event_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
index 9df77678eb..179f3a2f67 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
@@ -33,13 +33,13 @@ import abc
import unittest
from grpc.framework.face import interfaces
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.face.testing import callback as testing_callback
-from grpc_test.framework.face.testing import control
-from grpc_test.framework.face.testing import coverage
-from grpc_test.framework.face.testing import digest
-from grpc_test.framework.face.testing import stock_service
-from grpc_test.framework.face.testing import test_case
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.face.testing import callback as testing_callback
+from tests.unit.framework.face.testing import control
+from tests.unit.framework.face.testing import coverage
+from tests.unit.framework.face.testing import digest
+from tests.unit.framework.face.testing import stock_service
+from tests.unit.framework.face.testing import test_case
class EventInvocationSynchronousEventServiceTestCase(
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
index 70d86a0422..485524a356 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
@@ -37,12 +37,12 @@ import unittest
from grpc.framework.face import exceptions
from grpc.framework.foundation import future
from grpc.framework.foundation import logging_pool
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.face.testing import control
-from grpc_test.framework.face.testing import coverage
-from grpc_test.framework.face.testing import digest
-from grpc_test.framework.face.testing import stock_service
-from grpc_test.framework.face.testing import test_case
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.face.testing import control
+from tests.unit.framework.face.testing import coverage
+from tests.unit.framework.face.testing import digest
+from tests.unit.framework.face.testing import stock_service
+from tests.unit.framework.face.testing import test_case
_MAXIMUM_POOL_SIZE = 10
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/interfaces.py b/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
index 5932dabf1e..5932dabf1e 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/service.py b/src/python/grpcio/tests/unit/framework/face/testing/service.py
index ee9d6a3da3..ac0b89b6ee 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/service.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/service.py
@@ -33,7 +33,7 @@ import abc
# interfaces is referenced from specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
-from grpc_test.framework.face.testing import interfaces
+from tests.unit.framework.face.testing import interfaces
class UnaryUnaryTestMethodImplementation(interfaces.Method):
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/stock_service.py b/src/python/grpcio/tests/unit/framework/face/testing/stock_service.py
index 0f83ca4db1..117c723f79 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/stock_service.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/stock_service.py
@@ -33,8 +33,8 @@ from grpc.framework.common import cardinality
from grpc.framework.foundation import abandonment
from grpc.framework.foundation import stream
from grpc.framework.foundation import stream_util
-from grpc_test.framework.face.testing import service
-from grpc_test._junkdrawer import stock_pb2
+from tests.unit.framework.face.testing import service
+from tests.unit._junkdrawer import stock_pb2
SYMBOL_FORMAT = 'test symbol:%03d'
STREAM_LENGTH = 400
diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
index 858d5cf7fd..23d4d919c2 100644
--- a/src/python/grpcio_test/grpc_test/framework/face/testing/test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
@@ -33,7 +33,7 @@ import abc
# face_interfaces and interfaces are referenced in specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
-from grpc_test.framework.face.testing import interfaces # pylint: disable=unused-import
+from tests.unit.framework.face.testing import interfaces # pylint: disable=unused-import
class FaceTestCase(object):
diff --git a/src/python/grpcio_test/grpc_test/framework/foundation/__init__.py b/src/python/grpcio/tests/unit/framework/foundation/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/framework/foundation/__init__.py
+++ b/src/python/grpcio/tests/unit/framework/foundation/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/framework/foundation/_later_test.py b/src/python/grpcio/tests/unit/framework/foundation/_later_test.py
index 6c2459e185..6c2459e185 100644
--- a/src/python/grpcio_test/grpc_test/framework/foundation/_later_test.py
+++ b/src/python/grpcio/tests/unit/framework/foundation/_later_test.py
diff --git a/src/python/grpcio_test/grpc_test/framework/foundation/_logging_pool_test.py b/src/python/grpcio/tests/unit/framework/foundation/_logging_pool_test.py
index 452802da6a..452802da6a 100644
--- a/src/python/grpcio_test/grpc_test/framework/foundation/_logging_pool_test.py
+++ b/src/python/grpcio/tests/unit/framework/foundation/_logging_pool_test.py
diff --git a/src/python/grpcio_test/grpc_test/framework/foundation/stream_testing.py b/src/python/grpcio/tests/unit/framework/foundation/stream_testing.py
index 098a53d5e7..098a53d5e7 100644
--- a/src/python/grpcio_test/grpc_test/framework/foundation/stream_testing.py
+++ b/src/python/grpcio/tests/unit/framework/foundation/stream_testing.py
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/__init__.py b/src/python/grpcio/tests/unit/framework/interfaces/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/__init__.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/base/__init__.py b/src/python/grpcio/tests/unit/framework/interfaces/base/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/base/__init__.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/base/_control.py b/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
index 46a01876d8..38102b198a 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/base/_control.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
@@ -37,10 +37,10 @@ import threading
import time
from grpc.framework.interfaces.base import base
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.interfaces.base import _sequence
-from grpc_test.framework.interfaces.base import _state
-from grpc_test.framework.interfaces.base import test_interfaces # pylint: disable=unused-import
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.interfaces.base import _sequence
+from tests.unit.framework.interfaces.base import _state
+from tests.unit.framework.interfaces.base import test_interfaces # pylint: disable=unused-import
_GROUP = 'base test cases test group'
_METHOD = 'base test cases test method'
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/base/_sequence.py b/src/python/grpcio/tests/unit/framework/interfaces/base/_sequence.py
index f547d91681..571d0e1e63 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/base/_sequence.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/_sequence.py
@@ -33,7 +33,7 @@ import collections
import enum
from grpc.framework.interfaces.base import base
-from grpc_test.framework.common import test_constants
+from tests.unit.framework.common import test_constants
class Invocation(
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/base/_state.py b/src/python/grpcio/tests/unit/framework/interfaces/base/_state.py
index 21cf33aeb6..21cf33aeb6 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/base/_state.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/_state.py
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/base/test_cases.py b/src/python/grpcio/tests/unit/framework/interfaces/base/test_cases.py
index ddda1018c3..4f8e26c9a2 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/base/test_cases.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/test_cases.py
@@ -38,9 +38,9 @@ import unittest
from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.base import base
from grpc.framework.interfaces.base import utilities
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.interfaces.base import _control
-from grpc_test.framework.interfaces.base import test_interfaces
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.interfaces.base import _control
+from tests.unit.framework.interfaces.base import test_interfaces
_SYNCHRONICITY_VARIATION = (('Sync', False), ('Async', True))
@@ -271,6 +271,7 @@ def test_cases(implementation):
'_randomness': randomness,
'_synchronicity_variation': synchronicity_variation[1],
'_controller_creator': controller_creator,
+ '__module__': implementation.__module__,
}))
return test_case_classes
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/base/test_interfaces.py b/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
index 02426ab846..84afd24d47 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/base/test_interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
@@ -131,7 +131,7 @@ class Implementation(object):
@abc.abstractmethod
def service_initial_metadata(self):
- """Provices an operation's service-side initial metadata.
+ """Provides an operation's service-side initial metadata.
Returns:
A value to use for an operation's service-side initial metadata, or
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_3069_test_constant.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_3069_test_constant.py
index 363d9ce8f1..1ea356c0bf 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_3069_test_constant.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_3069_test_constant.py
@@ -30,7 +30,7 @@
"""A test constant working around issue 3069."""
# test_constants is referenced from specification in this module.
-from grpc_test.framework.common import test_constants # pylint: disable=unused-import
+from tests.unit.framework.common import test_constants # pylint: disable=unused-import
# TODO(issue 3069): Replace uses of this constant with
# test_constants.SHORT_TIMEOUT.
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/__init__.py b/src/python/grpcio/tests/unit/framework/interfaces/face/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/__init__.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_blocking_invocation_inline_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
index 2d2a081955..3bcefa601d 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_blocking_invocation_inline_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
@@ -34,13 +34,13 @@ import unittest
# test_interfaces is referenced from specification in this module.
from grpc.framework.interfaces.face import face
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.common import test_control
-from grpc_test.framework.common import test_coverage
-from grpc_test.framework.interfaces.face import _3069_test_constant
-from grpc_test.framework.interfaces.face import _digest
-from grpc_test.framework.interfaces.face import _stock_service
-from grpc_test.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.common import test_control
+from tests.unit.framework.common import test_coverage
+from tests.unit.framework.interfaces.face import _3069_test_constant
+from tests.unit.framework.interfaces.face import _digest
+from tests.unit.framework.interfaces.face import _stock_service
+from tests.unit.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
class TestCase(test_coverage.Coverage, unittest.TestCase):
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_digest.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py
index da56ed7b27..9304b6b1db 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_digest.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py
@@ -39,9 +39,9 @@ from grpc.framework.common import style
from grpc.framework.foundation import stream
from grpc.framework.foundation import stream_util
from grpc.framework.interfaces.face import face
-from grpc_test.framework.common import test_control # pylint: disable=unused-import
-from grpc_test.framework.interfaces.face import _service # pylint: disable=unused-import
-from grpc_test.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
+from tests.unit.framework.common import test_control # pylint: disable=unused-import
+from tests.unit.framework.interfaces.face import _service # pylint: disable=unused-import
+from tests.unit.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
_IDENTITY = lambda x: x
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_event_invocation_synchronous_event_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_event_invocation_synchronous_event_service.py
index 7cb273bf78..34db6c3e55 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_event_invocation_synchronous_event_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_event_invocation_synchronous_event_service.py
@@ -34,14 +34,14 @@ import unittest
# test_interfaces is referenced from specification in this module.
from grpc.framework.interfaces.face import face
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.common import test_control
-from grpc_test.framework.common import test_coverage
-from grpc_test.framework.interfaces.face import _3069_test_constant
-from grpc_test.framework.interfaces.face import _digest
-from grpc_test.framework.interfaces.face import _receiver
-from grpc_test.framework.interfaces.face import _stock_service
-from grpc_test.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.common import test_control
+from tests.unit.framework.common import test_coverage
+from tests.unit.framework.interfaces.face import _3069_test_constant
+from tests.unit.framework.interfaces.face import _digest
+from tests.unit.framework.interfaces.face import _receiver
+from tests.unit.framework.interfaces.face import _stock_service
+from tests.unit.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
class TestCase(test_coverage.Coverage, unittest.TestCase):
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_future_invocation_asynchronous_event_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
index 3032736975..c178f2f108 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
@@ -37,13 +37,13 @@ import unittest
# test_interfaces is referenced from specification in this module.
from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.face import face
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.common import test_control
-from grpc_test.framework.common import test_coverage
-from grpc_test.framework.interfaces.face import _3069_test_constant
-from grpc_test.framework.interfaces.face import _digest
-from grpc_test.framework.interfaces.face import _stock_service
-from grpc_test.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.common import test_control
+from tests.unit.framework.common import test_coverage
+from tests.unit.framework.interfaces.face import _3069_test_constant
+from tests.unit.framework.interfaces.face import _digest
+from tests.unit.framework.interfaces.face import _stock_service
+from tests.unit.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
class _PauseableIterator(object):
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_invocation.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
index 448e845a08..448e845a08 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_invocation.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_receiver.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py
index 2e444ff09d..2e444ff09d 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_receiver.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_receiver.py
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
index e25b8a038c..28941e2ad0 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
@@ -33,7 +33,7 @@ import abc
# face is referenced from specification in this module.
from grpc.framework.interfaces.face import face # pylint: disable=unused-import
-from grpc_test.framework.interfaces.face import test_interfaces
+from tests.unit.framework.interfaces.face import test_interfaces
class UnaryUnaryTestMethodImplementation(test_interfaces.Method):
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_stock_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_stock_service.py
index 808e2c4e36..5299655bb3 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_stock_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_stock_service.py
@@ -32,9 +32,9 @@
from grpc.framework.common import cardinality
from grpc.framework.foundation import abandonment
from grpc.framework.foundation import stream
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.interfaces.face import _service
-from grpc_test._junkdrawer import stock_pb2
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.interfaces.face import _service
+from tests.unit._junkdrawer import stock_pb2
_STOCK_GROUP_NAME = 'Stock'
_SYMBOL_FORMAT = 'test symbol:%03d'
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/test_cases.py b/src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py
index ca623662f7..462829b660 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/test_cases.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/test_cases.py
@@ -33,11 +33,11 @@
import unittest # pylint: disable=unused-import
# test_interfaces is referenced from specification in this module.
-from grpc_test.framework.interfaces.face import _blocking_invocation_inline_service
-from grpc_test.framework.interfaces.face import _event_invocation_synchronous_event_service
-from grpc_test.framework.interfaces.face import _future_invocation_asynchronous_event_service
-from grpc_test.framework.interfaces.face import _invocation
-from grpc_test.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
+from tests.unit.framework.interfaces.face import _blocking_invocation_inline_service
+from tests.unit.framework.interfaces.face import _event_invocation_synchronous_event_service
+from tests.unit.framework.interfaces.face import _future_invocation_asynchronous_event_service
+from tests.unit.framework.interfaces.face import _invocation
+from tests.unit.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
_TEST_CASE_SUPERCLASSES = (
_blocking_invocation_inline_service.TestCase,
@@ -63,5 +63,7 @@ def test_cases(implementation):
test_case_classes.append(
type(invoker_constructor.name() + super_class.NAME, (super_class,),
{'implementation': implementation,
- 'invoker_constructor': invoker_constructor}))
+ 'invoker_constructor': invoker_constructor,
+ '__module__': implementation.__module__,
+ }))
return test_case_classes
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/test_interfaces.py b/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
index b2b5c10fa6..b2b5c10fa6 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/test_interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/links/__init__.py b/src/python/grpcio/tests/unit/framework/interfaces/links/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/links/__init__.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/links/__init__.py
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/links/test_cases.py b/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
index ecf49d9cdb..dace6c23f3 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/links/test_cases.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
@@ -34,8 +34,8 @@ import abc
import unittest # pylint: disable=unused-import
from grpc.framework.interfaces.links import links
-from grpc_test.framework.common import test_constants
-from grpc_test.framework.interfaces.links import test_utilities
+from tests.unit.framework.common import test_constants
+from tests.unit.framework.interfaces.links import test_utilities
def at_least_n_payloads_received_predicate(n):
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/links/test_utilities.py b/src/python/grpcio/tests/unit/framework/interfaces/links/test_utilities.py
index 39c7f2fc63..39c7f2fc63 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/links/test_utilities.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/links/test_utilities.py
diff --git a/src/python/grpcio_test/grpc_test/resources.py b/src/python/grpcio/tests/unit/resources.py
index 2c3045313d..2c3045313d 100644
--- a/src/python/grpcio_test/grpc_test/resources.py
+++ b/src/python/grpcio/tests/unit/resources.py
diff --git a/src/python/grpcio_test/grpc_test/test_common.py b/src/python/grpcio/tests/unit/test_common.py
index 29431bfb9d..29431bfb9d 100644
--- a/src/python/grpcio_test/grpc_test/test_common.py
+++ b/src/python/grpcio/tests/unit/test_common.py
diff --git a/src/python/grpcio/tox.ini b/src/python/grpcio/tox.ini
new file mode 100644
index 0000000000..bfb1ca0cfa
--- /dev/null
+++ b/src/python/grpcio/tox.ini
@@ -0,0 +1,19 @@
+# Tox (http://tox.testrun.org/) is a tool for running tests
+# in multiple virtualenvs. This configuration file will run the
+# test suite on all supported python versions. To use it, "pip install tox"
+# and then run "tox" from this directory.
+
+[tox]
+skipsdist = true
+envlist = py27
+
+[testenv]
+commands =
+ {envpython} setup.py build_py
+ {envpython} setup.py test
+ coverage combine
+ coverage html --include='grpc/*' --omit='grpc/framework/alpha/*','grpc/early_adopter/*','grpc/framework/base/*','grpc/framework/face/*','grpc/_adapter/fore.py','grpc/_adapter/rear.py'
+ coverage report --include='grpc/*' --omit='grpc/framework/alpha/*','grpc/early_adopter/*','grpc/framework/base/*','grpc/framework/face/*','grpc/_adapter/fore.py','grpc/_adapter/rear.py'
+deps =
+ -rrequirements.txt
+passenv = *
diff --git a/src/python/grpcio_test/.gitignore b/src/python/grpcio_test/.gitignore
deleted file mode 100644
index 6158313bde..0000000000
--- a/src/python/grpcio_test/.gitignore
+++ /dev/null
@@ -1,12 +0,0 @@
-MANIFEST
-*.egg-info/
-build/
-dist/
-*.egg
-*.egg/
-*.eggs/
-*_pb2.py
-.coverage
-.coverage.*
-.cache/
-nosetests.xml
diff --git a/src/python/grpcio_test/MANIFEST.in b/src/python/grpcio_test/MANIFEST.in
deleted file mode 100644
index c9327307dc..0000000000
--- a/src/python/grpcio_test/MANIFEST.in
+++ /dev/null
@@ -1,4 +0,0 @@
-graft grpc_interop
-graft grpc_test
-include commands.py
-include requirements.txt
diff --git a/src/python/grpcio_test/commands.py b/src/python/grpcio_test/commands.py
deleted file mode 100644
index edaa2aa72d..0000000000
--- a/src/python/grpcio_test/commands.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright 2015, Google Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-"""Provides distutils command classes for the GRPC Python test setup process."""
-
-import distutils
-import os
-import os.path
-import subprocess
-import sys
-
-import setuptools
-from setuptools.command import build_py
-
-
-class RunTests(setuptools.Command):
- """Command to run all tests via py.test."""
-
- description = ''
- user_options = [('pytest-args=', 'a', 'arguments to pass to py.test')]
-
- def initialize_options(self):
- self.pytest_args = []
-
- def finalize_options(self):
- pass
-
- def run(self):
- # We import here to ensure that setup.py has had a chance to install the
- # relevant package eggs first.
- import pytest
-
- self.run_command('build_proto_modules')
- result = pytest.main(self.pytest_args)
- if result != 0:
- raise SystemExit(result)
-
-
-class BuildProtoModules(setuptools.Command):
- """Command to generate project *_pb2.py modules from proto files."""
-
- description = ''
- user_options = []
-
- def initialize_options(self):
- pass
-
- def finalize_options(self):
- self.protoc_command = distutils.spawn.find_executable('protoc')
- self.grpc_python_plugin_command = distutils.spawn.find_executable(
- 'grpc_python_plugin')
-
- def run(self):
- paths = []
- root_directory = os.getcwd()
- for walk_root, directories, filenames in os.walk(root_directory):
- for filename in filenames:
- if filename.endswith('.proto'):
- paths.append(os.path.join(walk_root, filename))
- command = [
- self.protoc_command,
- '--plugin=protoc-gen-python-grpc={}'.format(
- self.grpc_python_plugin_command),
- '-I {}'.format(root_directory),
- '--python_out={}'.format(root_directory),
- '--python-grpc_out={}'.format(root_directory),
- ] + paths
- try:
- subprocess.check_output(' '.join(command), cwd=root_directory, shell=True,
- stderr=subprocess.STDOUT)
- except subprocess.CalledProcessError as e:
- raise Exception('{}\nOutput:\n{}'.format(e.message, e.output))
-
-
-class BuildPy(build_py.build_py):
- """Custom project build command."""
-
- def run(self):
- self.run_command('build_proto_modules')
- build_py.build_py.run(self)
diff --git a/src/python/grpcio_test/grpc_test/conftest.py b/src/python/grpcio_test/grpc_test/conftest.py
deleted file mode 100644
index 357320ec64..0000000000
--- a/src/python/grpcio_test/grpc_test/conftest.py
+++ /dev/null
@@ -1,60 +0,0 @@
-import types
-import unittest
-
-import pytest
-
-
-class LoadTestsSuiteCollector(pytest.Collector):
-
- def __init__(self, name, parent, suite):
- super(LoadTestsSuiteCollector, self).__init__(name, parent=parent)
- self.suite = suite
- self.obj = suite
-
- def collect(self):
- collected = []
- for case in self.suite:
- if isinstance(case, unittest.TestCase):
- collected.append(LoadTestsCase(case.id(), self, case))
- elif isinstance(case, unittest.TestSuite):
- collected.append(
- LoadTestsSuiteCollector('suite_child_of_mine', self, case))
- return collected
-
- def reportinfo(self):
- return str(self.suite)
-
-
-class LoadTestsCase(pytest.Function):
-
- def __init__(self, name, parent, item):
- super(LoadTestsCase, self).__init__(name, parent, callobj=self._item_run)
- self.item = item
-
- def _item_run(self):
- result = unittest.TestResult()
- self.item(result)
- if result.failures:
- test_method, trace = result.failures[0]
- pytest.fail(trace, False)
- elif result.errors:
- test_method, trace = result.errors[0]
- pytest.fail(trace, False)
- elif result.skipped:
- test_method, reason = result.skipped[0]
- pytest.skip(reason)
-
-
-def pytest_pycollect_makeitem(collector, name, obj):
- if name == 'load_tests' and isinstance(obj, types.FunctionType):
- suite = unittest.TestSuite()
- loader = unittest.TestLoader()
- pattern = '*'
- try:
- # Check that the 'load_tests' object is actually a callable that actually
- # accepts the arguments expected for the load_tests protocol.
- suite = obj(loader, suite, pattern)
- except Exception as e:
- return None
- else:
- return LoadTestsSuiteCollector(name, collector, suite)
diff --git a/src/python/grpcio_test/requirements.txt b/src/python/grpcio_test/requirements.txt
deleted file mode 100644
index fea80ca07f..0000000000
--- a/src/python/grpcio_test/requirements.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-grpcio>=0.11.0b0
-oauth2client>=1.4.7
-protobuf>=3.0.0a3
-pytest>=2.6
-pytest-cov>=2.0
-pytest-xdist>=1.11
diff --git a/src/python/grpcio_test/setup.cfg b/src/python/grpcio_test/setup.cfg
deleted file mode 100644
index 3be93cb918..0000000000
--- a/src/python/grpcio_test/setup.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-[pytest]
-python_files = *_test.py