diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2020-04-03 01:46:59 +0100 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2020-04-03 01:46:59 +0100 |
commit | d7aa514d6a586115f0b05d5d6465787da1fa9b6c (patch) | |
tree | 8bd3246485d04a30817f828da1695bc9fb50b236 /test/unit | |
parent | 2bb8b3d88a191d96c6693007ad79ae808f872941 (diff) | |
download | unit-d7aa514d6a586115f0b05d5d6465787da1fa9b6c.tar.gz unit-d7aa514d6a586115f0b05d5d6465787da1fa9b6c.tar.bz2 |
Tests: added notification on "read_timeout" expiration.
Diffstat (limited to '')
-rw-r--r-- | test/unit/applications/websockets.py | 16 | ||||
-rw-r--r-- | test/unit/http.py | 18 |
2 files changed, 30 insertions, 4 deletions
diff --git a/test/unit/applications/websockets.py b/test/unit/applications/websockets.py index 309d37a3..fc15e8e4 100644 --- a/test/unit/applications/websockets.py +++ b/test/unit/applications/websockets.py @@ -52,7 +52,11 @@ class TestApplicationWebsocket(TestApplicationProto): ) resp = '' - while select.select([sock], [], [], 60)[0]: + while True: + rlist = select.select([sock], [], [], 60)[0] + if not rlist: + self.fail('Can\'t read response from server.') + resp += sock.recv(4096).decode() if ( @@ -73,7 +77,15 @@ class TestApplicationWebsocket(TestApplicationProto): def frame_read(self, sock, read_timeout=60): def recv_bytes(sock, bytes): data = b'' - while select.select([sock], [], [], read_timeout)[0]: + while True: + rlist = select.select([sock], [], [], read_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 read_timeout == 60: + self.fail('Can\'t read response from server.') + break + data += sock.recv(bytes - len(data)) if len(data) == bytes: 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: |