public class TestContainerUtils extends Object
Constructor and Description |
---|
TestContainerUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
exposePortsAsUdp(com.github.dockerjava.api.command.CreateContainerCmd cmd,
int... ports)
Workaround for UDP ports -- see https://github.com/testcontainers/testcontainers-java/issues/554
|
static String |
getFileFromContainerAsString(org.testcontainers.containers.Container container,
Path pathInContainer)
Reach into the container, pull the contents of a file, and return it as a string.
|
static String |
getInternalIpAddress(org.testcontainers.containers.Container container)
Retrieves the internal IP address of the container.
|
static int |
getMappedUdpPort(org.testcontainers.containers.Container container,
int port)
Workaround for UDP ports -- see https://github.com/testcontainers/testcontainers-java/issues/554
|
static void |
restartContainer(org.testcontainers.containers.Container container)
Restarts the container.
|
static void |
setGlobalMemAndCpuLimits(com.github.dockerjava.api.command.CreateContainerCmd cmd)
Set memory and CPU limits on the container in oder to help provide
more consistent timing across systems and runs.
|
public static void setGlobalMemAndCpuLimits(com.github.dockerjava.api.command.CreateContainerCmd cmd)
cmd
- reference to the create container command, obtain with withCreateContainerCmdModifierpublic static String getFileFromContainerAsString(org.testcontainers.containers.Container container, Path pathInContainer)
container
- containerpathInContainer
- path to the file in the containerpublic static String getInternalIpAddress(org.testcontainers.containers.Container container)
container
- containerpublic static void restartContainer(org.testcontainers.containers.Container container)
container
- container to restartpublic static void exposePortsAsUdp(com.github.dockerjava.api.command.CreateContainerCmd cmd, int... ports)
cmd
- ports
- public static int getMappedUdpPort(org.testcontainers.containers.Container container, int port)
container
- port
- Copyright © 2022. All rights reserved.