| 112 | import org.mockito.junit.MockitoRule; |
| 113 | |
| 114 | @RunWith(JUnit4.class) |
| 115 | public class RlsLoadBalancerTest { |
| 116 | |
| 117 | @Rule |
| 118 | public final GrpcCleanupRule grpcCleanupRule = new GrpcCleanupRule(); |
| 119 | @Rule |
| 120 | public final MockitoRule mocks = MockitoJUnit.rule(); |
| 121 | private final RlsLoadBalancerProvider provider = new RlsLoadBalancerProvider(); |
| 122 | private final FakeClock fakeClock = new FakeClock(); |
| 123 | private final SynchronizationContext syncContext = |
| 124 | new SynchronizationContext(new UncaughtExceptionHandler() { |
| 125 | @Override |
| 126 | public void uncaughtException(Thread t, Throwable e) { |
| 127 | throw new RuntimeException(e); |
| 128 | } |
| 129 | }); |
| 130 | @Mock |
| 131 | private MetricRecorder mockMetricRecorder; |
| 132 | @Mock |
| 133 | private Registration mockGaugeRegistration; |
| 134 | private final FakeHelper helperDelegate = new FakeHelper(); |
| 135 | private final Helper helper = |
| 136 | mock(Helper.class, AdditionalAnswers.delegatesTo(helperDelegate)); |
| 137 | private final FakeRlsServerImpl fakeRlsServerImpl = new FakeRlsServerImpl( |
| 138 | fakeClock.getScheduledExecutorService()); |
| 139 | private final Deque<FakeSubchannel> subchannels = new LinkedList<>(); |
| 140 | private final FakeThrottler fakeThrottler = new FakeThrottler(); |
| 141 | private final String channelTarget = "channelTarget"; |
| 142 | @Captor |
| 143 | private ArgumentCaptor<SubchannelPicker> pickerCaptor; |
| 144 | private MethodDescriptor<Void, Void> fakeSearchMethod; |
| 145 | private MethodDescriptor<Void, Void> fakeRescueMethod; |
| 146 | private RlsLoadBalancer rlsLb; |
| 147 | private String defaultTarget = "defaultTarget"; |
| 148 | private PickSubchannelArgs searchSubchannelArgs; |
| 149 | private PickSubchannelArgs rescueSubchannelArgs; |
| 150 | |
| 151 | @Before |
| 152 | public void setUp() { |
| 153 | fakeSearchMethod = |
| 154 | MethodDescriptor.<Void, Void>newBuilder() |
| 155 | .setFullMethodName("com.google/Search") |
| 156 | .setRequestMarshaller(TestMethodDescriptors.voidMarshaller()) |
| 157 | .setResponseMarshaller(TestMethodDescriptors.voidMarshaller()) |
| 158 | .setType(MethodType.CLIENT_STREAMING) |
| 159 | .build(); |
| 160 | fakeRescueMethod = |
| 161 | MethodDescriptor.<Void, Void>newBuilder() |
| 162 | .setFullMethodName("com.google/Rescue") |
| 163 | .setRequestMarshaller(TestMethodDescriptors.voidMarshaller()) |
| 164 | .setResponseMarshaller(TestMethodDescriptors.voidMarshaller()) |
| 165 | .setType(MethodType.UNARY) |
| 166 | .build(); |
| 167 | fakeRlsServerImpl.setLookupTable( |
| 168 | ImmutableMap.of( |
| 169 | RouteLookupRequest.create( |
| 170 | ImmutableMap.of( |
| 171 | "server", "fake-bigtable.googleapis.com", |
nothing calls this directly
no test coverage detected