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

Enable different sessions for different users #81

Closed
obecker opened this issue Jun 19, 2013 · 2 comments
Closed

Enable different sessions for different users #81

obecker opened this issue Jun 19, 2013 · 2 comments

Comments

@obecker
Copy link

obecker commented Jun 19, 2013

As it seems the current version uses the same client for all users, thus all users share the same session.

For testing the behavior of a webapp with say 100 concurrent user sessions, the client sessions in locust should be distinct. Additionally it should be possible to identify the current user or client. Our requirement is that each user uses a distinct login name in the login logic in on_start()

Or did I miss something and this is already doable?

@bogdangherca
Copy link

Hello!

All users share the same test scenario or locustfile, but this doesn't imply that all users share the same session.

You could implement the logic for session in your locustfile. If you want your client sessions to be distinct I suppose you could do something like this:

# locustfile.py

import random
from locust import Locust, TaskSet, task

# load user credentials from file
user_credentials = read_user_credentials_from_file()

class MyTasks(TaskSet):
    def on_start(self):
        credentials = random.choice(user_credentials)
        self.client.post("/login/", {"username":credentials[0], "password":credentials[1]})

    @task
    def some_task(self):
        ...

class MyLocust(Locust):
    task_set = MyTasks

@obecker
Copy link
Author

obecker commented Jun 19, 2013

I'm sorry, my fault.
Thanks for your quick reply.
Cheers,
Oliver

@obecker obecker closed this as completed Jun 19, 2013
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

2 participants