Merge "Wait longer for log lines in unit test"

This commit is contained in:
Zuul 2019-05-17 18:30:23 +00:00 committed by Gerrit Code Review
commit f1e2a21efe
1 changed files with 19 additions and 7 deletions

View File

@ -7493,6 +7493,8 @@ class TestObjectServer(unittest.TestCase):
'devices': self.devices,
'swift_dir': self.tempdir,
'mount_check': 'false',
# hopefully 1s is long enough to improve gate reliability?
'client_timeout': 1,
}
self.logger = debug_logger('test-object-server')
self.app = object_server.ObjectController(
@ -8156,14 +8158,24 @@ class TestObjectServer(unittest.TestCase):
conn.sock.fd._sock.close()
else:
conn.sock.fd._real_close()
# We've seen a bunch of failures here -- try waiting some non-zero
# amount of time.
sleep(0.01)
# and make sure it demonstrates the client disconnect
log_lines = self.logger.get_lines_for_level('info')
self.assertEqual(len(log_lines), 1)
self.assertIn(' 499 ', log_lines[0])
# the object server needs to recognize the socket is closed
# or at least timeout, we'll have to wait
timeout = time() + (self.conf['client_timeout'] + 1)
while True:
try:
# and make sure it demonstrates the client disconnect
log_lines = self.logger.get_lines_for_level('info')
self.assertEqual(len(log_lines), 1)
except AssertionError:
if time() < timeout:
sleep(0.01)
else:
raise
else:
break
status = log_lines[0].split()[7]
self.assertEqual(status, '499')
# verify successful object data and durable state file write
put_timestamp = context['put_timestamp']