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?
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
thank you very much, I will try it
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/
Most helpful comment
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: