Expose timeout capabilities and use them for tests

Change-Id: I5b6ee43e6a6b91859dacedb9791da74e247cd12b
This commit is contained in:
Julien Danjou
2016-05-26 15:23:44 +02:00
parent 4906e72416
commit 756d265232
8 changed files with 18 additions and 6 deletions

View File

@@ -50,6 +50,13 @@ class Characteristics(enum.Enum):
"""Coordinator components when used by multiple **hosts** work """Coordinator components when used by multiple **hosts** work
the same as if those components were only used by a single thread.""" the same as if those components were only used by a single thread."""
NON_TIMEOUT_BASED = 'NON_TIMEOUT_BASED'
"""The driver has the following property:
* Its operations are not based on the timeout of other clients, but on some
other more robust mechanisms.
"""
LINEARIZABLE = 'LINEARIZABLE' LINEARIZABLE = 'LINEARIZABLE'
"""The driver has the following properties: """The driver has the following properties:

View File

@@ -205,6 +205,7 @@ class FileDriver(coordination._RunWatchersMixin,
""" """
CHARACTERISTICS = ( CHARACTERISTICS = (
coordination.Characteristics.NON_TIMEOUT_BASED,
coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS, coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS,
coordination.Characteristics.DISTRIBUTED_ACROSS_PROCESSES, coordination.Characteristics.DISTRIBUTED_ACROSS_PROCESSES,
) )

View File

@@ -150,6 +150,7 @@ class IPCDriver(coordination.CoordinationDriver):
""" """
CHARACTERISTICS = ( CHARACTERISTICS = (
coordination.Characteristics.NON_TIMEOUT_BASED,
coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS, coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS,
coordination.Characteristics.DISTRIBUTED_ACROSS_PROCESSES, coordination.Characteristics.DISTRIBUTED_ACROSS_PROCESSES,
) )

View File

@@ -105,6 +105,7 @@ class MySQLDriver(coordination.CoordinationDriver):
""" """
CHARACTERISTICS = ( CHARACTERISTICS = (
coordination.Characteristics.NON_TIMEOUT_BASED,
coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS, coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS,
coordination.Characteristics.DISTRIBUTED_ACROSS_PROCESSES, coordination.Characteristics.DISTRIBUTED_ACROSS_PROCESSES,
coordination.Characteristics.DISTRIBUTED_ACROSS_HOSTS, coordination.Characteristics.DISTRIBUTED_ACROSS_HOSTS,

View File

@@ -161,6 +161,7 @@ class PostgresDriver(coordination.CoordinationDriver):
""" """
CHARACTERISTICS = ( CHARACTERISTICS = (
coordination.Characteristics.NON_TIMEOUT_BASED,
coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS, coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS,
coordination.Characteristics.DISTRIBUTED_ACROSS_PROCESSES, coordination.Characteristics.DISTRIBUTED_ACROSS_PROCESSES,
coordination.Characteristics.DISTRIBUTED_ACROSS_HOSTS, coordination.Characteristics.DISTRIBUTED_ACROSS_HOSTS,

View File

@@ -33,6 +33,7 @@ class ZakeDriver(zookeeper.KazooDriver):
""" """
CHARACTERISTICS = ( CHARACTERISTICS = (
coordination.Characteristics.NON_TIMEOUT_BASED,
coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS, coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS,
) )
""" """

View File

@@ -435,6 +435,7 @@ class KazooDriver(BaseZooKeeperDriver):
""" """
CHARACTERISTICS = ( CHARACTERISTICS = (
coordination.Characteristics.NON_TIMEOUT_BASED,
coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS, coordination.Characteristics.DISTRIBUTED_ACROSS_THREADS,
coordination.Characteristics.DISTRIBUTED_ACROSS_PROCESSES, coordination.Characteristics.DISTRIBUTED_ACROSS_PROCESSES,
coordination.Characteristics.DISTRIBUTED_ACROSS_HOSTS, coordination.Characteristics.DISTRIBUTED_ACROSS_HOSTS,

View File

@@ -47,13 +47,11 @@ class TestAPI(testscenarios.TestWithScenarios,
'bad_url': 'kazoo://localhost:1'}), 'bad_url': 'kazoo://localhost:1'}),
('zake', {'url': 'zake://?timeout=5'}), ('zake', {'url': 'zake://?timeout=5'}),
('memcached', {'url': os.getenv("TOOZ_TEST_MEMCACHED_URL"), ('memcached', {'url': os.getenv("TOOZ_TEST_MEMCACHED_URL"),
'bad_url': 'memcached://localhost:1', 'bad_url': 'memcached://localhost:1'}),
'timeout_capable': True}),
('ipc', {'url': 'ipc://'}), ('ipc', {'url': 'ipc://'}),
('file', {'url': 'file:///tmp'}), ('file', {'url': 'file:///tmp'}),
('redis', {'url': os.getenv("TOOZ_TEST_REDIS_URL"), ('redis', {'url': os.getenv("TOOZ_TEST_REDIS_URL"),
'bad_url': 'redis://localhost:1', 'bad_url': 'redis://localhost:1'}),
'timeout_capable': True}),
('postgresql', {'url': os.getenv("TOOZ_TEST_POSTGRESQL_URL"), ('postgresql', {'url': os.getenv("TOOZ_TEST_POSTGRESQL_URL"),
'bad_url': 'postgresql://localhost:1'}), 'bad_url': 'postgresql://localhost:1'}),
('mysql', {'url': os.getenv("TOOZ_TEST_MYSQL_URL"), ('mysql', {'url': os.getenv("TOOZ_TEST_MYSQL_URL"),
@@ -377,8 +375,9 @@ class TestAPI(testscenarios.TestWithScenarios,
self.assertTrue(member_id_test2 not in members_ids) self.assertTrue(member_id_test2 not in members_ids)
def test_timeout(self): def test_timeout(self):
if not getattr(self, "timeout_capable", False): if (tooz.coordination.Characteristics.NON_TIMEOUT_BASED
self.skipTest("This test only works with timeout capable drivers") in self._coord.CHARACTERISTICS):
self.skipTest("This driver is not based on timeout")
self._coord.stop() self._coord.stop()
if "?" in self.url: if "?" in self.url:
sep = "&" sep = "&"