From d7aa514d6a586115f0b05d5d6465787da1fa9b6c Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Fri, 3 Apr 2020 01:46:59 +0100 Subject: Tests: added notification on "read_timeout" expiration. --- test/unit/http.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'test/unit/http.py') diff --git a/test/unit/http.py b/test/unit/http.py index 8c71825a..8aacf18b 100644 --- a/test/unit/http.py +++ b/test/unit/http.py @@ -173,11 +173,25 @@ class TestHTTP(TestUnit): return self.http('PUT', **kwargs) def recvall(self, sock, **kwargs): - timeout = 60 if 'read_timeout' not in kwargs else kwargs['read_timeout'] + timeout_default = 60 + + timeout = ( + timeout_default + if 'read_timeout' not in kwargs + else kwargs['read_timeout'] + ) buff_size = 4096 if 'buff_size' not in kwargs else kwargs['buff_size'] data = b'' - while select.select([sock], [], [], timeout)[0]: + while True: + rlist = select.select([sock], [], [], timeout)[0] + if not rlist: + # For all current cases if the "read_timeout" was changed + # than test do not expect to get a response from server. + if timeout == timeout_default: + self.fail('Can\'t read response from server.') + break + try: part = sock.recv(buff_size) except: -- cgit