forked from Super-Ps/locustWebsocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testLocustB.py
42 lines (27 loc) · 1.03 KB
/
testLocustB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from locust import Locust ,events ,task,TaskSet
from testLocustA import WebSocketClient
import json
with open('./command.json', mode='r', encoding= 'utf-8') as f:
command = json.load(f)
command_data = (command['mcore'][1], command['mcore'][2])
class WebsocketLocust(Locust):
def __init__(self, *args, **kwargs):
super(WebsocketLocust, self).__init__(*args, **kwargs)
self.client = WebSocketClient(self.host)
class SupperDianCan(TaskSet):
@task
def test_baidu(self):
self.url = 'ws://arduinoserver-test.makeblock.com/socket.io/?transport=polling&EIO=3&t=1573719118.613421'
self.data = command_data
self.client.connect(self.url)
while True:
recv = self.client.recv()
print('####',recv)
# if eval(recv)['type'] == 'keepalive':
# self.client.send(recv)
# else:
self.client.send(self.data)
class WebsiteUser(WebsocketLocust):
task_set = SupperDianCan
min_wait=5000
max_wait=9000