From 9fe0e25604dff35db7eab1bca312821a81db6c1d Mon Sep 17 00:00:00 2001 From: Kota Tsuyuzaki Date: Tue, 8 Dec 2015 22:27:44 -0800 Subject: [PATCH] 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 --- test/unit/proxy/test_server.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index c3e8fc6b20..685463ac14 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -1204,6 +1204,12 @@ class TestObjectController(unittest.TestCase): pass 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 def test_policy_IO(self): def check_file(policy, cont, devs, check_val): @@ -5625,7 +5631,9 @@ class TestObjectController(unittest.TestCase): # read most of the object, and disconnect fd.read(10) 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! expected = ['Client disconnected on read'] * 2 @@ -5665,7 +5673,9 @@ class TestObjectController(unittest.TestCase): fd.close() sock.close() # 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'] warns = _test_servers[0].logger.get_lines_for_level('warning') self.assertEqual(expected, warns)