Package io.ebean.test.containers
Class CockroachContainer
java.lang.Object
io.ebean.test.containers.CockroachContainer
- All Implemented Interfaces:
Container<CockroachContainer>
Commands for controlling a CockroachDB docker container.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for CockroachContainer. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final io.ebean.test.containers.BaseBuilder<?, ?> protected final Commandsprotected io.ebean.test.containers.InternalConfigprotected static final System.Loggerprotected booleanprotected StopModeprotected booleanprotected booleanprotected int -
Method Summary
Modifier and TypeMethodDescriptionstatic CockroachContainer.BuilderCreate a builder for CockroachContainer.config()Returns the container configuration.Create a connection to this database container.protected booleanprotected voidCreate database, schema and user via JDBC .protected voidCreate the database, schema and user via docker commands.protected ProcessBuildercreateProcessBuilder(List<String> args) protected voidDrop and create database, schema and user via JDBC .protected voidDrop and create the database, schema and user via docker commands.protected booleanprotected voidexecuteSqlFile(String dbUser, String dbName, String containerFilePath) protected booleanIf we are using FastStartMode just check is the DB exists and if so assume it is all created correctly.protected booleanReturn true when the database is ready to take admin commands.booleanWait for the 'database system is ready'protected booleanbooleanReturn true if the container is running.jdbcUrl()Return the JDBC url to connect to this container.intport()Return the port this container is using.protected StringreadUrlContent(String url) Return http GET content given the url.voidRegister a JVM Shutdown hook to stop the container with the given mode.protected ProcessBuilderReturn the ProcessBuilder used to execute the container run command.protected voidSet a default container name if not using random port.protected booleanshutdownHook(boolean started) start()Start and return the container.booleanStart the container only without creating database, user, extensions etc.protected booleanStart with a mode of 'create', 'dropCreate' or 'container'.booleanStart the container returning true if successful.voidStart the container or throw a IllegalStateException.protected booleanbooleanStart the container and wait for it to be ready.booleanStart with a drop and create of the database and user.voidstop()Stop using the configured stopMode of 'stop' or 'remove'.voidStop and remove the container effectively deleting the container.booleanReturn true when the DB is ready for taking commands (like create database, user etc).
-
Field Details
-
log
-
buildConfig
protected final io.ebean.test.containers.BaseBuilder<?,?> buildConfig -
config
protected io.ebean.test.containers.InternalConfig config -
commands
-
waitForConnectivityAttempts
protected int waitForConnectivityAttempts -
shutdownMode
-
usingContainerId
protected boolean usingContainerId -
usingRandomPort
protected boolean usingRandomPort -
removeOnExit
protected boolean removeOnExit
-
-
Method Details
-
start
Description copied from interface:ContainerStart and return the container.Throws an IllegalStateException if the container can not be started.
-
builder
Create a builder for CockroachContainer. -
isDatabaseAdminReady
protected boolean isDatabaseAdminReady()Return true when the database is ready to take admin commands. -
isFastStartDatabaseExists
protected boolean isFastStartDatabaseExists() -
createDbPreConnectivity
protected void createDbPreConnectivity()Create the database, schema and user via docker commands. -
dropCreateDbPreConnectivity
protected void dropCreateDbPreConnectivity()Drop and create the database, schema and user via docker commands. -
createDatabase
protected boolean createDatabase() -
dropDatabaseIfExists
protected boolean dropDatabaseIfExists() -
isDatabaseReady
public boolean isDatabaseReady()Wait for the 'database system is ready' -
runProcess
Return the ProcessBuilder used to execute the container run command. -
createDbPostConnectivity
protected void createDbPostConnectivity()Create database, schema and user via JDBC . -
dropCreateDbPostConnectivity
protected void dropCreateDbPostConnectivity()Drop and create database, schema and user via JDBC . -
startWithCreate
public boolean startWithCreate()Start the container and wait for it to be ready.This checks if the container is already running.
Returns false if the wait for ready was unsuccessful.
-
startWithDropCreate
public boolean startWithDropCreate()Start with a drop and create of the database and user. -
jdbcUrl
Return the JDBC url to connect to this container. -
createConnection
Create a connection to this database container.- Throws:
SQLException
-
startMaybe
public boolean startMaybe()Description copied from interface:ContainerStart the container returning true if successful.- Specified by:
startMaybein interfaceContainer<C extends io.ebean.test.containers.DbContainer<C>>
-
startForMode
protected boolean startForMode()Start with a mode of 'create', 'dropCreate' or 'container'.Expected that mode create will be best most of the time.
-
startContainerOnly
public boolean startContainerOnly()Start the container only without creating database, user, extensions etc. -
fastStart
protected boolean fastStart()If we are using FastStartMode just check is the DB exists and if so assume it is all created correctly.This should only be used with Mode.Create and when the container is already running.
-
executeSqlFile
-
waitForDatabaseReady
public boolean waitForDatabaseReady()Return true when the DB is ready for taking commands (like create database, user etc). -
config
Description copied from interface:ContainerReturns the container configuration. -
startOrThrow
public void startOrThrow()Description copied from interface:ContainerStart the container or throw a IllegalStateException.- Specified by:
startOrThrowin interfaceContainer<C extends Container<C>>
-
port
public int port()Description copied from interface:ContainerReturn the port this container is using.This is typically useful if the container was started with a random port and, we need to know what that port was.
-
setDefaultContainerName
protected void setDefaultContainerName()Set a default container name if not using random port. -
isRunning
public boolean isRunning()Description copied from interface:ContainerReturn true if the container is running. -
registerShutdownHook
public void registerShutdownHook()Register a JVM Shutdown hook to stop the container with the given mode. -
shutdownHook
protected boolean shutdownHook(boolean started) -
startWithConnectivity
protected boolean startWithConnectivity() -
stop
public void stop()Stop using the configured stopMode of 'stop' or 'remove'.Remove additionally removes the container (expected use in build agents).
-
stopRemove
public void stopRemove()Stop and remove the container effectively deleting the container.- Specified by:
stopRemovein interfaceContainer<C extends Container<C>>
-
createProcessBuilder
-
dockerRun
-
readUrlContent
Return http GET content given the url.- Throws:
IOException
-