Exemplo n.º 1
0
def test_sync_list_container_grpc(docker_grpc_client):
    response = sync_list_repositories_grpc(docker_grpc_client)

    loadable_repo_symbols = response.repository_symbols

    assert docker_grpc_client.get_current_image(
    ).current_image == get_test_project_docker_image()

    assert isinstance(loadable_repo_symbols, list)
    assert len(loadable_repo_symbols) == 1
    assert isinstance(loadable_repo_symbols[0], LoadableRepositorySymbol)

    symbol = loadable_repo_symbols[0]

    assert symbol.repository_name == "bar_repo"
    assert symbol.attribute == "bar_repo"

    executable_path = response.executable_path
    assert executable_path

    repository_code_pointer_dict = response.repository_code_pointer_dict
    assert "bar_repo" in repository_code_pointer_dict
    assert isinstance(repository_code_pointer_dict["bar_repo"],
                      FileCodePointer)
    assert repository_code_pointer_dict["bar_repo"].python_file.endswith(
        "repo.py")
    assert repository_code_pointer_dict["bar_repo"].fn_name == "bar_repo"
Exemplo n.º 2
0
def dagster_docker_image():
    docker_image = get_test_project_docker_image()

    if not IS_BUILDKITE:
        # Being conservative here when first introducing this. This could fail
        # if the Docker daemon is not running, so for now we just skip the tests using this
        # fixture if the build fails, and warn with the output from the build command
        try:
            client = docker.from_env()
            client.images.get(docker_image)
            print(  # pylint: disable=print-call
                "Found existing image tagged {image}, skipping image build. To rebuild, first run: "
                "docker rmi {image}".format(image=docker_image)
            )
        except docker.errors.ImageNotFound:
            try:
                build_and_tag_test_image(docker_image)
            except subprocess.CalledProcessError as exc_info:
                pytest.skip(
                    "Skipped container tests due to a failure when trying to build the image. "
                    "Most likely, the docker deamon is not running.\n"
                    "Output:\n{}".format(exc_info.output.decode("utf-8"))
                )

    return docker_image
Exemplo n.º 3
0
def docker_service_up(docker_compose_file, service_name):
    check.str_param(service_name, "service_name")
    check.str_param(docker_compose_file, "docker_compose_file")
    check.invariant(os.path.isfile(docker_compose_file),
                    "docker_compose_file must specify a valid file")

    if not IS_BUILDKITE:
        env = os.environ.copy()
        env["IMAGE_NAME"] = get_test_project_docker_image()

        try:
            subprocess.check_output(
                [
                    "docker-compose", "-f", docker_compose_file, "stop",
                    service_name
                ],
                env=env,
            )
            subprocess.check_output(
                [
                    "docker-compose", "-f", docker_compose_file, "rm", "-f",
                    service_name
                ],
                env=env,
            )
        except Exception:  # pylint: disable=broad-except
            pass

        subprocess.check_output(
            [
                "docker-compose", "-f", docker_compose_file, "up", "-d",
                service_name
            ],
            env=env,
        )

        yield

        try:
            subprocess.check_output(
                [
                    "docker-compose", "-f", docker_compose_file, "stop",
                    service_name
                ],
                env=env,
            )
            subprocess.check_output(
                [
                    "docker-compose", "-f", docker_compose_file, "rm", "-f",
                    service_name
                ],
                env=env,
            )
        except Exception:  # pylint: disable=broad-except
            pass