Search in sources :

Example 1 with FixFor

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());
    }
}
Also used : List(java.util.List) SourceRecord(org.apache.kafka.connect.source.SourceRecord) Test(org.junit.Test) FixFor(io.debezium.doc.FixFor)

Example 2 with FixFor

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());
    }
}
Also used : List(java.util.List) SourceRecord(org.apache.kafka.connect.source.SourceRecord) Test(org.junit.Test) FixFor(io.debezium.doc.FixFor)

Example 3 with FixFor

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);
}
Also used : SourceRecord(org.apache.kafka.connect.source.SourceRecord) Test(org.junit.Test) FixFor(io.debezium.doc.FixFor)

Example 4 with FixFor

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));
        }
    });
}
Also used : Struct(org.apache.kafka.connect.data.Struct) Test(org.junit.Test) AbstractConnectorTest(io.debezium.embedded.AbstractConnectorTest) FixFor(io.debezium.doc.FixFor)

Example 5 with FixFor

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");
        }
    });
}
Also used : Struct(org.apache.kafka.connect.data.Struct) Test(org.junit.Test) AbstractConnectorTest(io.debezium.embedded.AbstractConnectorTest) FixFor(io.debezium.doc.FixFor)

Aggregations

FixFor (io.debezium.doc.FixFor)45 Test (org.junit.Test)45 AbstractConnectorTest (io.debezium.embedded.AbstractConnectorTest)18 TableId (io.debezium.relational.TableId)18 Table (io.debezium.relational.Table)17 Struct (org.apache.kafka.connect.data.Struct)13 SourceRecord (org.apache.kafka.connect.source.SourceRecord)12 CommonConnectorConfig (io.debezium.config.CommonConnectorConfig)6 Configuration (io.debezium.config.Configuration)6 Config (org.apache.kafka.common.config.Config)6 JdbcConnection (io.debezium.jdbc.JdbcConnection)3 RecordsForCollection (io.debezium.connector.mongodb.RecordMakers.RecordsForCollection)2 BigDecimal (java.math.BigDecimal)2 Duration (java.time.Duration)2 LocalDate (java.time.LocalDate)2 LocalDateTime (java.time.LocalDateTime)2 OffsetDateTime (java.time.OffsetDateTime)2 ZoneOffset (java.time.ZoneOffset)2 List (java.util.List)2 BsonTimestamp (org.bson.BsonTimestamp)2