addon to make locust.io work with tcp sockets
to test addon:
- Get locust.io
pip install locustio
- Run tcp server (it will run on port 8888)
python tcp_server
- Run locust with provided sample
locust -f locustfile.py
All configurations like host, port can be done in locustfile.
Socket client has only one function send_bytes
By default every response considered as successful. In case response need to be validated set attribute catch_response=True and handle:
response = self.client.send_bytes(request_name='get yes', input=b'get yes', catch_response=True)
data = response.data.decode('utf-8')
if data == 'yes':
response.success()
else:
response.failure(f'response is {data}')
- Response data received in bytes and need to be converted first
- TCP client has dirty hack time.sleep(1) It is done to make sure complete response from server received. If you don't experience any issues just remove it