use of org.apache.druid.metadata.MetadataStorageConnectorConfig in project druid by druid-io.
the class MySQLFirehoseDatabaseConnectorTest method testFailWhenNoAllowlistAndHaveProperty.
@Test
public void testFailWhenNoAllowlistAndHaveProperty() {
MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {
@Override
public String getConnectURI() {
return "jdbc:mysql://localhost:3306/test?user=maytas&password=secret&keyonly";
}
};
JdbcAccessSecurityConfig securityConfig = newSecurityConfigEnforcingAllowList(ImmutableSet.of(""));
expectedException.expectMessage("The property [password] is not in the allowed list");
expectedException.expect(IllegalArgumentException.class);
new MySQLFirehoseDatabaseConnector(connectorConfig, null, securityConfig, mySQLConnectorDriverConfig);
}
use of org.apache.druid.metadata.MetadataStorageConnectorConfig in project druid by druid-io.
the class MySQLFirehoseDatabaseConnectorTest method testFindPropertyKeysFromInvalidConnectUrl.
@Test
public void testFindPropertyKeysFromInvalidConnectUrl() {
final String url = "jdbc:mysql:/invalid-url::3006";
MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {
@Override
public String getConnectURI() {
return url;
}
};
expectedException.expect(RuntimeException.class);
expectedException.expectMessage(StringUtils.format("Invalid URL format for MySQL: [%s]", url));
new MySQLFirehoseDatabaseConnector(connectorConfig, null, new JdbcAccessSecurityConfig(), mySQLConnectorDriverConfig);
}
use of org.apache.druid.metadata.MetadataStorageConnectorConfig in project druid by druid-io.
the class MySQLFirehoseDatabaseConnectorTest method testSuccessOnlyValidProperty.
@Test
public void testSuccessOnlyValidProperty() {
MetadataStorageConnectorConfig connectorConfig = new MetadataStorageConnectorConfig() {
@Override
public String getConnectURI() {
return "jdbc:mysql://localhost:3306/test?user=maytas&password=secret&keyonly";
}
};
JdbcAccessSecurityConfig securityConfig = newSecurityConfigEnforcingAllowList(ImmutableSet.of("user", "password", "keyonly", "etc"));
new MySQLFirehoseDatabaseConnector(connectorConfig, null, securityConfig, mySQLConnectorDriverConfig);
}
use of org.apache.druid.metadata.MetadataStorageConnectorConfig in project druid by druid-io.
the class HadoopIngestionSpecTest method testDbUpdaterJobSpec.
@Test
public void testDbUpdaterJobSpec() {
final HadoopIngestionSpec schema;
schema = jsonReadWriteRead("{\n" + " \"ioConfig\": {\n" + " \"type\": \"hadoop\",\n" + " \"metadataUpdateSpec\": {\n" + " \"type\": \"db\",\n" + " \"connectURI\": \"jdbc:mysql://localhost/druid\",\n" + " \"user\": \"rofl\",\n" + " \"password\": \"p4ssw0rd\",\n" + " \"segmentTable\": \"segments\"\n" + " }\n" + " }\n" + "}", HadoopIngestionSpec.class);
final MetadataStorageUpdaterJobSpec spec = schema.getIOConfig().getMetadataUpdateSpec();
final MetadataStorageConnectorConfig connectorConfig = spec.get();
Assert.assertEquals("segments", spec.getSegmentTable());
Assert.assertEquals("jdbc:mysql://localhost/druid", connectorConfig.getConnectURI());
Assert.assertEquals("rofl", connectorConfig.getUser());
Assert.assertEquals("p4ssw0rd", connectorConfig.getPassword());
}
use of org.apache.druid.metadata.MetadataStorageConnectorConfig in project druid by druid-io.
the class CreateTables method getModules.
@Override
protected List<? extends Module> getModules() {
return ImmutableList.of(// See https://github.com/apache/druid/pull/4429#discussion_r123602930
new DruidProcessingModule(), new QueryableModule(), new QueryRunnerFactoryModule(), binder -> {
JsonConfigProvider.bindInstance(binder, Key.get(MetadataStorageConnectorConfig.class), new MetadataStorageConnectorConfig() {
@Override
public String getConnectURI() {
return connectURI;
}
@Override
public String getUser() {
return user;
}
@Override
public String getPassword() {
return password;
}
});
JsonConfigProvider.bindInstance(binder, Key.get(MetadataStorageTablesConfig.class), MetadataStorageTablesConfig.fromBase(base));
JsonConfigProvider.bindInstance(binder, Key.get(DruidNode.class, Self.class), new DruidNode("tools", "localhost", false, -1, null, true, false));
});
}
Aggregations