def setUp(self): """Establish a clean test environment.""" super(TestSheepdogStore, self).setUp() def _fake_execute(*cmd, **kwargs): pass self.config(default_store='sheepdog', group='glance_store') execute = mock.patch.object(processutils, 'execute').start() execute.side_effect = _fake_execute self.addCleanup(execute.stop) self.store = sheepdog.Store(self.conf) self.store.configure()
def test_add_image_to_different_backend(self, mock_exist, mock_create, mock_write): self.store = sheepdog.Store(self.conf, backend='sheepdog2') self.store.configure() data = six.BytesIO(b'xx') mock_exist.return_value = False (uri, size, checksum, loc) = self.store.add('fake_image_id', data, 2) self.assertEqual("sheepdog2", loc["backend"]) mock_exist.assert_called_once_with() mock_create.assert_called_once_with(2) mock_write.assert_called_once_with(b'xx', 0, 2)
def setUp(self): """Establish a clean test environment.""" super(TestSheepdogStore, self).setUp() def _fake_execute(*cmd, **kwargs): pass self.config(default_store='sheepdog', group='glance_store') execute = mock.patch.object(processutils, 'execute').start() execute.side_effect = _fake_execute self.addCleanup(execute.stop) self.store = sheepdog.Store(self.conf) self.store.configure() self.store_specs = { 'image': '6bd59e6e-c410-11e5-ab67-0a73f1fda51b', 'addr': '127.0.0.1', 'port': 7000 }
def setUp(self): """Establish a clean test environment.""" super(TestSheepdogMultiStore, self).setUp() enabled_backends = { "sheepdog1": "sheepdog", "sheepdog2": "sheepdog", } 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='sheepdog1', group='glance_store') # mock sheepdog commands def _fake_execute(*cmd, **kwargs): pass execute = mock.patch.object(processutils, 'execute').start() execute.side_effect = _fake_execute self.addCleanup(execute.stop) # Ensure stores + locations cleared location.SCHEME_TO_CLS_BACKEND_MAP = {} store.create_multi_stores(self.conf) self.addCleanup(setattr, location, 'SCHEME_TO_CLS_BACKEND_MAP', dict()) self.addCleanup(self.conf.reset) self.store = sheepdog.Store(self.conf, backend='sheepdog1') self.store.configure() self.store_specs = { 'image': '6bd59e6e-c410-11e5-ab67-0a73f1fda51b', 'addr': '127.0.0.1', 'port': 7000 }