Package org.opennms.smoketest.utils
Class TestContainerUtils
- java.lang.Object
-
- org.opennms.smoketest.utils.TestContainerUtils
-
public class TestContainerUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description TestContainerUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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/554static 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/554static 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.
-
-
-
Method Detail
-
setGlobalMemAndCpuLimits
public 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.- Parameters:
cmd
- reference to the create container command, obtain with withCreateContainerCmdModifier
-
getFileFromContainerAsString
public 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.- Parameters:
container
- containerpathInContainer
- path to the file in the container- Returns:
- the contents of the file as a string
-
getInternalIpAddress
public static String getInternalIpAddress(org.testcontainers.containers.Container container)
Retrieves the internal IP address of the container.- Parameters:
container
- container- Returns:
- ip address
-
restartContainer
public static void restartContainer(org.testcontainers.containers.Container container)
Restarts the container.- Parameters:
container
- container to restart
-
exposePortsAsUdp
public 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- Parameters:
cmd
-ports
-
-
getMappedUdpPort
public static int getMappedUdpPort(org.testcontainers.containers.Container container, int port)
Workaround for UDP ports -- see https://github.com/testcontainers/testcontainers-java/issues/554- Parameters:
container
-port
-- Returns:
-
-