use of io.pravega.segmentstore.contracts.tables.TableStore in project pravega by pravega.
the class TableBasedMetadataStoreMockTests method testRandomRuntimeExceptionDuringWrite.
@Test
public void testRandomRuntimeExceptionDuringWrite() {
TableStore mockTableStore = mock(TableStore.class);
@Cleanup TableBasedMetadataStore tableBasedMetadataStore = new TableBasedMetadataStore("test", mockTableStore, ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executorService());
when(mockTableStore.createSegment(any(), any(), any())).thenReturn(Futures.failedFuture(new CompletionException(new StreamSegmentExistsException("test"))));
// Throw random exception
Exception e = new ArithmeticException();
val td = BaseMetadataStore.TransactionData.builder().key("foo").version(1L).dbObject(2L).build();
CompletableFuture<List<Long>> f = new CompletableFuture<>();
f.completeExceptionally(e);
when(mockTableStore.put(anyString(), any(), any())).thenReturn(f);
AssertExtensions.assertFutureThrows("write should throw an exception", tableBasedMetadataStore.writeAll(Collections.singleton(td)), ex -> ex instanceof StorageMetadataException && ex.getCause() == e);
}
use of io.pravega.segmentstore.contracts.tables.TableStore in project pravega by pravega.
the class TableBasedMetadataStoreMockTests method testExceptionDuringRemove.
@Test
public void testExceptionDuringRemove() throws Exception {
TableStore mockTableStore = mock(TableStore.class);
@Cleanup TableBasedMetadataStore tableBasedMetadataStore = new TableBasedMetadataStore("test", mockTableStore, ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executorService());
when(mockTableStore.createSegment(any(), any(), any())).thenReturn(Futures.failedFuture(new CompletionException(new StreamSegmentExistsException("test"))));
// Throw random exception
Exception e = new ArithmeticException();
val td = BaseMetadataStore.TransactionData.builder().key("foo").version(1L).dbObject(2L).build();
val toRet = new ArrayList<Long>();
toRet.add(3L);
CompletableFuture<Void> f = new CompletableFuture<>();
f.completeExceptionally(e);
when(mockTableStore.remove(anyString(), any(), any())).thenReturn(f);
when(mockTableStore.put(anyString(), any(), any())).thenReturn(CompletableFuture.completedFuture(toRet));
tableBasedMetadataStore.writeAll(Collections.singleton(td)).get();
}
use of io.pravega.segmentstore.contracts.tables.TableStore in project pravega by pravega.
the class TableBasedMetadataStoreMockTests method testRandomExceptionDuringRead.
@Test
public void testRandomExceptionDuringRead() {
TableStore mockTableStore = mock(TableStore.class);
@Cleanup TableBasedMetadataStore tableBasedMetadataStore = new TableBasedMetadataStore("test", mockTableStore, ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executorService());
when(mockTableStore.createSegment(any(), any(), any())).thenReturn(Futures.failedFuture(new CompletionException(new StreamSegmentExistsException("test"))));
// Throw random exception
Exception e = new ArithmeticException();
val f = new CompletableFuture<List<TableEntry>>();
f.completeExceptionally(e);
when(mockTableStore.get(anyString(), any(), any())).thenReturn(f);
AssertExtensions.assertFutureThrows("read should throw an exception", tableBasedMetadataStore.read("test"), ex -> ex instanceof StorageMetadataException && ex.getCause() == e);
}
use of io.pravega.segmentstore.contracts.tables.TableStore in project pravega by pravega.
the class TableBasedMetadataStoreMockTests method testBadKeyVersionExceptionDuringWrite.
@Test
public void testBadKeyVersionExceptionDuringWrite() {
TableStore mockTableStore = mock(TableStore.class);
@Cleanup TableBasedMetadataStore tableBasedMetadataStore = new TableBasedMetadataStore("test", mockTableStore, ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executorService());
when(mockTableStore.createSegment(any(), any(), any())).thenReturn(Futures.failedFuture(new CompletionException(new StreamSegmentExistsException("test"))));
// Throw BadKeyVersionException exception
Exception e = new CompletionException(new BadKeyVersionException("test", new HashMap<>()));
val td = BaseMetadataStore.TransactionData.builder().key("foo").version(1L).dbObject(2L).build();
CompletableFuture<List<Long>> f = new CompletableFuture<>();
f.completeExceptionally(e);
when(mockTableStore.put(anyString(), any(), any())).thenReturn(f);
AssertExtensions.assertFutureThrows("write should throw an excpetion", tableBasedMetadataStore.writeAll(Collections.singleton(td)), ex -> ex instanceof StorageMetadataVersionMismatchException && ex.getCause() == e.getCause());
}
use of io.pravega.segmentstore.contracts.tables.TableStore in project pravega by pravega.
the class EndToEndStatsTest method setUp.
@Before
public void setUp() throws Exception {
zkTestServer = new TestingServerStarter().start();
serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig());
serviceBuilder.initialize();
StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
TableStore tableStore = serviceBuilder.createTableStoreService();
statsRecorder = new TestStatsRecorder();
server = new PravegaConnectionListener(false, false, "localhost", servicePort, store, tableStore, statsRecorder, TableSegmentStatsRecorder.noOp(), null, null, null, true, serviceBuilder.getLowPriorityExecutor(), SecurityConfigDefaults.TLS_PROTOCOL_VERSION);
server.startListening();
controllerWrapper = new ControllerWrapper(zkTestServer.getConnectString(), false, controllerPort, serviceHost, servicePort, containerCount);
controllerWrapper.awaitRunning();
}
Aggregations