use of org.apache.beam.model.fnexecution.v1.BeamFnWorkerStatusGrpc.BeamFnWorkerStatusImplBase in project beam by apache.
the class BeamFnStatusClientTest method testWorkerStatusResponse.
@Test
public void testWorkerStatusResponse() throws Exception {
BlockingQueue<WorkerStatusResponse> values = new LinkedBlockingQueue<>();
BlockingQueue<StreamObserver<WorkerStatusRequest>> requestObservers = new LinkedBlockingQueue<>();
StreamObserver<WorkerStatusResponse> inboundServerObserver = TestStreams.withOnNext(values::add).build();
Server server = InProcessServerBuilder.forName(apiServiceDescriptor.getUrl()).addService(new BeamFnWorkerStatusImplBase() {
@Override
public StreamObserver<WorkerStatusResponse> workerStatus(StreamObserver<WorkerStatusRequest> responseObserver) {
Uninterruptibles.putUninterruptibly(requestObservers, responseObserver);
return inboundServerObserver;
}
}).build();
server.start();
try {
BundleProcessorCache processorCache = mock(BundleProcessorCache.class);
when(processorCache.getActiveBundleProcessors()).thenReturn(Collections.emptyMap());
ManagedChannelFactory channelFactory = ManagedChannelFactory.createInProcess();
new BeamFnStatusClient(apiServiceDescriptor, channelFactory::forDescriptor, processorCache, PipelineOptionsFactory.create(), Caches.noop());
StreamObserver<WorkerStatusRequest> requestObserver = requestObservers.take();
requestObserver.onNext(WorkerStatusRequest.newBuilder().setId("id").build());
WorkerStatusResponse response = values.take();
assertThat(response.getStatusInfo(), containsString("No active processing bundles."));
assertThat(response.getId(), is("id"));
} finally {
server.shutdownNow();
}
}
Aggregations