コード例 #1
0
ファイル: test_imagebackend.py プロジェクト: CiscoAS/nova
    def test_prealloc_image(self):
        CONF.set_override('preallocate_images', 'space')

        fake_utils.fake_execute_clear_log()
        fake_utils.stub_out_utils_execute(self.stubs)
        image = self.image_class(self.INSTANCE, self.NAME)

        def fake_fetch(target, *args, **kwargs):
            return

        self.stubs.Set(os.path, 'exists', lambda _: True)

        image.cache(fake_fetch, self.TEMPLATE_PATH, self.SIZE)

        self.assertEqual(fake_utils.fake_execute_get_log(), [])
コード例 #2
0
    def test_prealloc_image(self):
        CONF.set_override('preallocate_images', 'space')

        fake_utils.fake_execute_clear_log()
        fake_utils.stub_out_utils_execute(self.stubs)
        image = self.image_class(self.INSTANCE, self.NAME)

        def fake_fetch(target, *args, **kwargs):
            return

        self.stubs.Set(os.path, 'exists', lambda _: True)

        image.cache(fake_fetch, self.TEMPLATE_PATH, self.SIZE)

        self.assertEqual(fake_utils.fake_execute_get_log(), [])
コード例 #3
0
ファイル: test_imagebackend.py プロジェクト: CiscoAS/nova
    def test_prealloc_image(self):
        CONF.set_override('preallocate_images', 'space')

        fake_utils.fake_execute_clear_log()
        fake_utils.stub_out_utils_execute(self.stubs)
        image = self.image_class(self.INSTANCE, self.NAME)

        def fake_fetch(target, *args, **kwargs):
            return

        self.stubs.Set(os.path, 'exists', lambda _: True)

        # Call twice to verify testing fallocate is only called once.
        image.cache(fake_fetch, self.TEMPLATE_PATH, self.SIZE)
        image.cache(fake_fetch, self.TEMPLATE_PATH, self.SIZE)

        self.assertEqual(fake_utils.fake_execute_get_log(),
            ['fallocate -n -l 1 %s.fallocate_test' % self.PATH,
             'fallocate -n -l %s %s' % (self.SIZE, self.PATH),
             'fallocate -n -l %s %s' % (self.SIZE, self.PATH)])
コード例 #4
0
    def test_prealloc_image(self):
        CONF.set_override('preallocate_images', 'space')

        fake_utils.fake_execute_clear_log()
        fake_utils.stub_out_utils_execute(self.stubs)
        image = self.image_class(self.INSTANCE, self.NAME)

        def fake_fetch(target, *args, **kwargs):
            return

        self.stubs.Set(os.path, 'exists', lambda _: True)

        # Call twice to verify testing fallocate is only called once.
        image.cache(fake_fetch, self.TEMPLATE_PATH, self.SIZE)
        image.cache(fake_fetch, self.TEMPLATE_PATH, self.SIZE)

        self.assertEqual(fake_utils.fake_execute_get_log(), [
            'fallocate -n -l 1 %s.fallocate_test' % self.PATH,
            'fallocate -n -l %s %s' % (self.SIZE, self.PATH),
            'fallocate -n -l %s %s' % (self.SIZE, self.PATH)
        ])