use of org.testcontainers.containers.MySQLContainer in project testcontainers-java by testcontainers.
the class SimpleMySQLTest method testCommandOverride.
@Test
public void testCommandOverride() throws SQLException {
MySQLContainer mysqlCustomConfig = (MySQLContainer) new MySQLContainer().withCommand("mysqld --auto_increment_increment=42");
mysqlCustomConfig.start();
try {
ResultSet resultSet = performQuery(mysqlCustomConfig, "show variables like 'auto_increment_increment'");
String result = resultSet.getString("Value");
assertEquals("Auto increment increment should be overriden by command line", "42", result);
} finally {
mysqlCustomConfig.stop();
}
}
use of org.testcontainers.containers.MySQLContainer in project testcontainers-java by testcontainers.
the class SimpleMySQLTest method testMySQLWithCustomIniFile.
@Test
public void testMySQLWithCustomIniFile() throws SQLException {
assumeFalse(SystemUtils.IS_OS_WINDOWS);
MySQLContainer mysqlCustomConfig = new MySQLContainer("mysql:5.6").withConfigurationOverride("somepath/mysql_conf_override");
mysqlCustomConfig.start();
try {
ResultSet resultSet = performQuery(mysqlCustomConfig, "SELECT @@GLOBAL.innodb_file_format");
String result = resultSet.getString(1);
assertEquals("The InnoDB file format has been set by the ini file content", "Barracuda", result);
} finally {
mysqlCustomConfig.stop();
}
}
use of org.testcontainers.containers.MySQLContainer in project testcontainers-java by testcontainers.
the class SimpleMySQLTest method testSpecificVersion.
@Test
public void testSpecificVersion() throws SQLException {
MySQLContainer mysqlOldVersion = (MySQLContainer) new MySQLContainer("mysql:5.5").withConfigurationOverride("somepath/mysql_conf_override").withLogConsumer(new Slf4jLogConsumer(logger));
mysqlOldVersion.start();
try {
ResultSet resultSet = performQuery(mysqlOldVersion, "SELECT VERSION()");
String resultSetString = resultSet.getString(1);
assertTrue("The database version can be set using a container rule parameter", resultSetString.startsWith("5.5"));
} finally {
mysqlOldVersion.stop();
}
}
use of org.testcontainers.containers.MySQLContainer in project testcontainers-java by testcontainers.
the class SimpleMySQLTest method testSimple.
/*
* Ordinarily you wouldn't try and run multiple containers simultaneously - this is just used for testing.
* To avoid memory issues with the default, low memory, docker machine setup, we instantiate only one container
* at a time, inside the test methods themselves.
*/
/*
@ClassRule
public static MySQLContainer mysql = new MySQLContainer();
@ClassRule
public static MySQLContainer mysqlOldVersion = new MySQLContainer("mysql:5.5");
@ClassRule
public static MySQLContainer mysqlCustomConfig = new MySQLContainer("mysql:5.6")
.withConfigurationOverride("somepath/mysql_conf_override");
*/
@Test
public void testSimple() throws SQLException {
MySQLContainer mysql = (MySQLContainer) new MySQLContainer().withConfigurationOverride("somepath/mysql_conf_override").withLogConsumer(new Slf4jLogConsumer(logger));
mysql.start();
try {
ResultSet resultSet = performQuery(mysql, "SELECT 1");
int resultSetInt = resultSet.getInt(1);
assertEquals("A basic SELECT query succeeds", 1, resultSetInt);
} finally {
mysql.stop();
}
}
Aggregations