Skip to content

Commit

Permalink
[postgres][tests]Fix test with wrong databasename(#2393)
Browse files Browse the repository at this point in the history
  • Loading branch information
loserwang1024 committed Aug 15, 2023
1 parent 0bb5deb commit 07314b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public static void stopAll() {
POSTGRES_CONTAINER_OLD.stop();
LOG.info("Containers are started.");
}

@Before
public void before() {
initializePostgresTable(POSTGRES_CONTAINER_OLD, "inventory");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.flink.table.planner.factories.TestValuesTableFactory;
import org.apache.flink.test.util.AbstractTestBase;

import com.ververica.cdc.connectors.postgres.source.PostgresConnectionPoolFactory;
import io.debezium.config.Configuration;
import io.debezium.connector.postgresql.connection.PostgresConnection;
import io.debezium.jdbc.JdbcConfiguration;
Expand Down Expand Up @@ -98,10 +99,14 @@ protected Connection getJdbcConnection(PostgreSQLContainer container) throws SQL

public static Connection getJdbcConnection(PostgreSQLContainer container, String databaseName)
throws SQLException {
String jdbcUrl =
String.format(
PostgresConnectionPoolFactory.JDBC_URL_PATTERN,
container.getHost(),
container.getMappedPort(PostgreSQLContainer.POSTGRESQL_PORT),
databaseName);
return DriverManager.getConnection(
container.withDatabaseName(databaseName).getJdbcUrl(),
container.getUsername(),
container.getPassword());
jdbcUrl, container.getUsername(), container.getPassword());
}

public static String getSlotName() {
Expand Down

0 comments on commit 07314b9

Please sign in to comment.