Skip to content

Commit eb3111e

Browse files
committed
Remove sleep
1 parent 82dc0b2 commit eb3111e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

ws/test_ws_ping.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /usr/bin/python3
2-
from framework import tester, nginx_server
2+
from framework import tester
33

44
from multiprocessing import Process
55
from random import randint
@@ -169,7 +169,6 @@ class Ws_ping(tester.TempestaTest):
169169
# Client
170170

171171
def run_test(self, port, n):
172-
time.sleep(2.0)
173172
asyncio.run(self.ws_ping_test(port, n))
174173

175174
async def ws_ping_test(self, port, n):
@@ -208,8 +207,6 @@ def run_ws(self, port, count=1, proxy=False):
208207
ssl_context.load_cert_chain("/tmp/cert.pem", keyfile="/tmp/key.pem")
209208
if proxy:
210209
self.start_all_servers()
211-
self.start_tempesta()
212-
213210
loop = asyncio.get_event_loop()
214211
for i in range(count):
215212
asyncio.ensure_future(websockets.serve(self.handler, hostname, port+i))
@@ -219,6 +216,9 @@ def test_ping_websockets(self):
219216
p1 = Process(target=self.run_ws, args=(8099,))
220217
p2 = Process(target=self.run_test, args=(81, 4))
221218
p1.start()
219+
self.get_tempesta().start()
220+
while not self.get_tempesta().is_running():
221+
pass
222222
p2.start()
223223
p2.join()
224224
p1.terminate()
@@ -242,13 +242,15 @@ async def handler(self, websocket, path):
242242
class Wss_ping(Ws_ping):
243243

244244
def run_test(self, port, n):
245-
time.sleep(2.0)
246245
asyncio.run(self.wss_ping_test(port, n))
247246

248247
def test_ping_websockets(self):
249248
p1 = Process(target=self.run_ws, args=(8099,))
250249
p2 = Process(target=self.run_test, args=(82, 4))
251250
p1.start()
251+
self.get_tempesta().start()
252+
while not self.get_tempesta().is_running():
253+
pass
252254
p2.start()
253255
p2.join()
254256
p1.terminate()
@@ -273,6 +275,9 @@ def test_ping_websockets(self):
273275
p1 = Process(target=self.run_ws, args=(8099, 1, True))
274276
p2 = Process(target=self.run_test, args=(82, 4))
275277
p1.start()
278+
self.get_tempesta().start()
279+
while not self.get_tempesta().is_running():
280+
pass
276281
p2.start()
277282
p2.join()
278283
p1.terminate()
@@ -287,13 +292,15 @@ class Wss_stress(Wss_ping):
287292
}
288293

289294
def run_test(self, port, n):
290-
time.sleep(2.0)
291295
asyncio.run(self.wss_ping_test(port, n))
292296

293297
def test_ping_websockets(self):
294298
p1 = Process(target=self.run_ws, args=(8099, 8))
295299
p2 = Process(target=self.run_test, args=(82, 400))
296300
p1.start()
301+
self.get_tempesta().start()
302+
while not self.get_tempesta().is_running():
303+
pass
297304
p2.start()
298305
p2.join()
299306
p1.terminate()

0 commit comments

Comments
 (0)