use of io.debezium.config.Configuration in project debezium by debezium.
the class MySqlConnector method validate.
@Override
public Config validate(Map<String, String> connectorConfigs) {
Configuration config = Configuration.from(connectorConfigs);
// First, validate all of the individual fields, which is easy since don't make any of the fields invisible ...
Map<String, ConfigValue> results = config.validate(MySqlConnectorConfig.EXPOSED_FIELDS);
// Get the config values for each of the connection-related fields ...
ConfigValue hostnameValue = results.get(MySqlConnectorConfig.HOSTNAME.name());
ConfigValue portValue = results.get(MySqlConnectorConfig.PORT.name());
ConfigValue userValue = results.get(MySqlConnectorConfig.USER.name());
ConfigValue passwordValue = results.get(MySqlConnectorConfig.PASSWORD.name());
// If there are no errors on any of these ...
if (hostnameValue.errorMessages().isEmpty() && portValue.errorMessages().isEmpty() && userValue.errorMessages().isEmpty() && passwordValue.errorMessages().isEmpty()) {
// Try to connect to the database ...
try (MySqlJdbcContext jdbcContext = new MySqlJdbcContext(config)) {
jdbcContext.start();
JdbcConnection mysql = jdbcContext.jdbc();
try {
mysql.execute("SELECT version()");
logger.info("Successfully tested connection for {} with user '{}'", jdbcContext.connectionString(), mysql.username());
} catch (SQLException e) {
logger.info("Failed testing connection for {} with user '{}'", jdbcContext.connectionString(), mysql.username());
hostnameValue.addErrorMessage("Unable to connect: " + e.getMessage());
} finally {
jdbcContext.shutdown();
}
}
}
return new Config(new ArrayList<>(results.values()));
}
use of io.debezium.config.Configuration in project beam by apache.
the class DebeziumIOTest method testSourceMySqlConnectorValidConfiguration.
@Test
public void testSourceMySqlConnectorValidConfiguration() {
Map<String, String> configurationMap = MYSQL_CONNECTOR_CONFIGURATION.getConfigurationMap();
Configuration debeziumConf = Configuration.from(configurationMap);
Map<String, ConfigValue> validConfig = debeziumConf.validate(MySqlConnectorConfig.ALL_FIELDS);
for (ConfigValue configValue : validConfig.values()) {
assertTrue(configValue.errorMessages().isEmpty());
}
}
use of io.debezium.config.Configuration in project beam by apache.
the class DebeziumIOTest method testSourceConnectorUsernamePassword.
@Test
public void testSourceConnectorUsernamePassword() {
String username = "debezium";
String password = "dbz";
ConnectorConfiguration configuration = MYSQL_CONNECTOR_CONFIGURATION.withUsername(username).withPassword(password);
Map<String, String> configurationMap = configuration.getConfigurationMap();
Configuration debeziumConf = Configuration.from(configurationMap);
Map<String, ConfigValue> validConfig = debeziumConf.validate(MySqlConnectorConfig.ALL_FIELDS);
for (ConfigValue configValue : validConfig.values()) {
assertTrue(configValue.errorMessages().isEmpty());
}
}
use of io.debezium.config.Configuration in project debezium by debezium.
the class PostgresConnectorIT method shouldSupportSSLParameters.
@Test
public void shouldSupportSSLParameters() throws Exception {
// the default docker image we're testing against doesn't use SSL, so check that the connector fails to start when
// SSL is enabled
Configuration config = TestHelper.defaultConfig().with(PostgresConnectorConfig.SSL_MODE, PostgresConnectorConfig.SecureConnectionMode.REQUIRED).build();
start(PostgresConnector.class, config, (success, msg, error) -> {
if (TestHelper.shouldSSLConnectionFail()) {
// we expect the task to fail at startup when we're printing the server info
assertThat(success).isFalse();
assertThat(error).isInstanceOf(ConnectException.class);
Throwable cause = error.getCause();
assertThat(cause).isInstanceOf(SQLException.class);
assertThat(PSQLState.CONNECTION_REJECTED).isEqualTo(new PSQLState(((SQLException) cause).getSQLState()));
}
});
if (TestHelper.shouldSSLConnectionFail()) {
assertConnectorNotRunning();
} else {
assertConnectorIsRunning();
Thread.sleep(10000);
stopConnector();
}
}
use of io.debezium.config.Configuration in project debezium by debezium.
the class PostgresConnectorIT method shouldValidateMinimalConfiguration.
@Test
public void shouldValidateMinimalConfiguration() throws Exception {
Configuration config = TestHelper.defaultConfig().build();
Config validateConfig = new PostgresConnector().validate(config.asMap());
validateConfig.configValues().forEach(configValue -> assertTrue("Unexpected error for: " + configValue.name(), configValue.errorMessages().isEmpty()));
}
Aggregations