use of io.pravega.storage.s3.S3StorageConfig in project pravega by pravega.
the class StorageFactoryTests method testS3StorageFactoryCreator.
private void testS3StorageFactoryCreator(S3StorageConfig config) {
StorageFactoryCreator factoryCreator = new S3StorageFactoryCreator();
val expected = new StorageFactoryInfo[] { StorageFactoryInfo.builder().name("S3").storageLayoutType(StorageLayoutType.CHUNKED_STORAGE).build() };
val factoryInfoList = factoryCreator.getStorageFactories();
Assert.assertEquals(1, factoryInfoList.length);
Assert.assertArrayEquals(expected, factoryInfoList);
// Simple Storage
ConfigSetup configSetup1 = mock(ConfigSetup.class);
when(configSetup1.getConfig(any())).thenReturn(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, config);
val factory1 = factoryCreator.createFactory(expected[0], configSetup1, executorService());
Assert.assertTrue(factory1 instanceof S3SimpleStorageFactory);
@Cleanup Storage storage1 = ((S3SimpleStorageFactory) factory1).createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executorService()));
Assert.assertTrue(storage1 instanceof ChunkedSegmentStorage);
Assert.assertTrue(((ChunkedSegmentStorage) storage1).getChunkStorage() instanceof S3ChunkStorage);
AssertExtensions.assertThrows("createStorageAdapter should throw UnsupportedOperationException.", () -> factory1.createStorageAdapter(), ex -> ex instanceof UnsupportedOperationException);
}
use of io.pravega.storage.s3.S3StorageConfig in project pravega by pravega.
the class S3IntegrationTest method createBuilder.
// endregion
// region StreamSegmentStoreTestBase Implementation
@Override
protected ServiceBuilder createBuilder(ServiceBuilderConfig.Builder configBuilder, int instanceId, boolean useChunkedSegmentStorage) {
Preconditions.checkState(useChunkedSegmentStorage);
ServiceBuilderConfig builderConfig = getBuilderConfig(configBuilder, instanceId);
return ServiceBuilder.newInMemoryBuilder(builderConfig).withStorageFactory(setup -> new LocalS3SimpleStorageFactory(setup.getConfig(S3StorageConfig::builder), setup.getStorageExecutor())).withDataLogFactory(setup -> new BookKeeperLogFactory(setup.getConfig(BookKeeperConfig::builder), getBookkeeper().getZkClient(), setup.getCoreExecutor()));
}
Aggregations