Merge "Ensure run_watchers called from mixin, not base class"

This commit is contained in:
Jenkins 2015-07-02 03:13:19 +00:00 committed by Gerrit Code Review
commit d6f7325fdf
4 changed files with 19 additions and 6 deletions

View File

@ -110,8 +110,8 @@ class FileLock(locking.Lock):
LOG.warn("Unreleased lock %s garbage collected", self.name)
class FileDriver(coordination.CoordinationDriver,
coordination._RunWatchersMixin):
class FileDriver(coordination._RunWatchersMixin,
coordination.CoordinationDriver):
"""A file based driver.
This driver uses files and directories (and associated file locks) to

View File

@ -114,8 +114,8 @@ class MemcachedLock(locking.Lock):
return self.coord.client.get(self.name)
class MemcachedDriver(coordination.CoordinationDriver,
coordination._RunWatchersMixin):
class MemcachedDriver(coordination._RunWatchersMixin,
coordination.CoordinationDriver):
"""A `memcached`_ based driver.
This driver users `memcached`_ concepts to provide the coordination driver

View File

@ -98,8 +98,8 @@ class RedisLock(locking.Lock):
self._lock.extend(self._lock.timeout)
class RedisDriver(coordination.CoordinationDriver,
coordination._RunWatchersMixin):
class RedisDriver(coordination._RunWatchersMixin,
coordination.CoordinationDriver):
"""Redis provides a few nice benefits that act as a poormans zookeeper.
It **is** fully functional and implements all of the coordination

View File

@ -69,3 +69,16 @@ class TestMemcacheDriverFailures(testcase.TestCase):
coord.start()
mock_client.set.side_effect = socket.timeout('timed-out')
self.assertRaises(coordination.ToozConnectionError, coord.heartbeat)
@mock.patch('tooz.coordination._RunWatchersMixin.run_watchers',
autospec=True)
@mock.patch('pymemcache.client.PooledClient')
def test_client_run_watchers_mixin(self, mock_client_cls,
mock_run_watchers):
mock_client = mock.MagicMock()
mock_client_cls.return_value = mock_client
member_id = str(uuid.uuid4()).encode('ascii')
coord = coordination.get_coordinator(self.FAKE_URL, member_id)
coord.start()
coord.run_watchers()
self.assertTrue(mock_run_watchers.called)