Ejemplo n.º 1
0
 def tearDownClass(cls):
     cls.base_container = None
     if not unittest_setup.config.skip_cleanup:
         if cls.cleanup_base_container:
             lxc.BaseImage().cleanup()
         cls.shared_host_dir.cleanup()
         shutil.rmtree(cls.test_dir)
def setup_base(container_path):
    """Test setup base container works.

    @param bucket: ContainerBucket to interact with containers.
    """
    logging.info('Rebuild base container in folder %s.', container_path)
    image = lxc.BaseImage(container_path)
    image.setup()
    logging.info('Base container created: %s', image.get().name)
Ejemplo n.º 3
0
    def setUpClass(cls):
        cls.test_dir = tempfile.mkdtemp(dir=lxc.DEFAULT_CONTAINER_PATH,
                                        prefix='container_unittest_')

        # Check if a base container exists on this machine and download one if
        # necessary.
        image = lxc.BaseImage()
        try:
            cls.base_container = image.get()
            cls.cleanup_base_container = False
        except error.ContainerError:
            image.setup()
            cls.base_container = image.get()
            cls.cleanup_base_container = True
        assert(cls.base_container is not None)
Ejemplo n.º 4
0
def main():
    """main script."""
    # Force to run the setup as superuser.
    # TODO(dshi): crbug.com/459344 Set remove this enforcement when test
    # container can be unprivileged container.
    if utils.sudo_require_password():
        logging.warn('SSP requires root privilege to run commands, please '
                     'grant root access to this process.')
        utils.run('sudo true')

    options = parse_options()
    image = lxc.BaseImage(container_path=options.path)
    if options.setup:
        image.setup(name=options.name, force_delete=options.force_delete)
    elif options.force_delete:
        image.cleanup()
    def setUpClass(cls):
        cls.test_dir = tempfile.mkdtemp(dir=lxc.DEFAULT_CONTAINER_PATH,
                                        prefix='zygote_unittest_')

        # Check if a base container exists on this machine and download one if
        # necessary.
        image = lxc.BaseImage()
        try:
            cls.base_container = image.get()
            cls.cleanup_base_container = False
        except error.ContainerError:
            image.setup()
            cls.base_container = image.get()
            cls.cleanup_base_container = True
        assert (cls.base_container is not None)

        # Set up the zygote host path.
        cls.shared_host_dir = lxc.SharedHostDir(
            os.path.join(cls.test_dir, 'host'))
 def tearDownClass(cls):
     cls.base_container = None
     if not unittest_setup.config.skip_cleanup:
         if cls.cleanup_base_container:
             lxc.BaseImage().cleanup()
         utils.run('sudo rm -r %s' % cls.test_dir)