Search in sources :

Example 1 with TestChannel

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());
}
Also used : TestChannel(io.grpc.protobuf.services.ChannelzTestHelper.TestChannel) Test(org.junit.Test)

Example 2 with TestChannel

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));
}
Also used : TestChannel(io.grpc.protobuf.services.ChannelzTestHelper.TestChannel) Test(org.junit.Test)

Example 3 with TestChannel

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));
}
Also used : TestChannel(io.grpc.protobuf.services.ChannelzTestHelper.TestChannel) Test(org.junit.Test)

Example 4 with TestChannel

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());
}
Also used : TestChannel(io.grpc.protobuf.services.ChannelzTestHelper.TestChannel) Test(org.junit.Test)

Example 5 with TestChannel

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)));
}
Also used : ChannelStats(io.grpc.InternalChannelz.ChannelStats) RootChannelList(io.grpc.InternalChannelz.RootChannelList) TestChannel(io.grpc.protobuf.services.ChannelzTestHelper.TestChannel) Test(org.junit.Test)

Aggregations

TestChannel (io.grpc.protobuf.services.ChannelzTestHelper.TestChannel)6 Test (org.junit.Test)6 ChannelStats (io.grpc.InternalChannelz.ChannelStats)1 RootChannelList (io.grpc.InternalChannelz.RootChannelList)1