Exemplo n.º 1
0
def build_log_generator(container, prefix, color_func):
    # if the container doesn't have a log_stream we need to attach to container
    # before log printer starts running
    if container.log_stream is None:
        stream = container.attach(stdout=True, stderr=True,  stream=True, logs=True)
        line_generator = split_buffer(stream)
    else:
        line_generator = split_buffer(container.log_stream)

    for line in line_generator:
        yield prefix + line
    yield color_func(wait_on_exit(container))
Exemplo n.º 2
0
def build_log_generator(container, prefix, color_func):
    # if the container doesn't have a log_stream we need to attach to container
    # before log printer starts running
    if container.log_stream is None:
        stream = container.attach(stdout=True,
                                  stderr=True,
                                  stream=True,
                                  logs=True)
        line_generator = split_buffer(stream)
    else:
        line_generator = split_buffer(container.log_stream)

    for line in line_generator:
        yield prefix + line
    yield color_func(wait_on_exit(container))
Exemplo n.º 3
0
def test_dag(docker_client, dag_dir=".", tag="latest", extra_test_dir="tests"):
    dag_dir = os.path.abspath(dag_dir)
    extra_test_dir = os.path.abspath(extra_test_dir)

    volumes = ["{dag_dir}:/airflow/dags".format(dag_dir=dag_dir)]
    if os.path.exists(extra_test_dir):
        volumes.append("{extra_test_dir}:/airflow/tests/ext".format(
            extra_test_dir=extra_test_dir))

    result = docker_client.containers.run(
        "airflowdocker/tester:{tag}".format(tag=tag),
        detach=True,
        tty=True,
        stdout=False,
        stderr=True,
        volumes=volumes,
    )
    try:
        logs = result.logs(stream=True, follow=True)
        for line in split_buffer(logs):
            print(line, end="")
    finally:
        result.wait()
        result.remove()

    if result.status:
        sys.exit(result.status)
Exemplo n.º 4
0
def build_log_generator(container, prefix, color_func):
    # Attach to container before log printer starts running
    stream = container.attach(stdout=True, stderr=True, stream=True, logs=True)
    line_generator = split_buffer(stream)

    for line in line_generator:
        yield prefix + line
    yield color_func(wait_on_exit(container))
Exemplo n.º 5
0
def build_log_generator(container, prefix, color_func):
    # Attach to container before log printer starts running
    stream = container.attach(stdout=True, stderr=True,  stream=True, logs=True)
    line_generator = split_buffer(stream)

    for line in line_generator:
        yield prefix + line
    yield color_func(wait_on_exit(container))
Exemplo n.º 6
0
def build_log_generator(container, log_args):
    # if the container doesn't have a log_stream we need to attach to container
    # before log printer starts running
    if container.log_stream is None:
        stream = container.logs(stdout=True, stderr=True, stream=True, **log_args)
    else:
        stream = container.log_stream

    return split_buffer(stream)
Exemplo n.º 7
0
def build_log_generator(container, log_args):
    # if the container doesn't have a log_stream we need to attach to container
    # before log printer starts running
    if container.log_stream is None:
        stream = container.logs(stdout=True, stderr=True, stream=True, **log_args)
    else:
        stream = container.log_stream

    return split_buffer(stream)
Exemplo n.º 8
0
    def assert_produces(self, reader, expectations):
        split = split_buffer(reader())

        for (actual, expected) in zip(split, expectations):
            self.assertEqual(type(actual), type(expected))
            self.assertEqual(actual, expected)
Exemplo n.º 9
0
    def assert_produces(self, reader, expectations):
        split = split_buffer(reader())

        for (actual, expected) in zip(split, expectations):
            assert type(actual) == type(expected)
            assert actual == expected
Exemplo n.º 10
0
    def assert_produces(self, reader, expectations):
        split = split_buffer(reader())

        for (actual, expected) in zip(split, expectations):
            assert type(actual) == type(expected)
            assert actual == expected