use of org.apache.bookkeeper.stream.proto.storage.GetStreamResponse in project bookkeeper by apache.
the class TestGrpcRootRangeService method testGetStreamFailure.
@Test
public void testGetStreamFailure() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcRootRangeService grpcService = new GrpcRootRangeService(rangeService);
GetStreamResponse getResp = GetStreamResponse.newBuilder().setCode(StatusCode.INTERNAL_SERVER_ERROR).build();
GetStreamRequest getReq = createGetStreamRequest(nsName, streamName);
when(rangeService.getStream(getReq)).thenReturn(FutureUtils.exception(CAUSE));
AtomicReference<GetStreamResponse> resultHolder = new AtomicReference<>();
AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
StreamObserver<GetStreamResponse> streamObserver = new StreamObserver<GetStreamResponse>() {
@Override
public void onNext(GetStreamResponse resp) {
resultHolder.set(resp);
}
@Override
public void onError(Throwable t) {
exceptionHolder.set(t);
latch.countDown();
}
@Override
public void onCompleted() {
latch.countDown();
}
};
grpcService.getStream(GetStreamRequest.newBuilder().setStreamName(StreamName.newBuilder().setColName(nsName).setStreamName(streamName)).build(), streamObserver);
latch.await();
assertNull(exceptionHolder.get());
assertNotNull(resultHolder.get());
assertEquals(getResp, resultHolder.get());
verify(rangeService, times(1)).getStream(getReq);
}
use of org.apache.bookkeeper.stream.proto.storage.GetStreamResponse in project bookkeeper by apache.
the class TestGrpcRootRangeService method testGetStreamSuccess.
@Test
public void testGetStreamSuccess() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcRootRangeService grpcService = new GrpcRootRangeService(rangeService);
GetStreamResponse getResp = GetStreamResponse.newBuilder().setCode(StatusCode.SUCCESS).setStreamProps(streamProps).build();
GetStreamRequest getReq = createGetStreamRequest(nsName, streamName);
when(rangeService.getStream(getReq)).thenReturn(CompletableFuture.completedFuture(getResp));
AtomicReference<GetStreamResponse> resultHolder = new AtomicReference<>();
AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
StreamObserver<GetStreamResponse> streamObserver = new StreamObserver<GetStreamResponse>() {
@Override
public void onNext(GetStreamResponse resp) {
resultHolder.set(resp);
}
@Override
public void onError(Throwable t) {
exceptionHolder.set(t);
latch.countDown();
}
@Override
public void onCompleted() {
latch.countDown();
}
};
grpcService.getStream(GetStreamRequest.newBuilder().setStreamName(StreamName.newBuilder().setColName(nsName).setStreamName(streamName)).build(), streamObserver);
latch.await();
assertNull(exceptionHolder.get());
assertNotNull(resultHolder.get());
assertTrue(getResp == resultHolder.get());
verify(rangeService, times(1)).getStream(getReq);
}
use of org.apache.bookkeeper.stream.proto.storage.GetStreamResponse in project bookkeeper by apache.
the class TestRootRangeStoreImpl method testGetStreamSuccess.
@Test
public void testGetStreamSuccess() throws Exception {
String nsName = name.getMethodName();
String streamName = name.getMethodName();
createNamespaceAndVerify(nsName, 0L);
createStreamAndVerify(nsName, streamName, MIN_DATA_STREAM_ID);
verifyStreamId(MIN_DATA_STREAM_ID);
CompletableFuture<GetStreamResponse> getFuture = rootRangeStore.getStream(createGetStreamRequest(nsName, streamName));
GetStreamResponse getResp = FutureUtils.result(getFuture);
assertEquals(StatusCode.SUCCESS, getResp.getCode());
assertEquals(MIN_DATA_STREAM_ID, getResp.getStreamProps().getStreamId());
assertEquals(streamName, getResp.getStreamProps().getStreamName());
assertEquals(streamConf, getResp.getStreamProps().getStreamConf());
}
use of org.apache.bookkeeper.stream.proto.storage.GetStreamResponse in project bookkeeper by apache.
the class TestRootRangeStoreImpl method testGetStreamNamespaceNotFound.
@Test
public void testGetStreamNamespaceNotFound() throws Exception {
String nsName = name.getMethodName();
String streamName = name.getMethodName();
CompletableFuture<GetStreamResponse> getFuture = rootRangeStore.getStream(createGetStreamRequest(nsName, streamName));
GetStreamResponse response = FutureUtils.result(getFuture);
assertEquals(StatusCode.NAMESPACE_NOT_FOUND, response.getCode());
}
Aggregations