use of io.debezium.doc.FixFor in project debezium by debezium.
the class RecordsSnapshotProducerIT method shouldGenerateSnapshotsForDecimalDatatypesUsingStringEncoding.
@Test
@FixFor("DBZ-606")
public void shouldGenerateSnapshotsForDecimalDatatypesUsingStringEncoding() throws Exception {
// PostGIS must not be used
TestHelper.dropAllSchemas();
TestHelper.executeDDL("postgres_create_tables.ddl");
PostgresConnectorConfig config = new PostgresConnectorConfig(TestHelper.defaultConfig().with(PostgresConnectorConfig.DECIMAL_HANDLING_MODE, DecimalHandlingMode.STRING).build());
TopicSelector selector = TopicSelector.create(config);
context = new PostgresTaskContext(config, new PostgresSchema(config, TestHelper.getTypeRegistry(), selector), selector);
snapshotProducer = new RecordsSnapshotProducer(context, new SourceInfo(TestHelper.TEST_SERVER), false);
TestConsumer consumer = testConsumer(1, "public", "Quoted_\"");
// insert data for each of different supported types
TestHelper.execute(INSERT_NUMERIC_DECIMAL_TYPES_STMT);
// then start the producer and validate all records are there
snapshotProducer.start(consumer, e -> {
});
consumer.await(TestHelper.waitTimeForRecords() * 30, TimeUnit.SECONDS);
Map<String, List<SchemaAndValueField>> expectedValuesByTableName = super.schemaAndValuesByTableNameStringEncodedDecimals();
consumer.process(record -> assertReadRecord(record, expectedValuesByTableName));
// check the offset information for each record
while (!consumer.isEmpty()) {
SourceRecord record = consumer.remove();
assertRecordOffset(record, true, consumer.isEmpty());
}
}
use of io.debezium.doc.FixFor in project debezium by debezium.
the class RecordsSnapshotProducerIT method shouldGenerateSnapshotsForDefaultDatatypesAdaptiveMicroseconds.
@Test
@FixFor("DBZ-342")
public void shouldGenerateSnapshotsForDefaultDatatypesAdaptiveMicroseconds() throws Exception {
PostgresConnectorConfig config = new PostgresConnectorConfig(TestHelper.defaultConfig().with(PostgresConnectorConfig.TIME_PRECISION_MODE, TemporalPrecisionMode.ADAPTIVE_TIME_MICROSECONDS).build());
TopicSelector selector = TopicSelector.create(config);
context = new PostgresTaskContext(config, new PostgresSchema(config, TestHelper.getTypeRegistry(), selector), selector);
snapshotProducer = new RecordsSnapshotProducer(context, new SourceInfo(TestHelper.TEST_SERVER), false);
TestConsumer consumer = testConsumer(ALL_STMTS.size(), "public", "Quoted_\"");
// insert data for each of different supported types
String statementsBuilder = ALL_STMTS.stream().collect(Collectors.joining(";" + System.lineSeparator())) + ";";
TestHelper.execute(statementsBuilder);
// then start the producer and validate all records are there
snapshotProducer.start(consumer, e -> {
});
consumer.await(TestHelper.waitTimeForRecords() * 30, TimeUnit.SECONDS);
Map<String, List<SchemaAndValueField>> expectedValuesByTableName = super.schemaAndValuesByTableNameAdaptiveTimeMicroseconds();
consumer.process(record -> assertReadRecord(record, expectedValuesByTableName));
// check the offset information for each record
while (!consumer.isEmpty()) {
SourceRecord record = consumer.remove();
assertRecordOffset(record, true, consumer.isEmpty());
}
}
use of io.debezium.doc.FixFor in project debezium by debezium.
the class RecordsStreamProducerIT method shouldProcessIntervalDelete.
@Test
@FixFor("DBZ-259")
public void shouldProcessIntervalDelete() throws Exception {
final String statements = "INSERT INTO table_with_interval VALUES (default, 'Foo', default);" + "INSERT INTO table_with_interval VALUES (default, 'Bar', default);" + "DELETE FROM table_with_interval WHERE id = 1;";
consumer = testConsumer(4);
recordsProducer.start(consumer, blackHole);
executeAndWait(statements);
final String topicPrefix = "public.table_with_interval";
final String topicName = topicName(topicPrefix);
final String pk = "id";
assertRecordInserted(topicPrefix, pk, 1);
assertRecordInserted(topicPrefix, pk, 2);
// first entry removed
SourceRecord record = consumer.remove();
assertEquals(topicName, record.topic());
VerifyRecord.isValidDelete(record, pk, 1);
// followed by a tombstone
record = consumer.remove();
assertEquals(topicName, record.topic());
VerifyRecord.isValidTombstone(record, pk, 1);
}
use of io.debezium.doc.FixFor in project debezium by debezium.
the class MySqlConnectorRegressionIT method shouldConsumeAllEventsFromDecimalTableInDatabaseUsingBinlogAndNoSnapshot.
@Test
@FixFor("DBZ-147")
public void shouldConsumeAllEventsFromDecimalTableInDatabaseUsingBinlogAndNoSnapshot() throws SQLException, InterruptedException {
// Use the DB configuration to define the connector's configuration ...
config = DATABASE.defaultConfig().with(MySqlConnectorConfig.TABLE_WHITELIST, DATABASE.qualifiedTableName("dbz_147_decimalvalues")).with(MySqlConnectorConfig.INCLUDE_SCHEMA_CHANGES, true).with(MySqlConnectorConfig.SNAPSHOT_MODE, SnapshotMode.NEVER.toString()).with(MySqlConnectorConfig.DECIMAL_HANDLING_MODE, DecimalHandlingMode.DOUBLE).build();
// Start the connector ...
start(MySqlConnector.class, config);
// ---------------------------------------------------------------------------------------------------------------
// Consume all of the events due to startup and initialization of the database
// ---------------------------------------------------------------------------------------------------------------
// Testing.Debug.enable();
int numCreateDatabase = 1;
// still read DDL for all tables
int numCreateTables = 9;
int numDataRecords = 1;
SourceRecords records = consumeRecordsByTopic(numCreateDatabase + numCreateTables + numDataRecords);
stopConnector();
assertThat(records).isNotNull();
assertThat(records.recordsForTopic(DATABASE.getServerName()).size()).isEqualTo(numCreateDatabase + numCreateTables);
assertThat(records.recordsForTopic(DATABASE.topicForTable("dbz_147_decimalvalues")).size()).isEqualTo(1);
// rather than 1+numCreateTables
assertThat(records.topics().size()).isEqualTo(2);
// Check that all records are valid, can be serialized and deserialized ...
records.forEach(this::validate);
records.forEach(record -> {
Struct value = (Struct) record.value();
if (record.topic().endsWith("dbz_147_decimalvalues")) {
Struct after = value.getStruct(Envelope.FieldName.AFTER);
Object decimalValue = after.get("decimal_value");
assertThat(decimalValue).isInstanceOf(Double.class);
Double doubleValue = (Double) decimalValue;
assertThat(doubleValue).isEqualTo(12345.67, Delta.delta(0.01));
}
});
}
use of io.debezium.doc.FixFor in project debezium by debezium.
the class MySqlConnectorRegressionIT method shouldConsumeDecimalAsStringFromSnapshot.
@Test
@FixFor("DBZ-611")
public void shouldConsumeDecimalAsStringFromSnapshot() throws SQLException, InterruptedException {
// Use the DB configuration to define the connector's configuration ...
config = DATABASE.defaultConfig().with(MySqlConnectorConfig.TABLE_WHITELIST, DATABASE.qualifiedTableName("dbz_147_decimalvalues")).with(MySqlConnectorConfig.INCLUDE_SCHEMA_CHANGES, true).with(MySqlConnectorConfig.DECIMAL_HANDLING_MODE, DecimalHandlingMode.STRING).build();
// Start the connector ...
start(MySqlConnector.class, config);
// ---------------------------------------------------------------------------------------------------------------
// Consume all of the events due to startup and initialization of the database
// ---------------------------------------------------------------------------------------------------------------
// Testing.Debug.enable();
int ddlRecords = 6;
int numDataRecords = 1;
SourceRecords records = consumeRecordsByTopic(ddlRecords + numDataRecords);
stopConnector();
assertThat(records).isNotNull();
assertThat(records.recordsForTopic(DATABASE.getServerName()).size()).isEqualTo(ddlRecords);
assertThat(records.recordsForTopic(DATABASE.topicForTable("dbz_147_decimalvalues")).size()).isEqualTo(1);
// rather than 1+numCreateTables
assertThat(records.topics().size()).isEqualTo(2);
// Check that all records are valid, can be serialized and deserialized ...
records.forEach(this::validate);
records.forEach(record -> {
Struct value = (Struct) record.value();
if (record.topic().endsWith("dbz_147_decimalvalues")) {
Struct after = value.getStruct(Envelope.FieldName.AFTER);
Object decimalValue = after.get("decimal_value");
assertThat(decimalValue).isInstanceOf(String.class);
assertThat(decimalValue).isEqualTo("12345.67");
}
});
}
Aggregations