Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Db2 Test Failures #134

Merged
merged 3 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/test/java/io/debezium/connector/db2/Db2ConnectorIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class Db2ConnectorIT extends AbstractConnectorTest {

@Before
public void before() throws SQLException {
TestHelper.dropAllTables();

connection = TestHelper.testConnection();
connection.execute("DELETE FROM ASNCDC.IBMSNAP_REGISTER");
connection.execute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
*/
package io.debezium.connector.db2;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;

import io.debezium.config.Configuration;
import io.debezium.connector.db2.util.TestHelper;
import io.debezium.doc.FixFor;
import io.debezium.junit.ConditionalFail;
import io.debezium.junit.Flaky;
import io.debezium.relational.TableId;

/**
Expand All @@ -15,6 +22,17 @@
* @author Chris Cranford
*/
public class Db2OnlineDefaultValueIT extends AbstractDb2DefaultValueIT {

@Rule
public TestRule conditionalFail = new ConditionalFail();

@Test
@FixFor("DBZ-4990")
@Flaky("DBZ-6048")
public void shouldHandleDateTimeDefaultTypes() throws Exception {
super.shouldHandleDateTimeDefaultTypes();
}

@Override
protected void performSchemaChange(Configuration config, Db2Connection connection, String alterStatement) throws Exception {
final TableId tableId = TableId.parse("DB2INST1.DV_TEST");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ protected JdbcConnection databaseConnection() {
@Override
protected Configuration.Builder getConfigurationBuilder() {
return TestHelper.defaultConfig()
.with(Db2ConnectorConfig.TABLE_INCLUDE_LIST, "DB2INST1\\.DBZ4321")
.with(Db2ConnectorConfig.CUSTOM_POST_PROCESSORS, "reselector")
.with("reselector.type", ReselectColumnsPostProcessor.class.getName());
}
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/io/debezium/connector/db2/util/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,19 @@ public static void waitForCDC() {

}
}

public static void dropAllTables() throws SQLException {
try (Db2Connection connection = testConnection()) {
LOGGER.info("Attempting to drop all tables (if exists)");
connection.query("SELECT TABNAME FROM syscat.tables WHERE TABSCHEMA = 'DB2INST1'", rs -> {
while (rs.next()) {
final String tableName = rs.getString(1);
LOGGER.info("Disabling CDC for table {}", tableName);
disableTableCdc(connection, "DB2INST1", tableName);
LOGGER.warn("Dropping table {}", tableName);
connection.execute("DROP TABLE IF EXISTS " + tableName);
}
});
}
}
}