Exemplo n.º 1
0
def test_envelope_in_sep_request():
    """ ser/des on envelope only much faster

    :return:
    """
    recv = [(rr.envelope, rr.request.SerializeToString())
            for rr in (add_envelope(r, 'test', '123')
                       for r in _generate(random_docs(num_docs)))]
    with TimeContext('serialize and deserialize'):
        for _ in range(
                num_reqs
        ):  # mimic chaining _pass, no need to deserialize request
            sent = [(msg[0].SerializeToString(), msg[1])
                    for msg in recv]  # mimic sent

            # mimic receive
            recv.clear()
            for m in sent:
                msg = jina_pb2.Envelope()
                msg.ParseFromString(m[0])
                msg.request_id += 'r'
                recv.append((msg, m[1]))

    for r in recv:
        assert r[0].request_id.endswith('r' * num_reqs)
Exemplo n.º 2
0
def test_add_route():
    envelope = jina_pb2.Envelope()
    add_route(envelope, 'name', 'identity')
    assert len(envelope.routes) == 1
    assert envelope.routes[0].pod == 'name'
    assert envelope.routes[0].pod_id == 'identity'