public abstract class TestContainerResourceManager<T extends GenericContainer<?>>
extends java.lang.Object
implements org.apache.beam.it.common.ResourceManager
Resource managers that extend this class will use TestContainers as a backend to spin up resources.
Optionally, a static resource can be specified by calling the useStaticContainer() method in
the TestContainerResourceManager.Builder
class. A static resource is a pre-configured database or other resource that
is ready to be connected to by the resource manager. This could be a pre-existing TestContainer
that has not been closed, a local database instance, a remote VM, or any other source that can be
connected to. If a static container is used, the host and port must also be configured using the
Builder's setHost() and setPort() methods, respectively.
Modifier and Type | Class and Description |
---|---|
static class |
TestContainerResourceManager.Builder<T extends TestContainerResourceManager<?>>
Builder for
TestContainerResourceManager . |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
HOST_IP |
protected int |
port |
Modifier | Constructor and Description |
---|---|
protected |
TestContainerResourceManager(T container,
B builder) |
protected |
TestContainerResourceManager(T container,
B builder,
java.util.concurrent.Callable<java.lang.Void> setup) |
Modifier and Type | Method and Description |
---|---|
void |
cleanupAll()
Deletes all created resources (VM's, etc.) and stops the container, making the manager object
unusable.
|
protected java.lang.String |
getDockerImageName() |
java.lang.String |
getHost()
Returns the host that the resource is running on.
|
protected int |
getPort(int mappedPort)
Returns the port that the resource is actually mapped to on the host.
|
protected TestContainerResourceManager(T container, B builder)
protected java.lang.String getDockerImageName()
public java.lang.String getHost()
protected int getPort(int mappedPort)
Note: When using a static container, the port that was specified in the builder will be returned regardless of what is passed into this method as a parameter.
mappedPort
- the port the resource was configured to listen onpublic void cleanupAll() throws TestContainerResourceManagerException
cleanupAll
in interface org.apache.beam.it.common.ResourceManager
TestContainerResourceManagerException
- if there is an error deleting the TestContainers
resources.