DBZ-3684 OracleSchemaMigrationIT - Fix possible false positive test failure

This commit is contained in:
Chris Cranford 2021-06-29 14:42:50 -04:00 committed by Gunnar Morling
parent 51825b0b47
commit 237a71ea3c
2 changed files with 18 additions and 2 deletions

View File

@ -49,13 +49,13 @@ public void beforeEach() throws Exception {
initializeConnectorTestFramework(); initializeConnectorTestFramework();
Testing.Files.delete(TestHelper.DB_HISTORY_PATH); Testing.Files.delete(TestHelper.DB_HISTORY_PATH);
TestHelper.dropTables(connection, "debezium_signal", "tablea", "tableb", "\"tableC\""); TestHelper.dropAllTables();
} }
@After @After
public void afterEach() throws Exception { public void afterEach() throws Exception {
if (connection != null) { if (connection != null) {
TestHelper.dropTables(connection, "tablea", "tableb", "\"tableC\""); TestHelper.dropAllTables();
connection.close(); connection.close();
} }
} }

View File

@ -387,4 +387,20 @@ public static OracleConnectorConfig.ConnectorAdapter adapter() {
final String s = System.getProperty(OracleConnectorConfig.CONNECTOR_ADAPTER.name()); final String s = System.getProperty(OracleConnectorConfig.CONNECTOR_ADAPTER.name());
return (s == null || s.length() == 0) ? OracleConnectorConfig.ConnectorAdapter.LOG_MINER : OracleConnectorConfig.ConnectorAdapter.parse(s); return (s == null || s.length() == 0) ? OracleConnectorConfig.ConnectorAdapter.LOG_MINER : OracleConnectorConfig.ConnectorAdapter.parse(s);
} }
/**
* Drops all tables visible to user {@link #SCHEMA_USER}.
*/
public static void dropAllTables() {
try (OracleConnection connection = testConnection()) {
connection.query("SELECT TABLE_NAME FROM USER_TABLES", rs -> {
while (rs.next()) {
connection.execute("DROP TABLE " + rs.getString(1));
}
});
}
catch (SQLException e) {
throw new RuntimeException("Failed to clean database");
}
}
} }