File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
jdbc-test/src/test/java/org/testcontainers/junit
mysql/src/main/java/org/testcontainers/containers Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,22 @@ public void testMySQLWithCustomIniFile() throws SQLException {
9494 }
9595 }
9696
97+ @ Test
98+ public void testCommandOverride () throws SQLException {
99+ MySQLContainer mysqlCustomConfig = (MySQLContainer ) new MySQLContainer ().withCommand ("mysqld --auto_increment_increment=42" );
100+ mysqlCustomConfig .start ();
101+
102+ try {
103+ ResultSet resultSet = performQuery (mysqlCustomConfig , "show variables like 'auto_increment_increment'" );
104+ String result = resultSet .getString ("Value" );
105+
106+ assertEquals ("Auto increment increment should be overriden by command line" , "42" , result );
107+ } finally {
108+ mysqlCustomConfig .stop ();
109+ }
110+
111+ }
112+
97113 @ NonNull
98114 protected ResultSet performQuery (MySQLContainer containerRule , String sql ) throws SQLException {
99115 HikariConfig hikariConfig = new HikariConfig ();
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ public class MySQLContainer<SELF extends MySQLContainer<SELF>> extends JdbcDatab
2020
2121 public MySQLContainer () {
2222 super (IMAGE + ":latest" );
23+ setCommand ("mysqld" );
2324 }
2425
2526 public MySQLContainer (String dockerImageName ) {
@@ -41,7 +42,6 @@ protected void configure() {
4142 addEnv ("MYSQL_USER" , username );
4243 addEnv ("MYSQL_PASSWORD" , password );
4344 addEnv ("MYSQL_ROOT_PASSWORD" , "test" );
44- setCommand ("mysqld" );
4545 setStartupAttempts (3 );
4646 }
4747
You can’t perform that action at this time.
0 commit comments