Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
def req():
    return Request(
        endpoint="endpoint1",
        service="test",
    )
Ejemplo n.º 7
0
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