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

Does locust support ‘CSV Data Set Config‘ feature like jmeter #79

Closed
foxracle opened this issue Jun 5, 2013 · 4 comments
Closed

Comments

@foxracle
Copy link

foxracle commented Jun 5, 2013

I am newcomer from Jmeter background, I want to get some help.

just like the example in [Quick start] section in doc of locust,
how could I share the thousands of pairs of userid and password between all threads like jmeter do?
Does locust support ‘CSV Data Set Config‘ feature like jmeter?

@heyman
Copy link
Member

heyman commented Jun 5, 2013

Hi!

Locust tests are essentially just python code so you just need to write code that reads your CSV file. For example, you could put this code at the module level in your load testing scripts. Here's a small pseudo code example:

# locustfile.py

import random
from locust import Locust, TaskSet, task

# load user credentials from CSV
user_credentials = read_user_credentials_from_csv()

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

@foxracle
Copy link
Author

foxracle commented Jun 6, 2013

thank you very much, I will try it

@foxracle foxracle closed this as completed Jun 6, 2013
@weitzman
Copy link

Just in case anyone stumbles upon this, there is a longer blog post on this topic at https://www.blazemeter.com/blog/how-to-run-locust-with-different-users/

@atmanishk
Copy link

user_credentials = read_user_credentials_from_csv()

can you please provide code for "read_user_credentials_from_csv()" function too.

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

4 participants