use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest in project bookkeeper by apache.
the class TestRangeStoreImpl method testPutMockStorageContainer.
@Test
public void testPutMockStorageContainer() throws Exception {
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
StorageContainerResponse response = createPutResponse(StatusCode.SUCCESS);
StorageContainerRequest request = createPutRequest(ROOT_STORAGE_CONTAINER_ID);
when(scStore.put(request)).thenReturn(CompletableFuture.completedFuture(response));
CompletableFuture<StorageContainerResponse> future = rangeStore.put(request);
verify(scStore, times(1)).put(eq(request));
assertTrue(response == future.get());
}
use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest in project bookkeeper by apache.
the class TestRangeStoreImpl method testDeleteMockStorageContainer.
@Test
public void testDeleteMockStorageContainer() throws Exception {
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(ROOT_STORAGE_CONTAINER_ID, scStore);
StorageContainerResponse response = createDeleteResponse(StatusCode.SUCCESS);
StorageContainerRequest request = createDeleteRequest(ROOT_STORAGE_CONTAINER_ID);
when(scStore.delete(request)).thenReturn(CompletableFuture.completedFuture(response));
CompletableFuture<StorageContainerResponse> future = rangeStore.delete(request);
verify(scStore, times(1)).delete(eq(request));
assertTrue(response == future.get());
}
use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest in project bookkeeper by apache.
the class TestRangeStoreImpl method testGetActiveRangesMockManager.
@Test
public void testGetActiveRangesMockManager() throws Exception {
long scId = System.currentTimeMillis();
StreamProperties props = StreamProperties.newBuilder(streamProps).setStorageContainerId(scId).build();
StorageContainer scStore = mock(StorageContainer.class);
when(scStore.stop()).thenReturn(FutureUtils.value(null));
rangeStore.getRegistry().setStorageContainer(scId, scStore);
StorageContainerResponse resp = StorageContainerResponse.newBuilder().setCode(StatusCode.STREAM_NOT_FOUND).build();
StorageContainerRequest request = createGetActiveRangesRequest(scId, 34L);
when(scStore.getActiveRanges(request)).thenReturn(CompletableFuture.completedFuture(resp));
CompletableFuture<StorageContainerResponse> future = rangeStore.getActiveRanges(request);
verify(scStore, times(1)).getActiveRanges(request);
assertTrue(resp == future.get());
}
use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest in project bookkeeper by apache.
the class StorageContainerImplTest method testGetActiveRanges.
//
// Meta Range Methods
//
@Test
public void testGetActiveRanges() throws Exception {
mockStorageContainer(SCID);
StorageContainerResponse expectedResp = StorageContainerResponse.getDefaultInstance();
when(mrStore.getActiveRanges(any(StorageContainerRequest.class))).thenReturn(FutureUtils.value(expectedResp));
StorageContainerRequest expectedReq = StorageContainerRequest.getDefaultInstance();
assertSame(expectedResp, FutureUtils.result(mrStore.getActiveRanges(expectedReq)));
verify(mrStore, times(1)).getActiveRanges(same(expectedReq));
}
use of org.apache.bookkeeper.stream.proto.storage.StorageContainerRequest in project bookkeeper by apache.
the class StorageContainerImplTest method testTxnWhenTableStoreNotCached.
@Test
public void testTxnWhenTableStoreNotCached() throws Exception {
mockStorageContainer(SCID);
StorageContainerResponse expectedResp = StorageContainerResponse.getDefaultInstance();
when(trStore.txn(any(StorageContainerRequest.class))).thenReturn(FutureUtils.value(expectedResp));
StorageContainerRequest request = newStorageContainerRequest(KV_TXN_REQ);
StorageContainerResponse response = FutureUtils.result(container.txn(request));
assertSame(expectedResp, response);
assertSame(trStore, container.getTableStoreCache().getTableStore(RID));
}
Aggregations