summaryrefslogtreecommitdiffhomepage
path: root/test/unit/http.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2019-11-14 17:14:55 +0300
committerAndrei Zeliankou <zelenkov@nginx.com>2019-11-14 17:14:55 +0300
commitb5e3e22a46df6700415583002a15cc15eaac8514 (patch)
treef74c3f8157dfab137eb91a6d5bf4927beb0baa40 /test/unit/http.py
parent02e197e9782ca19bd668c37c11f529f802823868 (diff)
downloadunit-b5e3e22a46df6700415583002a15cc15eaac8514.tar.gz
unit-b5e3e22a46df6700415583002a15cc15eaac8514.tar.bz2
Tests: waitforsocket() introduced.
Diffstat (limited to 'test/unit/http.py')
-rw-r--r--test/unit/http.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/unit/http.py b/test/unit/http.py
index 1a68ca3b..c7e3e36d 100644
--- a/test/unit/http.py
+++ b/test/unit/http.py
@@ -1,4 +1,5 @@
import re
+import time
import socket
import select
from unit.main import TestUnit
@@ -178,3 +179,20 @@ class TestHTTP(TestUnit):
headers[m.group(1)] = [headers[m.group(1)], m.group(2)]
return {'status': int(status), 'headers': headers, 'body': body}
+
+ def waitforsocket(self, port):
+ ret = False
+
+ for i in range(50):
+ try:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.connect(('127.0.0.1', port))
+ ret = True
+ break
+ except:
+ sock.close()
+ time.sleep(0.1)
+
+ sock.close()
+
+ self.assertTrue(ret, 'socket connected')