Skip to content

Commit

Permalink
fix some error when docker version is old
Browse files Browse the repository at this point in the history
close #2905
  • Loading branch information
liugddx committed Sep 27, 2022
1 parent b7d9dde commit c4f0a1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.testcontainers.lifecycle.Startables;
import org.testcontainers.utility.DockerImageName;

import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.DriverManager;
Expand All @@ -48,6 +50,7 @@
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand All @@ -61,7 +64,7 @@ public class JdbcMysqlIT extends FlinkContainer {
@BeforeEach
public void startPostgreSqlContainer() throws Exception {
// Non-root users need to grant XA_RECOVER_ADMIN permission on is_exactly_once = "true"
mc = new MySQLContainer<>(DockerImageName.parse("mysql:8.0.29"))
mc = new MySQLContainer<>(DockerImageName.parse("bitnami/mysql:8.0.29").asCompatibleSubstituteFor("mysql"))
.withNetwork(NETWORK)
.withNetworkAliases("mysql")
.withUsername("root")
Expand All @@ -78,13 +81,10 @@ public void startPostgreSqlContainer() throws Exception {
batchInsertData();
}

private void initializeJdbcTable() {
java.net.URL resource = FlinkContainer.class.getResource("/jdbc/init_sql/mysql_init.conf");
if (resource == null) {
throw new IllegalArgumentException("can't find find file");
}
private void initializeJdbcTable() throws URISyntaxException {
URI resource = Objects.requireNonNull(FlinkContainer.class.getResource("/jdbc/init_sql/mysql_init.conf")).toURI();

config = new ConfigBuilder(Paths.get(resource.getPath())).getConfig();
config = new ConfigBuilder(Paths.get(resource)).getConfig();

CheckConfigUtil.checkAllExists(this.config, "source_table", "sink_table", "type_source_table",
"type_sink_table", "insert_type_source_table_sql", "check_type_sink_table_sql");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ public class JdbcPostgresIT extends FlinkContainer {
@SuppressWarnings("checkstyle:MagicNumber")
@BeforeEach
public void startPostgreSqlContainer() throws Exception {
pg = new PostgreSQLContainer<>(DockerImageName.parse("postgres:14.3"))
pg = new PostgreSQLContainer<>(DockerImageName.parse("postgres:14-alpine"))
.withNetwork(NETWORK)
.withNetworkAliases("postgresql")
.withCommand("postgres -c max_prepared_transactions=100")
.withUsername("root")
.withLogConsumer(new Slf4jLogConsumer(LOGGER));
Startables.deepStart(Stream.of(pg)).join();
LOGGER.info("Postgres container started");
Expand Down

0 comments on commit c4f0a1c

Please sign in to comment.