use of io.grpc.protobuf.services.ChannelzTestHelper.TestChannel in project grpc-java by grpc.
the class ChannelzServiceTest method getChannel.
@Test
public void getChannel() throws ExecutionException, InterruptedException {
TestChannel root = new TestChannel();
assertChannelNotFound(root.getLogId().getId());
channelz.addRootChannel(root);
assertEquals(GetChannelResponse.newBuilder().setChannel(ChannelzProtoUtil.toChannel(root)).build(), getChannelHelper(root.getLogId().getId()));
channelz.removeRootChannel(root);
assertChannelNotFound(root.getLogId().getId());
}
use of io.grpc.protobuf.services.ChannelzTestHelper.TestChannel in project grpc-java by grpc.
the class ChannelzServiceTest method getTopChannels_onePage.
@Test
public void getTopChannels_onePage() throws Exception {
TestChannel root = new TestChannel();
channelz.addRootChannel(root);
assertEquals(GetTopChannelsResponse.newBuilder().addChannel(ChannelzProtoUtil.toChannel(root)).setEnd(true).build(), getTopChannelHelper(0));
}
use of io.grpc.protobuf.services.ChannelzTestHelper.TestChannel in project grpc-java by grpc.
the class ChannelzProtoUtilTest method toChannel.
@Test
public void toChannel() throws Exception {
assertEquals(channelProto, ChannelzProtoUtil.toChannel(channel));
channel.stats = toBuilder(channel.stats).setSubchannels(ImmutableList.<InternalWithLogId>of(subchannel)).build();
assertEquals(channelProto.toBuilder().addSubchannelRef(subchannelRef).build(), ChannelzProtoUtil.toChannel(channel));
TestChannel otherSubchannel = new TestChannel();
channel.stats = toBuilder(channel.stats).setSubchannels(ImmutableList.<InternalWithLogId>of(subchannel, otherSubchannel)).build();
assertEquals(channelProto.toBuilder().addSubchannelRef(subchannelRef).addSubchannelRef(ChannelzProtoUtil.toSubchannelRef(otherSubchannel)).build(), ChannelzProtoUtil.toChannel(channel));
}
use of io.grpc.protobuf.services.ChannelzTestHelper.TestChannel in project grpc-java by grpc.
the class ChannelzServiceTest method getSubchannel.
@Test
public void getSubchannel() throws Exception {
TestChannel subchannel = new TestChannel();
assertSubchannelNotFound(subchannel.getLogId().getId());
channelz.addSubchannel(subchannel);
assertEquals(GetSubchannelResponse.newBuilder().setSubchannel(ChannelzProtoUtil.toSubchannel(subchannel)).build(), getSubchannelHelper(subchannel.getLogId().getId()));
channelz.removeSubchannel(subchannel);
assertSubchannelNotFound(subchannel.getLogId().getId());
}
use of io.grpc.protobuf.services.ChannelzTestHelper.TestChannel in project grpc-java by grpc.
the class ChannelzProtoUtilTest method toGetTopChannelsResponse.
@Test
public void toGetTopChannelsResponse() {
// empty results
assertEquals(GetTopChannelsResponse.newBuilder().setEnd(true).build(), ChannelzProtoUtil.toGetTopChannelResponse(new RootChannelList(Collections.<InternalInstrumented<ChannelStats>>emptyList(), true)));
// 1 result, paginated
assertEquals(GetTopChannelsResponse.newBuilder().addChannel(channelProto).build(), ChannelzProtoUtil.toGetTopChannelResponse(new RootChannelList(ImmutableList.<InternalInstrumented<ChannelStats>>of(channel), false)));
// 1 result, end
assertEquals(GetTopChannelsResponse.newBuilder().addChannel(channelProto).setEnd(true).build(), ChannelzProtoUtil.toGetTopChannelResponse(new RootChannelList(ImmutableList.<InternalInstrumented<ChannelStats>>of(channel), true)));
// 2 results, end
TestChannel channel2 = new TestChannel();
assertEquals(GetTopChannelsResponse.newBuilder().addChannel(channelProto).addChannel(ChannelzProtoUtil.toChannel(channel2)).setEnd(true).build(), ChannelzProtoUtil.toGetTopChannelResponse(new RootChannelList(ImmutableList.<InternalInstrumented<ChannelStats>>of(channel, channel2), true)));
}
Aggregations