Multiple User Login Using JMeter

Multiple User Login Using JMeter

Jmeter   6 Amazing Comments

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.
jsmith,passw0rd
jdoe,secret
  • 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.

JMeter CSV Dataset Config

Remember to copy the CSV file to each load generator before running a distributed test. Also, make sure the file is located at the same place on each load generator.

By - CTO.
Tags: Design Variable Csv

Comments

Kiran Vishwakarma  

Can you please answer how to do multiple login in an ajax request. Can it be done by using csv or some other way??
Reply

Jerome
In reply to Kiran Vishwakarma
 

Hi Kiran, Sure the same way as a regular HTTP request.

Gayomi  

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

Jerome
In reply to Gayomi
 

Hi Gayomi,

I’m not sure to understand your issue. You should try to ask your question on StackOverflow.

Viktor  

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.

Reply

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

Thank you

Your comment has been submitted and will be published once it has been approved.

OK

OOPS!

Your post has failed. Please return to the page and try again. Thank You!

OK