diff --git a/gnes/proto/__init__.py b/gnes/proto/__init__.py index f066ac40..5cc8cee5 100644 --- a/gnes/proto/__init__.py +++ b/gnes/proto/__init__.py @@ -114,16 +114,16 @@ def add_route(evlp: 'gnes_pb2.Envelope', name: str): def merge_routes(msg: 'gnes_pb2.Message', prev_msgs: List['gnes_pb2.Message'], idx: int = -1): - r = msg.envelope.routes[idx] - if len(msg.envelope.routes) > 1: - msg.envelope.routes[idx - 1].service = colored('[%s]' % ', '.join( - [m.envelope.routes[idx - 1].service for m in prev_msgs]), 'yellow') - r.first_start_time.CopyFrom( - sorted((m.envelope.routes[idx].start_time for m in prev_msgs), - key=lambda x: (x.seconds, x.nanos))[0]) - r.last_end_time.CopyFrom( - sorted((m.envelope.routes[idx].end_time for m in prev_msgs), - key=lambda x: (x.seconds, x.nanos), reverse=True)[0]) + r = msg.envelope.routes.pop(idx) + msg.envelope.routes.extend([m.envelope.routes[idx - 1] for m in prev_msgs[:-1] if len(m.envelope.routes) > 1]) + msg.envelope.routes.extend([r]) + + # r.first_start_time.CopyFrom( + # sorted((m.envelope.routes[idx].start_time for m in prev_msgs), + # key=lambda x: (x.seconds, x.nanos))[0]) + # r.last_end_time.CopyFrom( + # sorted((m.envelope.routes[idx].end_time for m in prev_msgs), + # key=lambda x: (x.seconds, x.nanos), reverse=True)[0]) def send_message(sock: 'zmq.Socket', msg: 'gnes_pb2.Message', timeout: int = -1) -> None: diff --git a/tests/test_stream_grpc.py b/tests/test_stream_grpc.py index 02e56f00..9704a0a5 100644 --- a/tests/test_stream_grpc.py +++ b/tests/test_stream_grpc.py @@ -44,6 +44,7 @@ def setUp(self): def test_bm_frontend(self): args = set_frontend_parser().parse_args([ '--grpc_host', '127.0.0.1', + '--show_route_table' ]) p_args = set_router_parser().parse_args([ @@ -64,6 +65,7 @@ def test_bm_frontend(self): def test_grpc_frontend(self): args = set_frontend_parser().parse_args([ '--grpc_host', '127.0.0.1', + '--show_route_table' ]) p_args = set_router_parser().parse_args([