diff options
Diffstat (limited to 'src/python')
-rw-r--r-- | src/python/grpcio/.gitignore | 9 | ||||
-rw-r--r-- | src/python/grpcio/MANIFEST.in | 3 | ||||
-rw-r--r-- | src/python/grpcio/README.rst (renamed from src/python/src/README.rst) | 0 | ||||
-rw-r--r-- | src/python/grpcio/commands.py | 102 | ||||
-rw-r--r-- | src/python/grpcio/grpc/__init__.py (renamed from src/python/interop/interop/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/.gitignore (renamed from src/python/src/grpc/_adapter/.gitignore) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/__init__.py (renamed from src/python/src/grpc/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_c/module.c (renamed from src/python/src/grpc/_adapter/_c/module.c) | 6 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_c/types.c (renamed from src/python/src/grpc/_adapter/_c/types.c) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_c/types.h (renamed from src/python/src/grpc/_adapter/_c/types.h) | 9 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_c/types/call.c (renamed from src/python/src/grpc/_adapter/_c/types/call.c) | 8 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_c/types/channel.c (renamed from src/python/src/grpc/_adapter/_c/types/channel.c) | 58 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_c/types/client_credentials.c (renamed from src/python/src/grpc/_adapter/_c/types/client_credentials.c) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_c/types/completion_queue.c (renamed from src/python/src/grpc/_adapter/_c/types/completion_queue.c) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_c/types/server.c (renamed from src/python/src/grpc/_adapter/_c/types/server.c) | 4 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_c/types/server_credentials.c (renamed from src/python/src/grpc/_adapter/_c/types/server_credentials.c) | 4 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_c/utility.c (renamed from src/python/src/grpc/_adapter/_c/utility.c) | 21 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_common.py (renamed from src/python/src/grpc/_adapter/_common.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_intermediary_low.py (renamed from src/python/src/grpc/_adapter/_intermediary_low.py) | 2 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_low.py (renamed from src/python/src/grpc/_adapter/_low.py) | 18 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/_types.py (renamed from src/python/src/grpc/_adapter/_types.py) | 95 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/fore.py (renamed from src/python/src/grpc/_adapter/fore.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_adapter/rear.py (renamed from src/python/src/grpc/_adapter/rear.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/.gitignore (renamed from src/python/src/grpc/_cython/.gitignore) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/README.rst (renamed from src/python/src/grpc/_cython/README.rst) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/__init__.py (renamed from src/python/src/grpc/_cython/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/__init__.py (renamed from src/python/src/grpc/_cython/_cygrpc/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/call.pxd (renamed from src/python/src/grpc/_cython/_cygrpc/call.pxd) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/call.pyx (renamed from src/python/src/grpc/_cython/_cygrpc/call.pyx) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd (renamed from src/python/src/grpc/_cython/_cygrpc/channel.pxd) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx (renamed from src/python/src/grpc/_cython/_cygrpc/channel.pyx) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd (renamed from src/python/src/grpc/_cython/_cygrpc/completion_queue.pxd) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx (renamed from src/python/src/grpc/_cython/_cygrpc/completion_queue.pyx) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd (renamed from src/python/src/grpc/_cython/_cygrpc/credentials.pxd) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx (renamed from src/python/src/grpc/_cython/_cygrpc/credentials.pyx) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxd (renamed from src/python/src/grpc/_cython/_cygrpc/grpc.pxd) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/records.pxd (renamed from src/python/src/grpc/_cython/_cygrpc/records.pxd) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/records.pyx (renamed from src/python/src/grpc/_cython/_cygrpc/records.pyx) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/server.pxd (renamed from src/python/src/grpc/_cython/_cygrpc/server.pxd) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/server.pyx (renamed from src/python/src/grpc/_cython/_cygrpc/server.pyx) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/adapter_low.py (renamed from src/python/src/grpc/_cython/adapter_low.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/cygrpc.pyx (renamed from src/python/src/grpc/_cython/cygrpc.pyx) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_links/__init__.py (renamed from src/python/src/grpc/_adapter/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_links/invocation.py (renamed from src/python/src/grpc/_links/invocation.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_links/service.py (renamed from src/python/src/grpc/_links/service.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/early_adopter/__init__.py (renamed from src/python/src/grpc/_junkdrawer/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/early_adopter/implementations.py (renamed from src/python/src/grpc/early_adopter/implementations.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/__init__.py (renamed from src/python/src/grpc/_links/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/alpha/__init__.py (renamed from src/python/src/grpc/framework/alpha/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/alpha/_face_utilities.py (renamed from src/python/src/grpc/framework/alpha/_face_utilities.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/alpha/_reexport.py (renamed from src/python/src/grpc/framework/alpha/_reexport.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/alpha/exceptions.py (renamed from src/python/src/grpc/framework/alpha/exceptions.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/alpha/interfaces.py (renamed from src/python/src/grpc/framework/alpha/interfaces.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/alpha/utilities.py (renamed from src/python/src/grpc/framework/alpha/utilities.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/__init__.py (renamed from src/python/src/grpc/early_adopter/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/_cancellation.py (renamed from src/python/src/grpc/framework/base/_cancellation.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/_constants.py (renamed from src/python/src/grpc/framework/base/_constants.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/_context.py (renamed from src/python/src/grpc/framework/base/_context.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/_emission.py (renamed from src/python/src/grpc/framework/base/_emission.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/_ends.py (renamed from src/python/src/grpc/framework/base/_ends.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/_expiration.py (renamed from src/python/src/grpc/framework/base/_expiration.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/_ingestion.py (renamed from src/python/src/grpc/framework/base/_ingestion.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/_interfaces.py (renamed from src/python/src/grpc/framework/base/_interfaces.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/_reception.py (renamed from src/python/src/grpc/framework/base/_reception.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/_termination.py (renamed from src/python/src/grpc/framework/base/_termination.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/_transmission.py (renamed from src/python/src/grpc/framework/base/_transmission.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/exceptions.py (renamed from src/python/src/grpc/framework/base/exceptions.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/implementations.py (renamed from src/python/src/grpc/framework/base/implementations.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/in_memory.py (renamed from src/python/src/grpc/framework/base/in_memory.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/interfaces.py (renamed from src/python/src/grpc/framework/base/interfaces.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/null.py (renamed from src/python/src/grpc/framework/base/null.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/base/util.py (renamed from src/python/src/grpc/framework/base/util.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/common/__init__.py (renamed from src/python/src/grpc/framework/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/common/cardinality.py (renamed from src/python/src/grpc/framework/common/cardinality.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/common/style.py (renamed from src/python/src/grpc/framework/common/style.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/face/__init__.py (renamed from src/python/src/grpc/framework/base/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/face/_calls.py (renamed from src/python/src/grpc/framework/face/_calls.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/face/_control.py (renamed from src/python/src/grpc/framework/face/_control.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/face/_service.py (renamed from src/python/src/grpc/framework/face/_service.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/face/demonstration.py (renamed from src/python/src/grpc/framework/face/demonstration.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/face/exceptions.py (renamed from src/python/src/grpc/framework/face/exceptions.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/face/implementations.py (renamed from src/python/src/grpc/framework/face/implementations.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/face/interfaces.py (renamed from src/python/src/grpc/framework/face/interfaces.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/face/utilities.py (renamed from src/python/src/grpc/framework/face/utilities.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/foundation/__init__.py (renamed from src/python/src/grpc/framework/common/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/foundation/_timer_future.py (renamed from src/python/src/grpc/framework/foundation/_timer_future.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/foundation/abandonment.py (renamed from src/python/src/grpc/framework/foundation/abandonment.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/foundation/activated.py (renamed from src/python/src/grpc/framework/foundation/activated.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/foundation/callable_util.py (renamed from src/python/src/grpc/framework/foundation/callable_util.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/foundation/future.py (renamed from src/python/src/grpc/framework/foundation/future.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/foundation/later.py (renamed from src/python/src/grpc/framework/foundation/later.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/foundation/logging_pool.py (renamed from src/python/src/grpc/framework/foundation/logging_pool.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/foundation/relay.py (renamed from src/python/src/grpc/framework/foundation/relay.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/foundation/stream.py (renamed from src/python/src/grpc/framework/foundation/stream.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/foundation/stream_util.py (renamed from src/python/src/grpc/framework/foundation/stream_util.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/interfaces/__init__.py (renamed from src/python/src/grpc/framework/face/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/interfaces/links/__init__.py (renamed from src/python/src/grpc/framework/face/testing/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/interfaces/links/links.py (renamed from src/python/src/grpc/framework/interfaces/links/links.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/interfaces/links/utilities.py (renamed from src/python/src/grpc/framework/interfaces/links/utilities.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio/requirements.txt (renamed from src/python/requirements.txt) | 0 | ||||
-rw-r--r-- | src/python/grpcio/setup.cfg | 2 | ||||
-rw-r--r-- | src/python/grpcio/setup.py (renamed from src/python/src/setup.py) | 52 | ||||
-rw-r--r-- | src/python/grpcio_test/.gitignore | 10 | ||||
-rw-r--r-- | src/python/grpcio_test/MANIFEST.in | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/commands.py | 57 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/__init__.py (renamed from src/python/src/grpc/framework/foundation/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/_insecure_interop_test.py (renamed from src/python/interop/interop/_insecure_interop_test.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/_interop_test_case.py (renamed from src/python/interop/interop/_interop_test_case.py) | 5 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/_secure_interop_test.py (renamed from src/python/interop/interop/_secure_interop_test.py) | 6 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/client.py (renamed from src/python/interop/interop/client.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/credentials/README (renamed from src/python/interop/interop/credentials/README) | 0 | ||||
-rwxr-xr-x | src/python/grpcio_test/grpc_interop/credentials/ca.pem (renamed from src/python/interop/interop/credentials/ca.pem) | 0 | ||||
-rwxr-xr-x | src/python/grpcio_test/grpc_interop/credentials/server1.key (renamed from src/python/interop/interop/credentials/server1.key) | 0 | ||||
-rwxr-xr-x | src/python/grpcio_test/grpc_interop/credentials/server1.pem (renamed from src/python/interop/interop/credentials/server1.pem) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/empty_pb2.py (renamed from src/python/interop/interop/empty_pb2.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/messages_pb2.py (renamed from src/python/interop/interop/messages_pb2.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/methods.py (renamed from src/python/interop/interop/methods.py) | 27 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/resources.py (renamed from src/python/interop/interop/resources.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/server.py (renamed from src/python/interop/interop/server.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_interop/test_pb2.py (renamed from src/python/interop/interop/test_pb2.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_protoc_plugin/__init__.py (renamed from src/python/src/grpc/framework/interfaces/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_protoc_plugin/python_plugin_test.py | 541 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_protoc_plugin/test.proto | 139 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/__init__.py (renamed from src/python/src/grpc/framework/interfaces/links/__init__.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/.gitignore | 5 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/__init__.py (renamed from src/python/interop/setup.py) | 27 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/_blocking_invocation_inline_service_test.py (renamed from src/python/src/grpc/_adapter/_blocking_invocation_inline_service_test.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/_c_test.py (renamed from src/python/src/grpc/_adapter/_c_test.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/_event_invocation_synchronous_event_service_test.py (renamed from src/python/src/grpc/_adapter/_event_invocation_synchronous_event_service_test.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/_face_test_case.py (renamed from src/python/src/grpc/_adapter/_face_test_case.py) | 6 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/_future_invocation_asynchronous_event_service_test.py (renamed from src/python/src/grpc/_adapter/_future_invocation_asynchronous_event_service_test.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/_intermediary_low_test.py (renamed from src/python/src/grpc/_adapter/_intermediary_low_test.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/_links_test.py (renamed from src/python/src/grpc/_adapter/_links_test.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/_lonely_rear_link_test.py (renamed from src/python/src/grpc/_adapter/_lonely_rear_link_test.py) | 2 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/_low_test.py (renamed from src/python/src/grpc/_adapter/_low_test.py) | 32 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/_proto_scenarios.py (renamed from src/python/src/grpc/_adapter/_proto_scenarios.py) | 2 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_adapter/_test_links.py (renamed from src/python/src/grpc/_adapter/_test_links.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_cython/.gitignore | 7 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_cython/__init__.py | 28 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_cython/adapter_low_test.py (renamed from src/python/src/grpc/_cython/adapter_low_test.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_cython/cygrpc_test.py (renamed from src/python/src/grpc/_cython/cygrpc_test.py) | 2 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_cython/test_utilities.py (renamed from src/python/src/grpc/_cython/test_utilities.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_junkdrawer/__init__.py | 30 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_junkdrawer/math_pb2.py (renamed from src/python/src/grpc/_junkdrawer/math_pb2.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_junkdrawer/stock_pb2.py (renamed from src/python/src/grpc/_junkdrawer/stock_pb2.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_links/__init__.py | 30 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_links/_lonely_invocation_link_test.py (renamed from src/python/src/grpc/_links/_lonely_invocation_link_test.py) | 6 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_links/_proto_scenarios.py (renamed from src/python/src/grpc/_links/_proto_scenarios.py) | 6 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/_links/_transmission_test.py (renamed from src/python/src/grpc/_links/_transmission_test.py) | 20 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/early_adopter/__init__.py | 30 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/early_adopter/implementations_test.py (renamed from src/python/src/grpc/early_adopter/implementations_test.py) | 2 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/__init__.py | 30 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/base/__init__.py | 30 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/base/implementations_test.py (renamed from src/python/src/grpc/framework/base/implementations_test.py) | 2 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/base/interfaces_test_case.py (renamed from src/python/src/grpc/framework/base/interfaces_test_case.py) | 2 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/common/__init__.py | 30 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/common/test_constants.py (renamed from src/python/src/grpc/framework/common/test_constants.py) | 6 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/common/test_control.py (renamed from src/python/src/grpc/framework/common/test_control.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/common/test_coverage.py (renamed from src/python/src/grpc/framework/common/test_coverage.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/__init__.py | 30 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/_test_case.py (renamed from src/python/src/grpc/framework/face/_test_case.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/blocking_invocation_inline_service_test.py (renamed from src/python/src/grpc/framework/face/blocking_invocation_inline_service_test.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/event_invocation_synchronous_event_service_test.py (renamed from src/python/src/grpc/framework/face/event_invocation_synchronous_event_service_test.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/future_invocation_asynchronous_event_service_test.py (renamed from src/python/src/grpc/framework/face/future_invocation_asynchronous_event_service_test.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/__init__.py | 30 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/base_util.py (renamed from src/python/src/grpc/framework/face/testing/base_util.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/blocking_invocation_inline_service_test_case.py (renamed from src/python/src/grpc/framework/face/testing/blocking_invocation_inline_service_test_case.py) | 44 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/callback.py (renamed from src/python/src/grpc/framework/face/testing/callback.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/control.py (renamed from src/python/src/grpc/framework/face/testing/control.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/coverage.py (renamed from src/python/src/grpc/framework/face/testing/coverage.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/digest.py (renamed from src/python/src/grpc/framework/face/testing/digest.py) | 6 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/event_invocation_synchronous_event_service_test_case.py (renamed from src/python/src/grpc/framework/face/testing/event_invocation_synchronous_event_service_test_case.py) | 76 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py (renamed from src/python/src/grpc/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py) | 55 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/interfaces.py (renamed from src/python/src/grpc/framework/face/testing/interfaces.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/serial.py (renamed from src/python/src/grpc/framework/face/testing/serial.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/service.py (renamed from src/python/src/grpc/framework/face/testing/service.py) | 2 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/stock_service.py (renamed from src/python/src/grpc/framework/face/testing/stock_service.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/face/testing/test_case.py (renamed from src/python/src/grpc/framework/face/testing/test_case.py) | 2 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/foundation/__init__.py | 30 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/foundation/_later_test.py (renamed from src/python/src/grpc/framework/foundation/_later_test.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/foundation/_logging_pool_test.py (renamed from src/python/src/grpc/framework/foundation/_logging_pool_test.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/foundation/stream_testing.py (renamed from src/python/src/grpc/framework/foundation/stream_testing.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/interfaces/__init__.py | 30 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/interfaces/links/__init__.py | 30 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/interfaces/links/test_cases.py (renamed from src/python/src/grpc/framework/interfaces/links/test_cases.py) | 4 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/framework/interfaces/links/test_utilities.py (renamed from src/python/src/grpc/framework/interfaces/links/test_utilities.py) | 0 | ||||
-rw-r--r-- | src/python/grpcio_test/grpc_test/test_common.py | 71 | ||||
-rw-r--r-- | src/python/grpcio_test/requirements.txt | 5 | ||||
-rw-r--r-- | src/python/grpcio_test/setup.cfg | 3 | ||||
-rw-r--r-- | src/python/grpcio_test/setup.py | 84 | ||||
-rw-r--r-- | src/python/src/.gitignore | 4 | ||||
-rw-r--r-- | src/python/src/MANIFEST.in | 1 |
192 files changed, 1843 insertions, 229 deletions
diff --git a/src/python/grpcio/.gitignore b/src/python/grpcio/.gitignore new file mode 100644 index 0000000000..4c02b8d14d --- /dev/null +++ b/src/python/grpcio/.gitignore @@ -0,0 +1,9 @@ +MANIFEST +*.egg-info/ +build/ +dist/ +*.egg +*.egg/ +*.eggs/ +doc/ +_grpcio_metadata.py diff --git a/src/python/grpcio/MANIFEST.in b/src/python/grpcio/MANIFEST.in new file mode 100644 index 0000000000..9583dc7768 --- /dev/null +++ b/src/python/grpcio/MANIFEST.in @@ -0,0 +1,3 @@ +graft grpc +include commands.py +include requirements.txt diff --git a/src/python/src/README.rst b/src/python/grpcio/README.rst index 00bdecf56f..00bdecf56f 100644 --- a/src/python/src/README.rst +++ b/src/python/grpcio/README.rst diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py new file mode 100644 index 0000000000..89c0fbf0f3 --- /dev/null +++ b/src/python/grpcio/commands.py @@ -0,0 +1,102 @@ +# 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 setup process.""" + +import os +import os.path +import sys + +import setuptools +from setuptools.command import build_py + +_CONF_PY_ADDENDUM = """ +extensions.append('sphinx.ext.napoleon') +napoleon_google_docstring = True +napoleon_numpy_docstring = True + +html_theme = 'sphinx_rtd_theme' +""" + + +class SphinxDocumentation(setuptools.Command): + """Command to generate documentation via sphinx.""" + + description = '' + user_options = [] + + def initialize_options(self): + pass + + 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 sphinx + import sphinx.apidoc + metadata = self.distribution.metadata + src_dir = os.path.join( + os.getcwd(), self.distribution.package_dir['grpc']) + sys.path.append(src_dir) + sphinx.apidoc.main([ + '', '--force', '--full', '-H', metadata.name, '-A', metadata.author, + '-V', metadata.version, '-R', metadata.version, + '-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) + sphinx.main(['', os.path.join('doc', 'src'), os.path.join('doc', 'build')]) + + +class BuildProjectMetadata(setuptools.Command): + """Command to generate project metadata in a module.""" + + description = '' + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + with open('grpc/_grpcio_metadata.py', 'w') as module_file: + module_file.write('__version__ = """{}"""'.format( + self.distribution.get_version())) + + +class BuildPy(build_py.build_py): + """Custom project build command.""" + + def run(self): + self.run_command('build_project_metadata') + build_py.build_py.run(self) diff --git a/src/python/interop/interop/__init__.py b/src/python/grpcio/grpc/__init__.py index 7086519106..7086519106 100644 --- a/src/python/interop/interop/__init__.py +++ b/src/python/grpcio/grpc/__init__.py diff --git a/src/python/src/grpc/_adapter/.gitignore b/src/python/grpcio/grpc/_adapter/.gitignore index a6f96cd6db..a6f96cd6db 100644 --- a/src/python/src/grpc/_adapter/.gitignore +++ b/src/python/grpcio/grpc/_adapter/.gitignore diff --git a/src/python/src/grpc/__init__.py b/src/python/grpcio/grpc/_adapter/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/__init__.py +++ b/src/python/grpcio/grpc/_adapter/__init__.py diff --git a/src/python/src/grpc/_adapter/_c/module.c b/src/python/grpcio/grpc/_adapter/_c/module.c index 1f3aedd9d8..9b93b051f6 100644 --- a/src/python/src/grpc/_adapter/_c/module.c +++ b/src/python/grpcio/grpc/_adapter/_c/module.c @@ -53,6 +53,12 @@ PyMODINIT_FUNC init_c(void) { return; } + if (PyModule_AddStringConstant( + module, "PRIMARY_USER_AGENT_KEY", + GRPC_ARG_PRIMARY_USER_AGENT_STRING) < 0) { + return; + } + /* GRPC maintains an internal counter of how many times it has been initialized and handles multiple pairs of grpc_init()/grpc_shutdown() invocations accordingly. */ diff --git a/src/python/src/grpc/_adapter/_c/types.c b/src/python/grpcio/grpc/_adapter/_c/types.c index 8855c32ca6..8855c32ca6 100644 --- a/src/python/src/grpc/_adapter/_c/types.c +++ b/src/python/grpcio/grpc/_adapter/_c/types.c diff --git a/src/python/src/grpc/_adapter/_c/types.h b/src/python/grpcio/grpc/_adapter/_c/types.h index 4e0da4a28a..f646465c63 100644 --- a/src/python/src/grpc/_adapter/_c/types.h +++ b/src/python/grpcio/grpc/_adapter/_c/types.h @@ -113,6 +113,7 @@ Call *pygrpc_Call_new_empty(CompletionQueue *cq); void pygrpc_Call_dealloc(Call *self); PyObject *pygrpc_Call_start_batch(Call *self, PyObject *args, PyObject *kwargs); PyObject *pygrpc_Call_cancel(Call *self, PyObject *args, PyObject *kwargs); +PyObject *pygrpc_Call_peer(Call *self); extern PyTypeObject pygrpc_Call_type; @@ -129,6 +130,11 @@ Channel *pygrpc_Channel_new( void pygrpc_Channel_dealloc(Channel *self); Call *pygrpc_Channel_create_call( Channel *self, PyObject *args, PyObject *kwargs); +PyObject *pygrpc_Channel_check_connectivity_state(Channel *self, PyObject *args, + PyObject *kwargs); +PyObject *pygrpc_Channel_watch_connectivity_state(Channel *self, PyObject *args, + PyObject *kwargs); +PyObject *pygrpc_Channel_target(Channel *self); extern PyTypeObject pygrpc_Channel_type; @@ -181,6 +187,9 @@ pygrpc_tag *pygrpc_produce_request_tag(PyObject *user_tag, Call *empty_call); /* Construct a tag associated with a server shutdown. */ pygrpc_tag *pygrpc_produce_server_shutdown_tag(PyObject *user_tag); +/* Construct a tag associated with a channel state change. */ +pygrpc_tag *pygrpc_produce_channel_state_change_tag(PyObject *user_tag); + /* Frees all resources owned by the tag and the tag itself. */ void pygrpc_discard_tag(pygrpc_tag *tag); diff --git a/src/python/src/grpc/_adapter/_c/types/call.c b/src/python/grpcio/grpc/_adapter/_c/types/call.c index 0739070044..5e46605c45 100644 --- a/src/python/src/grpc/_adapter/_c/types/call.c +++ b/src/python/grpcio/grpc/_adapter/_c/types/call.c @@ -42,6 +42,7 @@ PyMethodDef pygrpc_Call_methods[] = { {"start_batch", (PyCFunction)pygrpc_Call_start_batch, METH_KEYWORDS, ""}, {"cancel", (PyCFunction)pygrpc_Call_cancel, METH_KEYWORDS, ""}, + {"peer", (PyCFunction)pygrpc_Call_peer, METH_NOARGS, ""}, {NULL} }; const char pygrpc_Call_doc[] = "See grpc._adapter._types.Call."; @@ -161,3 +162,10 @@ PyObject *pygrpc_Call_cancel(Call *self, PyObject *args, PyObject *kwargs) { } return PyInt_FromLong(errcode); } + +PyObject *pygrpc_Call_peer(Call *self) { + char *peer = grpc_call_get_peer(self->c_call); + PyObject *py_peer = PyString_FromString(peer); + gpr_free(peer); + return py_peer; +} diff --git a/src/python/src/grpc/_adapter/_c/types/channel.c b/src/python/grpcio/grpc/_adapter/_c/types/channel.c index c235597466..eb9d43d154 100644 --- a/src/python/src/grpc/_adapter/_c/types/channel.c +++ b/src/python/grpcio/grpc/_adapter/_c/types/channel.c @@ -36,10 +36,14 @@ #define PY_SSIZE_T_CLEAN #include <Python.h> #include <grpc/grpc.h> +#include <grpc/support/alloc.h> PyMethodDef pygrpc_Channel_methods[] = { {"create_call", (PyCFunction)pygrpc_Channel_create_call, METH_KEYWORDS, ""}, + {"check_connectivity_state", (PyCFunction)pygrpc_Channel_check_connectivity_state, METH_KEYWORDS, ""}, + {"watch_connectivity_state", (PyCFunction)pygrpc_Channel_watch_connectivity_state, METH_KEYWORDS, ""}, + {"target", (PyCFunction)pygrpc_Channel_target, METH_NOARGS, ""}, {NULL} }; const char pygrpc_Channel_doc[] = "See grpc._adapter._types.Channel."; @@ -104,7 +108,7 @@ Channel *pygrpc_Channel_new( if (creds) { self->c_chan = grpc_secure_channel_create(creds->c_creds, target, &c_args); } else { - self->c_chan = grpc_channel_create(target, &c_args); + self->c_chan = grpc_insecure_channel_create(target, &c_args); } pygrpc_discard_channel_args(c_args); return self; @@ -122,13 +126,61 @@ Call *pygrpc_Channel_create_call( const char *host; double deadline; char *keywords[] = {"cq", "method", "host", "deadline", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!ssd:create_call", keywords, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!szd:create_call", keywords, &pygrpc_CompletionQueue_type, &cq, &method, &host, &deadline)) { return NULL; } call = pygrpc_Call_new_empty(cq); call->c_call = grpc_channel_create_call( - self->c_chan, cq->c_cq, method, host, + self->c_chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq->c_cq, method, host, pygrpc_cast_double_to_gpr_timespec(deadline)); return call; } + +PyObject *pygrpc_Channel_check_connectivity_state( + Channel *self, PyObject *args, PyObject *kwargs) { + PyObject *py_try_to_connect; + int try_to_connect; + char *keywords[] = {"try_to_connect", NULL}; + grpc_connectivity_state state; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:connectivity_state", keywords, + &py_try_to_connect)) { + return NULL; + } + if (!PyBool_Check(py_try_to_connect)) { + Py_XDECREF(py_try_to_connect); + return NULL; + } + try_to_connect = Py_True == py_try_to_connect; + Py_DECREF(py_try_to_connect); + state = grpc_channel_check_connectivity_state(self->c_chan, try_to_connect); + return PyInt_FromLong(state); +} + +PyObject *pygrpc_Channel_watch_connectivity_state( + Channel *self, PyObject *args, PyObject *kwargs) { + PyObject *tag; + double deadline; + int last_observed_state; + CompletionQueue *completion_queue; + char *keywords[] = {"last_observed_state", "deadline", + "completion_queue", "tag"}; + if (!PyArg_ParseTupleAndKeywords( + args, kwargs, "idO!O:watch_connectivity_state", keywords, + &last_observed_state, &deadline, &pygrpc_CompletionQueue_type, + &completion_queue, &tag)) { + return NULL; + } + grpc_channel_watch_connectivity_state( + self->c_chan, (grpc_connectivity_state)last_observed_state, + pygrpc_cast_double_to_gpr_timespec(deadline), completion_queue->c_cq, + pygrpc_produce_channel_state_change_tag(tag)); + Py_RETURN_NONE; +} + +PyObject *pygrpc_Channel_target(Channel *self) { + char *target = grpc_channel_get_target(self->c_chan); + PyObject *py_target = PyString_FromString(target); + gpr_free(target); + return py_target; +} diff --git a/src/python/src/grpc/_adapter/_c/types/client_credentials.c b/src/python/grpcio/grpc/_adapter/_c/types/client_credentials.c index e314c15324..e314c15324 100644 --- a/src/python/src/grpc/_adapter/_c/types/client_credentials.c +++ b/src/python/grpcio/grpc/_adapter/_c/types/client_credentials.c diff --git a/src/python/src/grpc/_adapter/_c/types/completion_queue.c b/src/python/grpcio/grpc/_adapter/_c/types/completion_queue.c index 2dd44b6ddd..2dd44b6ddd 100644 --- a/src/python/src/grpc/_adapter/_c/types/completion_queue.c +++ b/src/python/grpcio/grpc/_adapter/_c/types/completion_queue.c diff --git a/src/python/src/grpc/_adapter/_c/types/server.c b/src/python/grpcio/grpc/_adapter/_c/types/server.c index 2a00f34039..2a11d09d21 100644 --- a/src/python/src/grpc/_adapter/_c/types/server.c +++ b/src/python/grpcio/grpc/_adapter/_c/types/server.c @@ -96,7 +96,7 @@ Server *pygrpc_Server_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) PyObject *py_args; grpc_channel_args c_args; char *keywords[] = {"cq", "args", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O:Channel", keywords, + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O:Server", keywords, &pygrpc_CompletionQueue_type, &cq, &py_args)) { return NULL; } @@ -155,7 +155,7 @@ PyObject *pygrpc_Server_add_http2_port( port = grpc_server_add_secure_http2_port( self->c_serv, addr, creds->c_creds); } else { - port = grpc_server_add_http2_port(self->c_serv, addr); + port = grpc_server_add_insecure_http2_port(self->c_serv, addr); } return PyInt_FromLong(port); diff --git a/src/python/src/grpc/_adapter/_c/types/server_credentials.c b/src/python/grpcio/grpc/_adapter/_c/types/server_credentials.c index f22edbf187..f6859b79d7 100644 --- a/src/python/src/grpc/_adapter/_c/types/server_credentials.c +++ b/src/python/grpcio/grpc/_adapter/_c/types/server_credentials.c @@ -128,8 +128,10 @@ ServerCredentials *pygrpc_ServerCredentials_ssl( } self = (ServerCredentials *)type->tp_alloc(type, 0); + /* TODO: Add a force_client_auth parameter in the python object and pass it + here as the last arg. */ self->c_creds = grpc_ssl_server_credentials_create( - root_certs, key_cert_pairs, num_key_cert_pairs); + root_certs, key_cert_pairs, num_key_cert_pairs, 0); gpr_free(key_cert_pairs); return self; } diff --git a/src/python/src/grpc/_adapter/_c/utility.c b/src/python/grpcio/grpc/_adapter/_c/utility.c index 51f3c9be01..2eea0e18ef 100644 --- a/src/python/src/grpc/_adapter/_c/utility.c +++ b/src/python/grpcio/grpc/_adapter/_c/utility.c @@ -88,6 +88,19 @@ pygrpc_tag *pygrpc_produce_server_shutdown_tag(PyObject *user_tag) { return tag; } +pygrpc_tag *pygrpc_produce_channel_state_change_tag(PyObject *user_tag) { + pygrpc_tag *tag = gpr_malloc(sizeof(pygrpc_tag)); + tag->user_tag = user_tag; + Py_XINCREF(tag->user_tag); + tag->call = NULL; + tag->ops = NULL; + tag->nops = 0; + grpc_call_details_init(&tag->request_call_details); + grpc_metadata_array_init(&tag->request_metadata); + tag->is_new_call = 0; + return tag; +} + void pygrpc_discard_tag(pygrpc_tag *tag) { if (!tag) { return; @@ -139,7 +152,7 @@ PyObject *pygrpc_consume_event(grpc_event event) { } int pygrpc_produce_op(PyObject *op, grpc_op *result) { - static const int OP_TUPLE_SIZE = 5; + static const int OP_TUPLE_SIZE = 6; static const int STATUS_TUPLE_SIZE = 2; static const int TYPE_INDEX = 0; static const int INITIAL_METADATA_INDEX = 1; @@ -148,6 +161,7 @@ int pygrpc_produce_op(PyObject *op, grpc_op *result) { static const int STATUS_INDEX = 4; static const int STATUS_CODE_INDEX = 0; static const int STATUS_DETAILS_INDEX = 1; + static const int WRITE_FLAGS_INDEX = 5; int type; Py_ssize_t message_size; char *message; @@ -170,7 +184,10 @@ int pygrpc_produce_op(PyObject *op, grpc_op *result) { return 0; } c_op.op = type; - c_op.flags = 0; + c_op.flags = PyInt_AsLong(PyTuple_GET_ITEM(op, WRITE_FLAGS_INDEX)); + if (PyErr_Occurred()) { + return 0; + } switch (type) { case GRPC_OP_SEND_INITIAL_METADATA: if (!pygrpc_cast_pyseq_to_send_metadata( diff --git a/src/python/src/grpc/_adapter/_common.py b/src/python/grpcio/grpc/_adapter/_common.py index 492849f4cb..492849f4cb 100644 --- a/src/python/src/grpc/_adapter/_common.py +++ b/src/python/grpcio/grpc/_adapter/_common.py diff --git a/src/python/src/grpc/_adapter/_intermediary_low.py b/src/python/grpcio/grpc/_adapter/_intermediary_low.py index 3c7f0a2619..e7bf9dc462 100644 --- a/src/python/src/grpc/_adapter/_intermediary_low.py +++ b/src/python/grpcio/grpc/_adapter/_intermediary_low.py @@ -127,7 +127,7 @@ class Call(object): def write(self, message, tag): return self._internal.start_batch([ - _types.OpArgs.send_message(message) + _types.OpArgs.send_message(message, 0) ], _TagAdapter(tag, Event.Kind.WRITE_ACCEPTED)) def complete(self, tag): diff --git a/src/python/src/grpc/_adapter/_low.py b/src/python/grpcio/grpc/_adapter/_low.py index dcf67dbc11..147086e725 100644 --- a/src/python/src/grpc/_adapter/_low.py +++ b/src/python/grpcio/grpc/_adapter/_low.py @@ -27,9 +27,12 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +from grpc import _grpcio_metadata from grpc._adapter import _c from grpc._adapter import _types +_USER_AGENT = 'Python-gRPC-{}'.format(_grpcio_metadata.__version__) + ClientCredentials = _c.ClientCredentials ServerCredentials = _c.ServerCredentials @@ -72,10 +75,14 @@ class Call(_types.Call): else: return self.call.cancel(code, details) + def peer(self): + return self.call.peer() + class Channel(_types.Channel): def __init__(self, target, args, creds=None): + args = list(args) + [(_c.PRIMARY_USER_AGENT_KEY, _USER_AGENT)] if creds is None: self.channel = _c.Channel(target, args) else: @@ -84,6 +91,17 @@ class Channel(_types.Channel): def create_call(self, completion_queue, method, host, deadline=None): return Call(self.channel.create_call(completion_queue.completion_queue, method, host, deadline)) + def check_connectivity_state(self, try_to_connect): + return self.channel.check_connectivity_state(try_to_connect) + + def watch_connectivity_state(self, last_observed_state, deadline, + completion_queue, tag): + self.channel.watch_connectivity_state( + last_observed_state, deadline, completion_queue.completion_queue, tag) + + def target(self): + return self.channel.target() + _NO_TAG = object() diff --git a/src/python/src/grpc/_adapter/_types.py b/src/python/grpcio/grpc/_adapter/_types.py index 5ddb1774ea..5470d2de4a 100644 --- a/src/python/src/grpc/_adapter/_types.py +++ b/src/python/grpcio/grpc/_adapter/_types.py @@ -31,13 +31,12 @@ import abc import collections import enum -# TODO(atash): decide whether or not to move these enums to the _c module to -# force build errors with upstream changes. class GrpcChannelArgumentKeys(enum.Enum): """Mirrors keys used in grpc_channel_args for GRPC-specific arguments.""" SSL_TARGET_NAME_OVERRIDE = 'grpc.ssl_target_name_override' + @enum.unique class CallError(enum.IntEnum): """Mirrors grpc_call_error in the C core.""" @@ -53,6 +52,7 @@ class CallError(enum.IntEnum): ERROR_INVALID_FLAGS = 9 ERROR_INVALID_METADATA = 10 + @enum.unique class StatusCode(enum.IntEnum): """Mirrors grpc_status_code in the C core.""" @@ -74,6 +74,14 @@ class StatusCode(enum.IntEnum): DATA_LOSS = 15 UNAUTHENTICATED = 16 + +@enum.unique +class OpWriteFlags(enum.IntEnum): + """Mirrors defined write-flag constants in the C core.""" + WRITE_BUFFER_HINT = 1 + WRITE_NO_COMPRESS = 2 + + @enum.unique class OpType(enum.IntEnum): """Mirrors grpc_op_type in the C core.""" @@ -86,12 +94,24 @@ class OpType(enum.IntEnum): RECV_STATUS_ON_CLIENT = 6 RECV_CLOSE_ON_SERVER = 7 + @enum.unique class EventType(enum.IntEnum): """Mirrors grpc_completion_type in the C core.""" - QUEUE_SHUTDOWN = 0 - QUEUE_TIMEOUT = 1 # if seen on the Python side, something went horridly wrong - OP_COMPLETE = 2 + QUEUE_SHUTDOWN = 0 + QUEUE_TIMEOUT = 1 # if seen on the Python side, something went horridly wrong + OP_COMPLETE = 2 + + +@enum.unique +class ConnectivityState(enum.IntEnum): + """Mirrors grpc_connectivity_state in the C core.""" + IDLE = 0 + CONNECTING = 1 + READY = 2 + TRANSIENT_FAILURE = 3 + FATAL_FAILURE = 4 + class Status(collections.namedtuple( 'Status', [ @@ -105,6 +125,7 @@ class Status(collections.namedtuple( details (str): ... """ + class CallDetails(collections.namedtuple( 'CallDetails', [ 'method', @@ -119,6 +140,7 @@ class CallDetails(collections.namedtuple( deadline (float): ... """ + class OpArgs(collections.namedtuple( 'OpArgs', [ 'type', @@ -126,6 +148,7 @@ class OpArgs(collections.namedtuple( 'trailing_metadata', 'message', 'status', + 'write_flags', ])): """Arguments passed into a GRPC operation. @@ -138,39 +161,40 @@ class OpArgs(collections.namedtuple( message (bytes): Only valid if type == OpType.SEND_MESSAGE, else is None. status (Status): Only valid if type == OpType.SEND_STATUS_FROM_SERVER, else is None. + write_flags (int): a bit OR'ing of 0 or more OpWriteFlags values. """ @staticmethod def send_initial_metadata(initial_metadata): - return OpArgs(OpType.SEND_INITIAL_METADATA, initial_metadata, None, None, None) + return OpArgs(OpType.SEND_INITIAL_METADATA, initial_metadata, None, None, None, 0) @staticmethod - def send_message(message): - return OpArgs(OpType.SEND_MESSAGE, None, None, message, None) + def send_message(message, flags): + return OpArgs(OpType.SEND_MESSAGE, None, None, message, None, flags) @staticmethod def send_close_from_client(): - return OpArgs(OpType.SEND_CLOSE_FROM_CLIENT, None, None, None, None) + return OpArgs(OpType.SEND_CLOSE_FROM_CLIENT, None, None, None, None, 0) @staticmethod def send_status_from_server(trailing_metadata, status_code, status_details): - return OpArgs(OpType.SEND_STATUS_FROM_SERVER, None, trailing_metadata, None, Status(status_code, status_details)) + return OpArgs(OpType.SEND_STATUS_FROM_SERVER, None, trailing_metadata, None, Status(status_code, status_details), 0) @staticmethod def recv_initial_metadata(): - return OpArgs(OpType.RECV_INITIAL_METADATA, None, None, None, None); + return OpArgs(OpType.RECV_INITIAL_METADATA, None, None, None, None, 0); @staticmethod def recv_message(): - return OpArgs(OpType.RECV_MESSAGE, None, None, None, None) + return OpArgs(OpType.RECV_MESSAGE, None, None, None, None, 0) @staticmethod def recv_status_on_client(): - return OpArgs(OpType.RECV_STATUS_ON_CLIENT, None, None, None, None) + return OpArgs(OpType.RECV_STATUS_ON_CLIENT, None, None, None, None, 0) @staticmethod def recv_close_on_server(): - return OpArgs(OpType.RECV_CLOSE_ON_SERVER, None, None, None, None) + return OpArgs(OpType.RECV_CLOSE_ON_SERVER, None, None, None, None, 0) class OpResult(collections.namedtuple( @@ -290,6 +314,15 @@ class Call: """ return CallError.ERROR + @abc.abstractmethod + def peer(self): + """Get the peer of this call. + + Returns: + str: the peer of this call. + """ + return None + class Channel: __metaclass__ = abc.ABCMeta @@ -321,6 +354,40 @@ class Channel: """ return None + @abc.abstractmethod + def check_connectivity_state(self, try_to_connect): + """Check and optionally repair the connectivity state of the channel. + + Args: + try_to_connect (bool): whether or not to try to connect the channel if + disconnected. + + Returns: + ConnectivityState: state of the channel at the time of this invocation. + """ + return None + + @abc.abstractmethod + def watch_connectivity_state(self, last_observed_state, deadline, + completion_queue, tag): + """Watch for connectivity state changes from the last_observed_state. + + Args: + last_observed_state (ConnectivityState): ... + deadline (float): ... + completion_queue (CompletionQueue): ... + tag (object) ... + """ + + @abc.abstractmethod + def target(self): + """Get the target of this channel. + + Returns: + str: the target of this channel. + """ + return None + class Server: __metaclass__ = abc.ABCMeta diff --git a/src/python/src/grpc/_adapter/fore.py b/src/python/grpcio/grpc/_adapter/fore.py index 7d88bda263..7d88bda263 100644 --- a/src/python/src/grpc/_adapter/fore.py +++ b/src/python/grpcio/grpc/_adapter/fore.py diff --git a/src/python/src/grpc/_adapter/rear.py b/src/python/grpcio/grpc/_adapter/rear.py index fd6f45f7a7..fd6f45f7a7 100644 --- a/src/python/src/grpc/_adapter/rear.py +++ b/src/python/grpcio/grpc/_adapter/rear.py diff --git a/src/python/src/grpc/_cython/.gitignore b/src/python/grpcio/grpc/_cython/.gitignore index c315029288..c315029288 100644 --- a/src/python/src/grpc/_cython/.gitignore +++ b/src/python/grpcio/grpc/_cython/.gitignore diff --git a/src/python/src/grpc/_cython/README.rst b/src/python/grpcio/grpc/_cython/README.rst index c0e66734e8..c0e66734e8 100644 --- a/src/python/src/grpc/_cython/README.rst +++ b/src/python/grpcio/grpc/_cython/README.rst diff --git a/src/python/src/grpc/_cython/__init__.py b/src/python/grpcio/grpc/_cython/__init__.py index b89398809f..b89398809f 100644 --- a/src/python/src/grpc/_cython/__init__.py +++ b/src/python/grpcio/grpc/_cython/__init__.py diff --git a/src/python/src/grpc/_cython/_cygrpc/__init__.py b/src/python/grpcio/grpc/_cython/_cygrpc/__init__.py index b89398809f..b89398809f 100644 --- a/src/python/src/grpc/_cython/_cygrpc/__init__.py +++ b/src/python/grpcio/grpc/_cython/_cygrpc/__init__.py diff --git a/src/python/src/grpc/_cython/_cygrpc/call.pxd b/src/python/grpcio/grpc/_cython/_cygrpc/call.pxd index fe9b81e3d3..fe9b81e3d3 100644 --- a/src/python/src/grpc/_cython/_cygrpc/call.pxd +++ b/src/python/grpcio/grpc/_cython/_cygrpc/call.pxd diff --git a/src/python/src/grpc/_cython/_cygrpc/call.pyx b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx index 4349786b3a..4349786b3a 100644 --- a/src/python/src/grpc/_cython/_cygrpc/call.pyx +++ b/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx diff --git a/src/python/src/grpc/_cython/_cygrpc/channel.pxd b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd index 3e341bf222..3e341bf222 100644 --- a/src/python/src/grpc/_cython/_cygrpc/channel.pxd +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd diff --git a/src/python/src/grpc/_cython/_cygrpc/channel.pyx b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx index b20313818d..b20313818d 100644 --- a/src/python/src/grpc/_cython/_cygrpc/channel.pyx +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx diff --git a/src/python/src/grpc/_cython/_cygrpc/completion_queue.pxd b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd index fd562ad75b..fd562ad75b 100644 --- a/src/python/src/grpc/_cython/_cygrpc/completion_queue.pxd +++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd diff --git a/src/python/src/grpc/_cython/_cygrpc/completion_queue.pyx b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx index 886d85360a..886d85360a 100644 --- a/src/python/src/grpc/_cython/_cygrpc/completion_queue.pyx +++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx diff --git a/src/python/src/grpc/_cython/_cygrpc/credentials.pxd b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd index 6b74a267e0..6b74a267e0 100644 --- a/src/python/src/grpc/_cython/_cygrpc/credentials.pxd +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd diff --git a/src/python/src/grpc/_cython/_cygrpc/credentials.pyx b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx index 2d74702fbd..2d74702fbd 100644 --- a/src/python/src/grpc/_cython/_cygrpc/credentials.pyx +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx diff --git a/src/python/src/grpc/_cython/_cygrpc/grpc.pxd b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxd index d065383587..d065383587 100644 --- a/src/python/src/grpc/_cython/_cygrpc/grpc.pxd +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxd diff --git a/src/python/src/grpc/_cython/_cygrpc/records.pxd b/src/python/grpcio/grpc/_cython/_cygrpc/records.pxd index 9ee487882a..9ee487882a 100644 --- a/src/python/src/grpc/_cython/_cygrpc/records.pxd +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pxd diff --git a/src/python/src/grpc/_cython/_cygrpc/records.pyx b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx index 4814769fd2..4814769fd2 100644 --- a/src/python/src/grpc/_cython/_cygrpc/records.pyx +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx diff --git a/src/python/src/grpc/_cython/_cygrpc/server.pxd b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd index 0257542a03..0257542a03 100644 --- a/src/python/src/grpc/_cython/_cygrpc/server.pxd +++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd diff --git a/src/python/src/grpc/_cython/_cygrpc/server.pyx b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx index dcf9d38337..dcf9d38337 100644 --- a/src/python/src/grpc/_cython/_cygrpc/server.pyx +++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx diff --git a/src/python/src/grpc/_cython/adapter_low.py b/src/python/grpcio/grpc/_cython/adapter_low.py index 2bb468eece..2bb468eece 100644 --- a/src/python/src/grpc/_cython/adapter_low.py +++ b/src/python/grpcio/grpc/_cython/adapter_low.py diff --git a/src/python/src/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx index f4d9661580..f4d9661580 100644 --- a/src/python/src/grpc/_cython/cygrpc.pyx +++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx diff --git a/src/python/src/grpc/_adapter/__init__.py b/src/python/grpcio/grpc/_links/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/_adapter/__init__.py +++ b/src/python/grpcio/grpc/_links/__init__.py diff --git a/src/python/src/grpc/_links/invocation.py b/src/python/grpcio/grpc/_links/invocation.py index 0058ae91f8..0058ae91f8 100644 --- a/src/python/src/grpc/_links/invocation.py +++ b/src/python/grpcio/grpc/_links/invocation.py diff --git a/src/python/src/grpc/_links/service.py b/src/python/grpcio/grpc/_links/service.py index 7783e91824..7783e91824 100644 --- a/src/python/src/grpc/_links/service.py +++ b/src/python/grpcio/grpc/_links/service.py diff --git a/src/python/src/grpc/_junkdrawer/__init__.py b/src/python/grpcio/grpc/early_adopter/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/_junkdrawer/__init__.py +++ b/src/python/grpcio/grpc/early_adopter/__init__.py diff --git a/src/python/src/grpc/early_adopter/implementations.py b/src/python/grpcio/grpc/early_adopter/implementations.py index 10919fae69..10919fae69 100644 --- a/src/python/src/grpc/early_adopter/implementations.py +++ b/src/python/grpcio/grpc/early_adopter/implementations.py diff --git a/src/python/src/grpc/_links/__init__.py b/src/python/grpcio/grpc/framework/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/_links/__init__.py +++ b/src/python/grpcio/grpc/framework/__init__.py diff --git a/src/python/src/grpc/framework/alpha/__init__.py b/src/python/grpcio/grpc/framework/alpha/__init__.py index b89398809f..b89398809f 100644 --- a/src/python/src/grpc/framework/alpha/__init__.py +++ b/src/python/grpcio/grpc/framework/alpha/__init__.py diff --git a/src/python/src/grpc/framework/alpha/_face_utilities.py b/src/python/grpcio/grpc/framework/alpha/_face_utilities.py index fb0cfe426d..fb0cfe426d 100644 --- a/src/python/src/grpc/framework/alpha/_face_utilities.py +++ b/src/python/grpcio/grpc/framework/alpha/_face_utilities.py diff --git a/src/python/src/grpc/framework/alpha/_reexport.py b/src/python/grpcio/grpc/framework/alpha/_reexport.py index 198cb95ad5..198cb95ad5 100644 --- a/src/python/src/grpc/framework/alpha/_reexport.py +++ b/src/python/grpcio/grpc/framework/alpha/_reexport.py diff --git a/src/python/src/grpc/framework/alpha/exceptions.py b/src/python/grpcio/grpc/framework/alpha/exceptions.py index 5234d3b91c..5234d3b91c 100644 --- a/src/python/src/grpc/framework/alpha/exceptions.py +++ b/src/python/grpcio/grpc/framework/alpha/exceptions.py diff --git a/src/python/src/grpc/framework/alpha/interfaces.py b/src/python/grpcio/grpc/framework/alpha/interfaces.py index 8380567c97..8380567c97 100644 --- a/src/python/src/grpc/framework/alpha/interfaces.py +++ b/src/python/grpcio/grpc/framework/alpha/interfaces.py diff --git a/src/python/src/grpc/framework/alpha/utilities.py b/src/python/grpcio/grpc/framework/alpha/utilities.py index 7d7f78f5e4..7d7f78f5e4 100644 --- a/src/python/src/grpc/framework/alpha/utilities.py +++ b/src/python/grpcio/grpc/framework/alpha/utilities.py diff --git a/src/python/src/grpc/early_adopter/__init__.py b/src/python/grpcio/grpc/framework/base/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/early_adopter/__init__.py +++ b/src/python/grpcio/grpc/framework/base/__init__.py diff --git a/src/python/src/grpc/framework/base/_cancellation.py b/src/python/grpcio/grpc/framework/base/_cancellation.py index ffbc90668f..ffbc90668f 100644 --- a/src/python/src/grpc/framework/base/_cancellation.py +++ b/src/python/grpcio/grpc/framework/base/_cancellation.py diff --git a/src/python/src/grpc/framework/base/_constants.py b/src/python/grpcio/grpc/framework/base/_constants.py index 8fbdc82782..8fbdc82782 100644 --- a/src/python/src/grpc/framework/base/_constants.py +++ b/src/python/grpcio/grpc/framework/base/_constants.py diff --git a/src/python/src/grpc/framework/base/_context.py b/src/python/grpcio/grpc/framework/base/_context.py index d84871d639..d84871d639 100644 --- a/src/python/src/grpc/framework/base/_context.py +++ b/src/python/grpcio/grpc/framework/base/_context.py diff --git a/src/python/src/grpc/framework/base/_emission.py b/src/python/grpcio/grpc/framework/base/_emission.py index 1829669a72..1829669a72 100644 --- a/src/python/src/grpc/framework/base/_emission.py +++ b/src/python/grpcio/grpc/framework/base/_emission.py diff --git a/src/python/src/grpc/framework/base/_ends.py b/src/python/grpcio/grpc/framework/base/_ends.py index 176f3ac06e..176f3ac06e 100644 --- a/src/python/src/grpc/framework/base/_ends.py +++ b/src/python/grpcio/grpc/framework/base/_ends.py diff --git a/src/python/src/grpc/framework/base/_expiration.py b/src/python/grpcio/grpc/framework/base/_expiration.py index 17acbef4c1..17acbef4c1 100644 --- a/src/python/src/grpc/framework/base/_expiration.py +++ b/src/python/grpcio/grpc/framework/base/_expiration.py diff --git a/src/python/src/grpc/framework/base/_ingestion.py b/src/python/grpcio/grpc/framework/base/_ingestion.py index 06d5b92f0b..06d5b92f0b 100644 --- a/src/python/src/grpc/framework/base/_ingestion.py +++ b/src/python/grpcio/grpc/framework/base/_ingestion.py diff --git a/src/python/src/grpc/framework/base/_interfaces.py b/src/python/grpcio/grpc/framework/base/_interfaces.py index d88cf76590..d88cf76590 100644 --- a/src/python/src/grpc/framework/base/_interfaces.py +++ b/src/python/grpcio/grpc/framework/base/_interfaces.py diff --git a/src/python/src/grpc/framework/base/_reception.py b/src/python/grpcio/grpc/framework/base/_reception.py index dd428964f1..dd428964f1 100644 --- a/src/python/src/grpc/framework/base/_reception.py +++ b/src/python/grpcio/grpc/framework/base/_reception.py diff --git a/src/python/src/grpc/framework/base/_termination.py b/src/python/grpcio/grpc/framework/base/_termination.py index ddcbc60293..ddcbc60293 100644 --- a/src/python/src/grpc/framework/base/_termination.py +++ b/src/python/grpcio/grpc/framework/base/_termination.py diff --git a/src/python/src/grpc/framework/base/_transmission.py b/src/python/grpcio/grpc/framework/base/_transmission.py index 6845129234..6845129234 100644 --- a/src/python/src/grpc/framework/base/_transmission.py +++ b/src/python/grpcio/grpc/framework/base/_transmission.py diff --git a/src/python/src/grpc/framework/base/exceptions.py b/src/python/grpcio/grpc/framework/base/exceptions.py index b8f4752184..b8f4752184 100644 --- a/src/python/src/grpc/framework/base/exceptions.py +++ b/src/python/grpcio/grpc/framework/base/exceptions.py diff --git a/src/python/src/grpc/framework/base/implementations.py b/src/python/grpcio/grpc/framework/base/implementations.py index 5656f9f981..5656f9f981 100644 --- a/src/python/src/grpc/framework/base/implementations.py +++ b/src/python/grpcio/grpc/framework/base/implementations.py diff --git a/src/python/src/grpc/framework/base/in_memory.py b/src/python/grpcio/grpc/framework/base/in_memory.py index c92d0bc663..c92d0bc663 100644 --- a/src/python/src/grpc/framework/base/in_memory.py +++ b/src/python/grpcio/grpc/framework/base/in_memory.py diff --git a/src/python/src/grpc/framework/base/interfaces.py b/src/python/grpcio/grpc/framework/base/interfaces.py index e22c10d975..e22c10d975 100644 --- a/src/python/src/grpc/framework/base/interfaces.py +++ b/src/python/grpcio/grpc/framework/base/interfaces.py diff --git a/src/python/src/grpc/framework/base/null.py b/src/python/grpcio/grpc/framework/base/null.py index 1e30d4557b..1e30d4557b 100644 --- a/src/python/src/grpc/framework/base/null.py +++ b/src/python/grpcio/grpc/framework/base/null.py diff --git a/src/python/src/grpc/framework/base/util.py b/src/python/grpcio/grpc/framework/base/util.py index c832c826cf..c832c826cf 100644 --- a/src/python/src/grpc/framework/base/util.py +++ b/src/python/grpcio/grpc/framework/base/util.py diff --git a/src/python/src/grpc/framework/__init__.py b/src/python/grpcio/grpc/framework/common/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/framework/__init__.py +++ b/src/python/grpcio/grpc/framework/common/__init__.py diff --git a/src/python/src/grpc/framework/common/cardinality.py b/src/python/grpcio/grpc/framework/common/cardinality.py index 610425e803..610425e803 100644 --- a/src/python/src/grpc/framework/common/cardinality.py +++ b/src/python/grpcio/grpc/framework/common/cardinality.py diff --git a/src/python/src/grpc/framework/common/style.py b/src/python/grpcio/grpc/framework/common/style.py index 6ae694bdcb..6ae694bdcb 100644 --- a/src/python/src/grpc/framework/common/style.py +++ b/src/python/grpcio/grpc/framework/common/style.py diff --git a/src/python/src/grpc/framework/base/__init__.py b/src/python/grpcio/grpc/framework/face/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/framework/base/__init__.py +++ b/src/python/grpcio/grpc/framework/face/__init__.py diff --git a/src/python/src/grpc/framework/face/_calls.py b/src/python/grpcio/grpc/framework/face/_calls.py index 87edeb0f0e..87edeb0f0e 100644 --- a/src/python/src/grpc/framework/face/_calls.py +++ b/src/python/grpcio/grpc/framework/face/_calls.py diff --git a/src/python/src/grpc/framework/face/_control.py b/src/python/grpcio/grpc/framework/face/_control.py index e918907b74..e918907b74 100644 --- a/src/python/src/grpc/framework/face/_control.py +++ b/src/python/grpcio/grpc/framework/face/_control.py diff --git a/src/python/src/grpc/framework/face/_service.py b/src/python/grpcio/grpc/framework/face/_service.py index cdf413356a..cdf413356a 100644 --- a/src/python/src/grpc/framework/face/_service.py +++ b/src/python/grpcio/grpc/framework/face/_service.py diff --git a/src/python/src/grpc/framework/face/demonstration.py b/src/python/grpcio/grpc/framework/face/demonstration.py index f6b4b609ff..f6b4b609ff 100644 --- a/src/python/src/grpc/framework/face/demonstration.py +++ b/src/python/grpcio/grpc/framework/face/demonstration.py diff --git a/src/python/src/grpc/framework/face/exceptions.py b/src/python/grpcio/grpc/framework/face/exceptions.py index f112df70bc..f112df70bc 100644 --- a/src/python/src/grpc/framework/face/exceptions.py +++ b/src/python/grpcio/grpc/framework/face/exceptions.py diff --git a/src/python/src/grpc/framework/face/implementations.py b/src/python/grpcio/grpc/framework/face/implementations.py index 4a6de52974..4a6de52974 100644 --- a/src/python/src/grpc/framework/face/implementations.py +++ b/src/python/grpcio/grpc/framework/face/implementations.py diff --git a/src/python/src/grpc/framework/face/interfaces.py b/src/python/grpcio/grpc/framework/face/interfaces.py index b7cc4c1169..b7cc4c1169 100644 --- a/src/python/src/grpc/framework/face/interfaces.py +++ b/src/python/grpcio/grpc/framework/face/interfaces.py diff --git a/src/python/src/grpc/framework/face/utilities.py b/src/python/grpcio/grpc/framework/face/utilities.py index a63fe8c60d..a63fe8c60d 100644 --- a/src/python/src/grpc/framework/face/utilities.py +++ b/src/python/grpcio/grpc/framework/face/utilities.py diff --git a/src/python/src/grpc/framework/common/__init__.py b/src/python/grpcio/grpc/framework/foundation/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/framework/common/__init__.py +++ b/src/python/grpcio/grpc/framework/foundation/__init__.py diff --git a/src/python/src/grpc/framework/foundation/_timer_future.py b/src/python/grpcio/grpc/framework/foundation/_timer_future.py index 2c9996aa9d..2c9996aa9d 100644 --- a/src/python/src/grpc/framework/foundation/_timer_future.py +++ b/src/python/grpcio/grpc/framework/foundation/_timer_future.py diff --git a/src/python/src/grpc/framework/foundation/abandonment.py b/src/python/grpcio/grpc/framework/foundation/abandonment.py index 960b4d06b4..960b4d06b4 100644 --- a/src/python/src/grpc/framework/foundation/abandonment.py +++ b/src/python/grpcio/grpc/framework/foundation/abandonment.py diff --git a/src/python/src/grpc/framework/foundation/activated.py b/src/python/grpcio/grpc/framework/foundation/activated.py index 426a71c705..426a71c705 100644 --- a/src/python/src/grpc/framework/foundation/activated.py +++ b/src/python/grpcio/grpc/framework/foundation/activated.py diff --git a/src/python/src/grpc/framework/foundation/callable_util.py b/src/python/grpcio/grpc/framework/foundation/callable_util.py index 32b0751a01..32b0751a01 100644 --- a/src/python/src/grpc/framework/foundation/callable_util.py +++ b/src/python/grpcio/grpc/framework/foundation/callable_util.py diff --git a/src/python/src/grpc/framework/foundation/future.py b/src/python/grpcio/grpc/framework/foundation/future.py index bfc16fc1ea..bfc16fc1ea 100644 --- a/src/python/src/grpc/framework/foundation/future.py +++ b/src/python/grpcio/grpc/framework/foundation/future.py diff --git a/src/python/src/grpc/framework/foundation/later.py b/src/python/grpcio/grpc/framework/foundation/later.py index 1d1e065041..1d1e065041 100644 --- a/src/python/src/grpc/framework/foundation/later.py +++ b/src/python/grpcio/grpc/framework/foundation/later.py diff --git a/src/python/src/grpc/framework/foundation/logging_pool.py b/src/python/grpcio/grpc/framework/foundation/logging_pool.py index 7c7a6eebfc..7c7a6eebfc 100644 --- a/src/python/src/grpc/framework/foundation/logging_pool.py +++ b/src/python/grpcio/grpc/framework/foundation/logging_pool.py diff --git a/src/python/src/grpc/framework/foundation/relay.py b/src/python/grpcio/grpc/framework/foundation/relay.py index 9c23946552..9c23946552 100644 --- a/src/python/src/grpc/framework/foundation/relay.py +++ b/src/python/grpcio/grpc/framework/foundation/relay.py diff --git a/src/python/src/grpc/framework/foundation/stream.py b/src/python/grpcio/grpc/framework/foundation/stream.py index 75c0cf145b..75c0cf145b 100644 --- a/src/python/src/grpc/framework/foundation/stream.py +++ b/src/python/grpcio/grpc/framework/foundation/stream.py diff --git a/src/python/src/grpc/framework/foundation/stream_util.py b/src/python/grpcio/grpc/framework/foundation/stream_util.py index 2210e4efcf..2210e4efcf 100644 --- a/src/python/src/grpc/framework/foundation/stream_util.py +++ b/src/python/grpcio/grpc/framework/foundation/stream_util.py diff --git a/src/python/src/grpc/framework/face/__init__.py b/src/python/grpcio/grpc/framework/interfaces/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/framework/face/__init__.py +++ b/src/python/grpcio/grpc/framework/interfaces/__init__.py diff --git a/src/python/src/grpc/framework/face/testing/__init__.py b/src/python/grpcio/grpc/framework/interfaces/links/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/framework/face/testing/__init__.py +++ b/src/python/grpcio/grpc/framework/interfaces/links/__init__.py diff --git a/src/python/src/grpc/framework/interfaces/links/links.py b/src/python/grpcio/grpc/framework/interfaces/links/links.py index 5ebbac8a6f..5ebbac8a6f 100644 --- a/src/python/src/grpc/framework/interfaces/links/links.py +++ b/src/python/grpcio/grpc/framework/interfaces/links/links.py diff --git a/src/python/src/grpc/framework/interfaces/links/utilities.py b/src/python/grpcio/grpc/framework/interfaces/links/utilities.py index 6e4fd76d93..6e4fd76d93 100644 --- a/src/python/src/grpc/framework/interfaces/links/utilities.py +++ b/src/python/grpcio/grpc/framework/interfaces/links/utilities.py diff --git a/src/python/requirements.txt b/src/python/grpcio/requirements.txt index 43395df03b..43395df03b 100644 --- a/src/python/requirements.txt +++ b/src/python/grpcio/requirements.txt diff --git a/src/python/grpcio/setup.cfg b/src/python/grpcio/setup.cfg new file mode 100644 index 0000000000..8f69613632 --- /dev/null +++ b/src/python/grpcio/setup.cfg @@ -0,0 +1,2 @@ +[build_ext] +inplace=1 diff --git a/src/python/src/setup.py b/src/python/grpcio/setup.py index a857ae98cc..caa71a4f7c 100644 --- a/src/python/src/setup.py +++ b/src/python/grpcio/setup.py @@ -30,11 +30,17 @@ """A setup module for the GRPC Python package.""" import os +import os.path import sys from distutils import core as _core 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 # 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 @@ -73,29 +79,27 @@ _C_EXTENSION_MODULE = _core.Extension( _EXTENSION_MODULES = [_C_EXTENSION_MODULE] _PACKAGES = ( - 'grpc', - 'grpc._adapter', - 'grpc._junkdrawer', - 'grpc._links', - 'grpc.early_adopter', - 'grpc.framework', - 'grpc.framework.alpha', - 'grpc.framework.base', - 'grpc.framework.common', - 'grpc.framework.face', - 'grpc.framework.face.testing', - 'grpc.framework.foundation', - 'grpc.framework.interfaces', - 'grpc.framework.interfaces.links', + setuptools.find_packages('.', exclude=['*._cython', '*._cython.*']) ) _PACKAGE_DIRECTORIES = { - 'grpc': 'grpc', - 'grpc._adapter': 'grpc/_adapter', - 'grpc._junkdrawer': 'grpc/_junkdrawer', - 'grpc._links': 'grpc/_links', - 'grpc.early_adopter': 'grpc/early_adopter', - 'grpc.framework': 'grpc/framework', + '': '.', +} + +_INSTALL_REQUIRES = ( + 'enum34==1.0.4', + 'futures==2.2.0', + 'protobuf==3.0.0a3', +) + +_SETUP_REQUIRES = ( + 'sphinx>=1.3', +) + _INSTALL_REQUIRES + +_COMMAND_CLASS = { + 'doc': commands.SphinxDocumentation, + 'build_project_metadata': commands.BuildProjectMetadata, + 'build_py': commands.BuildPy, } setuptools.setup( @@ -104,9 +108,7 @@ setuptools.setup( ext_modules=_EXTENSION_MODULES, packages=list(_PACKAGES), package_dir=_PACKAGE_DIRECTORIES, - install_requires=[ - 'enum34==1.0.4', - 'futures==2.2.0', - 'protobuf==3.0.0a3' - ] + install_requires=_INSTALL_REQUIRES, + setup_requires=_SETUP_REQUIRES, + cmdclass=_COMMAND_CLASS ) diff --git a/src/python/grpcio_test/.gitignore b/src/python/grpcio_test/.gitignore new file mode 100644 index 0000000000..218e3a15ab --- /dev/null +++ b/src/python/grpcio_test/.gitignore @@ -0,0 +1,10 @@ +MANIFEST +*.egg-info/ +build/ +dist/ +*.egg +*.egg/ +*.eggs/ +.coverage +.coverage.* +nosetests.xml diff --git a/src/python/grpcio_test/MANIFEST.in b/src/python/grpcio_test/MANIFEST.in new file mode 100644 index 0000000000..c9327307dc --- /dev/null +++ b/src/python/grpcio_test/MANIFEST.in @@ -0,0 +1,4 @@ +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 new file mode 100644 index 0000000000..c796d94c76 --- /dev/null +++ b/src/python/grpcio_test/commands.py @@ -0,0 +1,57 @@ +# 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 os +import os.path +import sys + +import setuptools + + +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 + result = pytest.main(self.pytest_args) + if result != 0: + raise SystemExit(result) diff --git a/src/python/src/grpc/framework/foundation/__init__.py b/src/python/grpcio_test/grpc_interop/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/framework/foundation/__init__.py +++ b/src/python/grpcio_test/grpc_interop/__init__.py diff --git a/src/python/interop/interop/_insecure_interop_test.py b/src/python/grpcio_test/grpc_interop/_insecure_interop_test.py index 98ea3a6648..825988a072 100644 --- a/src/python/interop/interop/_insecure_interop_test.py +++ b/src/python/grpcio_test/grpc_interop/_insecure_interop_test.py @@ -33,8 +33,8 @@ import unittest from grpc.early_adopter import implementations -from interop import _interop_test_case -from interop import methods +from grpc_interop import _interop_test_case +from grpc_interop import methods class InsecureInteropTest( diff --git a/src/python/interop/interop/_interop_test_case.py b/src/python/grpcio_test/grpc_interop/_interop_test_case.py index f40ef0ec83..b6d06b300d 100644 --- a/src/python/interop/interop/_interop_test_case.py +++ b/src/python/grpcio_test/grpc_interop/_interop_test_case.py @@ -29,7 +29,7 @@ """Common code for unit tests of the interoperability test code.""" -from interop import methods +from grpc_interop import methods class InteropTestCase(object): @@ -59,3 +59,6 @@ class InteropTestCase(object): def testCancelAfterFirstResponse(self): methods.TestCase.CANCEL_AFTER_FIRST_RESPONSE.test_interoperability(self.stub, None) + + def testTimeoutOnSleepingServer(self): + methods.TestCase.TIMEOUT_ON_SLEEPING_SERVER.test_interoperability(self.stub, None) diff --git a/src/python/interop/interop/_secure_interop_test.py b/src/python/grpcio_test/grpc_interop/_secure_interop_test.py index be7618f549..a2682dee99 100644 --- a/src/python/interop/interop/_secure_interop_test.py +++ b/src/python/grpcio_test/grpc_interop/_secure_interop_test.py @@ -33,9 +33,9 @@ import unittest from grpc.early_adopter import implementations -from interop import _interop_test_case -from interop import methods -from interop import resources +from grpc_interop import _interop_test_case +from grpc_interop import methods +from grpc_interop import resources _SERVER_HOST_OVERRIDE = 'foo.test.google.fr' diff --git a/src/python/interop/interop/client.py b/src/python/grpcio_test/grpc_interop/client.py index 41f0d94539..2dd2103cbe 100644 --- a/src/python/interop/interop/client.py +++ b/src/python/grpcio_test/grpc_interop/client.py @@ -34,8 +34,8 @@ from oauth2client import client as oauth2client_client from grpc.early_adopter import implementations -from interop import methods -from interop import resources +from grpc_interop import methods +from grpc_interop import resources _ONE_DAY_IN_SECONDS = 60 * 60 * 24 diff --git a/src/python/interop/interop/credentials/README b/src/python/grpcio_test/grpc_interop/credentials/README index cb20dcb49f..cb20dcb49f 100644 --- a/src/python/interop/interop/credentials/README +++ b/src/python/grpcio_test/grpc_interop/credentials/README diff --git a/src/python/interop/interop/credentials/ca.pem b/src/python/grpcio_test/grpc_interop/credentials/ca.pem index 6c8511a73c..6c8511a73c 100755 --- a/src/python/interop/interop/credentials/ca.pem +++ b/src/python/grpcio_test/grpc_interop/credentials/ca.pem diff --git a/src/python/interop/interop/credentials/server1.key b/src/python/grpcio_test/grpc_interop/credentials/server1.key index 143a5b8765..143a5b8765 100755 --- a/src/python/interop/interop/credentials/server1.key +++ b/src/python/grpcio_test/grpc_interop/credentials/server1.key diff --git a/src/python/interop/interop/credentials/server1.pem b/src/python/grpcio_test/grpc_interop/credentials/server1.pem index 8e582e571f..8e582e571f 100755 --- a/src/python/interop/interop/credentials/server1.pem +++ b/src/python/grpcio_test/grpc_interop/credentials/server1.pem diff --git a/src/python/interop/interop/empty_pb2.py b/src/python/grpcio_test/grpc_interop/empty_pb2.py index 8c1ce2f13e..8c1ce2f13e 100644 --- a/src/python/interop/interop/empty_pb2.py +++ b/src/python/grpcio_test/grpc_interop/empty_pb2.py diff --git a/src/python/interop/interop/messages_pb2.py b/src/python/grpcio_test/grpc_interop/messages_pb2.py index 0bf3d86a31..0bf3d86a31 100644 --- a/src/python/interop/interop/messages_pb2.py +++ b/src/python/grpcio_test/grpc_interop/messages_pb2.py diff --git a/src/python/interop/interop/methods.py b/src/python/grpcio_test/grpc_interop/methods.py index 194afadb17..7a831f3cbd 100644 --- a/src/python/interop/interop/methods.py +++ b/src/python/grpcio_test/grpc_interop/methods.py @@ -33,13 +33,15 @@ import enum import json import os import threading +import time from oauth2client import client as oauth2client_client from grpc.framework.alpha import utilities +from grpc.framework.alpha import exceptions -from interop import empty_pb2 -from interop import messages_pb2 +from grpc_interop import empty_pb2 +from grpc_interop import messages_pb2 _TIMEOUT = 7 @@ -318,6 +320,24 @@ def _cancel_after_first_response(stub): raise ValueError('expected call to be cancelled') +def _timeout_on_sleeping_server(stub): + request_payload_size = 27182 + with stub, _Pipe() as pipe: + response_iterator = stub.FullDuplexCall(pipe, 0.001) + + request = messages_pb2.StreamingOutputCallRequest( + response_type=messages_pb2.COMPRESSABLE, + payload=messages_pb2.Payload(body=b'\x00' * request_payload_size)) + pipe.add(request) + time.sleep(0.1) + try: + next(response_iterator) + except exceptions.ExpirationError: + pass + else: + raise ValueError('expected call to exceed deadline') + + def _compute_engine_creds(stub, args): response = _large_unary_common_behavior(stub, True, True) if args.default_service_account != response.username: @@ -351,6 +371,7 @@ class TestCase(enum.Enum): CANCEL_AFTER_FIRST_RESPONSE = 'cancel_after_first_response' COMPUTE_ENGINE_CREDS = 'compute_engine_creds' SERVICE_ACCOUNT_CREDS = 'service_account_creds' + TIMEOUT_ON_SLEEPING_SERVER = 'timeout_on_sleeping_server' def test_interoperability(self, stub, args): if self is TestCase.EMPTY_UNARY: @@ -367,6 +388,8 @@ class TestCase(enum.Enum): _cancel_after_begin(stub) elif self is TestCase.CANCEL_AFTER_FIRST_RESPONSE: _cancel_after_first_response(stub) + elif self is TestCase.TIMEOUT_ON_SLEEPING_SERVER: + _timeout_on_sleeping_server(stub) elif self is TestCase.COMPUTE_ENGINE_CREDS: _compute_engine_creds(stub, args) elif self is TestCase.SERVICE_ACCOUNT_CREDS: diff --git a/src/python/interop/interop/resources.py b/src/python/grpcio_test/grpc_interop/resources.py index 2c3045313d..2c3045313d 100644 --- a/src/python/interop/interop/resources.py +++ b/src/python/grpcio_test/grpc_interop/resources.py diff --git a/src/python/interop/interop/server.py b/src/python/grpcio_test/grpc_interop/server.py index a67d412038..60f630a6be 100644 --- a/src/python/interop/interop/server.py +++ b/src/python/grpcio_test/grpc_interop/server.py @@ -35,8 +35,8 @@ import time from grpc.early_adopter import implementations -from interop import methods -from interop import resources +from grpc_interop import methods +from grpc_interop import resources _ONE_DAY_IN_SECONDS = 60 * 60 * 24 diff --git a/src/python/interop/interop/test_pb2.py b/src/python/grpcio_test/grpc_interop/test_pb2.py index 71325d5a9f..71325d5a9f 100644 --- a/src/python/interop/interop/test_pb2.py +++ b/src/python/grpcio_test/grpc_interop/test_pb2.py diff --git a/src/python/src/grpc/framework/interfaces/__init__.py b/src/python/grpcio_test/grpc_protoc_plugin/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/framework/interfaces/__init__.py +++ b/src/python/grpcio_test/grpc_protoc_plugin/__init__.py diff --git a/src/python/grpcio_test/grpc_protoc_plugin/python_plugin_test.py b/src/python/grpcio_test/grpc_protoc_plugin/python_plugin_test.py new file mode 100644 index 0000000000..b200d129a9 --- /dev/null +++ b/src/python/grpcio_test/grpc_protoc_plugin/python_plugin_test.py @@ -0,0 +1,541 @@ +# 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 argparse +import contextlib +import distutils.spawn +import errno +import itertools +import os +import pkg_resources +import shutil +import subprocess +import sys +import tempfile +import threading +import time +import unittest + +from grpc.framework.alpha import exceptions +from grpc.framework.foundation import future + +# Identifiers of entities we expect to find in the generated module. +SERVICER_IDENTIFIER = 'EarlyAdopterTestServiceServicer' +SERVER_IDENTIFIER = 'EarlyAdopterTestServiceServer' +STUB_IDENTIFIER = 'EarlyAdopterTestServiceStub' +SERVER_FACTORY_IDENTIFIER = 'early_adopter_create_TestService_server' +STUB_FACTORY_IDENTIFIER = 'early_adopter_create_TestService_stub' + +# The timeout used in tests of RPCs that are supposed to expire. +SHORT_TIMEOUT = 2 +# The timeout used in tests of RPCs that are not supposed to expire. The +# absurdly large value doesn't matter since no passing execution of this test +# module will ever wait the duration. +LONG_TIMEOUT = 600 +NO_DELAY = 0 + + +class _ServicerMethods(object): + + def __init__(self, test_pb2, delay): + self._condition = threading.Condition() + self._delay = delay + self._paused = False + self._fail = False + self._test_pb2 = test_pb2 + + @contextlib.contextmanager + def pause(self): # pylint: disable=invalid-name + with self._condition: + self._paused = True + yield + with self._condition: + self._paused = False + self._condition.notify_all() + + @contextlib.contextmanager + def fail(self): # pylint: disable=invalid-name + with self._condition: + self._fail = True + yield + with self._condition: + self._fail = False + + def _control(self): # pylint: disable=invalid-name + with self._condition: + if self._fail: + raise ValueError() + while self._paused: + self._condition.wait() + time.sleep(self._delay) + + def UnaryCall(self, request, unused_rpc_context): + response = self._test_pb2.SimpleResponse() + response.payload.payload_type = self._test_pb2.COMPRESSABLE + response.payload.payload_compressable = 'a' * request.response_size + self._control() + return response + + def StreamingOutputCall(self, request, unused_rpc_context): + for parameter in request.response_parameters: + response = self._test_pb2.StreamingOutputCallResponse() + response.payload.payload_type = self._test_pb2.COMPRESSABLE + response.payload.payload_compressable = 'a' * parameter.size + self._control() + yield response + + def StreamingInputCall(self, request_iter, unused_rpc_context): + response = self._test_pb2.StreamingInputCallResponse() + aggregated_payload_size = 0 + for request in request_iter: + aggregated_payload_size += len(request.payload.payload_compressable) + response.aggregated_payload_size = aggregated_payload_size + self._control() + return response + + def FullDuplexCall(self, request_iter, unused_rpc_context): + for request in request_iter: + for parameter in request.response_parameters: + response = self._test_pb2.StreamingOutputCallResponse() + response.payload.payload_type = self._test_pb2.COMPRESSABLE + response.payload.payload_compressable = 'a' * parameter.size + self._control() + yield response + + def HalfDuplexCall(self, request_iter, unused_rpc_context): + responses = [] + for request in request_iter: + for parameter in request.response_parameters: + response = self._test_pb2.StreamingOutputCallResponse() + response.payload.payload_type = self._test_pb2.COMPRESSABLE + response.payload.payload_compressable = 'a' * parameter.size + self._control() + responses.append(response) + for response in responses: + yield response + + +@contextlib.contextmanager +def _CreateService(test_pb2, delay): + """Provides a servicer backend and a stub. + + The servicer is just the implementation + of the actual servicer passed to the face player of the python RPC + implementation; the two are detached. + + Non-zero delay puts a delay on each call to the servicer, representative of + communication latency. Timeout is the default timeout for the stub while + waiting for the service. + + Args: + test_pb2: The test_pb2 module generated by this test. + delay: Delay in seconds per response from the servicer. + + Yields: + A (servicer_methods, servicer, stub) three-tuple where servicer_methods is + the back-end of the service bound to the stub and the server and stub + are both activated and ready for use. + """ + servicer_methods = _ServicerMethods(test_pb2, delay) + + class Servicer(getattr(test_pb2, SERVICER_IDENTIFIER)): + + def UnaryCall(self, request, context): + return servicer_methods.UnaryCall(request, context) + + def StreamingOutputCall(self, request, context): + return servicer_methods.StreamingOutputCall(request, context) + + def StreamingInputCall(self, request_iter, context): + return servicer_methods.StreamingInputCall(request_iter, context) + + def FullDuplexCall(self, request_iter, context): + return servicer_methods.FullDuplexCall(request_iter, context) + + def HalfDuplexCall(self, request_iter, context): + return servicer_methods.HalfDuplexCall(request_iter, context) + + servicer = Servicer() + server = getattr( + test_pb2, SERVER_FACTORY_IDENTIFIER)(servicer, 0) + with server: + port = server.port() + stub = getattr(test_pb2, STUB_FACTORY_IDENTIFIER)('localhost', port) + with stub: + yield servicer_methods, stub, server + + +def _streaming_input_request_iterator(test_pb2): + for _ in range(3): + request = test_pb2.StreamingInputCallRequest() + request.payload.payload_type = test_pb2.COMPRESSABLE + request.payload.payload_compressable = 'a' + yield request + + +def _streaming_output_request(test_pb2): + request = test_pb2.StreamingOutputCallRequest() + sizes = [1, 2, 3] + request.response_parameters.add(size=sizes[0], interval_us=0) + request.response_parameters.add(size=sizes[1], interval_us=0) + request.response_parameters.add(size=sizes[2], interval_us=0) + return request + + +def _full_duplex_request_iterator(test_pb2): + request = test_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=1, interval_us=0) + yield request + request = test_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=2, interval_us=0) + request.response_parameters.add(size=3, interval_us=0) + yield request + + +class PythonPluginTest(unittest.TestCase): + """Test case for the gRPC Python protoc-plugin. + + While reading these tests, remember that the futures API + (`stub.method.async()`) only gives futures for the *non-streaming* responses, + else it behaves like its blocking cousin. + """ + + def setUp(self): + # Assume that the appropriate protoc and grpc_python_plugins are on the + # path. + protoc_command = 'protoc' + protoc_plugin_filename = distutils.spawn.find_executable( + 'grpc_python_plugin') + test_proto_filename = pkg_resources.resource_filename( + 'grpc_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' + + # Ensure that the output directory exists. + self.outdir = tempfile.mkdtemp() + + # Invoke protoc with the plugin. + cmd = [ + protoc_command, + '--plugin=protoc-gen-python-grpc=%s' % protoc_plugin_filename, + '-I .', + '--python_out=%s' % self.outdir, + '--python-grpc_out=%s' % self.outdir, + os.path.basename(test_proto_filename), + ] + subprocess.check_call(' '.join(cmd), shell=True, env=os.environ, + cwd=os.path.dirname(test_proto_filename)) + sys.path.append(self.outdir) + + def tearDown(self): + try: + shutil.rmtree(self.outdir) + except OSError as exc: + if exc.errno != errno.ENOENT: + raise + + # TODO(atash): Figure out which of these tests is hanging flakily with small + # probability. + + def testImportAttributes(self): + # check that we can access the generated module and its members. + import test_pb2 # pylint: disable=g-import-not-at-top + self.assertIsNotNone(getattr(test_pb2, SERVICER_IDENTIFIER, None)) + self.assertIsNotNone(getattr(test_pb2, SERVER_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 + with _CreateService( + test_pb2, NO_DELAY) as (servicer, stub, unused_server): + request = test_pb2.SimpleRequest(response_size=13) + + def testUnaryCall(self): + import test_pb2 # pylint: disable=g-import-not-at-top + with _CreateService(test_pb2, NO_DELAY) as (methods, stub, unused_server): + timeout = 6 # TODO(issue 2039): LONG_TIMEOUT like the other methods. + request = test_pb2.SimpleRequest(response_size=13) + response = stub.UnaryCall(request, timeout) + expected_response = methods.UnaryCall(request, 'not a real RpcContext!') + self.assertEqual(expected_response, response) + + def testUnaryCallAsync(self): + import test_pb2 # pylint: disable=g-import-not-at-top + request = test_pb2.SimpleRequest(response_size=13) + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + # Check that the call does not block waiting for the server to respond. + with methods.pause(): + response_future = stub.UnaryCall.async(request, LONG_TIMEOUT) + response = response_future.result() + expected_response = methods.UnaryCall(request, 'not a real RpcContext!') + self.assertEqual(expected_response, response) + + def testUnaryCallAsyncExpired(self): + import test_pb2 # pylint: disable=g-import-not-at-top + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + request = test_pb2.SimpleRequest(response_size=13) + with methods.pause(): + response_future = stub.UnaryCall.async(request, SHORT_TIMEOUT) + with self.assertRaises(exceptions.ExpirationError): + response_future.result() + + @unittest.skip('TODO(atash,nathaniel): figure out why this flakily hangs ' + 'forever and fix.') + def testUnaryCallAsyncCancelled(self): + import test_pb2 # pylint: disable=g-import-not-at-top + request = test_pb2.SimpleRequest(response_size=13) + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + with methods.pause(): + response_future = stub.UnaryCall.async(request, 1) + response_future.cancel() + self.assertTrue(response_future.cancelled()) + + def testUnaryCallAsyncFailed(self): + import test_pb2 # pylint: disable=g-import-not-at-top + request = test_pb2.SimpleRequest(response_size=13) + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + with methods.fail(): + response_future = stub.UnaryCall.async(request, LONG_TIMEOUT) + self.assertIsNotNone(response_future.exception()) + + def testStreamingOutputCall(self): + import test_pb2 # pylint: disable=g-import-not-at-top + request = _streaming_output_request(test_pb2) + with _CreateService(test_pb2, NO_DELAY) as (methods, stub, unused_server): + responses = stub.StreamingOutputCall(request, LONG_TIMEOUT) + expected_responses = methods.StreamingOutputCall( + request, 'not a real RpcContext!') + for expected_response, response in itertools.izip_longest( + expected_responses, responses): + self.assertEqual(expected_response, response) + + @unittest.skip('TODO(atash,nathaniel): figure out why this flakily hangs ' + 'forever and fix.') + def testStreamingOutputCallExpired(self): + import test_pb2 # pylint: disable=g-import-not-at-top + request = _streaming_output_request(test_pb2) + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + with methods.pause(): + responses = stub.StreamingOutputCall(request, SHORT_TIMEOUT) + with self.assertRaises(exceptions.ExpirationError): + list(responses) + + @unittest.skip('TODO(atash,nathaniel): figure out why this flakily hangs ' + 'forever and fix.') + def testStreamingOutputCallCancelled(self): + import test_pb2 # pylint: disable=g-import-not-at-top + request = _streaming_output_request(test_pb2) + with _CreateService(test_pb2, NO_DELAY) as ( + unused_methods, stub, unused_server): + responses = stub.StreamingOutputCall(request, SHORT_TIMEOUT) + next(responses) + responses.cancel() + with self.assertRaises(future.CancelledError): + next(responses) + + @unittest.skip('TODO(atash,nathaniel): figure out why this times out ' + 'instead of raising the proper error.') + def testStreamingOutputCallFailed(self): + import test_pb2 # pylint: disable=g-import-not-at-top + request = _streaming_output_request(test_pb2) + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + with methods.fail(): + responses = stub.StreamingOutputCall(request, 1) + self.assertIsNotNone(responses) + with self.assertRaises(exceptions.ServicerError): + next(responses) + + @unittest.skip('TODO(atash,nathaniel): figure out why this flakily hangs ' + 'forever and fix.') + def testStreamingInputCall(self): + import test_pb2 # pylint: disable=g-import-not-at-top + with _CreateService(test_pb2, NO_DELAY) as (methods, stub, unused_server): + response = stub.StreamingInputCall( + _streaming_input_request_iterator(test_pb2), LONG_TIMEOUT) + expected_response = methods.StreamingInputCall( + _streaming_input_request_iterator(test_pb2), 'not a real RpcContext!') + self.assertEqual(expected_response, response) + + def testStreamingInputCallAsync(self): + import test_pb2 # pylint: disable=g-import-not-at-top + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + with methods.pause(): + response_future = stub.StreamingInputCall.async( + _streaming_input_request_iterator(test_pb2), LONG_TIMEOUT) + response = response_future.result() + expected_response = methods.StreamingInputCall( + _streaming_input_request_iterator(test_pb2), 'not a real RpcContext!') + self.assertEqual(expected_response, response) + + def testStreamingInputCallAsyncExpired(self): + import test_pb2 # pylint: disable=g-import-not-at-top + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + with methods.pause(): + response_future = stub.StreamingInputCall.async( + _streaming_input_request_iterator(test_pb2), SHORT_TIMEOUT) + with self.assertRaises(exceptions.ExpirationError): + response_future.result() + self.assertIsInstance( + response_future.exception(), exceptions.ExpirationError) + + def testStreamingInputCallAsyncCancelled(self): + import test_pb2 # pylint: disable=g-import-not-at-top + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + with methods.pause(): + timeout = 6 # TODO(issue 2039): LONG_TIMEOUT like the other methods. + response_future = stub.StreamingInputCall.async( + _streaming_input_request_iterator(test_pb2), timeout) + response_future.cancel() + self.assertTrue(response_future.cancelled()) + with self.assertRaises(future.CancelledError): + response_future.result() + + def testStreamingInputCallAsyncFailed(self): + import test_pb2 # pylint: disable=g-import-not-at-top + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + with methods.fail(): + response_future = stub.StreamingInputCall.async( + _streaming_input_request_iterator(test_pb2), SHORT_TIMEOUT) + self.assertIsNotNone(response_future.exception()) + + def testFullDuplexCall(self): + import test_pb2 # pylint: disable=g-import-not-at-top + with _CreateService(test_pb2, NO_DELAY) as (methods, stub, unused_server): + responses = stub.FullDuplexCall( + _full_duplex_request_iterator(test_pb2), LONG_TIMEOUT) + expected_responses = methods.FullDuplexCall( + _full_duplex_request_iterator(test_pb2), 'not a real RpcContext!') + for expected_response, response in itertools.izip_longest( + expected_responses, responses): + self.assertEqual(expected_response, response) + + @unittest.skip('TODO(atash,nathaniel): figure out why this flakily hangs ' + 'forever and fix.') + def testFullDuplexCallExpired(self): + import test_pb2 # pylint: disable=g-import-not-at-top + request_iterator = _full_duplex_request_iterator(test_pb2) + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + with methods.pause(): + responses = stub.FullDuplexCall(request_iterator, SHORT_TIMEOUT) + with self.assertRaises(exceptions.ExpirationError): + list(responses) + + @unittest.skip('TODO(atash,nathaniel): figure out why this flakily hangs ' + 'forever and fix.') + def testFullDuplexCallCancelled(self): + import test_pb2 # pylint: disable=g-import-not-at-top + with _CreateService(test_pb2, NO_DELAY) as (methods, stub, unused_server): + request_iterator = _full_duplex_request_iterator(test_pb2) + responses = stub.FullDuplexCall(request_iterator, LONG_TIMEOUT) + next(responses) + responses.cancel() + with self.assertRaises(future.CancelledError): + next(responses) + + @unittest.skip('TODO(atash,nathaniel): figure out why this hangs forever ' + 'and fix.') + def testFullDuplexCallFailed(self): + import test_pb2 # pylint: disable=g-import-not-at-top + request_iterator = _full_duplex_request_iterator(test_pb2) + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + with methods.fail(): + responses = stub.FullDuplexCall(request_iterator, LONG_TIMEOUT) + self.assertIsNotNone(responses) + with self.assertRaises(exceptions.ServicerError): + next(responses) + + @unittest.skip('TODO(atash,nathaniel): figure out why this flakily hangs ' + 'forever and fix.') + def testHalfDuplexCall(self): + import test_pb2 # pylint: disable=g-import-not-at-top + with _CreateService(test_pb2, NO_DELAY) as ( + methods, stub, unused_server): + def half_duplex_request_iterator(): + request = test_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=1, interval_us=0) + yield request + request = test_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=2, interval_us=0) + request.response_parameters.add(size=3, interval_us=0) + yield request + responses = stub.HalfDuplexCall( + half_duplex_request_iterator(), LONG_TIMEOUT) + expected_responses = methods.HalfDuplexCall( + half_duplex_request_iterator(), 'not a real RpcContext!') + for check in itertools.izip_longest(expected_responses, responses): + expected_response, response = check + self.assertEqual(expected_response, response) + + def testHalfDuplexCallWedged(self): + import test_pb2 # pylint: disable=g-import-not-at-top + condition = threading.Condition() + wait_cell = [False] + @contextlib.contextmanager + def wait(): # pylint: disable=invalid-name + # Where's Python 3's 'nonlocal' statement when you need it? + with condition: + wait_cell[0] = True + yield + with condition: + wait_cell[0] = False + condition.notify_all() + def half_duplex_request_iterator(): + request = test_pb2.StreamingOutputCallRequest() + request.response_parameters.add(size=1, interval_us=0) + yield request + with condition: + while wait_cell[0]: + condition.wait() + with _CreateService(test_pb2, NO_DELAY) as (methods, stub, unused_server): + with wait(): + responses = stub.HalfDuplexCall( + half_duplex_request_iterator(), SHORT_TIMEOUT) + # half-duplex waits for the client to send all info + with self.assertRaises(exceptions.ExpirationError): + next(responses) + + +if __name__ == '__main__': + os.chdir(os.path.dirname(sys.argv[0])) + unittest.main(verbosity=2) diff --git a/src/python/grpcio_test/grpc_protoc_plugin/test.proto b/src/python/grpcio_test/grpc_protoc_plugin/test.proto new file mode 100644 index 0000000000..ed7c6a7b79 --- /dev/null +++ b/src/python/grpcio_test/grpc_protoc_plugin/test.proto @@ -0,0 +1,139 @@ +// 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. + +// An integration test service that covers all the method signature permutations +// of unary/streaming requests/responses. +// This file is duplicated around the code base. See GitHub issue #526. +syntax = "proto2"; + +package grpc.testing; + +enum PayloadType { + // Compressable text format. + COMPRESSABLE= 1; + + // Uncompressable binary format. + UNCOMPRESSABLE = 2; + + // Randomly chosen from all other formats defined in this enum. + RANDOM = 3; +} + +message Payload { + required PayloadType payload_type = 1; + oneof payload_body { + string payload_compressable = 2; + bytes payload_uncompressable = 3; + } +} + +message SimpleRequest { + // Desired payload type in the response from the server. + // If response_type is RANDOM, server randomly chooses one from other formats. + optional PayloadType response_type = 1 [default=COMPRESSABLE]; + + // Desired payload size in the response from the server. + // If response_type is COMPRESSABLE, this denotes the size before compression. + optional int32 response_size = 2; + + // Optional input payload sent along with the request. + optional Payload payload = 3; +} + +message SimpleResponse { + optional Payload payload = 1; +} + +message StreamingInputCallRequest { + // Optional input payload sent along with the request. + optional Payload payload = 1; + + // Not expecting any payload from the response. +} + +message StreamingInputCallResponse { + // Aggregated size of payloads received from the client. + optional int32 aggregated_payload_size = 1; +} + +message ResponseParameters { + // Desired payload sizes in responses from the server. + // If response_type is COMPRESSABLE, this denotes the size before compression. + required int32 size = 1; + + // Desired interval between consecutive responses in the response stream in + // microseconds. + required int32 interval_us = 2; +} + +message StreamingOutputCallRequest { + // Desired payload type in the response from the server. + // If response_type is RANDOM, the payload from each response in the stream + // might be of different types. This is to simulate a mixed type of payload + // stream. + optional PayloadType response_type = 1 [default=COMPRESSABLE]; + + repeated ResponseParameters response_parameters = 2; + + // Optional input payload sent along with the request. + optional Payload payload = 3; +} + +message StreamingOutputCallResponse { + optional Payload payload = 1; +} + +service TestService { + // One request followed by one response. + // The server returns the client payload as-is. + rpc UnaryCall(SimpleRequest) returns (SimpleResponse); + + // One request followed by a sequence of responses (streamed download). + // The server returns the payload with client desired type and sizes. + rpc StreamingOutputCall(StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); + + // A sequence of requests followed by one response (streamed upload). + // The server returns the aggregated size of client payload as the result. + rpc StreamingInputCall(stream StreamingInputCallRequest) + returns (StreamingInputCallResponse); + + // A sequence of requests with each request served by the server immediately. + // As one request could lead to multiple responses, this interface + // demonstrates the idea of full duplexing. + rpc FullDuplexCall(stream StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); + + // A sequence of requests followed by a sequence of responses. + // The server buffers all the client requests and then serves them in order. A + // stream of responses are returned to the client when the server starts with + // first request. + rpc HalfDuplexCall(stream StreamingOutputCallRequest) + returns (stream StreamingOutputCallResponse); +} diff --git a/src/python/src/grpc/framework/interfaces/links/__init__.py b/src/python/grpcio_test/grpc_test/__init__.py index 7086519106..7086519106 100644 --- a/src/python/src/grpc/framework/interfaces/links/__init__.py +++ b/src/python/grpcio_test/grpc_test/__init__.py diff --git a/src/python/grpcio_test/grpc_test/_adapter/.gitignore b/src/python/grpcio_test/grpc_test/_adapter/.gitignore new file mode 100644 index 0000000000..a6f96cd6db --- /dev/null +++ b/src/python/grpcio_test/grpc_test/_adapter/.gitignore @@ -0,0 +1,5 @@ +*.a +*.so +*.dll +*.pyc +*.pyd diff --git a/src/python/interop/setup.py b/src/python/grpcio_test/grpc_test/_adapter/__init__.py index 75012b0d8f..7086519106 100644 --- a/src/python/interop/setup.py +++ b/src/python/grpcio_test/grpc_test/_adapter/__init__.py @@ -27,31 +27,4 @@ # (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.""" -import setuptools - -_PACKAGES = ( - 'interop', -) - -_PACKAGE_DIRECTORIES = { - 'interop': 'interop', -} - -_PACKAGE_DATA = { - 'interop': [ - 'credentials/ca.pem', 'credentials/server1.key', - 'credentials/server1.pem',] -} - -_INSTALL_REQUIRES = ['oauth2client>=1.4.7', 'grpcio>=0.10.0a0'] - -setuptools.setup( - name='interop', - version='0.0.1', - packages=_PACKAGES, - package_dir=_PACKAGE_DIRECTORIES, - package_data=_PACKAGE_DATA, - install_requires=_INSTALL_REQUIRES -) diff --git a/src/python/src/grpc/_adapter/_blocking_invocation_inline_service_test.py b/src/python/grpcio_test/grpc_test/_adapter/_blocking_invocation_inline_service_test.py index 7a8ff0ad89..a1f776211c 100644 --- a/src/python/src/grpc/_adapter/_blocking_invocation_inline_service_test.py +++ b/src/python/grpcio_test/grpc_test/_adapter/_blocking_invocation_inline_service_test.py @@ -31,8 +31,8 @@ import unittest -from grpc._adapter import _face_test_case -from grpc.framework.face.testing import blocking_invocation_inline_service_test_case as test_case +from grpc_test._adapter import _face_test_case +from grpc_test.framework.face.testing import blocking_invocation_inline_service_test_case as test_case class BlockingInvocationInlineServiceTest( diff --git a/src/python/src/grpc/_adapter/_c_test.py b/src/python/grpcio_test/grpc_test/_adapter/_c_test.py index fe020e2a9c..fe020e2a9c 100644 --- a/src/python/src/grpc/_adapter/_c_test.py +++ b/src/python/grpcio_test/grpc_test/_adapter/_c_test.py diff --git a/src/python/src/grpc/_adapter/_event_invocation_synchronous_event_service_test.py b/src/python/grpcio_test/grpc_test/_adapter/_event_invocation_synchronous_event_service_test.py index b8ceb75d68..0d01ebc8dc 100644 --- a/src/python/src/grpc/_adapter/_event_invocation_synchronous_event_service_test.py +++ b/src/python/grpcio_test/grpc_test/_adapter/_event_invocation_synchronous_event_service_test.py @@ -31,8 +31,8 @@ import unittest -from grpc._adapter import _face_test_case -from grpc.framework.face.testing import event_invocation_synchronous_event_service_test_case as test_case +from grpc_test._adapter import _face_test_case +from grpc_test.framework.face.testing import event_invocation_synchronous_event_service_test_case as test_case class EventInvocationSynchronousEventServiceTest( diff --git a/src/python/src/grpc/_adapter/_face_test_case.py b/src/python/grpcio_test/grpc_test/_adapter/_face_test_case.py index 5fa974ed06..dfbd0b60af 100644 --- a/src/python/src/grpc/_adapter/_face_test_case.py +++ b/src/python/grpcio_test/grpc_test/_adapter/_face_test_case.py @@ -36,10 +36,10 @@ from grpc._adapter import rear from grpc.framework.base import util from grpc.framework.base import implementations as base_implementations from grpc.framework.face import implementations as face_implementations -from grpc.framework.face.testing import coverage -from grpc.framework.face.testing import serial -from grpc.framework.face.testing import test_case from grpc.framework.foundation import logging_pool +from grpc_test.framework.face.testing import coverage +from grpc_test.framework.face.testing import serial +from grpc_test.framework.face.testing import test_case _TIMEOUT = 3 _MAXIMUM_TIMEOUT = 90 diff --git a/src/python/src/grpc/_adapter/_future_invocation_asynchronous_event_service_test.py b/src/python/grpcio_test/grpc_test/_adapter/_future_invocation_asynchronous_event_service_test.py index 3773e65575..ea4a6a0bae 100644 --- a/src/python/src/grpc/_adapter/_future_invocation_asynchronous_event_service_test.py +++ b/src/python/grpcio_test/grpc_test/_adapter/_future_invocation_asynchronous_event_service_test.py @@ -31,8 +31,8 @@ import unittest -from grpc._adapter import _face_test_case -from grpc.framework.face.testing import future_invocation_asynchronous_event_service_test_case as test_case +from grpc_test._adapter import _face_test_case +from grpc_test.framework.face.testing import future_invocation_asynchronous_event_service_test_case as test_case class FutureInvocationAsynchronousEventServiceTest( diff --git a/src/python/src/grpc/_adapter/_intermediary_low_test.py b/src/python/grpcio_test/grpc_test/_adapter/_intermediary_low_test.py index 27a5b82e9c..27a5b82e9c 100644 --- a/src/python/src/grpc/_adapter/_intermediary_low_test.py +++ b/src/python/grpcio_test/grpc_test/_adapter/_intermediary_low_test.py diff --git a/src/python/src/grpc/_adapter/_links_test.py b/src/python/grpcio_test/grpc_test/_adapter/_links_test.py index 4729b84f84..c4686b327a 100644 --- a/src/python/src/grpc/_adapter/_links_test.py +++ b/src/python/grpcio_test/grpc_test/_adapter/_links_test.py @@ -32,12 +32,12 @@ import threading import unittest -from grpc._adapter import _proto_scenarios -from grpc._adapter import _test_links from grpc._adapter import fore from grpc._adapter import rear from grpc.framework.base import interfaces from grpc.framework.foundation import logging_pool +from grpc_test._adapter import _proto_scenarios +from grpc_test._adapter import _test_links _IDENTITY = lambda x: x _TIMEOUT = 32 diff --git a/src/python/src/grpc/_adapter/_lonely_rear_link_test.py b/src/python/grpcio_test/grpc_test/_adapter/_lonely_rear_link_test.py index 7f5021f40e..9b5758f60f 100644 --- a/src/python/src/grpc/_adapter/_lonely_rear_link_test.py +++ b/src/python/grpcio_test/grpc_test/_adapter/_lonely_rear_link_test.py @@ -31,10 +31,10 @@ import unittest -from grpc._adapter import _test_links from grpc._adapter import rear from grpc.framework.base import interfaces from grpc.framework.foundation import logging_pool +from grpc_test._adapter import _test_links _IDENTITY = lambda x: x _TIMEOUT = 2 diff --git a/src/python/src/grpc/_adapter/_low_test.py b/src/python/grpcio_test/grpc_test/_adapter/_low_test.py index a49cd007bf..44fe760fbc 100644 --- a/src/python/src/grpc/_adapter/_low_test.py +++ b/src/python/grpcio_test/grpc_test/_adapter/_low_test.py @@ -31,11 +31,12 @@ import threading import time import unittest +from grpc import _grpcio_metadata from grpc._adapter import _types from grpc._adapter import _low -def WaitForEvents(completion_queues, deadline): +def wait_for_events(completion_queues, deadline): """ Args: completion_queues: list of completion queues to wait for events on @@ -62,6 +63,7 @@ def WaitForEvents(completion_queues, deadline): thread.join() return results + class InsecureServerInsecureClient(unittest.TestCase): def setUp(self): @@ -97,7 +99,7 @@ class InsecureServerInsecureClient(unittest.TestCase): CLIENT_METADATA_BIN_VALUE = b'\0'*1000 SERVER_INITIAL_METADATA_KEY = 'init_me_me_me' SERVER_INITIAL_METADATA_VALUE = 'whodawha?' - SERVER_TRAILING_METADATA_KEY = 'California_is_in_a_drought' + SERVER_TRAILING_METADATA_KEY = 'california_is_in_a_drought' SERVER_TRAILING_METADATA_VALUE = 'zomg it is' SERVER_STATUS_CODE = _types.StatusCode.OK SERVER_STATUS_DETAILS = 'our work is never over' @@ -115,7 +117,7 @@ class InsecureServerInsecureClient(unittest.TestCase): client_initial_metadata = [(CLIENT_METADATA_ASCII_KEY, CLIENT_METADATA_ASCII_VALUE), (CLIENT_METADATA_BIN_KEY, CLIENT_METADATA_BIN_VALUE)] client_start_batch_result = client_call.start_batch([ _types.OpArgs.send_initial_metadata(client_initial_metadata), - _types.OpArgs.send_message(REQUEST), + _types.OpArgs.send_message(REQUEST, 0), _types.OpArgs.send_close_from_client(), _types.OpArgs.recv_initial_metadata(), _types.OpArgs.recv_message(), @@ -123,20 +125,34 @@ class InsecureServerInsecureClient(unittest.TestCase): ], client_call_tag) self.assertEquals(_types.CallError.OK, client_start_batch_result) - client_no_event, request_event, = WaitForEvents([self.client_completion_queue, self.server_completion_queue], time.time() + 2) + client_no_event, request_event, = wait_for_events([self.client_completion_queue, self.server_completion_queue], time.time() + 2) self.assertEquals(client_no_event, None) self.assertEquals(_types.EventType.OP_COMPLETE, request_event.type) self.assertIsInstance(request_event.call, _low.Call) self.assertIs(server_request_tag, request_event.tag) self.assertEquals(1, len(request_event.results)) - got_initial_metadata = dict(request_event.results[0].initial_metadata) + received_initial_metadata = dict(request_event.results[0].initial_metadata) + # Check that our metadata were transmitted self.assertEquals( dict(client_initial_metadata), - dict((x, got_initial_metadata[x]) for x in zip(*client_initial_metadata)[0])) + dict((x, received_initial_metadata[x]) for x in zip(*client_initial_metadata)[0])) + # Check that Python's user agent string is a part of the full user agent + # string + self.assertIn('Python-gRPC-{}'.format(_grpcio_metadata.__version__), + received_initial_metadata['user-agent']) self.assertEquals(METHOD, request_event.call_details.method) self.assertEquals(HOST, request_event.call_details.host) self.assertLess(abs(DEADLINE - request_event.call_details.deadline), DEADLINE_TOLERANCE) + # Check that the channel is connected, and that both it and the call have + # the proper target and peer; do this after the first flurry of messages to + # avoid the possibility that connection was delayed by the core until the + # first message was sent. + self.assertEqual(_types.ConnectivityState.READY, + self.client_channel.check_connectivity_state(False)) + self.assertIsNotNone(self.client_channel.target()) + self.assertIsNotNone(client_call.peer()) + server_call_tag = object() server_call = request_event.call server_initial_metadata = [(SERVER_INITIAL_METADATA_KEY, SERVER_INITIAL_METADATA_VALUE)] @@ -144,13 +160,13 @@ class InsecureServerInsecureClient(unittest.TestCase): server_start_batch_result = server_call.start_batch([ _types.OpArgs.send_initial_metadata(server_initial_metadata), _types.OpArgs.recv_message(), - _types.OpArgs.send_message(RESPONSE), + _types.OpArgs.send_message(RESPONSE, 0), _types.OpArgs.recv_close_on_server(), _types.OpArgs.send_status_from_server(server_trailing_metadata, SERVER_STATUS_CODE, SERVER_STATUS_DETAILS) ], server_call_tag) self.assertEquals(_types.CallError.OK, server_start_batch_result) - client_event, server_event, = WaitForEvents([self.client_completion_queue, self.server_completion_queue], time.time() + 1) + client_event, server_event, = wait_for_events([self.client_completion_queue, self.server_completion_queue], time.time() + 1) self.assertEquals(6, len(client_event.results)) found_client_op_types = set() diff --git a/src/python/src/grpc/_adapter/_proto_scenarios.py b/src/python/grpcio_test/grpc_test/_adapter/_proto_scenarios.py index 60a622ba8b..b3d6ec8607 100644 --- a/src/python/src/grpc/_adapter/_proto_scenarios.py +++ b/src/python/grpcio_test/grpc_test/_adapter/_proto_scenarios.py @@ -32,7 +32,7 @@ import abc import threading -from grpc._junkdrawer import math_pb2 +from grpc_test._junkdrawer import math_pb2 class ProtoScenario(object): diff --git a/src/python/src/grpc/_adapter/_test_links.py b/src/python/grpcio_test/grpc_test/_adapter/_test_links.py index 86c7e61b17..86c7e61b17 100644 --- a/src/python/src/grpc/_adapter/_test_links.py +++ b/src/python/grpcio_test/grpc_test/_adapter/_test_links.py diff --git a/src/python/grpcio_test/grpc_test/_cython/.gitignore b/src/python/grpcio_test/grpc_test/_cython/.gitignore new file mode 100644 index 0000000000..c315029288 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/_cython/.gitignore @@ -0,0 +1,7 @@ +*.h +*.c +*.a +*.so +*.dll +*.pyc +*.pyd diff --git a/src/python/grpcio_test/grpc_test/_cython/__init__.py b/src/python/grpcio_test/grpc_test/_cython/__init__.py new file mode 100644 index 0000000000..b89398809f --- /dev/null +++ b/src/python/grpcio_test/grpc_test/_cython/__init__.py @@ -0,0 +1,28 @@ +# 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. diff --git a/src/python/src/grpc/_cython/adapter_low_test.py b/src/python/grpcio_test/grpc_test/_cython/adapter_low_test.py index 9bab930e56..9bab930e56 100644 --- a/src/python/src/grpc/_cython/adapter_low_test.py +++ b/src/python/grpcio_test/grpc_test/_cython/adapter_low_test.py diff --git a/src/python/src/grpc/_cython/cygrpc_test.py b/src/python/grpcio_test/grpc_test/_cython/cygrpc_test.py index 22d210b16b..637506b42e 100644 --- a/src/python/src/grpc/_cython/cygrpc_test.py +++ b/src/python/grpcio_test/grpc_test/_cython/cygrpc_test.py @@ -31,7 +31,7 @@ import time import unittest from grpc._cython import cygrpc -from grpc._cython import test_utilities +from grpc_test._cython import test_utilities class TypeSmokeTest(unittest.TestCase): diff --git a/src/python/src/grpc/_cython/test_utilities.py b/src/python/grpcio_test/grpc_test/_cython/test_utilities.py index 21ea3075b4..21ea3075b4 100644 --- a/src/python/src/grpc/_cython/test_utilities.py +++ b/src/python/grpcio_test/grpc_test/_cython/test_utilities.py diff --git a/src/python/grpcio_test/grpc_test/_junkdrawer/__init__.py b/src/python/grpcio_test/grpc_test/_junkdrawer/__init__.py new file mode 100644 index 0000000000..7086519106 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/_junkdrawer/__init__.py @@ -0,0 +1,30 @@ +# 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. + + diff --git a/src/python/src/grpc/_junkdrawer/math_pb2.py b/src/python/grpcio_test/grpc_test/_junkdrawer/math_pb2.py index 20165955b4..20165955b4 100644 --- a/src/python/src/grpc/_junkdrawer/math_pb2.py +++ b/src/python/grpcio_test/grpc_test/_junkdrawer/math_pb2.py diff --git a/src/python/src/grpc/_junkdrawer/stock_pb2.py b/src/python/grpcio_test/grpc_test/_junkdrawer/stock_pb2.py index eef18f82d6..eef18f82d6 100644 --- a/src/python/src/grpc/_junkdrawer/stock_pb2.py +++ b/src/python/grpcio_test/grpc_test/_junkdrawer/stock_pb2.py diff --git a/src/python/grpcio_test/grpc_test/_links/__init__.py b/src/python/grpcio_test/grpc_test/_links/__init__.py new file mode 100644 index 0000000000..7086519106 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/_links/__init__.py @@ -0,0 +1,30 @@ +# 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. + + diff --git a/src/python/src/grpc/_links/_lonely_invocation_link_test.py b/src/python/grpcio_test/grpc_test/_links/_lonely_invocation_link_test.py index 3d629f4387..abe240e07a 100644 --- a/src/python/src/grpc/_links/_lonely_invocation_link_test.py +++ b/src/python/grpcio_test/grpc_test/_links/_lonely_invocation_link_test.py @@ -33,10 +33,10 @@ import unittest from grpc._adapter import _intermediary_low from grpc._links import invocation -from grpc.framework.common import test_constants from grpc.framework.interfaces.links import links -from grpc.framework.interfaces.links import test_cases -from grpc.framework.interfaces.links import test_utilities +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 _NULL_BEHAVIOR = lambda unused_argument: None diff --git a/src/python/src/grpc/_links/_proto_scenarios.py b/src/python/grpcio_test/grpc_test/_links/_proto_scenarios.py index ccf3c29782..0d74d66297 100644 --- a/src/python/src/grpc/_links/_proto_scenarios.py +++ b/src/python/grpcio_test/grpc_test/_links/_proto_scenarios.py @@ -32,7 +32,8 @@ import abc import threading -from grpc._junkdrawer import math_pb2 +from grpc_test._junkdrawer import math_pb2 +from grpc_test.framework.common import test_constants class ProtoScenario(object): @@ -219,10 +220,9 @@ class BidirectionallyUnaryScenario(ProtoScenario): class BidirectionallyStreamingScenario(ProtoScenario): """A scenario that transmits no protocol buffers in either direction.""" - _STREAM_LENGTH = 200 _REQUESTS = tuple( math_pb2.DivArgs(dividend=59 + index, divisor=7 + index) - for index in range(_STREAM_LENGTH)) + for index in range(test_constants.STREAM_LENGTH)) def __init__(self): self._lock = threading.Lock() diff --git a/src/python/src/grpc/_links/_transmission_test.py b/src/python/grpcio_test/grpc_test/_links/_transmission_test.py index 3eeec03f46..9cdc9620f0 100644 --- a/src/python/src/grpc/_links/_transmission_test.py +++ b/src/python/grpcio_test/grpc_test/_links/_transmission_test.py @@ -32,13 +32,14 @@ import unittest from grpc._adapter import _intermediary_low -from grpc._links import _proto_scenarios from grpc._links import invocation from grpc._links import service -from grpc.framework.common import test_constants from grpc.framework.interfaces.links import links -from grpc.framework.interfaces.links import test_cases -from grpc.framework.interfaces.links import test_utilities +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 _IDENTITY = lambda x: x @@ -94,12 +95,11 @@ class TransmissionTest(test_cases.TransmissionTest, unittest.TestCase): return _intermediary_low.Code.OK, 'An exuberant test "details" message!' def assertMetadataTransmitted(self, original_metadata, transmitted_metadata): - # we need to filter out any additional metadata added in transmitted_metadata - # since implementations are allowed to add to what is sent (in any position) - keys, _ = zip(*original_metadata) - self.assertSequenceEqual( - original_metadata, - [x for x in transmitted_metadata if x[0] in keys]) + self.assertTrue( + test_common.metadata_transmitted( + original_metadata, transmitted_metadata), + '%s erroneously transmitted as %s' % ( + original_metadata, transmitted_metadata)) class RoundTripTest(unittest.TestCase): diff --git a/src/python/grpcio_test/grpc_test/early_adopter/__init__.py b/src/python/grpcio_test/grpc_test/early_adopter/__init__.py new file mode 100644 index 0000000000..7086519106 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/early_adopter/__init__.py @@ -0,0 +1,30 @@ +# 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. + + diff --git a/src/python/src/grpc/early_adopter/implementations_test.py b/src/python/grpcio_test/grpc_test/early_adopter/implementations_test.py index 49f0e949c4..611637e8b8 100644 --- a/src/python/src/grpc/early_adopter/implementations_test.py +++ b/src/python/grpcio_test/grpc_test/early_adopter/implementations_test.py @@ -35,7 +35,7 @@ import unittest from grpc.early_adopter import implementations from grpc.framework.alpha import utilities -from grpc._junkdrawer import math_pb2 +from grpc_test._junkdrawer import math_pb2 SERVICE_NAME = 'math.Math' diff --git a/src/python/grpcio_test/grpc_test/framework/__init__.py b/src/python/grpcio_test/grpc_test/framework/__init__.py new file mode 100644 index 0000000000..7086519106 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/framework/__init__.py @@ -0,0 +1,30 @@ +# 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. + + diff --git a/src/python/grpcio_test/grpc_test/framework/base/__init__.py b/src/python/grpcio_test/grpc_test/framework/base/__init__.py new file mode 100644 index 0000000000..7086519106 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/framework/base/__init__.py @@ -0,0 +1,30 @@ +# 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. + + diff --git a/src/python/src/grpc/framework/base/implementations_test.py b/src/python/grpcio_test/grpc_test/framework/base/implementations_test.py index 72087f4456..5a7d1398fd 100644 --- a/src/python/src/grpc/framework/base/implementations_test.py +++ b/src/python/grpcio_test/grpc_test/framework/base/implementations_test.py @@ -32,9 +32,9 @@ import unittest from grpc.framework.base import implementations -from grpc.framework.base import interfaces_test_case from grpc.framework.base import util from grpc.framework.foundation import logging_pool +from grpc_test.framework.base import interfaces_test_case POOL_MAX_WORKERS = 10 DEFAULT_TIMEOUT = 30 diff --git a/src/python/src/grpc/framework/base/interfaces_test_case.py b/src/python/grpcio_test/grpc_test/framework/base/interfaces_test_case.py index dec10c2924..be775ad4e0 100644 --- a/src/python/src/grpc/framework/base/interfaces_test_case.py +++ b/src/python/grpcio_test/grpc_test/framework/base/interfaces_test_case.py @@ -35,8 +35,8 @@ import time from grpc.framework.base import interfaces from grpc.framework.base import util from grpc.framework.foundation import stream -from grpc.framework.foundation import stream_testing from grpc.framework.foundation import stream_util +from grpc_test.framework.foundation import stream_testing TICK = 0.1 SMALL_TIMEOUT = TICK * 50 diff --git a/src/python/grpcio_test/grpc_test/framework/common/__init__.py b/src/python/grpcio_test/grpc_test/framework/common/__init__.py new file mode 100644 index 0000000000..7086519106 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/framework/common/__init__.py @@ -0,0 +1,30 @@ +# 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. + + diff --git a/src/python/src/grpc/framework/common/test_constants.py b/src/python/grpcio_test/grpc_test/framework/common/test_constants.py index 237b8754ed..3126d0d82c 100644 --- a/src/python/src/grpc/framework/common/test_constants.py +++ b/src/python/grpcio_test/grpc_test/framework/common/test_constants.py @@ -35,3 +35,9 @@ SHORT_TIMEOUT = 4 # Absurdly large value for maximum duration in seconds for should-not-time-out # RPCs made during tests. LONG_TIMEOUT = 3000 + +# The number of payloads to transmit in streaming tests. +STREAM_LENGTH = 200 + +# The size of thread pools to use in tests. +POOL_SIZE = 10 diff --git a/src/python/src/grpc/framework/common/test_control.py b/src/python/grpcio_test/grpc_test/framework/common/test_control.py index 3960c4e649..3960c4e649 100644 --- a/src/python/src/grpc/framework/common/test_control.py +++ b/src/python/grpcio_test/grpc_test/framework/common/test_control.py diff --git a/src/python/src/grpc/framework/common/test_coverage.py b/src/python/grpcio_test/grpc_test/framework/common/test_coverage.py index a7ed3582c4..a7ed3582c4 100644 --- a/src/python/src/grpc/framework/common/test_coverage.py +++ b/src/python/grpcio_test/grpc_test/framework/common/test_coverage.py diff --git a/src/python/grpcio_test/grpc_test/framework/face/__init__.py b/src/python/grpcio_test/grpc_test/framework/face/__init__.py new file mode 100644 index 0000000000..7086519106 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/framework/face/__init__.py @@ -0,0 +1,30 @@ +# 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. + + diff --git a/src/python/src/grpc/framework/face/_test_case.py b/src/python/grpcio_test/grpc_test/framework/face/_test_case.py index 642d500628..486b6e630e 100644 --- a/src/python/src/grpc/framework/face/_test_case.py +++ b/src/python/grpcio_test/grpc_test/framework/face/_test_case.py @@ -30,9 +30,9 @@ """Common lifecycle code for in-memory-ticket-exchange Face-layer tests.""" from grpc.framework.face import implementations -from grpc.framework.face.testing import base_util -from grpc.framework.face.testing import test_case from grpc.framework.foundation import logging_pool +from grpc_test.framework.face.testing import base_util +from grpc_test.framework.face.testing import test_case _TIMEOUT = 3 _MAXIMUM_POOL_SIZE = 10 diff --git a/src/python/src/grpc/framework/face/blocking_invocation_inline_service_test.py b/src/python/grpcio_test/grpc_test/framework/face/blocking_invocation_inline_service_test.py index 763f0f0edc..8674666418 100644 --- a/src/python/src/grpc/framework/face/blocking_invocation_inline_service_test.py +++ b/src/python/grpcio_test/grpc_test/framework/face/blocking_invocation_inline_service_test.py @@ -31,8 +31,8 @@ import unittest -from grpc.framework.face import _test_case -from grpc.framework.face.testing import blocking_invocation_inline_service_test_case as test_case +from grpc_test.framework.face import _test_case +from grpc_test.framework.face.testing import blocking_invocation_inline_service_test_case as test_case class BlockingInvocationInlineServiceTest( diff --git a/src/python/src/grpc/framework/face/event_invocation_synchronous_event_service_test.py b/src/python/grpcio_test/grpc_test/framework/face/event_invocation_synchronous_event_service_test.py index e1ab3cf711..dca373ef7c 100644 --- a/src/python/src/grpc/framework/face/event_invocation_synchronous_event_service_test.py +++ b/src/python/grpcio_test/grpc_test/framework/face/event_invocation_synchronous_event_service_test.py @@ -31,8 +31,8 @@ import unittest -from grpc.framework.face import _test_case -from grpc.framework.face.testing import event_invocation_synchronous_event_service_test_case as test_case +from grpc_test.framework.face import _test_case +from grpc_test.framework.face.testing import event_invocation_synchronous_event_service_test_case as test_case class EventInvocationSynchronousEventServiceTest( diff --git a/src/python/src/grpc/framework/face/future_invocation_asynchronous_event_service_test.py b/src/python/grpcio_test/grpc_test/framework/face/future_invocation_asynchronous_event_service_test.py index 2d13bb911d..99fdf18123 100644 --- a/src/python/src/grpc/framework/face/future_invocation_asynchronous_event_service_test.py +++ b/src/python/grpcio_test/grpc_test/framework/face/future_invocation_asynchronous_event_service_test.py @@ -31,8 +31,8 @@ import unittest -from grpc.framework.face import _test_case -from grpc.framework.face.testing import future_invocation_asynchronous_event_service_test_case as test_case +from grpc_test.framework.face import _test_case +from grpc_test.framework.face.testing import future_invocation_asynchronous_event_service_test_case as test_case class FutureInvocationAsynchronousEventServiceTest( diff --git a/src/python/grpcio_test/grpc_test/framework/face/testing/__init__.py b/src/python/grpcio_test/grpc_test/framework/face/testing/__init__.py new file mode 100644 index 0000000000..7086519106 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/__init__.py @@ -0,0 +1,30 @@ +# 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. + + diff --git a/src/python/src/grpc/framework/face/testing/base_util.py b/src/python/grpcio_test/grpc_test/framework/face/testing/base_util.py index 1df1529b27..1df1529b27 100644 --- a/src/python/src/grpc/framework/face/testing/base_util.py +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/base_util.py diff --git a/src/python/src/grpc/framework/face/testing/blocking_invocation_inline_service_test_case.py b/src/python/grpcio_test/grpc_test/framework/face/testing/blocking_invocation_inline_service_test_case.py index e57ee00104..251e1eb68e 100644 --- a/src/python/src/grpc/framework/face/testing/blocking_invocation_inline_service_test_case.py +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/blocking_invocation_inline_service_test_case.py @@ -34,14 +34,12 @@ import abc import unittest # pylint: disable=unused-import from grpc.framework.face import exceptions -from grpc.framework.face.testing import control -from grpc.framework.face.testing import coverage -from grpc.framework.face.testing import digest -from grpc.framework.face.testing import stock_service -from grpc.framework.face.testing import test_case - -_TIMEOUT = 3 -_LONG_TIMEOUT = 45 +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 class BlockingInvocationInlineServiceTestCase( @@ -79,7 +77,7 @@ class BlockingInvocationInlineServiceTestCase( request = test_messages.request() response = self.stub.blocking_value_in_value_out( - name, request, _LONG_TIMEOUT) + name, request, test_constants.LONG_TIMEOUT) test_messages.verify(request, response, self) @@ -90,7 +88,7 @@ class BlockingInvocationInlineServiceTestCase( request = test_messages.request() response_iterator = self.stub.inline_value_in_stream_out( - name, request, _LONG_TIMEOUT) + name, request, test_constants.LONG_TIMEOUT) responses = list(response_iterator) test_messages.verify(request, responses, self) @@ -102,7 +100,7 @@ class BlockingInvocationInlineServiceTestCase( requests = test_messages.requests() response = self.stub.blocking_stream_in_value_out( - name, iter(requests), _LONG_TIMEOUT) + name, iter(requests), test_constants.LONG_TIMEOUT) test_messages.verify(requests, response, self) @@ -113,7 +111,7 @@ class BlockingInvocationInlineServiceTestCase( requests = test_messages.requests() response_iterator = self.stub.inline_stream_in_stream_out( - name, iter(requests), _LONG_TIMEOUT) + name, iter(requests), test_constants.LONG_TIMEOUT) responses = list(response_iterator) test_messages.verify(requests, responses, self) @@ -126,12 +124,12 @@ class BlockingInvocationInlineServiceTestCase( second_request = test_messages.request() first_response = self.stub.blocking_value_in_value_out( - name, first_request, _TIMEOUT) + name, first_request, test_constants.SHORT_TIMEOUT) test_messages.verify(first_request, first_response, self) second_response = self.stub.blocking_value_in_value_out( - name, second_request, _TIMEOUT) + name, second_request, test_constants.SHORT_TIMEOUT) test_messages.verify(second_request, second_response, self) @@ -144,7 +142,7 @@ class BlockingInvocationInlineServiceTestCase( with self.control.pause(), self.assertRaises( exceptions.ExpirationError): multi_callable = self.stub.unary_unary_multi_callable(name) - multi_callable(request, _TIMEOUT) + multi_callable(request, test_constants.SHORT_TIMEOUT) def testExpiredUnaryRequestStreamResponse(self): for name, test_messages_sequence in ( @@ -155,7 +153,7 @@ class BlockingInvocationInlineServiceTestCase( with self.control.pause(), self.assertRaises( exceptions.ExpirationError): response_iterator = self.stub.inline_value_in_stream_out( - name, request, _TIMEOUT) + name, request, test_constants.SHORT_TIMEOUT) list(response_iterator) def testExpiredStreamRequestUnaryResponse(self): @@ -167,7 +165,7 @@ class BlockingInvocationInlineServiceTestCase( with self.control.pause(), self.assertRaises( exceptions.ExpirationError): multi_callable = self.stub.stream_unary_multi_callable(name) - multi_callable(iter(requests), _TIMEOUT) + multi_callable(iter(requests), test_constants.SHORT_TIMEOUT) def testExpiredStreamRequestStreamResponse(self): for name, test_messages_sequence in ( @@ -178,7 +176,7 @@ class BlockingInvocationInlineServiceTestCase( with self.control.pause(), self.assertRaises( exceptions.ExpirationError): response_iterator = self.stub.inline_stream_in_stream_out( - name, iter(requests), _TIMEOUT) + name, iter(requests), test_constants.SHORT_TIMEOUT) list(response_iterator) def testFailedUnaryRequestUnaryResponse(self): @@ -188,7 +186,8 @@ class BlockingInvocationInlineServiceTestCase( request = test_messages.request() with self.control.fail(), self.assertRaises(exceptions.ServicerError): - self.stub.blocking_value_in_value_out(name, request, _TIMEOUT) + self.stub.blocking_value_in_value_out(name, request, + test_constants.SHORT_TIMEOUT) def testFailedUnaryRequestStreamResponse(self): for name, test_messages_sequence in ( @@ -198,7 +197,7 @@ class BlockingInvocationInlineServiceTestCase( with self.control.fail(), self.assertRaises(exceptions.ServicerError): response_iterator = self.stub.inline_value_in_stream_out( - name, request, _TIMEOUT) + name, request, test_constants.SHORT_TIMEOUT) list(response_iterator) def testFailedStreamRequestUnaryResponse(self): @@ -208,7 +207,8 @@ class BlockingInvocationInlineServiceTestCase( requests = test_messages.requests() with self.control.fail(), self.assertRaises(exceptions.ServicerError): - self.stub.blocking_stream_in_value_out(name, iter(requests), _TIMEOUT) + self.stub.blocking_stream_in_value_out(name, iter(requests), + test_constants.SHORT_TIMEOUT) def testFailedStreamRequestStreamResponse(self): for name, test_messages_sequence in ( @@ -218,5 +218,5 @@ class BlockingInvocationInlineServiceTestCase( with self.control.fail(), self.assertRaises(exceptions.ServicerError): response_iterator = self.stub.inline_stream_in_stream_out( - name, iter(requests), _TIMEOUT) + name, iter(requests), test_constants.SHORT_TIMEOUT) list(response_iterator) diff --git a/src/python/src/grpc/framework/face/testing/callback.py b/src/python/grpcio_test/grpc_test/framework/face/testing/callback.py index d0e63c8c56..d0e63c8c56 100644 --- a/src/python/src/grpc/framework/face/testing/callback.py +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/callback.py diff --git a/src/python/src/grpc/framework/face/testing/control.py b/src/python/grpcio_test/grpc_test/framework/face/testing/control.py index 3960c4e649..3960c4e649 100644 --- a/src/python/src/grpc/framework/face/testing/control.py +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/control.py diff --git a/src/python/src/grpc/framework/face/testing/coverage.py b/src/python/grpcio_test/grpc_test/framework/face/testing/coverage.py index f3aca113fe..f3aca113fe 100644 --- a/src/python/src/grpc/framework/face/testing/coverage.py +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/coverage.py diff --git a/src/python/src/grpc/framework/face/testing/digest.py b/src/python/grpcio_test/grpc_test/framework/face/testing/digest.py index db8fcbb018..54ff21779a 100644 --- a/src/python/src/grpc/framework/face/testing/digest.py +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/digest.py @@ -38,11 +38,11 @@ from grpc.framework.common import cardinality from grpc.framework.common import style from grpc.framework.face import exceptions from grpc.framework.face import interfaces as face_interfaces -from grpc.framework.face.testing import control as testing_control # pylint: disable=unused-import -from grpc.framework.face.testing import interfaces # pylint: disable=unused-import -from grpc.framework.face.testing import service as testing_service # pylint: disable=unused-import 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 _IDENTITY = lambda x: x diff --git a/src/python/src/grpc/framework/face/testing/event_invocation_synchronous_event_service_test_case.py b/src/python/grpcio_test/grpc_test/framework/face/testing/event_invocation_synchronous_event_service_test_case.py index 0f0b0e3d52..9df77678eb 100644 --- a/src/python/src/grpc/framework/face/testing/event_invocation_synchronous_event_service_test_case.py +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/event_invocation_synchronous_event_service_test_case.py @@ -33,14 +33,13 @@ import abc import unittest from grpc.framework.face import interfaces -from grpc.framework.face.testing import callback as testing_callback -from grpc.framework.face.testing import control -from grpc.framework.face.testing import coverage -from grpc.framework.face.testing import digest -from grpc.framework.face.testing import stock_service -from grpc.framework.face.testing import test_case - -_TIMEOUT = 3 +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 class EventInvocationSynchronousEventServiceTestCase( @@ -79,7 +78,8 @@ class EventInvocationSynchronousEventServiceTestCase( callback = testing_callback.Callback() self.stub.event_value_in_value_out( - name, request, callback.complete, callback.abort, _TIMEOUT) + name, request, callback.complete, callback.abort, + test_constants.SHORT_TIMEOUT) callback.block_until_terminated() response = callback.response() @@ -93,7 +93,8 @@ class EventInvocationSynchronousEventServiceTestCase( callback = testing_callback.Callback() self.stub.event_value_in_stream_out( - name, request, callback, callback.abort, _TIMEOUT) + name, request, callback, callback.abort, + test_constants.SHORT_TIMEOUT) callback.block_until_terminated() responses = callback.responses() @@ -107,7 +108,8 @@ class EventInvocationSynchronousEventServiceTestCase( callback = testing_callback.Callback() unused_call, request_consumer = self.stub.event_stream_in_value_out( - name, callback.complete, callback.abort, _TIMEOUT) + name, callback.complete, callback.abort, + test_constants.SHORT_TIMEOUT) for request in requests: request_consumer.consume(request) request_consumer.terminate() @@ -124,7 +126,7 @@ class EventInvocationSynchronousEventServiceTestCase( callback = testing_callback.Callback() unused_call, request_consumer = self.stub.event_stream_in_stream_out( - name, callback, callback.abort, _TIMEOUT) + name, callback, callback.abort, test_constants.SHORT_TIMEOUT) for request in requests: request_consumer.consume(request) request_consumer.terminate() @@ -147,11 +149,11 @@ class EventInvocationSynchronousEventServiceTestCase( first_callback.complete(first_response) self.stub.event_value_in_value_out( name, second_request, second_callback.complete, - second_callback.abort, _TIMEOUT) + second_callback.abort, test_constants.SHORT_TIMEOUT) self.stub.event_value_in_value_out( name, first_request, make_second_invocation, first_callback.abort, - _TIMEOUT) + test_constants.SHORT_TIMEOUT) second_callback.block_until_terminated() first_response = first_callback.response() @@ -168,7 +170,8 @@ class EventInvocationSynchronousEventServiceTestCase( with self.control.pause(): self.stub.event_value_in_value_out( - name, request, callback.complete, callback.abort, _TIMEOUT) + name, request, callback.complete, callback.abort, + test_constants.SHORT_TIMEOUT) callback.block_until_terminated() self.assertEqual(interfaces.Abortion.EXPIRED, callback.abortion()) @@ -182,7 +185,8 @@ class EventInvocationSynchronousEventServiceTestCase( with self.control.pause(): self.stub.event_value_in_stream_out( - name, request, callback, callback.abort, _TIMEOUT) + name, request, callback, callback.abort, + test_constants.SHORT_TIMEOUT) callback.block_until_terminated() self.assertEqual(interfaces.Abortion.EXPIRED, callback.abortion()) @@ -194,7 +198,8 @@ class EventInvocationSynchronousEventServiceTestCase( callback = testing_callback.Callback() self.stub.event_stream_in_value_out( - name, callback.complete, callback.abort, _TIMEOUT) + name, callback.complete, callback.abort, + test_constants.SHORT_TIMEOUT) callback.block_until_terminated() self.assertEqual(interfaces.Abortion.EXPIRED, callback.abortion()) @@ -207,7 +212,7 @@ class EventInvocationSynchronousEventServiceTestCase( callback = testing_callback.Callback() unused_call, request_consumer = self.stub.event_stream_in_stream_out( - name, callback, callback.abort, _TIMEOUT) + name, callback, callback.abort, test_constants.SHORT_TIMEOUT) for request in requests: request_consumer.consume(request) callback.block_until_terminated() @@ -223,10 +228,12 @@ class EventInvocationSynchronousEventServiceTestCase( with self.control.fail(): self.stub.event_value_in_value_out( - name, request, callback.complete, callback.abort, _TIMEOUT) + name, request, callback.complete, callback.abort, + test_constants.SHORT_TIMEOUT) callback.block_until_terminated() - self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, callback.abortion()) + self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, + callback.abortion()) def testFailedUnaryRequestStreamResponse(self): for name, test_messages_sequence in ( @@ -237,10 +244,12 @@ class EventInvocationSynchronousEventServiceTestCase( with self.control.fail(): self.stub.event_value_in_stream_out( - name, request, callback, callback.abort, _TIMEOUT) + name, request, callback, callback.abort, + test_constants.SHORT_TIMEOUT) callback.block_until_terminated() - self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, callback.abortion()) + self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, + callback.abortion()) def testFailedStreamRequestUnaryResponse(self): for name, test_messages_sequence in ( @@ -251,13 +260,15 @@ class EventInvocationSynchronousEventServiceTestCase( with self.control.fail(): unused_call, request_consumer = self.stub.event_stream_in_value_out( - name, callback.complete, callback.abort, _TIMEOUT) + name, callback.complete, callback.abort, + test_constants.SHORT_TIMEOUT) for request in requests: request_consumer.consume(request) request_consumer.terminate() callback.block_until_terminated() - self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, callback.abortion()) + self.assertEqual(interfaces.Abortion.SERVICER_FAILURE, + callback.abortion()) def testFailedStreamRequestStreamResponse(self): for name, test_messages_sequence in ( @@ -268,7 +279,7 @@ class EventInvocationSynchronousEventServiceTestCase( with self.control.fail(): unused_call, request_consumer = self.stub.event_stream_in_stream_out( - name, callback, callback.abort, _TIMEOUT) + name, callback, callback.abort, test_constants.SHORT_TIMEOUT) for request in requests: request_consumer.consume(request) request_consumer.terminate() @@ -287,10 +298,10 @@ class EventInvocationSynchronousEventServiceTestCase( self.stub.event_value_in_value_out( name, first_request, first_callback.complete, first_callback.abort, - _TIMEOUT) + test_constants.SHORT_TIMEOUT) self.stub.event_value_in_value_out( name, second_request, second_callback.complete, - second_callback.abort, _TIMEOUT) + second_callback.abort, test_constants.SHORT_TIMEOUT) first_callback.block_until_terminated() second_callback.block_until_terminated() @@ -312,7 +323,8 @@ class EventInvocationSynchronousEventServiceTestCase( with self.control.pause(): call = self.stub.event_value_in_value_out( - name, request, callback.complete, callback.abort, _TIMEOUT) + name, request, callback.complete, callback.abort, + test_constants.SHORT_TIMEOUT) call.cancel() callback.block_until_terminated() @@ -326,7 +338,8 @@ class EventInvocationSynchronousEventServiceTestCase( callback = testing_callback.Callback() call = self.stub.event_value_in_stream_out( - name, request, callback, callback.abort, _TIMEOUT) + name, request, callback, callback.abort, + test_constants.SHORT_TIMEOUT) call.cancel() callback.block_until_terminated() @@ -340,7 +353,8 @@ class EventInvocationSynchronousEventServiceTestCase( callback = testing_callback.Callback() call, request_consumer = self.stub.event_stream_in_value_out( - name, callback.complete, callback.abort, _TIMEOUT) + name, callback.complete, callback.abort, + test_constants.SHORT_TIMEOUT) for request in requests: request_consumer.consume(request) call.cancel() @@ -355,7 +369,7 @@ class EventInvocationSynchronousEventServiceTestCase( callback = testing_callback.Callback() call, unused_request_consumer = self.stub.event_stream_in_stream_out( - name, callback, callback.abort, _TIMEOUT) + name, callback, callback.abort, test_constants.SHORT_TIMEOUT) call.cancel() callback.block_until_terminated() diff --git a/src/python/src/grpc/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py b/src/python/grpcio_test/grpc_test/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py index 21bf9a4248..70d86a0422 100644 --- a/src/python/src/grpc/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py @@ -35,15 +35,15 @@ import threading import unittest from grpc.framework.face import exceptions -from grpc.framework.face.testing import control -from grpc.framework.face.testing import coverage -from grpc.framework.face.testing import digest -from grpc.framework.face.testing import stock_service -from grpc.framework.face.testing import test_case 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 -_TIMEOUT = 3 _MAXIMUM_POOL_SIZE = 10 @@ -110,7 +110,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( request = test_messages.request() response_future = self.stub.future_value_in_value_out( - name, request, _TIMEOUT) + name, request, test_constants.SHORT_TIMEOUT) response = response_future.result() test_messages.verify(request, response, self) @@ -122,7 +122,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( request = test_messages.request() response_iterator = self.stub.inline_value_in_stream_out( - name, request, _TIMEOUT) + name, request, test_constants.SHORT_TIMEOUT) responses = list(response_iterator) test_messages.verify(request, responses, self) @@ -138,7 +138,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( # returned to calling code before the iterator yields any requests. with request_iterator.pause(): response_future = self.stub.future_stream_in_value_out( - name, request_iterator, _TIMEOUT) + name, request_iterator, test_constants.SHORT_TIMEOUT) response = response_future.result() test_messages.verify(requests, response, self) @@ -154,7 +154,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( # returned to calling code before the iterator yields any requests. with request_iterator.pause(): response_iterator = self.stub.inline_stream_in_stream_out( - name, request_iterator, _TIMEOUT) + name, request_iterator, test_constants.SHORT_TIMEOUT) responses = list(response_iterator) test_messages.verify(requests, responses, self) @@ -167,13 +167,13 @@ class FutureInvocationAsynchronousEventServiceTestCase( second_request = test_messages.request() first_response_future = self.stub.future_value_in_value_out( - name, first_request, _TIMEOUT) + name, first_request, test_constants.SHORT_TIMEOUT) first_response = first_response_future.result() test_messages.verify(first_request, first_response, self) second_response_future = self.stub.future_value_in_value_out( - name, second_request, _TIMEOUT) + name, second_request, test_constants.SHORT_TIMEOUT) second_response = second_response_future.result() test_messages.verify(second_request, second_response, self) @@ -186,7 +186,8 @@ class FutureInvocationAsynchronousEventServiceTestCase( with self.control.pause(): multi_callable = self.stub.unary_unary_multi_callable(name) - response_future = multi_callable.future(request, _TIMEOUT) + response_future = multi_callable.future(request, + test_constants.SHORT_TIMEOUT) self.assertIsInstance( response_future.exception(), exceptions.ExpirationError) with self.assertRaises(exceptions.ExpirationError): @@ -200,7 +201,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( with self.control.pause(): response_iterator = self.stub.inline_value_in_stream_out( - name, request, _TIMEOUT) + name, request, test_constants.SHORT_TIMEOUT) with self.assertRaises(exceptions.ExpirationError): list(response_iterator) @@ -212,7 +213,8 @@ class FutureInvocationAsynchronousEventServiceTestCase( with self.control.pause(): multi_callable = self.stub.stream_unary_multi_callable(name) - response_future = multi_callable.future(iter(requests), _TIMEOUT) + response_future = multi_callable.future(iter(requests), + test_constants.SHORT_TIMEOUT) self.assertIsInstance( response_future.exception(), exceptions.ExpirationError) with self.assertRaises(exceptions.ExpirationError): @@ -226,7 +228,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( with self.control.pause(): response_iterator = self.stub.inline_stream_in_stream_out( - name, iter(requests), _TIMEOUT) + name, iter(requests), test_constants.SHORT_TIMEOUT) with self.assertRaises(exceptions.ExpirationError): list(response_iterator) @@ -238,7 +240,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( with self.control.fail(): response_future = self.stub.future_value_in_value_out( - name, request, _TIMEOUT) + name, request, test_constants.SHORT_TIMEOUT) # Because the servicer fails outside of the thread from which the # servicer-side runtime called into it its failure is @@ -261,7 +263,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( # expiration of the RPC. with self.control.fail(), self.assertRaises(exceptions.ExpirationError): response_iterator = self.stub.inline_value_in_stream_out( - name, request, _TIMEOUT) + name, request, test_constants.SHORT_TIMEOUT) list(response_iterator) def testFailedStreamRequestUnaryResponse(self): @@ -272,7 +274,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( with self.control.fail(): response_future = self.stub.future_stream_in_value_out( - name, iter(requests), _TIMEOUT) + name, iter(requests), test_constants.SHORT_TIMEOUT) # Because the servicer fails outside of the thread from which the # servicer-side runtime called into it its failure is @@ -295,7 +297,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( # expiration of the RPC. with self.control.fail(), self.assertRaises(exceptions.ExpirationError): response_iterator = self.stub.inline_stream_in_stream_out( - name, iter(requests), _TIMEOUT) + name, iter(requests), test_constants.SHORT_TIMEOUT) list(response_iterator) def testParallelInvocations(self): @@ -305,10 +307,11 @@ class FutureInvocationAsynchronousEventServiceTestCase( first_request = test_messages.request() second_request = test_messages.request() + # TODO(bug 2039): use LONG_TIMEOUT instead first_response_future = self.stub.future_value_in_value_out( - name, first_request, _TIMEOUT) + name, first_request, test_constants.SHORT_TIMEOUT) second_response_future = self.stub.future_value_in_value_out( - name, second_request, _TIMEOUT) + name, second_request, test_constants.SHORT_TIMEOUT) first_response = first_response_future.result() second_response = second_response_future.result() @@ -327,7 +330,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( with self.control.pause(): response_future = self.stub.future_value_in_value_out( - name, request, _TIMEOUT) + name, request, test_constants.SHORT_TIMEOUT) cancel_method_return_value = response_future.cancel() self.assertFalse(cancel_method_return_value) @@ -341,7 +344,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( with self.control.pause(): response_iterator = self.stub.inline_value_in_stream_out( - name, request, _TIMEOUT) + name, request, test_constants.SHORT_TIMEOUT) response_iterator.cancel() with self.assertRaises(future.CancelledError): @@ -355,7 +358,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( with self.control.pause(): response_future = self.stub.future_stream_in_value_out( - name, iter(requests), _TIMEOUT) + name, iter(requests), test_constants.SHORT_TIMEOUT) cancel_method_return_value = response_future.cancel() self.assertFalse(cancel_method_return_value) @@ -369,7 +372,7 @@ class FutureInvocationAsynchronousEventServiceTestCase( with self.control.pause(): response_iterator = self.stub.inline_stream_in_stream_out( - name, iter(requests), _TIMEOUT) + name, iter(requests), test_constants.SHORT_TIMEOUT) response_iterator.cancel() with self.assertRaises(future.CancelledError): diff --git a/src/python/src/grpc/framework/face/testing/interfaces.py b/src/python/grpcio_test/grpc_test/framework/face/testing/interfaces.py index 5932dabf1e..5932dabf1e 100644 --- a/src/python/src/grpc/framework/face/testing/interfaces.py +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/interfaces.py diff --git a/src/python/src/grpc/framework/face/testing/serial.py b/src/python/grpcio_test/grpc_test/framework/face/testing/serial.py index 47fc5822de..47fc5822de 100644 --- a/src/python/src/grpc/framework/face/testing/serial.py +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/serial.py diff --git a/src/python/src/grpc/framework/face/testing/service.py b/src/python/grpcio_test/grpc_test/framework/face/testing/service.py index bf54d41d66..ee9d6a3da3 100644 --- a/src/python/src/grpc/framework/face/testing/service.py +++ b/src/python/grpcio_test/grpc_test/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.framework.face.testing import interfaces +from grpc_test.framework.face.testing import interfaces class UnaryUnaryTestMethodImplementation(interfaces.Method): diff --git a/src/python/src/grpc/framework/face/testing/stock_service.py b/src/python/grpcio_test/grpc_test/framework/face/testing/stock_service.py index 61aaf444a0..0f83ca4db1 100644 --- a/src/python/src/grpc/framework/face/testing/stock_service.py +++ b/src/python/grpcio_test/grpc_test/framework/face/testing/stock_service.py @@ -30,11 +30,11 @@ """Examples of Python implementations of the stock.proto Stock service.""" from grpc.framework.common import cardinality -from grpc.framework.face.testing import service from grpc.framework.foundation import abandonment from grpc.framework.foundation import stream from grpc.framework.foundation import stream_util -from grpc._junkdrawer import stock_pb2 +from grpc_test.framework.face.testing import service +from grpc_test._junkdrawer import stock_pb2 SYMBOL_FORMAT = 'test symbol:%03d' STREAM_LENGTH = 400 diff --git a/src/python/src/grpc/framework/face/testing/test_case.py b/src/python/grpcio_test/grpc_test/framework/face/testing/test_case.py index e60e3d1d40..858d5cf7fd 100644 --- a/src/python/src/grpc/framework/face/testing/test_case.py +++ b/src/python/grpcio_test/grpc_test/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.framework.face.testing import interfaces # pylint: disable=unused-import +from grpc_test.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_test/grpc_test/framework/foundation/__init__.py new file mode 100644 index 0000000000..7086519106 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/framework/foundation/__init__.py @@ -0,0 +1,30 @@ +# 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. + + diff --git a/src/python/src/grpc/framework/foundation/_later_test.py b/src/python/grpcio_test/grpc_test/framework/foundation/_later_test.py index 6c2459e185..6c2459e185 100644 --- a/src/python/src/grpc/framework/foundation/_later_test.py +++ b/src/python/grpcio_test/grpc_test/framework/foundation/_later_test.py diff --git a/src/python/src/grpc/framework/foundation/_logging_pool_test.py b/src/python/grpcio_test/grpc_test/framework/foundation/_logging_pool_test.py index 452802da6a..452802da6a 100644 --- a/src/python/src/grpc/framework/foundation/_logging_pool_test.py +++ b/src/python/grpcio_test/grpc_test/framework/foundation/_logging_pool_test.py diff --git a/src/python/src/grpc/framework/foundation/stream_testing.py b/src/python/grpcio_test/grpc_test/framework/foundation/stream_testing.py index 098a53d5e7..098a53d5e7 100644 --- a/src/python/src/grpc/framework/foundation/stream_testing.py +++ b/src/python/grpcio_test/grpc_test/framework/foundation/stream_testing.py diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/__init__.py b/src/python/grpcio_test/grpc_test/framework/interfaces/__init__.py new file mode 100644 index 0000000000..7086519106 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/framework/interfaces/__init__.py @@ -0,0 +1,30 @@ +# 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. + + diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/links/__init__.py b/src/python/grpcio_test/grpc_test/framework/interfaces/links/__init__.py new file mode 100644 index 0000000000..7086519106 --- /dev/null +++ b/src/python/grpcio_test/grpc_test/framework/interfaces/links/__init__.py @@ -0,0 +1,30 @@ +# 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. + + diff --git a/src/python/src/grpc/framework/interfaces/links/test_cases.py b/src/python/grpcio_test/grpc_test/framework/interfaces/links/test_cases.py index bf1f09d99d..26ca035c44 100644 --- a/src/python/src/grpc/framework/interfaces/links/test_cases.py +++ b/src/python/grpcio_test/grpc_test/framework/interfaces/links/test_cases.py @@ -33,9 +33,9 @@ import abc import unittest # pylint: disable=unused-import -from grpc.framework.common import test_constants from grpc.framework.interfaces.links import links -from grpc.framework.interfaces.links import test_utilities +from grpc_test.framework.common import test_constants +from grpc_test.framework.interfaces.links import test_utilities def at_least_n_payloads_received_predicate(n): diff --git a/src/python/src/grpc/framework/interfaces/links/test_utilities.py b/src/python/grpcio_test/grpc_test/framework/interfaces/links/test_utilities.py index 6c2e3346aa..6c2e3346aa 100644 --- a/src/python/src/grpc/framework/interfaces/links/test_utilities.py +++ b/src/python/grpcio_test/grpc_test/framework/interfaces/links/test_utilities.py diff --git a/src/python/grpcio_test/grpc_test/test_common.py b/src/python/grpcio_test/grpc_test/test_common.py new file mode 100644 index 0000000000..f8e1f1e43f --- /dev/null +++ b/src/python/grpcio_test/grpc_test/test_common.py @@ -0,0 +1,71 @@ +# 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. + +"""Common code used throughout tests of gRPC.""" + +import collections + + +def metadata_transmitted(original_metadata, transmitted_metadata): + """Judges whether or not metadata was acceptably transmitted. + + gRPC is allowed to insert key-value pairs into the metadata values given by + applications and to reorder key-value pairs with different keys but it is not + allowed to alter existing key-value pairs or to reorder key-value pairs with + the same key. + + Args: + original_metadata: A metadata value used in a test of gRPC. + transmitted_metadata: A metadata value corresponding to original_metadata + after having been transmitted via gRPC. + + Returns: + A boolean indicating whether transmitted_metadata accurately reflects + original_metadata after having been transmitted via gRPC. + """ + original = collections.defaultdict(list) + for key, value in original_metadata: + original[key].append(value) + transmitted = collections.defaultdict(list) + for key, value in transmitted_metadata: + transmitted[key].append(value) + + for key, values in original.iteritems(): + transmitted_values = transmitted[key] + transmitted_iterator = iter(transmitted_values) + try: + for value in values: + while True: + transmitted_value = next(transmitted_iterator) + if value == transmitted_value: + break + except StopIteration: + return False + else: + return True diff --git a/src/python/grpcio_test/requirements.txt b/src/python/grpcio_test/requirements.txt new file mode 100644 index 0000000000..856198def5 --- /dev/null +++ b/src/python/grpcio_test/requirements.txt @@ -0,0 +1,5 @@ +pytest>=2.6 +pytest-cov>=2.0 +pytest-xdist>=1.11 +oauth2client>=1.4.7 +grpcio>=0.10.0a0 diff --git a/src/python/grpcio_test/setup.cfg b/src/python/grpcio_test/setup.cfg new file mode 100644 index 0000000000..b32d3f5972 --- /dev/null +++ b/src/python/grpcio_test/setup.cfg @@ -0,0 +1,3 @@ +[pytest] +norecursedirs = _cython +python_files = *_test.py diff --git a/src/python/grpcio_test/setup.py b/src/python/grpcio_test/setup.py new file mode 100644 index 0000000000..a6203cae2d --- /dev/null +++ b/src/python/grpcio_test/setup.py @@ -0,0 +1,84 @@ +# 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. + +"""A setup module for the GRPC Python interop testing package.""" + +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('.', exclude=['*._cython', '*._cython.*']) + +_PACKAGE_DIRECTORIES = { + '': '.', +} + +_PACKAGE_DATA = { + 'grpc_interop': [ + 'credentials/ca.pem', + 'credentials/server1.key', + 'credentials/server1.pem', + ], + 'grpc_protoc_plugin': [ + 'test.proto', + ], +} + +_SETUP_REQUIRES = ( + 'pytest>=2.6', + 'pytest-cov>=2.0', + 'pytest-xdist>=1.11', +) + +_INSTALL_REQUIRES = ( + 'oauth2client>=1.4.7', + 'grpcio>=0.10.0a0', +) + +_COMMAND_CLASS = { + 'test': commands.RunTests +} + +setuptools.setup( + name='grpcio_test', + version='0.10.0a0', + packages=_PACKAGES, + package_dir=_PACKAGE_DIRECTORIES, + package_data=_PACKAGE_DATA, + install_requires=_INSTALL_REQUIRES + _SETUP_REQUIRES, + setup_requires=_SETUP_REQUIRES, + cmdclass=_COMMAND_CLASS, +) diff --git a/src/python/src/.gitignore b/src/python/src/.gitignore deleted file mode 100644 index 144e501237..0000000000 --- a/src/python/src/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -MANIFEST -grpcio.egg-info/ -build/ -dist/ diff --git a/src/python/src/MANIFEST.in b/src/python/src/MANIFEST.in deleted file mode 100644 index 6f32db0548..0000000000 --- a/src/python/src/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -graft grpc |