-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have the ability to run one task once to test it #1950
Comments
There are a couple of options, either run a single User in the debugger (using locust-plugins): https://github.com/SvenskaSpel/locust-plugins/blob/master/examples/debug_ex.py Or (again using locust-plugins) use |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
Fixed in #1985, released in 2.7.0 |
motion to reopen, therefore I don't see how 1985 soles the need to test locust tasks. i'm looking for more of an # ...
import inspect
import locust
import locust.util.load_locustfile
# collect all classes like locust does
all_user_classes_this_file = [ i[1] for i in inspect.getmembers(sys.modules[__name__]) if inspect.isclass(i[1]) and locust.util.load_locustfile.is_user_class(i)]
# define a new run function that only schedules each task one time total
class MyOnceHttpUser(locust.HttpUser):
def run(self): # bad & broken run implementation, do not use, lost of missing error handling
self.on_start()
for i in self.user.tasks:
self.schedule_task(i)
while self._task_queue:
self.execute_next_task()
self.on_stop()
# run each http task one time
for user_class in all_user_classes_this_file:
MyOnceHttpUser.run(user_class) while poking around, I noticed there is a SequentialHttpTask class, i didin't look at its run method but maybe it would help provide this requested battery. |
Is your feature request related to a problem? Please describe.
I am coming from funkload, where you basically create a script that can be also executed once to test your code. This is especially necessary when you are creating a complex user journey including e.g. login, selection of some pages, addition to basket and full checkout. As far as I see right now, I would have to start locust for any change I am doing and then executing it with one user? Maybe I didn't get it right. I would prefer to have the ability to just execute a specific task once, so I can also check any logs on the target system.
Describe the solution you'd like
I assume the easist would be to have a parameter
--run-once
or similar, which would run every task only once. And optimally an additional parameter--run-task
that takes the name of a task to run.Describe alternatives you've considered
As mentioned, I guess the only alternative at the moment is to run with 1 user and stop the script after some seconds.
Additional context
This request is basically about debugging posibilities for locust script, especially when they become more complex.
The text was updated successfully, but these errors were encountered: