Search in sources :

Example 1 with RangeStore

use of org.apache.bookkeeper.stream.storage.api.RangeStore in project bookkeeper by apache.

the class TestRangeStoreBuilder method testBuild.

@Test
public void testBuild() {
    RangeStore rangeStore = RangeStoreBuilder.newBuilder().withStorageConfiguration(mock(StorageConfiguration.class)).withStorageContainerManagerFactory(mock(StorageContainerManagerFactory.class)).withStorageResources(StorageResources.create()).withRangeStoreFactory(storeFactory).withDefaultBackendUri(uri).build();
    assertTrue(rangeStore instanceof RangeStoreImpl);
}
Also used : StorageContainerManagerFactory(org.apache.bookkeeper.stream.storage.api.sc.StorageContainerManagerFactory) RangeStore(org.apache.bookkeeper.stream.storage.api.RangeStore) RangeStoreImpl(org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl) Test(org.junit.Test)

Example 2 with RangeStore

use of org.apache.bookkeeper.stream.storage.api.RangeStore in project bookkeeper by apache.

the class TestGrpcTableService method testRangeActiveRangesException.

@Test
public void testRangeActiveRangesException() throws Exception {
    RangeStore rangeService = mock(RangeStore.class);
    GrpcTableService grpcService = new GrpcTableService(rangeService);
    StorageContainerRequest request = StorageContainerRequest.newBuilder().setKvRangeReq(RangeRequest.newBuilder().setKey(TEST_KEY).setHeader(ROUTING_HEADER)).build();
    when(rangeService.range(request)).thenReturn(FutureUtils.exception(new StatusRuntimeException(Status.NOT_FOUND)));
    TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
    grpcService.range(request, responseObserver);
    responseObserver.verifyException(Status.NOT_FOUND);
    verify(rangeService, times(1)).range(request);
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) TestResponseObserver(org.apache.bookkeeper.stream.server.TestResponseObserver) StatusRuntimeException(io.grpc.StatusRuntimeException) RangeStore(org.apache.bookkeeper.stream.storage.api.RangeStore) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 3 with RangeStore

use of org.apache.bookkeeper.stream.storage.api.RangeStore in project bookkeeper by apache.

the class TestGrpcTableService method testPutFailure.

@Test
public void testPutFailure() throws Exception {
    RangeStore rangeService = mock(RangeStore.class);
    GrpcTableService grpcService = new GrpcTableService(rangeService);
    StorageContainerRequest request = StorageContainerRequest.newBuilder().setKvPutReq(PutRequest.newBuilder().setKey(TEST_KEY).setValue(TEST_VAL).setHeader(ROUTING_HEADER)).build();
    StorageContainerResponse response = StorageContainerResponse.newBuilder().setCode(StatusCode.INTERNAL_SERVER_ERROR).build();
    when(rangeService.put(request)).thenReturn(FutureUtils.exception(CAUSE));
    TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
    grpcService.put(request, responseObserver);
    responseObserver.verifySuccess(response);
    verify(rangeService, times(1)).put(request);
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) TestResponseObserver(org.apache.bookkeeper.stream.server.TestResponseObserver) RangeStore(org.apache.bookkeeper.stream.storage.api.RangeStore) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 4 with RangeStore

use of org.apache.bookkeeper.stream.storage.api.RangeStore in project bookkeeper by apache.

the class TestGrpcTableService method testPutSuccess.

// 
// Meta KeyRange Server Requests tests
// 
@Test
public void testPutSuccess() throws Exception {
    RangeStore rangeService = mock(RangeStore.class);
    GrpcTableService grpcService = new GrpcTableService(rangeService);
    StorageContainerRequest request = StorageContainerRequest.newBuilder().setKvPutReq(PutRequest.newBuilder().setKey(TEST_KEY).setValue(TEST_VAL).setHeader(ROUTING_HEADER)).build();
    StorageContainerResponse response = StorageContainerResponse.newBuilder().setCode(StatusCode.SUCCESS).setKvPutResp(PutResponse.newBuilder()).build();
    when(rangeService.put(request)).thenReturn(CompletableFuture.completedFuture(response));
    TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
    grpcService.put(request, responseObserver);
    responseObserver.verifySuccess(response);
    verify(rangeService, times(1)).put(request);
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) TestResponseObserver(org.apache.bookkeeper.stream.server.TestResponseObserver) RangeStore(org.apache.bookkeeper.stream.storage.api.RangeStore) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Example 5 with RangeStore

use of org.apache.bookkeeper.stream.storage.api.RangeStore in project bookkeeper by apache.

the class TestGrpcTableService method testRangeSuccess.

@Test
public void testRangeSuccess() throws Exception {
    RangeStore rangeService = mock(RangeStore.class);
    GrpcTableService grpcService = new GrpcTableService(rangeService);
    StorageContainerRequest request = StorageContainerRequest.newBuilder().setKvRangeReq(RangeRequest.newBuilder().setKey(TEST_KEY).setHeader(ROUTING_HEADER)).build();
    StorageContainerResponse response = StorageContainerResponse.newBuilder().setCode(StatusCode.SUCCESS).setKvRangeResp(RangeResponse.newBuilder()).build();
    when(rangeService.range(request)).thenReturn(CompletableFuture.completedFuture(response));
    TestResponseObserver<StorageContainerResponse> responseObserver = new TestResponseObserver<>();
    grpcService.range(request, responseObserver);
    responseObserver.verifySuccess(response);
    verify(rangeService, times(1)).range(request);
}
Also used : StorageContainerRequest(org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest) TestResponseObserver(org.apache.bookkeeper.stream.server.TestResponseObserver) RangeStore(org.apache.bookkeeper.stream.storage.api.RangeStore) StorageContainerResponse(org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse) Test(org.junit.Test)

Aggregations

RangeStore (org.apache.bookkeeper.stream.storage.api.RangeStore)10 Test (org.junit.Test)10 StorageContainerRequest (org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest)9 StorageContainerResponse (org.apache.bookkeeper.stream.proto.storage.StorageContainerResponse)9 TestResponseObserver (org.apache.bookkeeper.stream.server.TestResponseObserver)9 StatusRuntimeException (io.grpc.StatusRuntimeException)3 StorageContainerManagerFactory (org.apache.bookkeeper.stream.storage.api.sc.StorageContainerManagerFactory)1 RangeStoreImpl (org.apache.bookkeeper.stream.storage.impl.RangeStoreImpl)1