@@ -544,49 +544,54 @@ def test_sync_client_resets_failure_tracking_after_application_error():
544544 assert client ._client_failure_tracker .consecutive_failures == 0
545545
546546
547- def test_async_client_stores_resolved_transport_inputs ():
548- resiliency = GrpcClientResiliencyOptions ()
549- channel_options = GrpcChannelOptions (max_send_message_length = 4321 )
550- interceptors = [DefaultAsyncClientInterceptorImpl (METADATA )]
551- with patch ("durabletask.client.shared.get_async_grpc_channel" , return_value = MagicMock ()), patch (
552- "durabletask.client.stubs.TaskHubSidecarServiceStub" , return_value = MagicMock ()
553- ):
554- client = AsyncTaskHubGrpcClient (
555- host_address = "localhost:4001" ,
556- secure_channel = True ,
557- interceptors = interceptors ,
558- channel_options = channel_options ,
559- resiliency_options = resiliency ,
560- )
561- assert client ._resiliency_options is resiliency
562- assert client ._host_address == "localhost:4001"
563- assert client ._secure_channel is True
564- assert client ._channel_options is channel_options
565- assert client ._interceptors == interceptors
566-
567-
568547@pytest .mark .asyncio
569- async def test_async_client_recreates_sdk_owned_channel_after_unavailable ():
548+ async def test_async_client_recreates_sdk_owned_channel_with_original_transport_inputs ():
570549 rpc_error = make_aio_rpc_error (grpc .StatusCode .UNAVAILABLE )
571-
550+ first_channel = MagicMock (name = "first-channel" )
551+ first_channel .close = AsyncMock ()
552+ second_channel = MagicMock (name = "second-channel" )
553+ second_channel .close = AsyncMock ()
572554 first_stub = MagicMock ()
573555 first_stub .GetInstance = AsyncMock (side_effect = rpc_error )
574556 second_stub = MagicMock ()
575557 second_stub .GetInstance = AsyncMock (return_value = MagicMock (exists = False ))
558+ host_address = "localhost:4001"
559+ interceptors = [DefaultAsyncClientInterceptorImpl (METADATA )]
560+ channel_options = GrpcChannelOptions (max_send_message_length = 4321 )
576561
577- with patch ("durabletask.client.shared.get_async_grpc_channel" , side_effect = [MagicMock (), MagicMock ()]), patch (
562+ with patch (
563+ "durabletask.client.shared.get_async_grpc_channel" ,
564+ side_effect = [first_channel , second_channel ],
565+ ) as mock_get_channel , patch (
578566 "durabletask.client.stubs.TaskHubSidecarServiceStub" , side_effect = [first_stub , second_stub ]
579567 ):
580568 client = AsyncTaskHubGrpcClient (
581- host_address = "localhost:4001" ,
569+ host_address = host_address ,
570+ secure_channel = True ,
571+ interceptors = interceptors ,
572+ channel_options = channel_options ,
582573 resiliency_options = GrpcClientResiliencyOptions (
583574 channel_recreate_failure_threshold = 1 ,
584575 min_recreate_interval_seconds = 0.0 ,
585576 ),
586577 )
587- with pytest .raises (grpc .aio .AioRpcError ):
578+ try :
579+ with pytest .raises (grpc .aio .AioRpcError ):
580+ await client .get_orchestration_state ("abc" )
588581 await client .get_orchestration_state ("abc" )
589- await client .get_orchestration_state ("abc" )
582+ finally :
583+ await client .close ()
584+
585+ expected_channel_call = call (
586+ host_address = host_address ,
587+ secure_channel = True ,
588+ interceptors = interceptors ,
589+ channel_options = channel_options ,
590+ )
591+ assert mock_get_channel .call_args_list == [
592+ expected_channel_call ,
593+ expected_channel_call ,
594+ ]
590595
591596
592597@pytest .mark .asyncio
0 commit comments