Ensure run_watchers called from mixin, not base class

A new mixin was introduced to share run_watchers across drivers,
but the base class's run_watchers() currently gets called instead,
resulting in a NotImplemented error.

Change-Id: I5f23f63100a9c00837025b291cb1db0a5187a8e9
Closes-bug: #1470264
This commit is contained in:
Adam Gandelman 2015-06-30 16:04:01 -07:00
parent 89895e7c6d
commit f9cd68f8d0
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) LOG.warn("Unreleased lock %s garbage collected", self.name)
class FileDriver(coordination.CoordinationDriver, class FileDriver(coordination._RunWatchersMixin,
coordination._RunWatchersMixin): coordination.CoordinationDriver):
"""A file based driver. """A file based driver.
This driver uses files and directories (and associated file locks) to 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) return self.coord.client.get(self.name)
class MemcachedDriver(coordination.CoordinationDriver, class MemcachedDriver(coordination._RunWatchersMixin,
coordination._RunWatchersMixin): coordination.CoordinationDriver):
"""A `memcached`_ based driver. """A `memcached`_ based driver.
This driver users `memcached`_ concepts to provide the coordination 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) self._lock.extend(self._lock.timeout)
class RedisDriver(coordination.CoordinationDriver, class RedisDriver(coordination._RunWatchersMixin,
coordination._RunWatchersMixin): coordination.CoordinationDriver):
"""Redis provides a few nice benefits that act as a poormans zookeeper. """Redis provides a few nice benefits that act as a poormans zookeeper.
It **is** fully functional and implements all of the coordination It **is** fully functional and implements all of the coordination

View File

@ -69,3 +69,16 @@ class TestMemcacheDriverFailures(testcase.TestCase):
coord.start() coord.start()
mock_client.set.side_effect = socket.timeout('timed-out') mock_client.set.side_effect = socket.timeout('timed-out')
self.assertRaises(coordination.ToozConnectionError, coord.heartbeat) 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)