summaryrefslogtreecommitdiff
path: root/test/unit/__init__.py
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-05-17 23:20:23 +0000
committerGerrit Code Review <review@openstack.org>2023-05-17 23:20:23 +0000
commitd098ffd04c6454608742730d5ff84deaef605820 (patch)
tree2589904c4ddc5ba7c4dd5350ff0af51bf7b7c9f1 /test/unit/__init__.py
parenta0c5ac29a1e4f5dd5ee66ceb3d319774017cadfc (diff)
parent647ee83906df8fae336b479c0f169be2ced1772c (diff)
downloadswift-d098ffd04c6454608742730d5ff84deaef605820.tar.gz
Merge "Unit test for keepalive timeout"
Diffstat (limited to 'test/unit/__init__.py')
-rw-r--r--test/unit/__init__.py11
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)