From 5444bed32f1405ebb53b0c37d3b3246d097ace89 Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Thu, 16 Jun 2016 23:37:12 +0000 Subject: [PATCH] Rename FATAL_FAILURE SHUTDOWN --- src/python/grpcio/grpc/__init__.py | 4 ++-- src/python/grpcio/grpc/_adapter/_types.py | 2 +- src/python/grpcio/grpc/_common.py | 4 ++-- .../grpcio/grpc/_cython/_cygrpc/records.pyx.pxi | 2 +- src/python/grpcio/grpc/beta/interfaces.py | 3 +++ src/python/grpcio/tests/tests.json | 2 ++ src/python/grpcio/tests/unit/_api_test.py | 14 ++++++++++++++ .../tests/unit/beta/_connectivity_channel_test.py | 10 ++++++++++ 8 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 1cc0c3a2505..28adca37723 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -212,14 +212,14 @@ class ChannelConnectivity(enum.Enum): READY: The channel is ready to conduct RPCs. TRANSIENT_FAILURE: The channel has seen a failure from which it expects to recover. - FATAL_FAILURE: The channel has seen a failure from which it cannot recover. + SHUTDOWN: The channel has seen a failure from which it cannot recover. """ IDLE = (_cygrpc.ConnectivityState.idle, 'idle') CONNECTING = (_cygrpc.ConnectivityState.connecting, 'connecting') READY = (_cygrpc.ConnectivityState.ready, 'ready') TRANSIENT_FAILURE = ( _cygrpc.ConnectivityState.transient_failure, 'transient failure') - FATAL_FAILURE = (_cygrpc.ConnectivityState.fatal_failure, 'fatal failure') + SHUTDOWN = (_cygrpc.ConnectivityState.shutdown, 'shutdown') @enum.unique diff --git a/src/python/grpcio/grpc/_adapter/_types.py b/src/python/grpcio/grpc/_adapter/_types.py index f8405949d43..b7cc6fbbb59 100644 --- a/src/python/grpcio/grpc/_adapter/_types.py +++ b/src/python/grpcio/grpc/_adapter/_types.py @@ -114,7 +114,7 @@ class ConnectivityState(enum.IntEnum): CONNECTING = cygrpc.ConnectivityState.connecting READY = cygrpc.ConnectivityState.ready TRANSIENT_FAILURE = cygrpc.ConnectivityState.transient_failure - FATAL_FAILURE = cygrpc.ConnectivityState.fatal_failure + FATAL_FAILURE = cygrpc.ConnectivityState.shutdown class Status(collections.namedtuple( diff --git a/src/python/grpcio/grpc/_common.py b/src/python/grpcio/grpc/_common.py index 1fd1704f18b..f351bea9e39 100644 --- a/src/python/grpcio/grpc/_common.py +++ b/src/python/grpcio/grpc/_common.py @@ -46,8 +46,8 @@ CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY = { cygrpc.ConnectivityState.ready: grpc.ChannelConnectivity.READY, cygrpc.ConnectivityState.transient_failure: grpc.ChannelConnectivity.TRANSIENT_FAILURE, - cygrpc.ConnectivityState.fatal_failure: - grpc.ChannelConnectivity.FATAL_FAILURE, + cygrpc.ConnectivityState.shutdown: + grpc.ChannelConnectivity.SHUTDOWN, } CYGRPC_STATUS_CODE_TO_STATUS_CODE = { diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi index 2e52953c0a3..0055d0d3a28 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi @@ -33,7 +33,7 @@ class ConnectivityState: connecting = GRPC_CHANNEL_CONNECTING ready = GRPC_CHANNEL_READY transient_failure = GRPC_CHANNEL_TRANSIENT_FAILURE - fatal_failure = GRPC_CHANNEL_SHUTDOWN + shutdown = GRPC_CHANNEL_SHUTDOWN class ChannelArgKey: diff --git a/src/python/grpcio/grpc/beta/interfaces.py b/src/python/grpcio/grpc/beta/interfaces.py index 4343b6c4b52..90f6bbbfcc1 100644 --- a/src/python/grpcio/grpc/beta/interfaces.py +++ b/src/python/grpcio/grpc/beta/interfaces.py @@ -36,6 +36,9 @@ import six import grpc ChannelConnectivity = grpc.ChannelConnectivity +# FATAL_FAILURE was a Beta-API name for SHUTDOWN +ChannelConnectivity.FATAL_FAILURE = ChannelConnectivity.SHUTDOWN + StatusCode = grpc.StatusCode diff --git a/src/python/grpcio/tests/tests.json b/src/python/grpcio/tests/tests.json index c13031fa8ec..782dc00cdc8 100644 --- a/src/python/grpcio/tests/tests.json +++ b/src/python/grpcio/tests/tests.json @@ -1,5 +1,6 @@ [ "_api_test.AllTest", + "_api_test.ChannelConnectivityTest", "_auth_test.AccessTokenCallCredentialsTest", "_auth_test.GoogleCallCredentialsTest", "_base_interface_test.AsyncEasyTest", @@ -13,6 +14,7 @@ "_channel_ready_future_test.ChannelReadyFutureTest", "_channel_test.ChannelTest", "_connectivity_channel_test.ChannelConnectivityTest", + "_connectivity_channel_test.ConnectivityStatesTest", "_core_over_links_base_interface_test.AsyncEasyTest", "_core_over_links_base_interface_test.AsyncPeasyTest", "_core_over_links_base_interface_test.SyncEasyTest", diff --git a/src/python/grpcio/tests/unit/_api_test.py b/src/python/grpcio/tests/unit/_api_test.py index 1d724c3ed4f..1501ec2a047 100644 --- a/src/python/grpcio/tests/unit/_api_test.py +++ b/src/python/grpcio/tests/unit/_api_test.py @@ -33,6 +33,8 @@ import unittest import six +import grpc + from tests.unit import _from_grpc_import_star @@ -86,5 +88,17 @@ class AllTest(unittest.TestCase): _from_grpc_import_star.GRPC_ELEMENTS) +class ChannelConnectivityTest(unittest.TestCase): + + def testChannelConnectivity(self): + self.assertSequenceEqual( + (grpc.ChannelConnectivity.IDLE, + grpc.ChannelConnectivity.CONNECTING, + grpc.ChannelConnectivity.READY, + grpc.ChannelConnectivity.TRANSIENT_FAILURE, + grpc.ChannelConnectivity.SHUTDOWN,), + tuple(grpc.ChannelConnectivity)) + + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/src/python/grpcio/tests/unit/beta/_connectivity_channel_test.py b/src/python/grpcio/tests/unit/beta/_connectivity_channel_test.py index 5dc87206394..488f7d7141b 100644 --- a/src/python/grpcio/tests/unit/beta/_connectivity_channel_test.py +++ b/src/python/grpcio/tests/unit/beta/_connectivity_channel_test.py @@ -187,5 +187,15 @@ class ChannelConnectivityTest(unittest.TestCase): server_completion_queue_thread.join() +class ConnectivityStatesTest(unittest.TestCase): + + def testBetaConnectivityStates(self): + self.assertIsNotNone(interfaces.ChannelConnectivity.IDLE) + self.assertIsNotNone(interfaces.ChannelConnectivity.CONNECTING) + self.assertIsNotNone(interfaces.ChannelConnectivity.READY) + self.assertIsNotNone(interfaces.ChannelConnectivity.TRANSIENT_FAILURE) + self.assertIsNotNone(interfaces.ChannelConnectivity.FATAL_FAILURE) + + if __name__ == '__main__': unittest.main(verbosity=2)