mirror of https://github.com/grpc/grpc-java.git
test: cover the change that added Subchannel.getInternalSubchannel() (#5774)
This commit is contained in:
parent
cdeafcf6e0
commit
a1bc92a748
|
@ -109,6 +109,7 @@ import io.grpc.internal.ManagedChannelImpl.ScParser;
|
|||
import io.grpc.internal.TestUtils.MockClientTransportInfo;
|
||||
import io.grpc.stub.ClientCalls;
|
||||
import io.grpc.testing.TestMethodDescriptors;
|
||||
import io.grpc.util.ForwardingSubchannel;
|
||||
import java.io.IOException;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.URI;
|
||||
|
@ -2456,6 +2457,40 @@ public class ManagedChannelImplTest {
|
|||
verify(mockStream).start(any(ClientStreamListener.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateBalancingState_withWrappedSubchannel() {
|
||||
ClientStream mockStream = mock(ClientStream.class);
|
||||
createChannel();
|
||||
|
||||
ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT);
|
||||
call.start(mockCallListener, new Metadata());
|
||||
|
||||
final Subchannel subchannel1 =
|
||||
createSubchannelSafely(helper, addressGroup, Attributes.EMPTY, subchannelStateListener);
|
||||
requestConnectionSafely(helper, subchannel1);
|
||||
|
||||
MockClientTransportInfo transportInfo = transports.poll();
|
||||
ConnectionClientTransport mockTransport = transportInfo.transport;
|
||||
ManagedClientTransport.Listener transportListener = transportInfo.listener;
|
||||
when(mockTransport.newStream(same(method), any(Metadata.class), any(CallOptions.class)))
|
||||
.thenReturn(mockStream);
|
||||
transportListener.transportReady();
|
||||
|
||||
Subchannel wrappedSubchannel1 = new ForwardingSubchannel() {
|
||||
@Override
|
||||
protected Subchannel delegate() {
|
||||
return subchannel1;
|
||||
}
|
||||
};
|
||||
when(mockPicker.pickSubchannel(any(PickSubchannelArgs.class)))
|
||||
.thenReturn(PickResult.withSubchannel(wrappedSubchannel1));
|
||||
updateBalancingStateSafely(helper, READY, mockPicker);
|
||||
|
||||
executor.runDueTasks();
|
||||
verify(mockTransport).newStream(same(method), any(Metadata.class), any(CallOptions.class));
|
||||
verify(mockStream).start(any(ClientStreamListener.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateBalancingStateWithShutdownShouldBeIgnored() {
|
||||
channelBuilder.nameResolverFactory(
|
||||
|
|
Loading…
Reference in New Issue