You need to create a different thread with unique session for each user? Learn how to use different logins per user with a CSV file. design , variable , csv https://octoperf.com/blog/2017/12/14/multiple-user-login-jmeter/ OctoPerf ZI Les Paluds, 276 Avenue du Douard, 13400 Aubagne, France +334 42 84 12 59 contact@octoperf.com Jmeter 255 2021-01-04

Multiple User Login Using JMeter

OctoPerf is JMeter on steroids!
Schedule a Demo

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.
1
2
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.

Multiple User Login Using JMeter
Tags:
Share:
Comments (8)
  • 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
  • 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
  • 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
    • 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

    Reply
  • 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”.

    Reply
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

Want to become a super load tester?
OctoPerf Superman