use of org.apache.bookkeeper.stream.proto.storage.DeleteNamespaceResponse in project bookkeeper by apache.
the class TestRootRangeStoreImpl method testDeleteNamespaceNotFound.
@Test
public void testDeleteNamespaceNotFound() throws Exception {
String nsName = name.getMethodName();
CompletableFuture<DeleteNamespaceResponse> deleteFuture = rootRangeStore.deleteNamespace(createDeleteNamespaceRequest(nsName));
// create first namespace
DeleteNamespaceResponse response = FutureUtils.result(deleteFuture);
assertEquals(StatusCode.NAMESPACE_NOT_FOUND, response.getCode());
verifyNamespaceNotExists(nsName, 0L);
verifyNamespaceId(-1L);
}
use of org.apache.bookkeeper.stream.proto.storage.DeleteNamespaceResponse in project bookkeeper by apache.
the class TestGrpcRootRangeService method testDeleteNamespaceSuccess.
@Test
public void testDeleteNamespaceSuccess() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcRootRangeService grpcService = new GrpcRootRangeService(rangeService);
DeleteNamespaceResponse deleteResp = DeleteNamespaceResponse.newBuilder().setCode(StatusCode.SUCCESS).build();
DeleteNamespaceRequest deleteReq = createDeleteNamespaceRequest(nsName);
when(rangeService.deleteNamespace(deleteReq)).thenReturn(CompletableFuture.completedFuture(deleteResp));
AtomicReference<DeleteNamespaceResponse> resultHolder = new AtomicReference<>();
AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
StreamObserver<DeleteNamespaceResponse> streamObserver = new StreamObserver<DeleteNamespaceResponse>() {
@Override
public void onNext(DeleteNamespaceResponse resp) {
resultHolder.set(resp);
}
@Override
public void onError(Throwable t) {
exceptionHolder.set(t);
latch.countDown();
}
@Override
public void onCompleted() {
latch.countDown();
}
};
grpcService.deleteNamespace(DeleteNamespaceRequest.newBuilder().setName(nsName).build(), streamObserver);
latch.await();
assertNull(exceptionHolder.get());
assertNotNull(resultHolder.get());
assertTrue(deleteResp == resultHolder.get());
verify(rangeService, times(1)).deleteNamespace(deleteReq);
}
use of org.apache.bookkeeper.stream.proto.storage.DeleteNamespaceResponse in project bookkeeper by apache.
the class TestGrpcRootRangeService method testDeleteNamespaceFailure.
@Test
public void testDeleteNamespaceFailure() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcRootRangeService grpcService = new GrpcRootRangeService(rangeService);
DeleteNamespaceResponse deleteResp = DeleteNamespaceResponse.newBuilder().setCode(StatusCode.INTERNAL_SERVER_ERROR).build();
DeleteNamespaceRequest deleteReq = createDeleteNamespaceRequest(nsName);
when(rangeService.deleteNamespace(deleteReq)).thenReturn(FutureUtils.exception(CAUSE));
AtomicReference<DeleteNamespaceResponse> resultHolder = new AtomicReference<>();
AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
CountDownLatch latch = new CountDownLatch(1);
StreamObserver<DeleteNamespaceResponse> streamObserver = new StreamObserver<DeleteNamespaceResponse>() {
@Override
public void onNext(DeleteNamespaceResponse resp) {
resultHolder.set(resp);
}
@Override
public void onError(Throwable t) {
exceptionHolder.set(t);
latch.countDown();
}
@Override
public void onCompleted() {
latch.countDown();
}
};
grpcService.deleteNamespace(DeleteNamespaceRequest.newBuilder().setName(nsName).build(), streamObserver);
latch.await();
assertNull(exceptionHolder.get());
assertNotNull(resultHolder.get());
assertEquals(deleteResp, resultHolder.get());
verify(rangeService, times(1)).deleteNamespace(deleteReq);
}
use of org.apache.bookkeeper.stream.proto.storage.DeleteNamespaceResponse in project bookkeeper by apache.
the class TestRangeStoreImpl method testDeleteNamespaceMockRootStorageContainerStore.
@Test
public void testDeleteNamespaceMockRootStorageContainerStore() throws Exception {
String colName = "test-delete-namespace-no-root-storage-container-store";
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
DeleteNamespaceResponse deleteResp = DeleteNamespaceResponse.newBuilder().setCode(StatusCode.NAMESPACE_NOT_FOUND).build();
DeleteNamespaceRequest request = createDeleteNamespaceRequest(colName);
when(scStore.deleteNamespace(request)).thenReturn(CompletableFuture.completedFuture(deleteResp));
CompletableFuture<DeleteNamespaceResponse> deleteRespFuture = rangeStore.deleteNamespace(request);
verify(scStore, times(1)).deleteNamespace(request);
assertTrue(deleteResp == deleteRespFuture.get());
}
use of org.apache.bookkeeper.stream.proto.storage.DeleteNamespaceResponse in project bookkeeper by apache.
the class TestRootRangeStoreImpl method testDeleteNamespaceInvalidName.
@Test
public void testDeleteNamespaceInvalidName() throws Exception {
String nsName = "";
CompletableFuture<DeleteNamespaceResponse> deleteFuture = rootRangeStore.deleteNamespace(createDeleteNamespaceRequest(nsName));
DeleteNamespaceResponse response = FutureUtils.result(deleteFuture);
assertEquals(StatusCode.INVALID_NAMESPACE_NAME, response.getCode());
}
Aggregations