use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest in project bookkeeper by apache.
the class TestGrpcMetaRangeService method testGetActiveRangesFailure.
@Test
public void testGetActiveRangesFailure() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcMetaRangeService grpcService = new GrpcMetaRangeService(rangeService);
StorageContainerRequest request = StorageContainerRequest.newBuilder().setGetActiveRangesReq(GetActiveRangesRequest.newBuilder().setStreamId(23456L).build()).build();
StorageContainerResponse response = StorageContainerResponse.newBuilder().setCode(StatusCode.INTERNAL_SERVER_ERROR).build();
when(rangeService.getActiveRanges(request)).thenReturn(FutureUtils.exception(CAUSE));
TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
grpcService.getActiveRanges(request, responseObserver);
responseObserver.verifySuccess(response);
verify(rangeService, times(1)).getActiveRanges(request);
}
use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest in project bookkeeper by apache.
the class TestGrpcMetaRangeService method testGetActiveRangesSuccess.
//
// Meta KeyRange Server Requests tests
//
@Test
public void testGetActiveRangesSuccess() throws Exception {
RangeStoreImpl rangeService = mock(RangeStoreImpl.class);
GrpcMetaRangeService grpcService = new GrpcMetaRangeService(rangeService);
StorageContainerRequest request = StorageContainerRequest.newBuilder().setGetActiveRangesReq(GetActiveRangesRequest.newBuilder().setStreamId(23456L).build()).build();
StorageContainerResponse response = StorageContainerResponse.newBuilder().setCode(StatusCode.SUCCESS).setGetActiveRangesResp(GetActiveRangesResponse.newBuilder()).build();
when(rangeService.getActiveRanges(request)).thenReturn(CompletableFuture.completedFuture(response));
TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
grpcService.getActiveRanges(request, responseObserver);
responseObserver.verifySuccess(response);
verify(rangeService, times(1)).getActiveRanges(request);
}
use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest in project bookkeeper by apache.
the class TestGrpcTableService method testDeleteException.
@Test
public void testDeleteException() throws Exception {
RangeStore rangeService = mock(RangeStore.class);
GrpcTableService grpcService = new GrpcTableService(rangeService);
StorageContainerRequest request = StorageContainerRequest.newBuilder().setKvDeleteReq(DeleteRangeRequest.newBuilder().setKey(TEST_KEY).setHeader(ROUTING_HEADER)).build();
when(rangeService.delete(request)).thenReturn(FutureUtils.exception(new StatusRuntimeException(Status.NOT_FOUND)));
TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
grpcService.delete(request, responseObserver);
responseObserver.verifyException(Status.NOT_FOUND);
verify(rangeService, times(1)).delete(request);
}
use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest in project bookkeeper by apache.
the class TestKvUtils method testNewKvIncrementRequest.
@Test
public void testNewKvIncrementRequest() {
try (IncrementOption<ByteBuf> option = Options.incrementAndGet()) {
IncrementRequest.Builder incrBuilder = newIncrementRequest(key, 100L, option);
StorageContainerRequest request = newKvIncrementRequest(scId, incrBuilder);
assertEquals(scId, request.getScId());
assertEquals(KV_INCR_REQ, request.getRequestCase());
assertEquals(incrBuilder.build(), request.getKvIncrReq());
}
}
use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest in project bookkeeper by apache.
the class TestKvUtils method testNewKvPutRequest.
@Test
public void testNewKvPutRequest() {
try (PutOption<ByteBuf> option = Options.putAndGet()) {
PutRequest.Builder putBuilder = newPutRequest(key, value, option);
StorageContainerRequest request = newKvPutRequest(scId, putBuilder);
assertEquals(scId, request.getScId());
assertEquals(KV_PUT_REQ, request.getRequestCase());
assertEquals(putBuilder.build(), request.getKvPutReq());
}
}
Aggregations