Exemple #1
0
    def setUp(self):
        """Establish a clean test environment."""
        super(TestReSize, self).setUp()

        rbd_store.rados = MockRados
        rbd_store.rbd = MockRBD

        self.store = rbd_store.Store(self.conf)
        self.store.configure()
        self.store_specs = {
            'pool': 'fake_pool',
            'image': 'fake_image',
            'snapshot': 'fake_snapshot'
        }
        self.location = rbd_store.StoreLocation(self.store_specs, self.conf)
        self.hash_algo = 'sha256'
    def setUp(self):
        """Establish a clean test environment"""
        super(TestStore, self).setUp()

        rbd_store.rados = MockRados
        rbd_store.rbd = MockRBD

        self.store = rbd_store.Store(self.conf)
        self.store.configure()
        self.store.chunk_size = 2
        self.called_commands_actual = []
        self.called_commands_expected = []
        self.store_specs = {'image': 'fake_image', 'snapshot': 'fake_snapshot'}
        self.location = rbd_store.StoreLocation(self.store_specs)
        # Provide enough data to get more than one chunk iteration.
        self.data_len = 3 * 1024
        self.data_iter = StringIO.StringIO('*' * self.data_len)
    def setUp(self):
        """Establish a clean test environment."""
        super(TestStore, self).setUp()

        rbd_store.rados = MockRados
        rbd_store.rbd = MockRBD

        self.store = rbd_store.Store(self.conf)
        self.store.configure()
        self.store.chunk_size = 2
        self.called_commands_actual = []
        self.called_commands_expected = []
        self.store_specs = {'pool': 'fake_pool',
                            'image': 'fake_image',
                            'snapshot': 'fake_snapshot'}
        self.location = rbd_store.StoreLocation(self.store_specs,
                                                self.conf)
        # Provide enough data to get more than one chunk iteration.
        self.data_len = 3 * units.Ki
        self.data_iter = six.BytesIO(b'*' * self.data_len)
        self.hash_algo = 'sha256'
Exemple #4
0
    def setUp(self):
        """Establish a clean test environment."""
        super(TestMultiStore, self).setUp()
        enabled_backends = {"ceph1": "rbd", "ceph2": "rbd"}
        self.conf = self._CONF
        self.conf(args=[])
        self.conf.register_opt(cfg.DictOpt('enabled_backends'))
        self.config(enabled_backends=enabled_backends)
        store.register_store_opts(self.conf)
        self.config(default_backend='ceph1', group='glance_store')

        # Ensure stores + locations cleared
        g_location.SCHEME_TO_CLS_BACKEND_MAP = {}

        with mock.patch.object(rbd_store.Store, '_set_url_prefix'):
            store.create_multi_stores(self.conf)

        self.addCleanup(setattr, g_location, 'SCHEME_TO_CLS_BACKEND_MAP',
                        dict())
        self.addCleanup(self.conf.reset)

        rbd_store.rados = MockRados
        rbd_store.rbd = MockRBD

        self.store = rbd_store.Store(self.conf, backend="ceph1")
        self.store.configure()
        self.store.chunk_size = 2
        self.called_commands_actual = []
        self.called_commands_expected = []
        self.store_specs = {
            'pool': 'fake_pool',
            'image': 'fake_image',
            'snapshot': 'fake_snapshot'
        }
        self.location = rbd_store.StoreLocation(self.store_specs, self.conf)
        # Provide enough data to get more than one chunk iteration.
        self.data_len = 3 * units.Ki
        self.data_iter = six.BytesIO(b'*' * self.data_len)
Exemple #5
0
    def test_add_w_image_size_zero_to_different_backend(self):
        """Assert that correct size is returned even though 0 was provided."""
        self.store = rbd_store.Store(self.conf, backend="ceph2")
        self.store.configure()
        self.called_commands_actual = []
        self.called_commands_expected = []
        self.store_specs = {'pool': 'fake_pool_1',
                            'image': 'fake_image_1',
                            'snapshot': 'fake_snapshot_1'}
        self.location = rbd_store.StoreLocation(self.store_specs,
                                                self.conf)
        # Provide enough data to get more than one chunk iteration.
        self.data_len = 3 * units.Ki
        self.data_iter = six.BytesIO(b'*' * self.data_len)
        self.store.chunk_size = units.Ki
        with mock.patch.object(rbd_store.rbd.Image, 'resize') as resize:
            with mock.patch.object(rbd_store.rbd.Image, 'write') as write:
                ret = self.store.add('fake_image_id', self.data_iter, 0)

                self.assertTrue(resize.called)
                self.assertTrue(write.called)
                self.assertEqual(ret[1], self.data_len)
                self.assertEqual("ceph2", ret[3]['backend'])