Esempio n. 1
0
def build_adapters(systest, tag, branch, local, force_rebuild):
    """ Builds a docker images for a preCICE adapter, participating in tests """
    baseimage_name = "precice-{tag}-{branch}:latest".format(tag=tag,
                                                            branch=branch)

    participants = get_test_participants(systest)
    docker_args = {
        'tag': '',
        'build_args': {
            "from":
            docker.get_namespace() + baseimage_name if local else 'precice/' +
            baseimage_name
        },
        'force_rebuild': force_rebuild,
        'dockerfile': 'Dockerfile'
    }

    with common.chdir(os.path.join(os.getcwd(), 'adapters')):
        for participant in participants:

            docker_args['tag'] = '-'.join([participant, tag, branch])
            docker_args['dockerfile'] = "Dockerfile." + participant

            # skip "light-adapters" (e.g. nutils )
            if os.path.exists("Dockerfile.{}".format(participant)):
                try:
                    docker.build_image(**docker_args)
                except CalledProcessError as e:
                    print("BUILD FAILED WITH: {}".format(e))
                    raise STBuildException()
Esempio n. 2
0
def main():
    parser = argparse.ArgumentParser(
        description='Test script for Dockerfile of Chainer')
    parser.add_argument('--subdir', '-s', choices=['python2', 'python3'],
                        default='python2',
                        help='Sub-directory name ("python2" or "python3")')
    parser.add_argument('--interactive', '-i', action='store_true',
                        help='Run bash instead of test')
    args = parser.parse_args()

    os.chdir('chainer/docker/%s' % args.subdir)
    name = docker.make_random_name()
    docker.build_image(name)
    cmd = [
        'nvidia-docker', 'run', '--rm',
        '-u', str(os.getuid()),
    ]

    if args.interactive:
        cmd += ['-it', name, '/bin/bash']
    else:
        if args.subdir == 'python2':
            python_command = 'python'
        else:
            python_command = 'python3'
        cmd += [
            name, python_command, '-c', 'import cupy; cupy.array([1])',
        ]

    subprocess.check_call(cmd)
Esempio n. 3
0
def build(systest, tag, branch, local, force_rebuild):
    """ Builds a docker image for systest. """
    baseimage_name = "precice-" + tag + "-" + branch + ":latest"
    test_tag = systest + "-" + tag + "-" + branch
    if local:
        docker.build_image(
            tag=test_tag,
            build_args={"from": docker.get_namespace() + baseimage_name},
            force_rebuild=force_rebuild)
    else:
        docker.build_image(
            tag=test_tag,
            build_args={"from": 'precicecoupling/' + baseimage_name},
            force_rebuild=force_rebuild)
Esempio n. 4
0
def build(systest, tag, branch, local, force_rebuild):
    """ Builds a docker image for systest. """

    baseimage_name = "precice-{tag}-{branch}:latest".format(tag=tag,
                                                            branch=branch)
    test_tag = "-".join([systest, tag, branch])

    docker.build_image(
        tag=test_tag,
        build_args={
            "from":
            docker.get_namespace() + baseimage_name if local else 'precice/' +
            baseimage_name
        },
        force_rebuild=force_rebuild)
Esempio n. 5
0
def build(systest, tag, branch, local, force_rebuild):
    """ Builds a docker image for systest. """

    baseimage_name = "precice-{tag}-{branch}:latest".format(tag=tag,
                                                            branch=branch)
    test_tag = "-".join([systest, tag, branch])

    try:
        docker.build_image(
            tag=test_tag,
            build_args={
                "from":
                docker.get_namespace() +
                baseimage_name if local else 'precice/' + baseimage_name
            },
            force_rebuild=force_rebuild)
    except CalledProcessError as e:
        print("BUILD FAILED WITH: {}".format(e))
        raise STBuildException()
Esempio n. 6
0
def build(systest, tag, branch, local, force_rebuild):
    """ Builds a docker image for systest. """
    baseimage_name = "precice-" + tag + "-" + branch + ":latest"
    test_tag = systest + "-" + tag + "-" + branch
    if local:
        docker.build_image(
            tag=test_tag,
            build_args={"from": docker.get_namespace() + baseimage_name},
            force_rebuild=force_rebuild)
    else:
        match = re.search(r'ubuntu(\d+)', baseimage_name)
        if match:
            ubuntu_version = match.group(1)
        else:
            raise Exception("Could not detect preCICE image to import from")
        docker.build_image(tag=test_tag,
                           build_args={
                               "from":
                               'precicecoupling/precice_ubuntu' +
                               ubuntu_version + ':latest'
                           },
                           force_rebuild=force_rebuild)
Esempio n. 7
0
def main():
    parser = argparse.ArgumentParser(
        description='Test script for Dockerfile of Chainer')
    parser.add_argument('--interactive', '-i', action='store_true',
                        help='Run bash instead of test')
    args = parser.parse_args()

    os.chdir('chainer/docker')
    name = docker.make_random_name()
    docker.build_image(name)
    cmd = [
        'nvidia-docker', 'run', '--rm',
        '-u', str(os.getuid()),
    ]

    if args.interactive:
        cmd += ['-it', name, '/bin/bash']
    else:
        cmd += [
            name, 'python', '-c', 'import cupy; cupy.array([1])',
        ]

    subprocess.check_call(cmd)
Esempio n. 8
0
    # converting features provided via command-line to dictionary
    precice_base_features = dict()
    assert (args.operating_system)
    if args.operating_system:  # first feature is mandatory always describes the os
        precice_base_features["os"] = args.operating_system
    if args.precice_installation:  # second feature is optional if it exists it describes the preCICE installation
        precice_base_features["installation"] = args.precice_installation
    if args.petsc == "yes":
        precice_base_features["petsc"] = "yes"

    precice_base_tag = system_testing.compose_tag(args.docker_username,
                                                  "precice",
                                                  precice_base_features,
                                                  args.branch)

    print("Building {} image with the following features: {}".format(
        adapter_name, features))

    docker.build_image(tag=tag,
                       dockerfile=args.dockerfile,
                       build_args={
                           "branch": args.branch,
                           "adapter_branch": args.adapter_branch,
                           "from": precice_base_tag
                       },
                       force_rebuild=args.force_rebuild,
                       namespace="")

    with open(".docker_tag", "w") as f:
        f.write(tag)
Esempio n. 9
0
    assert(dockerfile.split(".")[0] == "Dockerfile")  # We have the convention that our Dockerfiles always start with the term "Dockerfile"

    # converting features provided in filename to dictionary
    features = dict()
    i = 0
    for feature in dockerfile.split(".")[1:]:  # Extract features from filename and join features with "." as separator.
        i += 1
        if i == 1:  # first feature is mandatory always describes the os
            assert(feature in ["Ubuntu1604", "Ubuntu1804", "Arch"])  # we expect that one of the following operating systems is used
            features["os"] = feature
        if i == 2:  # second feature is optional if it exists it describes the preCICE installation
            assert(feature in ["package", "home", "sudo"])  # we expect that one of the following installation procedures is used
            features["installation"] = feature
        if i >= 3:  # third and following features are optional
            assert(feature in ["mpich"])  # we expect one of these optional features
            if feature is "mpich":
                features["mpich"] = "yes"
    assert(i > 0)  # at least one feature (the os) should have been provided
    if args.petsc == "yes":
        features["petsc"] = "yes"

    print("Building preCICE image with the following features: {}".format(features))

    tag = system_testing.compose_tag(args.docker_username, "precice", features, args.branch)
    docker.build_image(tag=tag,
                       dockerfile=args.dockerfile,
                       build_args={"branch" : args.branch, "petsc_para" : args.petsc},
                       force_rebuild=args.force_rebuild,
                       namespace="")
                       
Esempio n. 10
0
        print("Deleting following docker containers:", lst2)
        answer = input("\nOk? (yes/no)\n")
        if answer in ["yes", "y"]:
            for x in lst2:
                ccall("docker container rm -f " + x)
        else:
            print(
                "BE CAREFUL!: Not deleting previous containers can later lead to problems."
            )

    # Building preCICE
    print("\n\nBuilding preCICE docker image with choosen branch\n\n")
    with common.chdir(os.path.join(os.getcwd(), 'precice')):
        docker.build_image("precice-" + args.dockerfile.lower() + "-" +
                           args.branch,
                           args.dockerfile,
                           build_args={"branch": args.branch},
                           force_rebuild="precice" in args.force_rebuild)
    # Starting system tests
    failed = []
    success = []
    for test in tests:
        test_basename = determine_test_name(test)
        print("\n\nStarting system test %s\n\n" % test)
        try:
            build_run_compare(test, args.dockerfile.lower(),
                              args.branch.lower(), True, "tests"
                              in args.force_rebuild, not args.keep)
        except subprocess.CalledProcessError:
            failed.append(test_basename)
        else: