Skip to content

Commit

Permalink
[ci] Sanitize each test use case (Db2ConnectorIT)
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Feb 10, 2024
1 parent 287fb43 commit ef7ee32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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
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);
}
});
}
}
}

0 comments on commit ef7ee32

Please sign in to comment.