Skip to content

Commit d46eada

Browse files
committed
Remove sleep
Remove time import
1 parent 82dc0b2 commit d46eada

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

ws/test_ws_ping.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
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
66
import websockets
77
import asyncio
8-
import time
98
import ssl
109
import os
1110
from framework.x509 import CertGenerator
@@ -169,7 +168,6 @@ class Ws_ping(tester.TempestaTest):
169168
# Client
170169

171170
def run_test(self, port, n):
172-
time.sleep(2.0)
173171
asyncio.run(self.ws_ping_test(port, n))
174172

175173
async def ws_ping_test(self, port, n):
@@ -208,8 +206,6 @@ def run_ws(self, port, count=1, proxy=False):
208206
ssl_context.load_cert_chain("/tmp/cert.pem", keyfile="/tmp/key.pem")
209207
if proxy:
210208
self.start_all_servers()
211-
self.start_tempesta()
212-
213209
loop = asyncio.get_event_loop()
214210
for i in range(count):
215211
asyncio.ensure_future(websockets.serve(self.handler, hostname, port+i))
@@ -219,6 +215,9 @@ def test_ping_websockets(self):
219215
p1 = Process(target=self.run_ws, args=(8099,))
220216
p2 = Process(target=self.run_test, args=(81, 4))
221217
p1.start()
218+
self.get_tempesta().start()
219+
while not self.get_tempesta().is_running():
220+
pass
222221
p2.start()
223222
p2.join()
224223
p1.terminate()
@@ -242,13 +241,15 @@ async def handler(self, websocket, path):
242241
class Wss_ping(Ws_ping):
243242

244243
def run_test(self, port, n):
245-
time.sleep(2.0)
246244
asyncio.run(self.wss_ping_test(port, n))
247245

248246
def test_ping_websockets(self):
249247
p1 = Process(target=self.run_ws, args=(8099,))
250248
p2 = Process(target=self.run_test, args=(82, 4))
251249
p1.start()
250+
self.get_tempesta().start()
251+
while not self.get_tempesta().is_running():
252+
pass
252253
p2.start()
253254
p2.join()
254255
p1.terminate()
@@ -273,6 +274,9 @@ def test_ping_websockets(self):
273274
p1 = Process(target=self.run_ws, args=(8099, 1, True))
274275
p2 = Process(target=self.run_test, args=(82, 4))
275276
p1.start()
277+
self.get_tempesta().start()
278+
while not self.get_tempesta().is_running():
279+
pass
276280
p2.start()
277281
p2.join()
278282
p1.terminate()
@@ -287,13 +291,15 @@ class Wss_stress(Wss_ping):
287291
}
288292

289293
def run_test(self, port, n):
290-
time.sleep(2.0)
291294
asyncio.run(self.wss_ping_test(port, n))
292295

293296
def test_ping_websockets(self):
294297
p1 = Process(target=self.run_ws, args=(8099, 8))
295298
p2 = Process(target=self.run_test, args=(82, 400))
296299
p1.start()
300+
self.get_tempesta().start()
301+
while not self.get_tempesta().is_running():
302+
pass
297303
p2.start()
298304
p2.join()
299305
p1.terminate()

0 commit comments

Comments
 (0)