Class MySqlContainer.Builder
- All Implemented Interfaces:
ContainerBuilder<MySqlContainer,,MySqlContainer.Builder> ContainerBuilderDb<MySqlContainer,MySqlContainer.Builder>
- Enclosing class:
MySqlContainer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe internal port.protected intThe exposed port.protected StringThe character set to use.protected StringThe collation to use.protected StringContainer name.protected StringDocker command.protected StringThe host name.protected StringImage name.protected intThe internal port.protected intMaximum number of attempts to find the 'database ready to accept connections' log message in the container.protected StringDefine a mirror for images to use with CI builds.protected final StringThe database platform.protected intThe exposed port.protected StopModeBy default, via JVM shutdown hook stop and remove the container unless there is a ~/.ebean/ignore-docker-shutdown marker file.protected StartModeThe mode used when starting (create, dropCreate, container [only]).protected final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadminInternalPort(int adminInternalPort) Set the internal admin (to the container) port.adminPassword(String adminPassword) Set the password for the DB admin user.adminPort(int adminPort) Set the exposed admin port.Set the password for the DB admin user.build()Build the container.protected StringOverride to build jdbc url for extraDb.protected Stringprotected StringOverride to build appropriate jdbc url.protected StringReturn summary of the port db name and other details.characterSet(String characterSet) Set the character set to use.Set the collation to use.containerName(String containerName) Set the container name.Set the DB name - e.g.protected Stringprotected Stringdocker()Set the docker command to use (defaults to 'docker').extensions(String extensions) Set the DB extensions to install in comma delimited form.Set the name of an extra database to create.extraDbExtensions(String extraDbExtensions) Set extra database extensions.extraDbInitSqlFile(String extraDbInitSqlFile) Set a file to execute after creating the extra database.extraDbPassword(String extraDbPassword) Set the password for an extra user.extraDbSeedSqlFile(String extraDbSeedSqlFile) Set a file to execute after creating the extra database.extraDbUser(String extraDbUser) Set the name of an extra user to create.protected voidextraProperties(Properties properties) Override to configure extra properties.fastStartMode(boolean fastStartMode) Defaults to true - If true ONLY check the existence of the DB and if present skip the other usual checks (does user exist, create extensions if not exists etc).protected Stringprotected StringgetHost()protected intgetPort()Set the docker image to use.protected voidSet the schema if it hasn't already set.initSqlFile(String initSqlFile) Set the SQL file to execute after creating the database.inMemory(boolean inMemory) Set to true to run using in memory storage for data via tmpfs.protected io.ebean.test.containers.InternalConfigDbReturn the internal configuration.internalPort(int internalPort) Set the internal (to the container) port.maxReadyAttempts(int maxReadyAttempts) Set the max attempts to wait for DB ready.Set a container mirror for images to use with CI builds.Set the DB password.port(int port) Set the exposed port with 0 meaning use a random port.protected intprop(Properties properties, String key, int defaultValue) protected Stringprop(Properties properties, String key, String defaultValue) properties(Properties properties) Load configuration from properties.Set the DB schema.seedSqlFile(String seedSqlFile) Set the SQL file to execute after creating the database and initSqlFile.protected MySqlContainer.Builderself()shutdownMode(StopMode shutdownMode) Set the shutdown hook mode to automatically stop/remove the container on JVM shutdown.start()Build and start the container.Set the start mode.Set the temp fs for in-memory use.Set the DB user.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.ebean.test.containers.ContainerBuilder
adminInternalPort, adminPort, containerName, docker, image, internalPort, maxReadyAttempts, mirror, port, shutdownMode, startMode
-
Field Details
-
characterSet
The character set to use. -
collation
The collation to use. -
platform
The database platform.Expected to be one of 'postgres','mysql', 'oracle' or 'sqlserver'.
-
containerName
Container name. -
host
The host name. When running in Docker this is often set to172.17.0.1invalid input: '<'/code. -
port
protected int portThe exposed port. -
internalPort
protected int internalPortThe internal port. -
adminPort
protected int adminPortThe exposed port. -
adminInternalPort
protected int adminInternalPortThe internal port. -
mirror
Define a mirror for images to use with CI builds. -
image
Image name. -
startMode
The mode used when starting (create, dropCreate, container [only]). -
shutdownMode
By default, via JVM shutdown hook stop and remove the container unless there is a ~/.ebean/ignore-docker-shutdown marker file. -
maxReadyAttempts
protected int maxReadyAttemptsMaximum number of attempts to find the 'database ready to accept connections' log message in the container.100 attempts equates to 10 seconds.
-
docker
Docker command. -
version
-
-
Constructor Details
-
Builder
Expose for MariaDB config.
-
-
Method Details
-
buildJdbcUrl
Override to build appropriate jdbc url. -
buildJdbcAdminUrl
-
build
Description copied from interface:ContainerBuilderBuild the container. -
start
Description copied from interface:ContainerBuilderBuild and start the container. -
getDbName
-
properties
Load configuration from properties.- Specified by:
propertiesin interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
adminUser
Set the password for the DB admin user.- Specified by:
adminUserin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
adminPassword
Set the password for the DB admin user.- Specified by:
adminPasswordin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
tmpfs
Set the temp fs for in-memory use.- Specified by:
tmpfsin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
fastStartMode
Defaults to true - If true ONLY check the existence of the DB and if present skip the other usual checks (does user exist, create extensions if not exists etc).- Specified by:
fastStartModein interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
dbName
Set the DB name - e.g. my_app1, my_app2, my_app3 etc. Defaults to test_db.The DB name should not have any special characters (alpha and underscore) and should be unique for the project.
ebean-test-docker is designed to share the same container across multiple projects. The way this works is that each project should have a unique db name. This means that as developers testing is faster as containers stay running and are shared and running tests for a project means setting up unique "database" using the dbName.
- Specified by:
dbNamein interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
user
Set the DB user. Defaults to being the same as the dbName.- Specified by:
userin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
password
Set the DB password. Defaults to test.- Specified by:
passwordin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
schema
Set the DB schema.- Specified by:
schemain interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
characterSet
Set the character set to use.- Specified by:
characterSetin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
collation
Set the collation to use.- Specified by:
collationin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
extensions
Set the DB extensions to install in comma delimited form.Postgres hstore, pgcrypto etc.
Example:
.extensions("hstore,pgcrypto,uuid-ossp")- Specified by:
extensionsin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
initSqlFile
Set the SQL file to execute after creating the database.- Specified by:
initSqlFilein interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
seedSqlFile
Set the SQL file to execute after creating the database and initSqlFile.- Specified by:
seedSqlFilein interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
extraDb
Set the name of an extra database to create.Use this when the application being tested uses 2 databases.
- Specified by:
extraDbin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
extraDbUser
Set the name of an extra user to create. If an extra database is also created this would be the owner of that extra database.Use this when the application being tested uses 2 databases.
- Specified by:
extraDbUserin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
extraDbPassword
Set the password for an extra user. If nothing is set this would default to be the same as the main users password.Use this when the application being tested uses 2 databases.
- Specified by:
extraDbPasswordin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
extraDbExtensions
Description copied from interface:ContainerBuilderDbSet extra database extensions.- Specified by:
extraDbExtensionsin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
extraDbInitSqlFile
Set a file to execute after creating the extra database.- Specified by:
extraDbInitSqlFilein interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
extraDbSeedSqlFile
Set a file to execute after creating the extra database.- Specified by:
extraDbSeedSqlFilein interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
inMemory
Set to true to run using in memory storage for data via tmpfs.- Specified by:
inMemoryin interfaceContainerBuilderDb<C,SELF extends io.ebean.test.containers.BaseDbBuilder<C, SELF>>
-
initDefaultSchema
protected void initDefaultSchema()Set the schema if it hasn't already set. Some databases (NuoDB) effectively require a default schema and it is reasonable for this to default to the username. -
buildSummary
Return summary of the port db name and other details. -
deriveUsername
-
internalConfig
protected io.ebean.test.containers.InternalConfigDb internalConfig()Return the internal configuration. -
docker
-
getHost
-
getPort
protected int getPort() -
self
-
startMode
Description copied from interface:ContainerBuilderSet the start mode. One of create, dropCreate, or container [only].- Specified by:
startModein interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C, SELF>>
-
shutdownMode
Description copied from interface:ContainerBuilderSet the shutdown hook mode to automatically stop/remove the container on JVM shutdown.- Specified by:
shutdownModein interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C, SELF>>
-
extraProperties
Override to configure extra properties. -
prop
-
prop
-
containerName
Set the container name.- Specified by:
containerNamein interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C, SELF>>
-
mirror
Set a container mirror for images to use with CI builds.For example "my.ecr/mirror".
The mirror is not used when deemed to be running locally. Typically determined via a
~/.ebean/ignore-docker-shutdownfile or alternative marker file set via system propertyebean.test.localDevelopment>.- Specified by:
mirrorin interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C, SELF>>
-
port
Set the exposed port with 0 meaning use a random port.When the port is set to `0` then docker will assign a random port. This port is available after the container has started.
LocalstackContainer container = LocalstackContainer.builder("0.14") .port(0) .build(); container.start(); int assignedPort = container.port(); AmazonDynamoDB amazonDynamoDB = container.dynamoDB();- Specified by:
portin interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C, SELF>>
-
internalPort
Set the internal (to the container) port.- Specified by:
internalPortin interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C, SELF>>
-
adminPort
Set the exposed admin port.- Specified by:
adminPortin interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C, SELF>>
-
adminInternalPort
Set the internal admin (to the container) port.- Specified by:
adminInternalPortin interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C, SELF>>
-
image
Set the docker image to use.- Specified by:
imagein interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C, SELF>>
-
maxReadyAttempts
Set the max attempts to wait for DB ready.- Specified by:
maxReadyAttemptsin interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C, SELF>>
-
docker
Set the docker command to use (defaults to 'docker').- Specified by:
dockerin interfaceContainerBuilder<C,SELF extends io.ebean.test.containers.BaseBuilder<C, SELF>>
-
buildExtraJdbcUrl
Override to build jdbc url for extraDb.
-