def test_should_retry_on_error(retry_flag, error_code, result): request = Request( headers={'re': retry_flag}, ) error = TChannelError.from_code(error_code, description="retry") assert request.should_retry_on_error(error) == result
def test_should_retry_on_error(retry_flag, error_code, result): request = Request( headers={'re': retry_flag}, ) error = ProtocolError(code=error_code, description="retry") assert request.should_retry_on_error(error) == result
def test_build_raw_request_message(): message_factory = MessageFactory() req = Request( ttl=32, service="test", headers={}, id=1111, ) req.state = StreamState.init message = message_factory.build_raw_request_message(req, None, True) assert message.ttl / 1000.0 == req.ttl assert message.flags == req.flags assert message.id == req.id assert message.service == req.service assert message.headers == req.headers
def test_zipkin_trace_zero_sampling(): run_times = 100000 hook = ZipkinTraceHook(sample_rate=0) request = Request() request.tracing.traceflags = True for _ in range(run_times): hook.before_send_request(request) assert not request.tracing.annotations
def req(): return Request( endpoint="endpoint1", service="test", )
def test_should_retry_on_error(retry_flag, error_code, result): request = Request(headers={'re': retry_flag}, ) error = ProtocolError(code=error_code, description="retry") assert request.should_retry_on_error(error) == result