Example #1
0
def raw(respw, server, transport, **kwargs):
    rpc = RPC(
        service='client',
        outbounds={
            'yarpc-test': tr.factory(server, transport),
        },
    )

    expected = rand.string(7)

    request = Request(procedure='echo/raw', body=expected, ttl=10000)
    client = RawClient(rpc.channel('yarpc-test'))
    future = client.call(request)
    response = future.result()

    if response.body == expected:
        respw.success("Server said: %s" % response.body)
    else:
        respw.fail("expected %s, got %s" % (expected, response.body))
Example #2
0
def thrift(respw, server, transport, **kwargs):
    rpc = RPC(
        service='client',
        outbounds={
            'yarpc-test': tr.factory(server, transport),
        },
    )

    expected = rand.string(7)

    request = Request(
        body=service.Echo.echo(service.Ping(beep=expected)),
        ttl=10000,
    )
    client = ThriftClient(rpc.channel('yarpc-test'))
    future = client.call(request)
    response = future.result()

    if response.body.boop == expected:
        respw.success("Server said: %s" % response.body.boop)
    else:
        respw.fail("expected %s, got %s" % (expected, response.body))
Example #3
0
def headers(respw, server, transport, encoding, **kwargs):
    rpc = RPC(
        service='client',
        outbounds={
            'yarpc-test': tr.factory(server, transport),
        },
    )
    caller = get_caller(encoding, rpc.channel('yarpc-test'))

    for test in tests:
        desc, give, want = test
        try:
            resp = caller.call(give).result()
        except Exception as e:
            respw.fail('%s: call failed, %s' % (desc, str(e)))
        else:
            got = resp.headers
            if want != got:
                respw.fail(
                    '%s: call failed, got %s, want %s' % (desc, got, want)
                )
            else:
                respw.success('%s: returns valid headers' % desc)