Commit 600cc94a authored by Julien Muchembled's avatar Julien Muchembled

qa: in threaded tests, detect another case where a bug could call tic() endlessly

parent 744dbf5f
...@@ -43,6 +43,7 @@ from .. import NeoTestBase, Patch, getTempDirectory, setupMySQLdb, \ ...@@ -43,6 +43,7 @@ from .. import NeoTestBase, Patch, getTempDirectory, setupMySQLdb, \
BIND = IP_VERSION_FORMAT_DICT[ADDRESS_TYPE], 0 BIND = IP_VERSION_FORMAT_DICT[ADDRESS_TYPE], 0
LOCAL_IP = socket.inet_pton(ADDRESS_TYPE, IP_VERSION_FORMAT_DICT[ADDRESS_TYPE]) LOCAL_IP = socket.inet_pton(ADDRESS_TYPE, IP_VERSION_FORMAT_DICT[ADDRESS_TYPE])
MAX_TIC_COUNT = 100
class LockLock(object): class LockLock(object):
...@@ -255,7 +256,7 @@ class TestSerialized(Serialized): ...@@ -255,7 +256,7 @@ class TestSerialized(Serialized):
def poll(self, timeout): def poll(self, timeout):
if timeout: if timeout:
for x in xrange(1000): for x in xrange(MAX_TIC_COUNT):
r = self._epoll.poll(0) r = self._epoll.poll(0)
if r: if r:
return r return r
...@@ -556,9 +557,11 @@ class NEOCluster(object): ...@@ -556,9 +557,11 @@ class NEOCluster(object):
def _lock(blocking=True): def _lock(blocking=True):
if blocking: if blocking:
logging.info('<SimpleQueue>._lock.acquire()') logging.info('<SimpleQueue>._lock.acquire()')
while not lock(False): for i in xrange(MAX_TIC_COUNT):
if lock(False):
return True
Serialized.tic(step=1, quiet=True) Serialized.tic(step=1, quiet=True)
return True raise Exception("tic is looping forever")
return lock(False) return lock(False)
self._lock = _lock self._lock = _lock
_patches = ( _patches = (
......
...@@ -19,9 +19,13 @@ from ZODB.tests.BasicStorage import BasicStorage ...@@ -19,9 +19,13 @@ from ZODB.tests.BasicStorage import BasicStorage
from ZODB.tests.StorageTestBase import StorageTestBase from ZODB.tests.StorageTestBase import StorageTestBase
from . import ZODBTestCase from . import ZODBTestCase
from .. import Patch, threaded
class BasicTests(ZODBTestCase, StorageTestBase, BasicStorage): class BasicTests(ZODBTestCase, StorageTestBase, BasicStorage):
pass
def check_checkCurrentSerialInTransaction(self):
with Patch(threaded, MAX_TIC_COUNT=100000):
super(BasicTests, self).check_checkCurrentSerialInTransaction()
if __name__ == "__main__": if __name__ == "__main__":
suite = unittest.makeSuite(BasicTests, 'check') suite = unittest.makeSuite(BasicTests, 'check')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment