test_docker.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:aardvark 作者: Netflix-Skunkworks 项目源码 文件源码
def tearDown(self):
        '''Test case common fixture teardown.'''

        logger.info("======= tearDown: %s", self.delete_artifacts)

        self.log_docker_constructs()

        new_containers = self.new_constructs('container')
        new_images = self.new_constructs('image')
        new_volumes = self.new_constructs('volume')

        if self.delete_artifacts:
            # Every case should clean up its docker images and containers.

            for container in new_containers:
                # These should have been launched with the --rm flag,
                # so they should be removed once stopped.
                logger.info("REMOVING %s", container['id'])
                pexpect.run('docker stop {}'.format(container['id']))

            for image in new_images:
                logger.info("REMOVING %s", image['id'])
                pexpect.run('docker rmi {}'.format(image['id']))

            for volume in new_volumes:
                logger.info("REMOVING %s", volume['name'])
                pexpect.run('docker volume rm {}'.format(volume['name']))

        else:
            # We'll leave behind any new docker constructs, so we need
            # to update the "original docker volumes".
            self.constructs['current']['container'].extend(new_containers)
            self.constructs['current']['image'].extend(new_images)
            self.constructs['current']['volume'].extend(new_volumes)

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号