seaworthy

seaworthy

Todo

Write some API reference docs for seaworthy.

class DockerHelper(namespace='test', client=None)[source]

Todo

Document this properly.

teardown()[source]

Clean up all resources when we’re done with them.

output_lines(output, encoding='utf-8', error_exc=None)[source]

Convert bytestring container output or the result of a container exec command into a sequence of unicode lines.

Parameters:
  • output – Container output bytes or an docker.models.containers.ExecResult instance.
  • encoding – The encoding to use when converting bytes to unicode (default utf-8).
  • error_exc – Optional exception to raise if output is an ExecResult with a nonzero exit code.
Returns:

list[str]

wait_for_logs_matching(container, matcher, timeout=10, encoding='utf-8', **logs_kwargs)[source]

Wait for matching log line(s) from the given container by streaming the container’s stdout and/or stderr outputs.

Each log line is decoded and any trailing whitespace is stripped before the line is matched.

Parameters:
  • container (Container) – Container who’s log lines to wait for.
  • matcher – Callable that returns True once it has matched a decoded log line(s).
  • timeout – Timeout value in seconds.
  • encoding – Encoding to use when decoding container output to strings.
  • logs_kwargs – Additional keyword arguments to pass to container.logs(). For example, the stdout and stderr boolean arguments can be used to determine whether to stream stdout or stderr or both (the default).
Returns:

The final matching log line.

Raises:
  • TimeoutError – When the timeout value is reached before matching log lines have been found.
  • RuntimeError – When all log lines have been consumed but matching log lines have not been found (the container must have stopped for its stream to have ended without error).