use of io.pravega.segmentstore.storage.ConfigSetup in project pravega by pravega.
the class InMemorySimpleStorageFactoryTests method testInMemorySimpleStorageFactoryCreator.
@Test
public void testInMemorySimpleStorageFactoryCreator() {
StorageFactoryCreator factoryCreator = new InMemoryStorageFactoryCreator();
@Cleanup("shutdownNow") val executor = ExecutorServiceHelpers.newScheduledThreadPool(1, "test");
val expected = new StorageFactoryInfo[] { StorageFactoryInfo.builder().name("INMEMORY").storageLayoutType(StorageLayoutType.CHUNKED_STORAGE).build(), StorageFactoryInfo.builder().name("INMEMORY").storageLayoutType(StorageLayoutType.ROLLING_STORAGE).build() };
val factoryInfoList = factoryCreator.getStorageFactories();
Assert.assertEquals(2, factoryInfoList.length);
Assert.assertArrayEquals(expected, factoryInfoList);
// Simple Storage
ConfigSetup configSetup1 = mock(ConfigSetup.class);
when(configSetup1.getConfig(any())).thenReturn(ChunkedSegmentStorageConfig.DEFAULT_CONFIG);
val factory1 = factoryCreator.createFactory(expected[0], configSetup1, executor);
Assert.assertTrue(factory1 instanceof InMemorySimpleStorageFactory);
@Cleanup Storage storage1 = ((InMemorySimpleStorageFactory) factory1).createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executor));
Assert.assertTrue(storage1 instanceof ChunkedSegmentStorage);
// Legacy Storage
ConfigSetup configSetup2 = mock(ConfigSetup.class);
when(configSetup2.getConfig(any())).thenReturn(ChunkedSegmentStorageConfig.DEFAULT_CONFIG);
val factory2 = factoryCreator.createFactory(expected[1], configSetup2, executor);
Assert.assertTrue(factory2 instanceof InMemoryStorageFactory);
Storage storage2 = factory2.createStorageAdapter();
Assert.assertTrue(storage2 instanceof AsyncStorageWrapper);
SyncStorage syncStorage = factory2.createSyncStorage();
Assert.assertNotNull(syncStorage);
}
Aggregations