Skip to content

Commit

Permalink
Update MariaDB containers
Browse files Browse the repository at this point in the history
* update connector to recent version
* set default image to current LTS (10.3 is EOL)
* add Foundation image from quay.io: these permit testing preview mariadb images, available 6 months before official release, like new authentication, vector, ...
  • Loading branch information
rusher committed Nov 25, 2024
1 parent f7267c7 commit 86b89e2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
6 changes: 3 additions & 3 deletions modules/mariadb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ dependencies {
api project(':jdbc')

compileOnly project(':r2dbc')
compileOnly 'org.mariadb:r2dbc-mariadb:1.0.3'
compileOnly 'org.mariadb:r2dbc-mariadb:1.3.0'

testImplementation project(':jdbc-test')
testImplementation 'org.mariadb.jdbc:mariadb-java-client:3.4.1'
testImplementation 'org.mariadb.jdbc:mariadb-java-client:3.5.1'

testImplementation testFixtures(project(':r2dbc'))
testRuntimeOnly 'org.mariadb:r2dbc-mariadb:1.0.3'
testRuntimeOnly 'org.mariadb:r2dbc-mariadb:1.3.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public class MariaDBContainer<SELF extends MariaDBContainer<SELF>> extends JdbcD

private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("mariadb");

private static final DockerImageName FOUNDATION_IMAGE_NAME = DockerImageName.parse("quay.io/repository/mariadb-foundation/mariadb-devel");

@Deprecated
public static final String DEFAULT_TAG = "10.3.6";
public static final String DEFAULT_TAG = "10.11.10";

public static final String NAME = "mariadb";

Expand Down Expand Up @@ -55,7 +57,7 @@ public MariaDBContainer(String dockerImageName) {

public MariaDBContainer(final DockerImageName dockerImageName) {
super(dockerImageName);
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, FOUNDATION_IMAGE_NAME);

addExposedPort(MARIADB_PORT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import org.testcontainers.utility.DockerImageName;

public interface MariaDBTestImages {
DockerImageName MARIADB_IMAGE = DockerImageName.parse("mariadb:10.3.39");
DockerImageName MARIADB_IMAGE = DockerImageName.parse("mariadb:10.11.10");
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected ConnectionFactoryOptions getOptions(MariaDBContainer<?> container) {

@Override
protected String createR2DBCUrl() {
return "r2dbc:tc:mariadb:///db?TC_IMAGE_TAG=10.3.39";
return "r2dbc:tc:mariadb:///db?TC_IMAGE_TAG=10.11.10";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@ public static Iterable<Object[]> data() {
"jdbc:tc:mariadb://hostname/databasename?user=someuser&TC_INITSCRIPT=somepath/init_mariadb.sql",
EnumSet.of(Options.ScriptedSchema, Options.JDBCParams),
},
{ "jdbc:tc:mariadb:10.3.39://hostname/databasename", EnumSet.noneOf(Options.class) },
{ "jdbc:tc:mariadb:10.11.10://hostname/databasename", EnumSet.noneOf(Options.class) },
{
"jdbc:tc:mariadb:10.3.39://hostname/databasename?TC_INITSCRIPT=somepath/init_unicode_mariadb.sql&useUnicode=yes&characterEncoding=utf8",
"jdbc:tc:mariadb:10.11.10://hostname/databasename?TC_INITSCRIPT=somepath/init_unicode_mariadb.sql&useUnicode=yes&characterEncoding=utf8",
EnumSet.of(Options.CharacterSet),
},
{
"jdbc:tc:mariadb:10.3.39://hostname/databasename?user=someuser&TC_INITSCRIPT=somepath/init_mariadb.sql",
"jdbc:tc:mariadb:10.11.10://hostname/databasename?user=someuser&TC_INITSCRIPT=somepath/init_mariadb.sql",
EnumSet.of(Options.ScriptedSchema, Options.JDBCParams),
},
{
"jdbc:tc:mariadb:10.3.39://hostname/databasename?user=someuser&TC_INITFUNCTION=org.testcontainers.jdbc.AbstractJDBCDriverTest::sampleInitFunction",
"jdbc:tc:mariadb:10.11.10://hostname/databasename?user=someuser&TC_INITFUNCTION=org.testcontainers.jdbc.AbstractJDBCDriverTest::sampleInitFunction",
EnumSet.of(Options.ScriptedSchema, Options.JDBCParams),
},
{
"jdbc:tc:mariadb:10.3.39://hostname/databasename?user=someuser&password=somepwd&TC_INITSCRIPT=somepath/init_mariadb.sql",
"jdbc:tc:mariadb:10.11.10://hostname/databasename?user=someuser&password=somepwd&TC_INITSCRIPT=somepath/init_mariadb.sql",
EnumSet.of(Options.ScriptedSchema, Options.JDBCParams),
},
{
"jdbc:tc:mariadb:10.3.39://hostname/databasename?user=someuser&password=somepwd&TC_INITFUNCTION=org.testcontainers.jdbc.AbstractJDBCDriverTest::sampleInitFunction",
"jdbc:tc:mariadb:10.11.10://hostname/databasename?user=someuser&password=somepwd&TC_INITFUNCTION=org.testcontainers.jdbc.AbstractJDBCDriverTest::sampleInitFunction",
EnumSet.of(Options.ScriptedSchema, Options.JDBCParams),
},
{
"jdbc:tc:mariadb:10.3.39://hostname/databasename?TC_MY_CNF=somepath/mariadb_conf_override",
"jdbc:tc:mariadb:10.11.10://hostname/databasename?TC_MY_CNF=somepath/mariadb_conf_override",
EnumSet.of(Options.CustomIniFile),
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void testSimple() throws SQLException {
public void testSpecificVersion() throws SQLException {
try (
MariaDBContainer<?> mariadbOldVersion = new MariaDBContainer<>(
MariaDBTestImages.MARIADB_IMAGE.withTag("10.3.39")
MariaDBTestImages.MARIADB_IMAGE.withTag("10.11.10")
)
) {
mariadbOldVersion.start();
Expand All @@ -49,7 +49,7 @@ public void testSpecificVersion() throws SQLException {

assertThat(resultSetString)
.as("The database version can be set using a container rule parameter")
.startsWith("10.3.39");
.startsWith("10.11.10");
}
}

Expand All @@ -59,7 +59,7 @@ public void testMariaDBWithCustomIniFile() throws SQLException {

try (
MariaDBContainer<?> mariadbCustomConfig = new MariaDBContainer<>(
MariaDBTestImages.MARIADB_IMAGE.withTag("10.3.39")
MariaDBTestImages.MARIADB_IMAGE.withTag("10.11.10")
)
.withConfigurationOverride("somepath/mariadb_conf_override")
) {
Expand Down Expand Up @@ -107,7 +107,7 @@ public void testWithOnlyUserReadableCustomIniFile() throws Exception {

try (
MariaDBContainer<?> mariadbCustomConfig = new MariaDBContainer<>(
MariaDBTestImages.MARIADB_IMAGE.withTag("10.3.39")
MariaDBTestImages.MARIADB_IMAGE.withTag("10.11.10")
)
.withConfigurationOverride("somepath/mariadb_conf_override")
) {
Expand Down Expand Up @@ -144,6 +144,18 @@ public void testEmptyPasswordWithRootUser() throws SQLException {
}
}

@Test
public void testFondationImages() throws SQLException {
try (MariaDBContainer<?> mysql = new MariaDBContainer<>("quay.io/repository/mariadb-foundation/mariadb-devel?tab=tags&tag=11.7").withUsername("root")) {
mysql.start();

ResultSet resultSet = performQuery(mysql, "SELECT 1");
int resultSetInt = resultSet.getInt(1);

assertThat(resultSetInt).isEqualTo(1);
}
}

private void assertThatCustomIniFileWasUsed(MariaDBContainer<?> mariadb) throws SQLException {
try (ResultSet resultSet = performQuery(mariadb, "SELECT @@GLOBAL.innodb_max_undo_log_size")) {
long result = resultSet.getLong(1);
Expand Down

0 comments on commit 86b89e2

Please sign in to comment.