Example #1
0
    def test_kvs_configure_called_twice(self):
        """Check if configure() is called again."""
        target = core.KeyValueStore
        with mock.patch.object(target, 'configure') as configure_mock:
            store = core.get_key_value_store(self.store_name)
            other_store = core.get_key_value_store(self.store_name)

            store.configure(backing_store=self.kvs_backend)
            other_store.configure(backing_store=self.kvs_backend)

            self.assertThat(configure_mock.mock_calls, matchers.HasLength(2))
Example #2
0
    def test_kvs_configure_called_twice(self):
        """Check if configure() is called again."""
        target = core.KeyValueStore
        with mock.patch.object(target, 'configure') as configure_mock:
            store = core.get_key_value_store(self.store_name)
            other_store = core.get_key_value_store(self.store_name)

            store.configure(backing_store=self.kvs_backend)
            other_store.configure(backing_store=self.kvs_backend)

            self.assertThat(configure_mock.mock_calls, matchers.HasLength(2))
Example #3
0
    def test_different_instances_initialization(self):
        """Simulate race condition on token storage initialization."""
        store = core.get_key_value_store(self.store_name)
        self.assertFalse(store.is_configured)
        other_store = core.get_key_value_store(self.store_name)
        self.assertFalse(other_store.is_configured)

        other_store.configure(backing_store=self.kvs_backend)
        self.assertTrue(other_store.is_configured)
        # This error shows that core.get_key_value_store() returns a shared
        # object protected from re-configuration with an exception.
        self.assertRaises(RuntimeError, store.configure,
                          backing_store=self.kvs_backend)
Example #4
0
    def test_different_instances_initialization(self):
        """Simulate race condition on token storage initialization."""
        store = core.get_key_value_store(self.store_name)
        self.assertFalse(store.is_configured)
        other_store = core.get_key_value_store(self.store_name)
        self.assertFalse(other_store.is_configured)

        other_store.configure(backing_store=self.kvs_backend)
        self.assertTrue(other_store.is_configured)
        # This error shows that core.get_key_value_store() returns a shared
        # object protected from re-configuration with an exception.
        self.assertRaises(RuntimeError,
                          store.configure,
                          backing_store=self.kvs_backend)
Example #5
0
 def _get_kvs_region(self, name=None):
     if name is None:
         name = uuid.uuid4().hex
     return core.get_key_value_store(name)
 def _get_kvs_region(self, name=None):
     if name is None:
         name = uuid.uuid4().hex
     return core.get_key_value_store(name)