Skip to content
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

run each task in sequence #311

Closed
ghost opened this issue Aug 3, 2015 · 13 comments
Closed

run each task in sequence #311

ghost opened this issue Aug 3, 2015 · 13 comments

Comments

@ghost
Copy link

ghost commented Aug 3, 2015

Is there a way to run each task in a sequence, instead of being chosen randomly?

@vividhsv
Copy link

You can't have tasks run in a sequence. However, you can make multiple requests within the same task which would be run sequentially.

@abslodov
Copy link

Does anyone know if there's a tool like Locust that allows for sequential task running? That would be hugely useful...

@sp1rs
Copy link

sp1rs commented Aug 24, 2015

@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..

@giantryansaul
Copy link
Contributor

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.

@abslodov
Copy link

@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 ?

@giantryansaul
Copy link
Contributor

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))

@ghost
Copy link
Author

ghost commented Aug 26, 2015

I raised this issue, and as far as I am concerned @giantryansaul offers a reasonable solution.

@ghost ghost closed this as completed Aug 26, 2015
@javivdm
Copy link

javivdm commented Sep 14, 2017

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!

@giantryansaul
Copy link
Contributor

@javivdm The waits are applied to the tasks, so you can use sleep functions to specify waits between the requests.

@wessel-techtribe-nl
Copy link

wessel-techtribe-nl commented Jan 26, 2018

This issue #171 mentions sorting the tasks and overriding the get_task method to do it sequentially

@heyman
Copy link
Member

heyman commented Jan 26, 2018

@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)

@aslam7
Copy link

aslam7 commented Nov 20, 2018

https://docs.locust.io/en/stable/writing-a-locustfile.html#tasksets-can-be-nested

@shankar96
Copy link

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?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants