Beispiel #1
0
 def test_logger_output(self):
     """Test the log file output"""
     docker_instance = Docker()
     docker_instance.pull('gentoo', 'stage3-amd64')
     docker_instance.add_bash_command("echo Log Text!")
     docker_instance.run()
     self.assertEqual(docker_instance.log, "Log Text!\n")
Beispiel #2
0
class GentooBuilder:
    def __init__(self, image_owner='allenh1', image_name='ros_gentoo_base'):
        self.container = Docker()
        self.container.pull(image_owner, image_name)
        self.package_list = dict()

    def add_target(self, ros_distro, pkg):
        # TODO(allenh1): it might be nice to add a Python3 target
        # in case we want to test both.
        self.package_list['ros-%s/%s' % (ros_distro, pkg)] = 'unknown'

    def run(self, verbose=True, log_file=None):
        # TODO(allenh1): add the ability to check out a non-master
        # branch of the overlay (for CI).
        info('testing gentoo package integrity')
        for pkg in sorted(self.package_list.keys()):
            self.container.add_bash_command('emaint sync -r ros-overlay')
            self.container.add_bash_command('emerge %s' % pkg)
            try:
                self.container.run(rm=True,
                                   show_cmd=True,
                                   privileged=True,
                                   log_file=log_file)
                self.package_list[pkg] = 'building'
                ok("  '%s': building" % pkg)
            except ContainerError:
                self.package_list[pkg] = 'failing'
                err("  '%s': failing" % pkg)
            if verbose:
                print(self.container.log)
            self.container.clear_commands()
        return self.package_list
 def regenerate_manifests(
     self, regen_dict, image_owner='allenh1', image_name='ros_gentoo_base'
 ):
     info(
         "Pulling docker image '%s/%s:latest'..." % (
             image_owner, image_name
         )
     )
     dock = Docker()
     dock.pull(image_owner, image_name)
     info('Running docker image...')
     info('Generating manifests...')
     dock.map_directory(
         '/home/%s/.gnupg' % os.getenv('USER'),
         '/root/.gnupg'
     )
     dock.map_directory(self.repo.repo_dir, '/tmp/ros-overlay')
     for key in regen_dict.keys():
         for pkg in regen_dict[key]:
             pkg_dir = '/tmp/ros-overlay/ros-{0}/{1}'.format(key, pkg)
             dock.add_bash_command('cd {0}'.format(pkg_dir))
             dock.add_bash_command('repoman manifest')
     try:
         dock.run(show_cmd=True)
     except docker.errors.ContainerError:
         print(dock.log)
         raise
Beispiel #4
0
def set_up_container():
    d = Docker()
    curr = os.getcwd()
    try:
        d.pull('allenh1', 'asw_test_env')
    except:
        d.build(os.path.realpath("../docker/Dockerfile"))
    info("Using repo in directory '%s'" % os.path.realpath(".."))
    d.map_directory(os.path.realpath(".."), repo_location)
    return d
Beispiel #5
0
 def test_pull(self):
     """Test Docker pull"""
     docker_instance = Docker()
     docker_instance.pull('allenh1', 'ros_gentoo_base')
     docker_instance.add_bash_command("echo Hello, Gentoo")
     docker_instance.run()