Is there a way to run each task in a sequence, instead of being chosen randomly?
You can't have tasks run in a sequence. However, you can make multiple requests within the same task which would be run sequentially.
Does anyone know if there's a tool like Locust that allows for sequential task running? That would be hugely useful...
@vividhsv why cannot we not add functionality like sequence task ? ..
like weight attribute , we can also have sequence number like attribute ?
I think it can be possible..
I have had similar issues in the past where the sequence of events needs to be correct to accurately measure performance for a business case. To make tasks more readable, you can break them down into separate methods without the @task decorator and have a single task control the sequence of events. Locust still reports each request made, whether you put those requests into single tasks or not.
@heyman @HeyHugo @cgbystrom @Jahaja can we get this added as a feature?
Would this be difficult to just accomplish on a fork @giantryansaul @vividhsv @sp1rs ?
I think I meant more that your task can define the entire workflow and not just a single request. You would not need a fork of locust to accomplish this. Here is an example:
class UserWorkflow(TaskSet):
def on_start(self):
self.login()
def login(self):
self.client.post("/login", {"username":"jack_sparrow", "password":"blackpearl"})
@task(1)
def user_workflow(self):
self.load_home_page()
self.get_list_of_posts()
self.get_single_post(123)
def load_home_page(self):
self.client.get("/")
def get_list_of_posts(self):
self.client.get("/posts")
def get_single_post(self, post_id):
self.client.get("/posts/{}".format(post_id))
I raised this issue, and as far as I am concerned @giantryansaul offers a reasonable solution.
When you put multiple requests under the same task as showed above, is the min and max wait still applied to each request or does it only apply to each task?
From the documentation I understand that the waits are only applied to each task. Therefore, is there a way to run requests sequentially and still have the waits applied to each request?
Thanks!
@javivdm The waits are applied to the tasks, so you can use sleep functions to specify waits between the requests.
This issue https://github.com/locustio/locust/issues/171 mentions sorting the tasks and overriding the get_task method to do it sequentially
@javivdm You can make a Locust user sleep between making requests in the same task by manually calling self.wait() within your task.
(Super late reply, but posting it for anyone else who might have the same question)
You can't have tasks run in a sequence. However, you can make multiple requests within the same task which would be run sequentially.
How to do so?
Most helpful comment
I think I meant more that your task can define the entire workflow and not just a single request. You would not need a fork of locust to accomplish this. Here is an example: