Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upcustom client from locust documentation doesn't work at all #771
Comments
This comment has been minimized.
This comment has been minimized.
|
I have found several bugs related to problem above. Also I have working code. First of all you guys must investigate these problems and take action is this a bug or outdated wiki. ProblemsExample from https://docs.locust.io/en/latest/testing-other-systems.html#sample-xml-rpc-locust-client does not work.
Wrapper from documentation example
|
This comment has been minimized.
This comment has been minimized.
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. |
This comment has been minimized.
This comment has been minimized.
|
Yeah, brutally yes, that I meant ;) So If I will be able to find additional time I will do some update to the docs. Cheers! |
This comment has been minimized.
This comment has been minimized.
|
@JaniszM If you name the inlined class |
This comment has been minimized.
This comment has been minimized.
|
@heyman Unfortunatelly not. Looks like scope of the inner class in python has nothing to do with super class. |
This comment has been minimized.
This comment has been minimized.
|
@JaniszM I just tested, and the following code works perfectly fine for me: from locust import HttpLocust, TaskSet, task
class WebsiteUser(HttpLocust):
host = "http://127.0.0.1:8089"
min_wait = 2000
max_wait = 5000
class task_set(TaskSet):
@task
def page404(self):
self.client.get("/does_not_exist")
@task
def index(self):
self.client.get("/")
@task
def stats(self):
self.client.get("/stats/requests") |
This comment has been minimized.
This comment has been minimized.
|
Thats weird. Maybe this is matter of python version? |
This comment has been minimized.
This comment has been minimized.
|
Not updated for a long time? Closing this as could not reproduce. |


Looks like while implementing custom client like
HttpLocustwhen adding inlineTaskSetclass toLocustinline 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_setshould 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:
Class
ApiMessageUserthat setstask_set = ApiMessageclass attribute is loaded and executed correctly but classApiVehicleUserwhich is inline class is not loaded. No error is raised neither.Environment settings (for bug reports)
Steps to reproduce (for bug reports)
Bellow is a snippet of the locust file:
The thing is that I must have
HttpLocustandwebsocketclient at one Locust class to combine tests. If I uncomment# task_set = ApiVehiclethenApiVehicletaks 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 thatApiVehiclewill 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 = ApiVehicleand 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
@taskdecorator to inline class, nothing works.