Package io.debezium.connector.oracle
Class OracleDefaultValueIT
java.lang.Object
io.debezium.embedded.AbstractConnectorTest
io.debezium.connector.oracle.OracleDefaultValueIT
- All Implemented Interfaces:
Testing
Integration test that tests all supported data types and default value combinations during
both snapshot and streaming phases in conjunction with schema changes to the table.
- 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
AbstractConnectorTest.SourceRecordsNested classes/interfaces inherited from interface io.debezium.util.Testing
Testing.Debug, Testing.Files, Testing.InterruptableFunction, Testing.Network, Testing.Print, Testing.Timer -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Configurationprivate Consumer<Configuration.Builder>private io.debezium.connector.oracle.OracleConnectionFields inherited from class io.debezium.embedded.AbstractConnectorTest
consumedLines, engine, 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) Asserts that the schema field's default value is the supplied value and that the emitted events field value is at least a non-null value; expectation is that the emitted event value is dynamic, likely based on some database function call, likeTO_DATEorTO_TIMESTAMP.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 voidassertSchemaFieldWithDefaultSysdate(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()private longgetOracleIntervalDaySecond(int days, int hours, int minutes, int seconds, int micros) private StringgetOracleIntervalDaySecondString(int days, int hours, int minutes, int seconds, int micros) private longgetOracleIntervalYearMonth(int years, int month) private StringgetOracleIntervalYearMonthString(int years, int month) voidvoidvoidvoidprivate voidshouldHandleDefaultValuesCommon(List<OracleDefaultValueIT.ColumnDefinition> columnDefinitions) Handles executing the full common set of default value tests for the supplied column definitions.voidvoidvoidvoidvoidprivate voidtestDefaultValuesAlterTableAdd(List<OracleDefaultValueIT.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<OracleDefaultValueIT.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<OracleDefaultValueIT.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, consumeDmlRecordsByTopic, consumeDmlRecordsByTopic, consumeDmlRecordsByTopic, consumeRecord, consumeRecords, consumeRecords, consumeRecords, consumeRecordsByTopic, consumeRecordsByTopic, consumeRecordsByTopic, consumeRecordsByTopicUntil, consumeRecordsUntil, debug, getConsumer, getMaximumEnqueuedRecordCount, getSnapshotMetricsObjectName, getStreamingMetricsObjectName, getStreamingMetricsObjectName, getStreamingNamespace, initializeConnectorTestFramework, isStreamingRunning, isStreamingRunning, isTransactionRecord, loggingCompletion, print, readLastCommittedOffset, readLastCommittedOffsets, setConsumeTimeout, skipAvroValidation, start, start, start, start, start, start, start, startAndConsumeTillEnd, startAndConsumeTillEnd, stopConnector, stopConnector, validate, waitForAvailableRecords, waitForConnectorShutdown, waitForSnapshotToBeCompleted, waitForStreamingRunning, waitForStreamingRunning, waitTimeForRecords, waitTimeForRecordsAfterNulls
-
Field Details
-
connection
private io.debezium.connector.oracle.OracleConnection connection -
configUpdater
-
config
-
-
Constructor Details
-
OracleDefaultValueIT
public OracleDefaultValueIT()
-
-
Method Details
-
before
- Throws:
Exception
-
after
- Throws:
Exception
-
shouldHandleNumericDefaultTypes
- Throws:
Exception
-
shouldHandleFloatPointDefaultTypes
- Throws:
Exception
-
shouldHandleCharacterDefaultTypes
- Throws:
Exception
-
shouldHandleDateTimeDefaultTypes
- Throws:
Exception
-
shouldHandleIntervalDefaultTypes
- Throws:
Exception
-
shouldHandleIntervalDefaultTypesAsString
- Throws:
Exception
-
shouldHandleDefaultValueFromSequencesAsNoDefault
- Throws:
Exception
-
shouldHandleDefaultValuesWhereSqlMayContainsTrailingSpaces
@FixFor("DBZ-4360") public void shouldHandleDefaultValuesWhereSqlMayContainsTrailingSpaces() throws Exception- Throws:
Exception
-
shouldHandleDefaultValueForNonOptionalColumnUsingUnparseableValues
@FixFor("DBZ-4388") public void shouldHandleDefaultValueForNonOptionalColumnUsingUnparseableValues() throws Exception- Throws:
Exception
-
getOracleIntervalYearMonth
private long getOracleIntervalYearMonth(int years, int month) -
getOracleIntervalYearMonthString
-
getOracleIntervalDaySecond
private long getOracleIntervalDaySecond(int days, int hours, int minutes, int seconds, int micros) -
getOracleIntervalDaySecondString
private String getOracleIntervalDaySecondString(int days, int hours, int minutes, int seconds, int micros) -
shouldHandleDefaultValuesCommon
private void shouldHandleDefaultValuesCommon(List<OracleDefaultValueIT.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<OracleDefaultValueIT.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<OracleDefaultValueIT.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<OracleDefaultValueIT.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
-
assertSchemaFieldDefaultAndNonNullValue
private static void assertSchemaFieldDefaultAndNonNullValue(org.apache.kafka.connect.source.SourceRecord record, String fieldName, Object defaultValue) Asserts that the schema field's default value is the supplied value and that the emitted events field value is at least a non-null value; expectation is that the emitted event value is dynamic, likely based on some database function call, likeTO_DATEorTO_TIMESTAMP.- Parameters:
record- the change event record, nevernullfieldName- the field name, nevernulldefaultValue- the expected schema field's default value
-
assertSchemaFieldWithDefaultSysdate
-
assertSchemaFieldValueWithDefault
-