1
1
#! /usr/bin/python3
2
- from framework import tester , nginx_server
2
+ from framework import tester
3
3
4
4
from multiprocessing import Process
5
5
from random import randint
6
6
import websockets
7
7
import asyncio
8
- import time
9
8
import ssl
10
9
import os
11
10
from framework .x509 import CertGenerator
@@ -169,7 +168,6 @@ class Ws_ping(tester.TempestaTest):
169
168
# Client
170
169
171
170
def run_test (self , port , n ):
172
- time .sleep (2.0 )
173
171
asyncio .run (self .ws_ping_test (port , n ))
174
172
175
173
async def ws_ping_test (self , port , n ):
@@ -208,8 +206,6 @@ def run_ws(self, port, count=1, proxy=False):
208
206
ssl_context .load_cert_chain ("/tmp/cert.pem" , keyfile = "/tmp/key.pem" )
209
207
if proxy :
210
208
self .start_all_servers ()
211
- self .start_tempesta ()
212
-
213
209
loop = asyncio .get_event_loop ()
214
210
for i in range (count ):
215
211
asyncio .ensure_future (websockets .serve (self .handler , hostname , port + i ))
@@ -219,6 +215,9 @@ def test_ping_websockets(self):
219
215
p1 = Process (target = self .run_ws , args = (8099 ,))
220
216
p2 = Process (target = self .run_test , args = (81 , 4 ))
221
217
p1 .start ()
218
+ self .get_tempesta ().start ()
219
+ while not self .get_tempesta ().is_running ():
220
+ pass
222
221
p2 .start ()
223
222
p2 .join ()
224
223
p1 .terminate ()
@@ -242,13 +241,15 @@ async def handler(self, websocket, path):
242
241
class Wss_ping (Ws_ping ):
243
242
244
243
def run_test (self , port , n ):
245
- time .sleep (2.0 )
246
244
asyncio .run (self .wss_ping_test (port , n ))
247
245
248
246
def test_ping_websockets (self ):
249
247
p1 = Process (target = self .run_ws , args = (8099 ,))
250
248
p2 = Process (target = self .run_test , args = (82 , 4 ))
251
249
p1 .start ()
250
+ self .get_tempesta ().start ()
251
+ while not self .get_tempesta ().is_running ():
252
+ pass
252
253
p2 .start ()
253
254
p2 .join ()
254
255
p1 .terminate ()
@@ -273,6 +274,9 @@ def test_ping_websockets(self):
273
274
p1 = Process (target = self .run_ws , args = (8099 , 1 , True ))
274
275
p2 = Process (target = self .run_test , args = (82 , 4 ))
275
276
p1 .start ()
277
+ self .get_tempesta ().start ()
278
+ while not self .get_tempesta ().is_running ():
279
+ pass
276
280
p2 .start ()
277
281
p2 .join ()
278
282
p1 .terminate ()
@@ -287,13 +291,15 @@ class Wss_stress(Wss_ping):
287
291
}
288
292
289
293
def run_test (self , port , n ):
290
- time .sleep (2.0 )
291
294
asyncio .run (self .wss_ping_test (port , n ))
292
295
293
296
def test_ping_websockets (self ):
294
297
p1 = Process (target = self .run_ws , args = (8099 , 8 ))
295
298
p2 = Process (target = self .run_test , args = (82 , 400 ))
296
299
p1 .start ()
300
+ self .get_tempesta ().start ()
301
+ while not self .get_tempesta ().is_running ():
302
+ pass
297
303
p2 .start ()
298
304
p2 .join ()
299
305
p1 .terminate ()
0 commit comments