Skip to content

Commit 9de26f1

Browse files
Fix default configuration file in mysql (#8131)
* Remove use of deprecated (removed in 8.3) MySQL config option * Update MySQL default images to latest - 5.6 went EOL in Feb 2021. Stop testing against it. - 5.7 went EOL in Oct 2023. Retain tests for a bit, but stop using it as the default. - 8.0.34+ is now LTS rather than rolling - use this as the default for most tests - Add 8.3.0 as a candidate "innovation" version which will eventually become LTS * Updates various docs to use 8.0 in the examples rather than EOL 5.7. * Update MariaDB images to latest 10.3 patch release Fixes #8130 --------- Co-authored-by: Eddú Meléndez <[email protected]>
1 parent 8881967 commit 9de26f1

File tree

29 files changed

+98
-113
lines changed

29 files changed

+98
-113
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
redis:
22
image: redis
33
db:
4-
image: mysql:5.7.34
4+
image: mysql:8.0.36
55
environment:
66
MYSQL_RANDOM_ROOT_PASSWORD: "true"

core/src/test/resources/composev2/compose-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ services:
22
redis:
33
image: redis
44
db:
5-
image: mysql:8.0.33
5+
image: mysql:8.0.36
66
environment:
77
MYSQL_RANDOM_ROOT_PASSWORD: "true"

docs/examples/junit4/generic/src/test/java/generic/ImageNameSubstitutionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public void simpleExample() {
1212
try (
1313
// spotless:off
1414
// directDockerHubReference {
15-
// Referring directly to an image on Docker Hub (mysql:8.0.24)
15+
// Referring directly to an image on Docker Hub (mysql:8.0.36)
1616
final MySQLContainer<?> mysql = new MySQLContainer<>(
17-
DockerImageName.parse("mysql:8.0.24")
17+
DockerImageName.parse("mysql:8.0.36")
1818
)
1919
// start the container and use it for testing
2020
// }
@@ -36,7 +36,7 @@ public void substitutedExample() {
3636
// hardcodedMirror {
3737
// Referring directly to an image on a private registry - image name will vary
3838
final MySQLContainer<?> mysql = new MySQLContainer<>(
39-
DockerImageName.parse("registry.mycompany.com/mirror/mysql:8.0.24")
39+
DockerImageName.parse("registry.mycompany.com/mirror/mysql:8.0.36")
4040
.asCompatibleSubstituteFor("mysql")
4141
)
4242
// start the container and use it for testing

docs/examples/junit4/generic/src/test/java/generic/support/TestSpecificImageNameSubstitutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class TestSpecificImageNameSubstitutor extends ImageNameSubstitutor {
1212

1313
@Override
1414
public DockerImageName apply(final DockerImageName original) {
15-
if (original.equals(DockerImageName.parse("registry.mycompany.com/mirror/mysql:8.0.24"))) {
15+
if (original.equals(DockerImageName.parse("registry.mycompany.com/mirror/mysql:8.0.36"))) {
1616
return DockerImageName.parse("mysql");
1717
} else {
1818
return original;

docs/features/image_name_substitution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Consider this if:
5353

5454
* Developers and CI machines need to use different image names. For example, developers are able to pull images from Docker Hub, but CI machines need to pull from a private registry
5555
* Your private registry has copies of images from Docker Hub where the names are predictable, and just adding a prefix is enough.
56-
For example, `registry.mycompany.com/mirror/mysql:8.0.24` can be derived from the original Docker Hub image name (`mysql:8.0.24`) with a consistent prefix string: `registry.mycompany.com/mirror/`
56+
For example, `registry.mycompany.com/mirror/mysql:8.0.36` can be derived from the original Docker Hub image name (`mysql:8.0.36`) with a consistent prefix string: `registry.mycompany.com/mirror/`
5757

5858
In this case, image name references in code are **unchanged**.
5959
i.e. you would leave as-is:

docs/features/reuse.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ GenericContainer container = new GenericContainer("redis:6-alpine")
3030
### Reusable Container with Testcontainers JDBC URL
3131

3232
If using the [Testcontainers JDBC URL support](../../modules/databases/jdbc#database-containers-launched-via-jdbc-url-scheme)
33-
the URL **must** follow the pattern of `jdbc:tc:mysql:5.7.34:///databasename?TC_REUSABLE=true`.
33+
the URL **must** follow the pattern of `jdbc:tc:mysql:8.0.36:///databasename?TC_REUSABLE=true`.
3434
`TC_REUSABLE=true` is set as a parameter of the JDBC URL.

docs/modules/databases/jdbc.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Insert `tc:` after `jdbc:` as follows. Note that the hostname, port and database
2020

2121
!!! note
2222
We will use `///` (host-less URIs) from now on to emphasis the unimportance of the `host:port` pair.
23-
From Testcontainers' perspective, `jdbc:mysql:5.7.34://localhost:3306/databasename` and `jdbc:mysql:5.7.34:///databasename` is the same URI.
23+
From Testcontainers' perspective, `jdbc:mysql:8.0.36://localhost:3306/databasename` and `jdbc:mysql:8.0.36:///databasename` is the same URI.
2424

2525
!!! warning
2626
If you're using the JDBC URL support, there is no need to instantiate an instance of the container - Testcontainers will do it automagically.
@@ -45,11 +45,11 @@ Insert `tc:` after `jdbc:` as follows. Note that the hostname, port and database
4545

4646
#### Using MariaDB
4747

48-
`jdbc:tc:mariadb:10.2.14:///databasename`
48+
`jdbc:tc:mariadb:10.3.39:///databasename`
4949

5050
#### Using MySQL
5151

52-
`jdbc:tc:mysql:5.7.34:///databasename`
52+
`jdbc:tc:mysql:8.0.36:///databasename`
5353

5454
#### Using MSSQL Server
5555

@@ -92,21 +92,21 @@ Insert `tc:` after `jdbc:` as follows. Note that the hostname, port and database
9292

9393
Testcontainers can run an init script after the database container is started, but before your code is given a connection to it. The script must be on the classpath, and is referenced as follows:
9494

95-
`jdbc:tc:mysql:5.7.34:///databasename?TC_INITSCRIPT=somepath/init_mysql.sql`
95+
`jdbc:tc:mysql:8.0.36:///databasename?TC_INITSCRIPT=somepath/init_mysql.sql`
9696

9797
This is useful if you have a fixed script for setting up database schema, etc.
9898

9999
### Using an init script from a file
100100

101101
If the init script path is prefixed `file:`, it will be loaded from a file (relative to the working directory, which will usually be the project root).
102102

103-
`jdbc:tc:mysql:5.7.34:///databasename?TC_INITSCRIPT=file:src/main/resources/init_mysql.sql`
103+
`jdbc:tc:mysql:8.0.36:///databasename?TC_INITSCRIPT=file:src/main/resources/init_mysql.sql`
104104

105105
### Using an init function
106106

107107
Instead of running a fixed script for DB setup, it may be useful to call a Java function that you define. This is intended to allow you to trigger database schema migration tools. To do this, add TC_INITFUNCTION to the URL as follows, passing a full path to the class name and method:
108108

109-
`jdbc:tc:mysql:5.7.34:///databasename?TC_INITFUNCTION=org.testcontainers.jdbc.JDBCDriverTest::sampleInitFunction`
109+
`jdbc:tc:mysql:8.0.36:///databasename?TC_INITFUNCTION=org.testcontainers.jdbc.JDBCDriverTest::sampleInitFunction`
110110

111111
The init function must be a public static method which takes a `java.sql.Connection` as its only parameter, e.g.
112112
```java
@@ -121,7 +121,7 @@ public class JDBCDriverTest {
121121

122122
By default database container is being stopped as soon as last connection is closed. There are cases when you might need to start container and keep it running till you stop it explicitly or JVM is shutdown. To do this, add `TC_DAEMON` parameter to the URL as follows:
123123

124-
`jdbc:tc:mysql:5.7.34:///databasename?TC_DAEMON=true`
124+
`jdbc:tc:mysql:8.0.36:///databasename?TC_DAEMON=true`
125125

126126
With this parameter database container will keep running even when there're no open connections.
127127

docs/modules/databases/mysql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ See [Database containers](./index.md) for documentation and usage that is common
77
For MySQL databases, it is possible to override configuration settings using resources on the classpath. Assuming `somepath/mysql_conf_override`
88
is a directory on the classpath containing .cnf files, the following URL can be used:
99

10-
`jdbc:tc:mysql:5.7.34://hostname/databasename?TC_MY_CNF=somepath/mysql_conf_override`
10+
`jdbc:tc:mysql:8.0.36://hostname/databasename?TC_MY_CNF=somepath/mysql_conf_override`
1111

1212
Any .cnf files in this classpath directory will be mapped into the database container's /etc/mysql/conf.d directory,
1313
and will be able to override server settings when the container starts.

docs/modules/databases/r2dbc.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The started container will be terminated when the `ConnectionFactory` is closed.
2222
**Note that, unlike Testcontainers' JDBC URL support, it is not possible to specify an image tag in the 'scheme' part of the URL, and it is always necessary to specify a tag using `TC_IMAGE_TAG`.**
2323

2424
So that the URL becomes:
25-
`r2dbc:tc:mysql:///databasename?TC_IMAGE_TAG=5.7.34`
25+
`r2dbc:tc:mysql:///databasename?TC_IMAGE_TAG=8.0.36`
2626

2727
!!! note
2828
We will use `///` (host-less URIs) from now on to emphasis the unimportance of the `host:port` pair.
@@ -35,11 +35,11 @@ So that the URL becomes:
3535

3636
#### Using MySQL
3737

38-
`r2dbc:tc:mysql:///databasename?TC_IMAGE_TAG=5.7.34`
38+
`r2dbc:tc:mysql:///databasename?TC_IMAGE_TAG=8.0.36`
3939

4040
#### Using MariaDB
4141

42-
`r2dbc:tc:mariadb:///databasename?TC_IMAGE_TAG=10.3.6`
42+
`r2dbc:tc:mariadb:///databasename?TC_IMAGE_TAG=10.3.39`
4343

4444
#### Using PostgreSQL
4545

modules/jdbc-test/src/main/java/org/testcontainers/jdbc/AbstractJDBCDriverTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ private HikariDataSource verifyCharacterSet(String jdbcUrl) throws SQLException
204204
private void performTestForCustomIniFile(HikariDataSource dataSource) throws SQLException {
205205
assumeFalse(SystemUtils.IS_OS_WINDOWS);
206206
Statement statement = dataSource.getConnection().createStatement();
207-
statement.execute("SELECT @@GLOBAL.innodb_file_format");
207+
statement.execute("SELECT @@GLOBAL.innodb_max_undo_log_size");
208208
ResultSet resultSet = statement.getResultSet();
209209

210210
assertThat(resultSet.next()).as("The query returns a result").isTrue();
211-
String result = resultSet.getString(1);
211+
long result = resultSet.getLong(1);
212212

213-
assertThat(result).as("The InnoDB file format has been set by the ini file content").isEqualTo("Barracuda");
213+
assertThat(result).as("The InnoDB max undo log size has been set by the ini file content").isEqualTo(20000000);
214214
}
215215

216216
private HikariDataSource getDataSource(String jdbcUrl, int poolSize) {

0 commit comments

Comments
 (0)