use of org.apache.druid.common.aws.AWSCredentialsConfig in project druid by druid-io.
the class TestAWSCredentialsProvider method testWithFileSessionCredentials.
@Test
public void testWithFileSessionCredentials() throws IOException {
AWSCredentialsConfig config = EasyMock.createMock(AWSCredentialsConfig.class);
EasyMock.expect(config.getAccessKey()).andReturn(new DefaultPasswordProvider(""));
EasyMock.expect(config.getSecretKey()).andReturn(new DefaultPasswordProvider(""));
File file = folder.newFile();
try (BufferedWriter out = Files.newWriter(file, StandardCharsets.UTF_8)) {
out.write("sessionToken=sessionTokenSample\nsecretKey=secretKeySample\naccessKey=accessKeySample\n");
}
EasyMock.expect(config.getFileSessionCredentials()).andReturn(file.getAbsolutePath()).atLeastOnce();
EasyMock.replay(config);
AWSCredentialsProvider provider = awsModule.getAWSCredentialsProvider(config);
AWSCredentials credentials = provider.getCredentials();
Assert.assertTrue(credentials instanceof AWSSessionCredentials);
AWSSessionCredentials sessionCredentials = (AWSSessionCredentials) credentials;
Assert.assertEquals("accessKeySample", sessionCredentials.getAWSAccessKeyId());
Assert.assertEquals("secretKeySample", sessionCredentials.getAWSSecretKey());
Assert.assertEquals("sessionTokenSample", sessionCredentials.getSessionToken());
// try to create
ServerSideEncryptingAmazonS3.Builder amazonS3ClientBuilder = s3Module.getServerSideEncryptingAmazonS3Builder(provider, new AWSProxyConfig(), new AWSEndpointConfig(), new AWSClientConfig(), new S3StorageConfig(new NoopServerSideEncryption()));
s3Module.getAmazonS3Client(amazonS3ClientBuilder);
}
use of org.apache.druid.common.aws.AWSCredentialsConfig in project druid by druid-io.
the class TestAWSCredentialsProvider method testWithFixedAWSKeys.
@Test
public void testWithFixedAWSKeys() {
AWSCredentialsConfig config = EasyMock.createMock(AWSCredentialsConfig.class);
EasyMock.expect(config.getAccessKey()).andReturn(new DefaultPasswordProvider("accessKeySample")).atLeastOnce();
EasyMock.expect(config.getSecretKey()).andReturn(new DefaultPasswordProvider("secretKeySample")).atLeastOnce();
EasyMock.replay(config);
AWSCredentialsProvider provider = awsModule.getAWSCredentialsProvider(config);
AWSCredentials credentials = provider.getCredentials();
Assert.assertEquals("accessKeySample", credentials.getAWSAccessKeyId());
Assert.assertEquals("secretKeySample", credentials.getAWSSecretKey());
// try to create
ServerSideEncryptingAmazonS3.Builder amazonS3ClientBuilder = s3Module.getServerSideEncryptingAmazonS3Builder(provider, new AWSProxyConfig(), new AWSEndpointConfig(), new AWSClientConfig(), new S3StorageConfig(new NoopServerSideEncryption()));
s3Module.getAmazonS3Client(amazonS3ClientBuilder);
}
use of org.apache.druid.common.aws.AWSCredentialsConfig in project druid by druid-io.
the class KinesisIndexTaskTest method makeToolboxFactory.
private void makeToolboxFactory() throws IOException {
directory = tempFolder.newFolder();
final TestUtils testUtils = new TestUtils();
final ObjectMapper objectMapper = testUtils.getTestObjectMapper();
objectMapper.setInjectableValues(((InjectableValues.Std) objectMapper.getInjectableValues()).addValue(AWSCredentialsConfig.class, new AWSCredentialsConfig()));
for (Module module : new KinesisIndexingServiceModule().getJacksonModules()) {
objectMapper.registerModule(module);
}
final TaskConfig taskConfig = new TaskConfig(new File(directory, "baseDir").getPath(), new File(directory, "baseTaskDir").getPath(), null, 50000, null, true, null, null, null, false, false, TaskConfig.BATCH_PROCESSING_MODE_DEFAULT.name());
final TestDerbyConnector derbyConnector = derby.getConnector();
derbyConnector.createDataSourceTable();
derbyConnector.createPendingSegmentsTable();
derbyConnector.createSegmentTable();
derbyConnector.createRulesTable();
derbyConnector.createConfigTable();
derbyConnector.createTaskTables();
derbyConnector.createAuditTable();
taskStorage = new MetadataTaskStorage(derbyConnector, new TaskStorageConfig(null), new DerbyMetadataStorageActionHandlerFactory(derbyConnector, derby.metadataTablesConfigSupplier().get(), objectMapper));
metadataStorageCoordinator = new IndexerSQLMetadataStorageCoordinator(testUtils.getTestObjectMapper(), derby.metadataTablesConfigSupplier().get(), derbyConnector);
taskLockbox = new TaskLockbox(taskStorage, metadataStorageCoordinator);
final TaskActionToolbox taskActionToolbox = new TaskActionToolbox(taskLockbox, taskStorage, metadataStorageCoordinator, emitter, new SupervisorManager(null) {
@Override
public boolean checkPointDataSourceMetadata(String supervisorId, int taskGroupId, @Nullable DataSourceMetadata checkpointMetadata) {
LOG.info("Adding checkpoint hash to the set");
checkpointRequestsHash.add(Objects.hash(supervisorId, taskGroupId, checkpointMetadata));
return true;
}
});
final TaskActionClientFactory taskActionClientFactory = new LocalTaskActionClientFactory(taskStorage, taskActionToolbox, new TaskAuditLogConfig(false));
final SegmentHandoffNotifierFactory handoffNotifierFactory = dataSource -> new SegmentHandoffNotifier() {
@Override
public boolean registerSegmentHandoffCallback(SegmentDescriptor descriptor, Executor exec, Runnable handOffRunnable) {
if (doHandoff) {
// Simulate immediate handoff
exec.execute(handOffRunnable);
}
return true;
}
@Override
public void start() {
// Noop
}
@Override
public void close() {
// Noop
}
};
final LocalDataSegmentPusherConfig dataSegmentPusherConfig = new LocalDataSegmentPusherConfig();
dataSegmentPusherConfig.storageDirectory = getSegmentDirectory();
final DataSegmentPusher dataSegmentPusher = new LocalDataSegmentPusher(dataSegmentPusherConfig);
toolboxFactory = new TaskToolboxFactory(taskConfig, // taskExecutorNode
null, taskActionClientFactory, emitter, dataSegmentPusher, new TestDataSegmentKiller(), // DataSegmentMover
null, // DataSegmentArchiver
null, new TestDataSegmentAnnouncer(), EasyMock.createNiceMock(DataSegmentServerAnnouncer.class), handoffNotifierFactory, this::makeTimeseriesOnlyConglomerate, DirectQueryProcessingPool.INSTANCE, NoopJoinableFactory.INSTANCE, () -> EasyMock.createMock(MonitorScheduler.class), new SegmentCacheManagerFactory(testUtils.getTestObjectMapper()), testUtils.getTestObjectMapper(), testUtils.getTestIndexIO(), MapCache.create(1024), new CacheConfig(), new CachePopulatorStats(), testUtils.getTestIndexMergerV9(), EasyMock.createNiceMock(DruidNodeAnnouncer.class), EasyMock.createNiceMock(DruidNode.class), new LookupNodeService("tier"), new DataNodeService("tier", 1, ServerType.INDEXER_EXECUTOR, 0), new SingleFileTaskReportFileWriter(reportsFile), null, AuthTestUtils.TEST_AUTHORIZER_MAPPER, new NoopChatHandlerProvider(), testUtils.getRowIngestionMetersFactory(), new TestAppenderatorsManager(), new NoopIndexingServiceClient(), null, null, null);
}
use of org.apache.druid.common.aws.AWSCredentialsConfig in project druid by druid-io.
the class KinesisIndexTaskSerdeTest method injectsProperAwsCredentialsConfig.
@Test
public void injectsProperAwsCredentialsConfig() throws Exception {
KinesisIndexTask target = new KinesisIndexTask("id", null, DATA_SCHEMA, TUNING_CONFIG, IO_CONFIG, null, null);
ObjectMapper objectMapper = createObjectMapper();
String serialized = objectMapper.writeValueAsString(target);
KinesisIndexTask deserialized = objectMapper.readValue(serialized, KinesisIndexTask.class);
AWSCredentialsConfig awsCredentialsConfig = deserialized.getAwsCredentialsConfig();
Assert.assertEquals(ACCESS_KEY, awsCredentialsConfig.getAccessKey().getPassword());
Assert.assertEquals(SECRET_KEY, awsCredentialsConfig.getSecretKey().getPassword());
Assert.assertEquals(FILE_SESSION_CREDENTIALS, awsCredentialsConfig.getFileSessionCredentials());
}
Aggregations