From 217c50a8ed02a10c51fc145303f6979aa7e4875b Mon Sep 17 00:00:00 2001 From: Scott Leberknight <174812+sleberknight@users.noreply.github.com> Date: Fri, 2 May 2025 20:44:57 -0400 Subject: [PATCH] Switch to mysql:lts container MySQL tests are now failing when using mysql:latest (where 'latest' is 9.3.0-1.el9) See "[Bug]: mysql container Unable to start" at https://github.com/testcontainers/testcontainers-java/issues/10184 Switch to mysql:lts so that: (a) it works again (b) it is hopefully more stable --- .../error/dao/jdbi3/MySqlJdbi3ApplicationErrorDaoTest.java | 4 ++-- .../error/dao/jdk/MySqlJdbcApplicationErrorDaoTest.java | 4 ++-- .../org/kiwiproject/dropwizard/error/util/TestHelpers.java | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/MySqlJdbi3ApplicationErrorDaoTest.java b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/MySqlJdbi3ApplicationErrorDaoTest.java index c941f58..ad67f5f 100644 --- a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/MySqlJdbi3ApplicationErrorDaoTest.java +++ b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdbi3/MySqlJdbi3ApplicationErrorDaoTest.java @@ -1,7 +1,7 @@ package org.kiwiproject.dropwizard.error.dao.jdbi3; import static org.kiwiproject.dropwizard.error.util.TestHelpers.migrateDatabase; -import static org.kiwiproject.dropwizard.error.util.TestHelpers.newLatestMySQLContainer; +import static org.kiwiproject.dropwizard.error.util.TestHelpers.newLtsMySQLContainer; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; @@ -16,7 +16,7 @@ class MySqlJdbi3ApplicationErrorDaoTest extends AbstractJdbi3ApplicationErrorDaoTest { @Container - private static final MySQLContainer MYSQL = newLatestMySQLContainer(); + private static final MySQLContainer MYSQL = newLtsMySQLContainer(); @RegisterExtension final Jdbi3DaoExtension jdbi3DaoExtension = diff --git a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/MySqlJdbcApplicationErrorDaoTest.java b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/MySqlJdbcApplicationErrorDaoTest.java index e7fb852..ab04c9e 100644 --- a/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/MySqlJdbcApplicationErrorDaoTest.java +++ b/src/test/java/org/kiwiproject/dropwizard/error/dao/jdk/MySqlJdbcApplicationErrorDaoTest.java @@ -1,7 +1,7 @@ package org.kiwiproject.dropwizard.error.dao.jdk; import static org.kiwiproject.dropwizard.error.util.TestHelpers.migrateDatabase; -import static org.kiwiproject.dropwizard.error.util.TestHelpers.newLatestMySQLContainer; +import static org.kiwiproject.dropwizard.error.util.TestHelpers.newLtsMySQLContainer; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DisplayName; @@ -17,7 +17,7 @@ class MySqlJdbcApplicationErrorDaoTest extends AbstractJdbcApplicationErrorDaoTe private static SimpleSingleConnectionDataSource dataSource; @Container - private static final MySQLContainer MYSQL = newLatestMySQLContainer(); + private static final MySQLContainer MYSQL = newLtsMySQLContainer(); @BeforeAll static void beforeAll() { diff --git a/src/test/java/org/kiwiproject/dropwizard/error/util/TestHelpers.java b/src/test/java/org/kiwiproject/dropwizard/error/util/TestHelpers.java index e214786..c587840 100644 --- a/src/test/java/org/kiwiproject/dropwizard/error/util/TestHelpers.java +++ b/src/test/java/org/kiwiproject/dropwizard/error/util/TestHelpers.java @@ -12,12 +12,11 @@ import org.testcontainers.containers.MySQLContainer; import org.testcontainers.utility.DockerImageName; +import javax.sql.DataSource; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; -import javax.sql.DataSource; - @UtilityClass @Slf4j public class TestHelpers { @@ -41,8 +40,8 @@ private static void checkIsH2Connection(Connection conn) throws SQLException { "Connection is not to an H2 database. Database product name: %s", databaseProductName); } - public static MySQLContainer newLatestMySQLContainer() { - return new MySQLContainer<>(DockerImageName.parse("mysql:latest")); + public static MySQLContainer newLtsMySQLContainer() { + return new MySQLContainer<>(DockerImageName.parse("mysql:lts")); } /**