custom client from locust documentation doesn't work at all
See original GitHub issueLooks like while implementing custom client like HttpLocust
when adding inline TaskSet
class to Locust
inline class is not loaded by Locust.
Expected behaviour
Any inline class should be executed by Locust.
According to https://docs.locust.io/en/latest/testing-other-systems.html#sample-xml-rpc-locust-client class task_set
should be loaded by Locust and all tasks in this class should be executed.
Actual behavior
I have implemented websocket client following this documentation. I have two Locust classes in one file loaded by locust and executed by:
locust -f locustfiles/api_load_tests.py --host=https://my_ip--csv=${report_dir}/report_data --no-web -c ${NUM_CLIENTS} -r ${HATCH_RATE} # ApiVehicleUser ApiMessageUser
Class ApiMessageUser
that sets task_set = ApiMessage
class attribute is loaded and executed correctly but class ApiVehicleUser
which is inline class is not loaded. No error is raised neither.
Environment settings (for bug reports)
- OS: Ubuntu 16.04.4 LTS
- Python version: Python 3.5.2
- Locust version: Locust 0.8
Steps to reproduce (for bug reports)
Bellow is a snippet of the locust file:
class BtsLocust(Locust):
"""
Provides an Http and websocket clients.
"""
def __init__(self, *args, **kwargs):
super(BtsLocust, self).__init__(*args, **kwargs)
self.ws_client = locust_ws_client.LocustWebSocketClient(self.host) # this is wrapper like `XmlRpcClient` class
class ApiVehicleUser(BtsLocust):
# task_set = ApiVehicle
min_wait = 500
max_wait = 500
@task
class ApiVehicle(TaskSet):
def on_start(self):
# some setup
def on_stop(self):
# some clean up
@task
def here_goes_my_tasks_for_ApiVehicle(self):
# some setup
class ApiMessage(TaskSet):
def on_start(self):
# some setup
@task
def here_goes_my_tasks_for_ApiMessage(self):
# some setup
class ApiMessageUser(HttpLocust):
task_set = ApiMessage
min_wait = 500
max_wait = 500
The thing is that I must have HttpLocust
and websocket
client at one Locust class to combine tests. If I uncomment # task_set = ApiVehicle
then ApiVehicle
taks set cannot access to websocket client because for some it is not inherited (and HttpLocust is). So there are few problems over here but the main is mentioned above. So assuming that ApiVehicle
will be loaded into Locust all should be fine.
Extra ideas
If anyone have idea how to integrate these two clients using even workarounds I would be glad to do this. I tried to set task_set = ApiVehicle
and pass ws_client from outside by __init__
methods but this is messing up too much in Locust super-class and causes too much problems.
I have tried also to add @task
decorator to inline class, nothing works.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
by “you guys”, do you mean the small group of unpaid volunteers helping to maintain the project that provided free software for you?
If so, a quicker option would be for you to step up and take action. The documentation is part of the codebase, and I’d be happy to review a Pull Request with your proposed changes.
@JaniszM If you name the inlined class
task_set
- like it is in the documentation - I think it should work.