Sleep enough for trampoline
When running unite test suite in local poor resource environment, sometimes test/unit/proxy/test_server.py fails due to a lack of waiting time to trampoline of eventlet thread. This patch enables to sleep 1 more second when it doesn't seem to have enough time to tranpoline. Change-Id: I0bbc8fc245919d3c0a071ff87ff6e20b8d58f9b8
This commit is contained in:

committed by
Alistair Coles

parent
d0f5e38f84
commit
9fe0e25604
@@ -1204,6 +1204,12 @@ class TestObjectController(unittest.TestCase):
|
|||||||
pass
|
pass
|
||||||
self.assertEqual(res.status_int, expected)
|
self.assertEqual(res.status_int, expected)
|
||||||
|
|
||||||
|
def _sleep_enough(self, condition):
|
||||||
|
for sleeptime in (0.1, 1.0):
|
||||||
|
sleep(sleeptime)
|
||||||
|
if condition():
|
||||||
|
break
|
||||||
|
|
||||||
@unpatch_policies
|
@unpatch_policies
|
||||||
def test_policy_IO(self):
|
def test_policy_IO(self):
|
||||||
def check_file(policy, cont, devs, check_val):
|
def check_file(policy, cont, devs, check_val):
|
||||||
@@ -5625,7 +5631,9 @@ class TestObjectController(unittest.TestCase):
|
|||||||
# read most of the object, and disconnect
|
# read most of the object, and disconnect
|
||||||
fd.read(10)
|
fd.read(10)
|
||||||
sock.fd._sock.close()
|
sock.fd._sock.close()
|
||||||
sleep(0.1)
|
condition = \
|
||||||
|
lambda: _test_servers[0].logger.get_lines_for_level('warning')
|
||||||
|
self._sleep_enough(condition)
|
||||||
|
|
||||||
# check for disconnect message!
|
# check for disconnect message!
|
||||||
expected = ['Client disconnected on read'] * 2
|
expected = ['Client disconnected on read'] * 2
|
||||||
@@ -5665,7 +5673,9 @@ class TestObjectController(unittest.TestCase):
|
|||||||
fd.close()
|
fd.close()
|
||||||
sock.close()
|
sock.close()
|
||||||
# sleep to trampoline enough
|
# sleep to trampoline enough
|
||||||
sleep(0.1)
|
condition = \
|
||||||
|
lambda: _test_servers[0].logger.get_lines_for_level('warning')
|
||||||
|
self._sleep_enough(condition)
|
||||||
expected = ['Client disconnected without sending enough data']
|
expected = ['Client disconnected without sending enough data']
|
||||||
warns = _test_servers[0].logger.get_lines_for_level('warning')
|
warns = _test_servers[0].logger.get_lines_for_level('warning')
|
||||||
self.assertEqual(expected, warns)
|
self.assertEqual(expected, warns)
|
||||||
|
Reference in New Issue
Block a user