Problem
You want to simulate a realistic load test where every user is having a unique user session. You application may only accept one user login per account at a time. You want each concurrent user to pick a different login password.
It’s way more realistic to simulate concurrent users using unique logins and passwords because it’s closer to the real world load. It’s a good practice to avoid using a single user login and password for all concurrent users. Typically, web servers create web sessions per account. Using a single account for multiple users can mess up things on server side pretty quickly.
Solution
JMeter provides a facility to manage login and password: CSV Dataset Config. By defining a CSV file containing all the login and password couples, JMeter can pick a line from the file on each user iteration and assign them into variables. This is fairly straightforward, I’m going to explain how:
- First, create a csv file containing a couple of logins and passwords. Example: CSVSample_user.csv.
|
|
- Then, in JMeter create a CSV Dataset Config under the Thread Group,
- Configure CSV Dataset in All Threads sharing mode to ensure each thread is picking a new csv line,
- Finally, create an HTTP Sampler and ${USERNAME} as username, and ${PASSWORD} as password.
The screenshot below shows the example configuration in JMeter.
Can you please answer how to do multiple login in an ajax request. Can it be done by using csv or some other way??
In reply to Kiran Vishwakarma
Hi Kiran, Sure the same way as a regular HTTP request.
I want to do the Login page concurrent test with 100 users.When I add the 100 dummy login details app says there are no particular user in the system.How should I handle this?
In reply to Gayomi
Hi Gayomi,
I’m not sure to understand your issue. You should try to ask your question on StackOverflow.
Hello,
I’ve been using this method for quite a while now, but I’ve always had an issue with it, which became rather critical lately. I have several test plans that run multiple thread groups in parallel (such as a read thread and a write thread). Within such a test plan, I have a CSV data set config fetching a list of test users and their passwords, and an HTTP authorization manager to authenticate each user.
In one of the thread groups, it is absolutely crucial to not have more than 1 thread running for the same user. Imagine a chain of operations that has to be performed in a specific order, without skipping or inserting steps in between. If this thread ran more than 1 thread with the same username, it would mess up the order and all hell would break lose (spoiler: this is exactly what happens).
What I have an issue with is, when the thread group creates several threads to run in parallel, it seems to pick from a random username from the CSV file, instead of going sequentially down the list. What happens then is that very often, the same user is authenticated more than once for that crucial thread group that I mentioned earlier, which is something I absolutely must avoid happening. I suspect that this has something to do with the test plan running more than 1 thread group in parallel, while using the same authorization manager. The problem is, I cannot isolate the authentication in these separate thread groups. The only solution I have so far is to run two different instances of JMeter with 1 thread group each, but this is less than optimal, especially for larger test plans.
In reply to Viktor
Hi Viktor, Thanks for your insight and sharing your particular struggles! Handling unique logins with JMeter can be particularly difficult because it doesn’t manage login uniqueness. We have partially solved this issue by splitting CSV accross multiple load generators when running large scale load tests. We also run only a single thread group per JMeter instance, to avoid interleaving between different scripts.
I am wondering if there is a way in jmeter to know which unique data we have used in a csv file to avoid creating more data each test
Thanks for this article! I configured it and added the users.csv (tab delimited, separated with quotes). In the HTTP sampler my request body looked like:
loginForm=loginForm&submitButton=&uname=%22myuser%22&upass=%22mypassword%22
To eliminate the unwanted %22 characters, in my CSV Data Set Config, I set “File Encoding = UTF-8” and “Allow quoted data = true”.