Class Commands

java.lang.Object
io.ebean.test.containers.Commands

public class Commands extends Object
Common Docker container commands.
  • Constructor Details

    • Commands

      public Commands()
      Create with 'docker' as the command.
    • Commands

      public Commands(String docker)
      Construct with explicit docker command.
  • Method Details

    • stopIfRunning

      public void stopIfRunning(String containerName, boolean skipRunningCheck)
      Stop the container checking to see if it is running first.
    • removeIfRegistered

      public void removeIfRegistered(String containerName, boolean skipRunningCheck)
      Stop and remove the container.
    • remove

      public void remove(String containerName)
      Remove the container.
    • start

      public void start(String containerName)
      Start the container.
    • stop

      public void stop(String containerName)
      Stop the container.
    • removeContainers

      public void removeContainers(String... containerNames)
    • stopContainers

      public void stopContainers(String... containerNames)
    • isRunning

      public boolean isRunning(String containerName)
      Return true if the container is running.
    • isRegistered

      public boolean isRegistered(String containerName)
      Return true if the container is registered (exists and maybe running or not).
    • port

      public int port(String containerName)
      Return the first mapped port for the given container.
    • logsContain

      public boolean logsContain(String containerName, String match)
      Return true if the logs of the container contain the match text.
    • logsContain

      public boolean logsContain(String containerName, String match, String clearMatch)
    • logsWithMatch

      public List<String> logsWithMatch(String containerName, String match, String clearMatch)
      Return true if the logs of the container contain the match text.
    • logs

      public List<String> logs(String containerName)
      Return true if the logs of the container contain the match text.
    • ports

      public List<String> ports(String containerName)
      Return the ports output as lines.
    • registeredPortMatch

      public String registeredPortMatch(String containerName, int matchPort)
      Check if the port matches the existing port bindings and if not return the existing port bindings.
    • logsContain

      public boolean logsContain(String containerName, String logMessage, int tail)
      Return true if the container logs contains the logMessage.

      Usually used to find a log entry to indicate the container is ready for use.

      Parameters:
      containerName - The container logs to search
      logMessage - The logMessage we are looking for (to usually indicate the container is ready).
      tail - The number of logs to tail (such that we get recent and minimal logs)
      Returns:
      True if the logs searched contain the logMessage
    • logs

      public List<String> logs(String containerName, int tail)
      Return the logs for the container with a tail.

      If tail = 0 then all logs are returned (but we should be careful using that).