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

    expected = {"token": rand.string(7)}

    request = Request(procedure="echo", body=expected, ttl=10000)
    client = JSONClient(rpc.channel("yarpc-test"))
    response = yield client.call(request)

    if response.body == expected:
        respw.success("Server said: %s" % response.body["token"])
    else:
        respw.fail("expected %s, got %s" % (expected, response.body))
Beispiel #2
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'))
    response = yield client.call(request)

    if response.body == expected:
        respw.success("Server said: %s" % response.body)
    else:
        respw.fail("expected %s, got %s" % (expected, response.body))
Beispiel #3
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'))
    response = yield client.call(request)

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

    expected = {
        'token': rand.string(7),
    }

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

    if response.body == expected:
        respw.success("Server said: %s" % response.body['token'])
    else:
        respw.fail("expected %s, got %s" % (expected, response.body))
Beispiel #5
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 = yield caller.call(give)
        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)