use of org.apache.bookkeeper.stream.proto.storage.DeleteStreamRequest in project bookkeeper by apache.
the class StorageContainerImplTest method testDeleteStream.
@Test
public void testDeleteStream() throws Exception {
mockStorageContainer(SCID);
DeleteStreamResponse expectedResp = DeleteStreamResponse.getDefaultInstance();
when(rrStore.deleteStream(any(DeleteStreamRequest.class))).thenReturn(FutureUtils.value(expectedResp));
DeleteStreamRequest expectedReq = DeleteStreamRequest.getDefaultInstance();
assertSame(expectedResp, FutureUtils.result(rrStore.deleteStream(expectedReq)));
verify(rrStore, times(1)).deleteStream(same(expectedReq));
}
use of org.apache.bookkeeper.stream.proto.storage.DeleteStreamRequest in project bookkeeper by apache.
the class TestGrpcRootRangeService method testDeleteStreamFailure.
@Test
public void testDeleteStreamFailure() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcRootRangeService grpcService = new GrpcRootRangeService(rangeService);
DeleteStreamResponse deleteResp = DeleteStreamResponse.newBuilder().setCode(StatusCode.INTERNAL_SERVER_ERROR).build();
DeleteStreamRequest deleteReq = createDeleteStreamRequest(nsName, streamName);
when(rangeService.deleteStream(deleteReq)).thenReturn(FutureUtils.exception(CAUSE));
AtomicReference<DeleteStreamResponse> resultHolder = new AtomicReference<>();
AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
StreamObserver<DeleteStreamResponse> streamObserver = new StreamObserver<DeleteStreamResponse>() {
@Override
public void onNext(DeleteStreamResponse resp) {
resultHolder.set(resp);
}
@Override
public void onError(Throwable t) {
exceptionHolder.set(t);
latch.countDown();
}
@Override
public void onCompleted() {
latch.countDown();
}
};
grpcService.deleteStream(DeleteStreamRequest.newBuilder().setColName(nsName).setName(streamName).build(), streamObserver);
latch.await();
assertNull(exceptionHolder.get());
assertNotNull(resultHolder.get());
assertEquals(deleteResp, resultHolder.get());
verify(rangeService, times(1)).deleteStream(deleteReq);
}
use of org.apache.bookkeeper.stream.proto.storage.DeleteStreamRequest in project bookkeeper by apache.
the class TestGrpcRootRangeService method testDeleteStreamSuccess.
@Test
public void testDeleteStreamSuccess() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcRootRangeService grpcService = new GrpcRootRangeService(rangeService);
DeleteStreamResponse deleteResp = DeleteStreamResponse.newBuilder().setCode(StatusCode.SUCCESS).build();
DeleteStreamRequest deleteReq = createDeleteStreamRequest(nsName, streamName);
when(rangeService.deleteStream(deleteReq)).thenReturn(CompletableFuture.completedFuture(deleteResp));
AtomicReference<DeleteStreamResponse> resultHolder = new AtomicReference<>();
AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
StreamObserver<DeleteStreamResponse> streamObserver = new StreamObserver<DeleteStreamResponse>() {
@Override
public void onNext(DeleteStreamResponse resp) {
resultHolder.set(resp);
}
@Override
public void onError(Throwable t) {
exceptionHolder.set(t);
latch.countDown();
}
@Override
public void onCompleted() {
latch.countDown();
}
};
grpcService.deleteStream(DeleteStreamRequest.newBuilder().setColName(nsName).setName(streamName).build(), streamObserver);
latch.await();
assertNull(exceptionHolder.get());
assertNotNull(resultHolder.get());
assertTrue(deleteResp == resultHolder.get());
verify(rangeService, times(1)).deleteStream(deleteReq);
}
use of org.apache.bookkeeper.stream.proto.storage.DeleteStreamRequest in project bookkeeper by apache.
the class TestRangeStoreImpl method testDeleteStreamMockRootStorageContainerStore.
@Test
public void testDeleteStreamMockRootStorageContainerStore() throws Exception {
String colName = "test-delete-namespace-no-root-storage-container-store";
String streamName = colName;
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
DeleteStreamResponse deleteResp = DeleteStreamResponse.newBuilder().setCode(StatusCode.STREAM_NOT_FOUND).build();
DeleteStreamRequest deleteReq = createDeleteStreamRequest(colName, streamName);
when(scStore.deleteStream(deleteReq)).thenReturn(CompletableFuture.completedFuture(deleteResp));
CompletableFuture<DeleteStreamResponse> deleteRespFuture = rangeStore.deleteStream(deleteReq);
verify(scStore, times(1)).deleteStream(deleteReq);
assertTrue(deleteResp == deleteRespFuture.get());
}
Aggregations