DBZ-693 Expanding test; updating connector option description

This commit is contained in:
Gunnar Morling 2018-05-28 12:19:55 +02:00
parent 764a1d0d58
commit 8d7806e71a
3 changed files with 17 additions and 9 deletions

View File

@ -513,9 +513,9 @@ public static EventProcessingFailureHandlingMode parse(String value) {
.withType(Type.STRING)
.withWidth(Width.LONG)
.withImportance(Importance.LOW)
.withDescription("A semicolon separated list of SQL statements to be executed when JDBC connection (not binlog reading connection) to the database is established. "
+ "Typically used for configuration of session parameters. "
+ "Use doubled semicolon ';;' to use it as a character not as a delimiter");
.withDescription("A semicolon separated list of SQL statements to be executed when a JDBC connection (not binlog reading connection) to the database is established. "
+ "Note that the connector may establish JDBC connections at its own discretion, so this should typically be used for configuration of session parameters only,"
+ "but not for executing DML statements. Use doubled semicolon (';;') to use a semicolon as a character and not as a delimiter.");
public static final Field SERVER_ID = Field.create("database.server.id")
.withDisplayName("Cluster ID")

View File

@ -456,9 +456,10 @@ public String getPostgresPluginName() {
.withType(Type.STRING)
.withWidth(Width.LONG)
.withImportance(Importance.LOW)
.withDescription("A semicolon separated list of SQL statements to be executed when JDBC connection (not binlog reading connection) to the database is established. "
+ "Typically used for configuration of session parameters. "
+ "Use doubled semicolon ';;' to use it as a character not as a delimiter");
.withDescription("A semicolon separated list of SQL statements to be executed when a JDBC connection to the database is established. "
+ "Note that the connector may establish JDBC connections at its own discretion, so this should typically be used for configuration"
+ "of session parameters only, but not for executing DML statements. Use doubled semicolon (';;') to use a semicolon as a character "
+ "and not as a delimiter.");
public static final Field SERVER_NAME = Field.create(DATABASE_CONFIG_PREFIX + "server.name")
.withDisplayName("Namespace")

View File

@ -44,6 +44,7 @@
import io.debezium.connector.postgresql.connection.ReplicationConnection;
import io.debezium.data.Envelope;
import io.debezium.data.VerifyRecord;
import io.debezium.doc.FixFor;
import io.debezium.embedded.AbstractConnectorTest;
import io.debezium.embedded.EmbeddedEngine;
import io.debezium.jdbc.TemporalPrecisionMode;
@ -67,7 +68,7 @@ public class PostgresConnectorIT extends AbstractConnectorTest {
"CREATE SCHEMA s1; " +
"CREATE SCHEMA s2; " +
"CREATE TABLE s1.a (pk SERIAL, aa integer, PRIMARY KEY(pk));" +
"CREATE TABLE s2.a (pk SERIAL, aa integer, PRIMARY KEY(pk));" +
"CREATE TABLE s2.a (pk SERIAL, aa integer, bb varchar(20), PRIMARY KEY(pk));" +
INSERT_STMT;
private PostgresConnector connector;
@ -243,18 +244,24 @@ public void shouldIgnoreViews() throws Exception {
}
@Test
@FixFor("DBZ-693")
public void shouldExecuteOnConnectStatements() throws Exception {
TestHelper.execute(SETUP_TABLES_STMT);
Configuration.Builder configBuilder = TestHelper.defaultConfig()
.with(PostgresConnectorConfig.SNAPSHOT_MODE, INITIAL.getValue())
.with(PostgresConnectorConfig.ON_CONNECT_STATEMENTS, "INSERT INTO s1.a (aa) VALUES (2); INSERT INTO s2.a (aa) VALUES (2)")
.with(PostgresConnectorConfig.ON_CONNECT_STATEMENTS, "INSERT INTO s1.a (aa) VALUES (2); INSERT INTO s2.a (aa, bb) VALUES (2, 'hello;; world');")
.with(PostgresConnectorConfig.DROP_SLOT_ON_STOP, Boolean.FALSE);
start(PostgresConnector.class, configBuilder.build());
assertConnectorIsRunning();
SourceRecords actualRecords = consumeRecordsByTopic(2);
SourceRecords actualRecords = consumeRecordsByTopic(7);
assertKey(actualRecords.allRecordsInOrder().get(0), "pk", 1);
assertKey(actualRecords.allRecordsInOrder().get(1), "pk", 2);
// JdbcConnection#connection() is called multiple times during connector start-up,
// so the given statements will be executed multiple times, resulting in multiple
// records; here we're interested just in the first insert for s2.a
assertValueField(actualRecords.allRecordsInOrder().get(6), "after/bb", "hello; world");
}
@Test