def _get_docker_ipython_output(context):
    """Get first 16 lines of ipython output if not already retrieved"""
    if hasattr(context, "ipython_stdout"):
        return context.ipython_stdout

    try:
        context.ipython_stdout = _read_lines_with_timeout(context.result, max_lines=64)
    finally:
        kill_docker_containers(context.project_name)

    return context.ipython_stdout
def _get_docker_ipython_output(context):
    """Get first 16 lines of ipython output if not already retrieved"""
    if hasattr(context, "ipython_stdout"):
        return context.ipython_stdout
    context.ipython_stdout = timeout(
        lambda: "\n".join(context.result.stdout.readline().decode()
                          for _ in range(16)),
        duration=30,
    )
    kill_docker_containers(context.project_name)
    return context.ipython_stdout
Exemple #3
0
def read_docker_stderr(context, msg):
    """Read stderr and raise AssertionError if the given message is not there."""

    if hasattr(context.result.stderr, "read"):
        context.result.stderr = context.result.stderr.read().decode("utf-8")

    try:
        if msg not in context.result.stderr:
            print(context.result.stderr)
            assert False, "Message '{0}' not found in stderr".format(msg)
    finally:
        kill_docker_containers(context.project_name)
def read_docker_stdout(context, msg):
    """Read stdout and raise AssertionError if the given message is not there."""

    if hasattr(context.result.stdout, "read"):
        context.result.stdout = context.result.stdout.read().decode("utf-8")
    if msg == "Python":
        msg = f"Python 3.{sys.version_info[1]}"

    try:
        if msg not in context.result.stdout:
            print(context.result.stdout)
            assert False, f"Message '{msg}' not found in stdout"
    finally:
        kill_docker_containers(context.project_name)
Exemple #5
0
def _check_service_up(context: behave.runner.Context, url: str, string: str):
    """
    Check that a service is running and responding appropriately

    Args:
        context: Test context.
        url: Url that is to be read.
        string: The string to be checked.
    """
    data = download_url(url)

    try:
        assert context.result.poll() is None
        assert string in data
    finally:
        if "docker" in context.result.args:
            kill_docker_containers(context.project_name)
        else:
            context.result.terminate()
Exemple #6
0
def after_scenario(context, feature):
    if "docker" in feature.tags:
        kill_docker_containers(context.project_name)
    docker_prune()
    rmtree(context.temp_dir)