diff options
author | Zuul <zuul@review.opendev.org> | 2023-05-17 23:20:23 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2023-05-17 23:20:23 +0000 |
commit | d098ffd04c6454608742730d5ff84deaef605820 (patch) | |
tree | 2589904c4ddc5ba7c4dd5350ff0af51bf7b7c9f1 /test/unit/__init__.py | |
parent | a0c5ac29a1e4f5dd5ee66ceb3d319774017cadfc (diff) | |
parent | 647ee83906df8fae336b479c0f169be2ced1772c (diff) | |
download | swift-d098ffd04c6454608742730d5ff84deaef605820.tar.gz |
Merge "Unit test for keepalive timeout"
Diffstat (limited to 'test/unit/__init__.py')
-rw-r--r-- | test/unit/__init__.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/unit/__init__.py b/test/unit/__init__.py index f9847a10a..0d0206f08 100644 --- a/test/unit/__init__.py +++ b/test/unit/__init__.py @@ -512,6 +512,17 @@ def readuntil2crlfs(fd): return rv +def readlength(fd, size, timeout=1.0): + buf = b'' + with eventlet.Timeout(timeout): + while len(buf) < size: + chunk = fd.read(min(64, size - len(buf))) + buf += chunk + if len(buf) >= size: + break + return buf + + def connect_tcp(hostport): rv = socket.socket() rv.connect(hostport) |