Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@pytest.mark.parametrize("backoff", [None, default_backoff(), backoff_linear_with_jitter(0.05, 0.1)])
def test_infinite_retries_deadline_and_backoff(backoff):
service = _AlwaysUnavailable()
server = grpc_server(service.handler)
with default_channel() as channel:
interceptor = RetryInterceptor(max_retry_count=-1, retriable_codes=[grpc.StatusCode.UNAVAILABLE],
add_retry_count_to_header=True, back_off_func=backoff)
ch = grpc.intercept_channel(channel, interceptor)
client = zone_service_pb2_grpc.ZoneServiceStub(ch)
with pytest.raises(grpc.RpcError) as e:
client.Get(zone_service_pb2.GetZoneRequest(zone_id="id"), timeout=5)
assert e.value.code() == grpc.StatusCode.DEADLINE_EXCEEDED