Search code examples
jmeterbeanshell

Alternatives to using CSV in JMeter (for generating usernames)


I have a JMeter Test Plan with following structure

Test Plan

**ThreadGroup1**
--CSV Data Config-001
----SimpleController
--------------LoginRequest
--------------Action-abc-Request

**ThreadGroup2**
--CSV Data Config-002
----SimpleController
--------------LoginRequest
--------------Action-xyz-Request

I have two CSV files which contain list of users like this..

**CSV-001**
Username1
Username2
.. ..
Username50

**CSV-002**
Username51
Username52
.. ..
Username100

In my scenario, I need to run a load test with say 100 users. 50 users login from ThreadGroup1 and other 50 users login from ThreadGroup2. Users from both threadgroups login simultaneously.

Currently, I have to go through process of manually creating/editing these CSV files whenever I change the number of total users.

Please suggest if there are any alternative time-saving & performance-efficient approaches through I which can fulfill my scenario requirements (without using CSV files).

I will appreciate, if you can explain the alternative solution with some details as I am quite new to JMeter stuff. Thanks.


Solution

  • Another idea is to use

    Username${__threadNum}

    for the first thread group and

    Username${__BeanShell(ctx.getThreadNum()+Z+1)}

    for the second, where Z equals the total number of threads in thread group 1. You also need to add 1 since ctx.getThreadNum() returns a thread number using a 0 based index, whereas the __threadNum function is 1 based.