Package io.debezium.connector.db2
Class AbstractDb2DefaultValueIT
java.lang.Object
io.debezium.embedded.AbstractConnectorTest
io.debezium.connector.db2.AbstractDb2DefaultValueIT
- All Implemented Interfaces:
io.debezium.util.Testing
- Direct Known Subclasses:
Db2OfflineDefaultValueIT,ZZZDb2OnlineDefaultValueIT
public abstract class AbstractDb2DefaultValueIT
extends io.debezium.embedded.AbstractConnectorTest
Abstract default value integration test.
This test is extended by two variants, online and offline schema evolution. All tests should
be included in this class and therefore should pass both variants to make sure that the
schema evolution process works regardless of mode used by the user.
- Author:
- Chris Cranford
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumDefines the different assertion types for a given column definition.private static classDefines a column definition and its attributes that are used by tests.Nested classes/interfaces inherited from class io.debezium.embedded.AbstractConnectorTest
io.debezium.embedded.AbstractConnectorTest.SourceRecordsNested classes/interfaces inherited from interface io.debezium.util.Testing
io.debezium.util.Testing.Debug, io.debezium.util.Testing.Files, io.debezium.util.Testing.InterruptableFunction, io.debezium.util.Testing.Network, io.debezium.util.Testing.Print, io.debezium.util.Testing.Timer -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate io.debezium.config.Configurationprivate io.debezium.connector.db2.Db2ConnectionFields inherited from class io.debezium.embedded.AbstractConnectorTest
consumedLines, engine, isEngineRunning, logger, logTestName, OFFSET_STORE_PATH, pollTimeoutInMs, skipTestRule -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafter()private static voidassertSchemaFieldDefaultAndNonNullValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object defaultValue) private static voidassertSchemaFieldNoDefaultWithValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object fieldValue) Asserts that the schema field's default value is not set and that the emitted event value matches.private static voidassertSchemaFieldValueWithDefault(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object expectedDefault, Consumer<Object> valueCheck) private static voidassertSchemaFieldWithDefaultCurrentDate(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object expectedValue) private static voidassertSchemaFieldWithSameDefaultAndValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object expectedValue) Asserts that the schema field's default value and after emitted event value are the same.voidbefore()protected abstract voidperformSchemaChange(io.debezium.config.Configuration config, io.debezium.connector.db2.Db2Connection connection, String alterStatement) voidvoidvoidprivate voidshouldHandleDefaultValuesCommon(List<AbstractDb2DefaultValueIT.ColumnDefinition> columnDefinitions) Handles executing the full common set of default value tests for the supplied column definitions.voidvoidprivate voidtestDefaultValuesAlterTableAdd(List<AbstractDb2DefaultValueIT.ColumnDefinition> columnDefinitions) Alters the underlying table changing adding a new column prefixed withAto each of the column definition with the initial default value definition.private voidtestDefaultValuesAlterTableModifyExisting(List<AbstractDb2DefaultValueIT.ColumnDefinition> columnDefinitions) Alters the underlying table changing the default value to its second form.private voidRestarts the connector and verifies when the database history topic is loaded that we can parse all the loaded history statements without failures.private voidtestDefaultValuesCreateTableAndSnapshot(List<AbstractDb2DefaultValueIT.ColumnDefinition> columnDefinitions) Creates the table and pre-inserts a record captured during the snapshot phase.Methods inherited from class io.debezium.embedded.AbstractConnectorTest
assertBeginTransaction, assertConfigurationErrors, assertConfigurationErrors, assertConfigurationErrors, assertConnectorIsRunning, assertConnectorNotRunning, assertDelete, assertEndTransaction, assertEngineIsRunning, assertHasNoSourceQuery, assertInsert, assertKey, assertNoConfigurationErrors, assertNoRecordsToConsume, assertOffset, assertOffset, assertOnlyTransactionRecordsToConsume, assertRecordTransactionMetadata, assertSchemaMatchesStruct, assertSchemaMatchesStruct, assertSourceQuery, assertTombstone, assertTombstone, assertUpdate, assertValueField, configValue, consumeAvailableRecords, consumeAvailableRecordsByTopic, consumeDmlRecordsByTopic, consumeDmlRecordsByTopic, consumeDmlRecordsByTopic, consumeRecord, consumeRecords, consumeRecords, consumeRecords, consumeRecordsButSkipUntil, consumeRecordsByTopic, consumeRecordsByTopic, consumeRecordsByTopic, consumeRecordsByTopicUntil, consumeRecordsUntil, createEngine, createEngineBuilder, debug, getConsumer, getMaximumEnqueuedRecordCount, getSnapshotMetricsObjectName, getSnapshotMetricsObjectName, getSnapshotMetricsObjectName, getStreamingMetricsObjectName, getStreamingMetricsObjectName, getStreamingMetricsObjectName, getStreamingMetricsObjectName, getStreamingNamespace, initializeConnectorTestFramework, isStreamingRunning, isStreamingRunning, isStreamingRunning, isStreamingRunning, isTransactionRecord, loggingCompletion, print, readLastCommittedOffset, readLastCommittedOffsets, setConsumeTimeout, skipAvroValidation, start, start, start, start, start, start, start, startAndConsumeTillEnd, startAndConsumeTillEnd, stopConnector, stopConnector, storeOffsets, validate, waitForAvailableRecords, waitForConnectorShutdown, waitForEngineShutdown, waitForSnapshotToBeCompleted, waitForSnapshotToBeCompleted, waitForSnapshotWithCustomMetricsToBeCompleted, waitForStreamingRunning, waitForStreamingRunning, waitForStreamingRunning, waitForStreamingWithCustomMetricsToStart, waitTimeForEngine, waitTimeForRecords, waitTimeForRecordsAfterNullsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.debezium.util.Testing
once, once, resetBeforeEachTest, time, time
-
Field Details
-
connection
private io.debezium.connector.db2.Db2Connection connection -
config
private io.debezium.config.Configuration config
-
-
Constructor Details
-
AbstractDb2DefaultValueIT
public AbstractDb2DefaultValueIT()
-
-
Method Details
-
before
- Throws:
SQLException
-
after
- Throws:
SQLException
-
shouldHandleBooleanDefaultTypes
- Throws:
Exception
-
shouldHandleNumericDefaultTypes
- Throws:
Exception
-
shouldHandleFloatPointDefaultTypes
- Throws:
Exception
-
shouldHandleCharacterDefaultTypes
- Throws:
Exception
-
shouldHandleDateTimeDefaultTypes
- Throws:
Exception
-
performSchemaChange
protected abstract void performSchemaChange(io.debezium.config.Configuration config, io.debezium.connector.db2.Db2Connection connection, String alterStatement) throws Exception - Throws:
Exception
-
shouldHandleDefaultValuesCommon
private void shouldHandleDefaultValuesCommon(List<AbstractDb2DefaultValueIT.ColumnDefinition> columnDefinitions) throws Exception Handles executing the full common set of default value tests for the supplied column definitions.- Parameters:
columnDefinitions- list of column definitions, should not benull- Throws:
Exception- if an exception occurred
-
TestDefaultValuesByRestartAndLoadingHistoryTopic
Restarts the connector and verifies when the database history topic is loaded that we can parse all the loaded history statements without failures.- Throws:
Exception
-
testDefaultValuesCreateTableAndSnapshot
private void testDefaultValuesCreateTableAndSnapshot(List<AbstractDb2DefaultValueIT.ColumnDefinition> columnDefinitions) throws Exception Creates the table and pre-inserts a record captured during the snapshot phase. The snapshot record will be validated against the supplied column definitions. The goal of this method is to test that when a table is snapshot which uses default values that both the in-memory schema representation and the snapshot pipeline change event have the right default value resolution.- Parameters:
columnDefinitions- list of column definitions, should not benull- Throws:
Exception- if an exception occurred
-
testDefaultValuesAlterTableModifyExisting
private void testDefaultValuesAlterTableModifyExisting(List<AbstractDb2DefaultValueIT.ColumnDefinition> columnDefinitions) throws Exception Alters the underlying table changing the default value to its second form. This method then inserts a new record that is then validated against the supplied column definitions. The goal of this method is to test that when DDL modifies an existing column in an existing table that the right default value resolution occurs and that the in-memory schema representation is correct as well as the change event capture pipeline.- Parameters:
columnDefinitions- list of column definitions, should not benull- Throws:
Exception- if an exception occurred
-
testDefaultValuesAlterTableAdd
private void testDefaultValuesAlterTableAdd(List<AbstractDb2DefaultValueIT.ColumnDefinition> columnDefinitions) throws Exception Alters the underlying table changing adding a new column prefixed withAto each of the column definition with the initial default value definition. The goal of this method is to test that when DDL adds a new column to an existing table that the right default value resolution occurs and that the in-memory schema representation is correct as well as the change event capture pipeline.- Parameters:
columnDefinitions- list of column definitions, should not benull- Throws:
Exception- if an exception occurred
-
assertSchemaFieldWithSameDefaultAndValue
private static void assertSchemaFieldWithSameDefaultAndValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object expectedValue) Asserts that the schema field's default value and after emitted event value are the same.- Parameters:
record- the change event record, nevernullfieldName- the field name, nevernullexpectedValue- the expected value in the field's default and "after" struct
-
assertSchemaFieldNoDefaultWithValue
private static void assertSchemaFieldNoDefaultWithValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object fieldValue) Asserts that the schema field's default value is not set and that the emitted event value matches.- Parameters:
record- the change event record, nevernullfieldName- the field name, nevernullfieldValue- the expected value in the field's "after" struct
-
assertSchemaFieldValueWithDefault
-
assertSchemaFieldWithDefaultCurrentDate
-
assertSchemaFieldDefaultAndNonNullValue
-