예제 #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")
예제 #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
예제 #3
0
 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
예제 #4
0
 def regenerate_manifests(self, regen_dict):
     info('Building docker image...')
     docker_file = resource_filename('repoman_docker', 'Dockerfile')
     dock = Docker(docker_file, 'gentoo_repoman')
     dock.build()
     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')
             dock.add_bash_command('cd /tmp/ros-overlay')
     dock.run(show_cmd=True)
예제 #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()
예제 #6
0
 def test_run(self):
     """Test Docker run"""
     docker_instance = Docker()
     docker_instance.build('tests/docker/Dockerfile')
     docker_instance.add_bash_command("echo Hello, docker")
     docker_instance.run()