currently I have started working with Locust. I follow the class-picker docs and practice with a simple test, but quickly realized that every time I increase the number of users during the test, Locust will reset the statistics table. Besides, Locust behevior of ramping up users is quite strange: instead of increasing from 2 users to 5 users, it set the number of users to 0 first and then increase to 5. Is that an obvious thing when running Locust in class-picker mode?
Here is test.py
from locust import HttpUser, constant, task
class MyReqRes1(HttpUser):
wait_time = constant(1)
host = "http://example.com"
@task
def get_users(self):
res = self.client.get("/hello")
print(res.status_code)
class MyReqRes2(HttpUser):
wait_time = constant(1)
host = "http://example.com"
@task
def get_users(self):
res = self.client.get("/world")
print(res.status_code)
And here is my command to run:
locust -f test.py --class-picker
I am trying to keep Locust ramping up users normally (the way it do without --class-picker arguments) and keep the statistic table as well.
The user class UI picker is designed to let you choose a user class to use for the test run. This means that user class will be used for the whole duration of the test. If you want to choose a different user class, you need to start a new test which results in the behavior you described: Locust stops all currently running users, resets the stats, switches user classes, starts the new test by spawning new users at your defined spawn rate to reach the number of desired users.
In other words, it's designed to let you have multiple different test scenarios defined in the same file and let you choose the one you want at run time.
The user class UI picker does not allow you to choose one user class, start a test and get X number of users, choose another class, add Y users, choose another class, add Z users, end up with X+Y+Z running users, which sounds like what you're trying to do. There is not currently a way to accomplish that.
Of course, you're welcome to put together a pull request with that kind of behavior and it can be reviewed and perhaps included in a future version.