Sharing mode of CSV Data Set Config

Parameterization in JMeter script is handled by the CSV Data Set Config element. CSV Data Set Config provides the easiest way to call the external CSV (Comma Separated Values) file which contains parameter values. But the confusion starts when a single CSV file is shared between multiple thread groups, threads and requests and we do not know how the test data will be distributed among them. This may also lead to the wrong calculation of the required test data. To predict the correct test data requirement and use the test data wisely, it is necessary to understand the sharing modes of CSV Data Set Config element in JMeter.

Let’s try to understand the sharing modes of CSV Data Set Config with an example.

Example:

Consider, there is one CSV file (say “perfTestData.csv”) having 10 values which are:

CSV Data Set Config Sharing Mode 01
Figure 01: CSV Data Set Config File

And the test scenario has following metrics:

  1. No. of Thread Groups: 2
  2. No. of threads in each Thread Group: 2
  3. No. of iterations in each Thread Group: 2
  4. No. of occurrence of the parameter in each iteration: 2. Refer the figure 02.
  5. All request samplers have ${perfVar} parameter which is defined as a variable in the “CSV Data Set Config” element. Refer the figure 03.
CSV Data Set Config Sharing Mode 02
Figure 02: JMeter Scenario
CSV Data Set Config Element 06
Figure 03: CSV Data Set Config Element

Let’s run the script by selecting the different sharing mode one-by-one:

1. Sharing Mode: All Threads

In this mode, Thread Groups share the value of the CSV file. A new value of the parameter is passed in each iteration, by each thread and thread group.

Key Points: 
1. Each thread group, thread, and iteration will have a separate value.
2. The parameter value will be shared at occurrence level i.e. if more than one parameter occurrences in the same iteration then the same value will be passed.

Thread Group 1:
ThreadNum 1 -> Iteration 1 -> Request 1 -> perfVar = 2011
ThreadNum 1 -> Iteration 1 -> Request 2 -> perfVar = 2011
ThreadNum 1 -> Iteration 2 -> Request 1 -> perfVar = 2012
ThreadNum 1 -> Iteration 2 -> Request 2 -> perfVar = 2012

ThreadNum 2 -> Iteration 1 -> Request 1 -> perfVar = 2013
ThreadNum 2 -> Iteration 1 -> Request 2 -> perfVar = 2013
ThreadNum 2 -> Iteration 2 -> Request 1 -> perfVar = 2014
ThreadNum 2 -> Iteration 2 -> Request 2 -> perfVar = 2014

Thread Group 2:
ThreadNum 1 -> Iteration 1 -> Request 1 -> perfVar = 2015
ThreadNum 1 -> Iteration 1 -> Request 2 -> perfVar = 2015
ThreadNum 1 -> Iteration 2 -> Request 1 -> perfVar = 2016
ThreadNum 1 -> Iteration 2 -> Request 2 -> perfVar = 2016

ThreadNum 2 -> Iteration 1 -> Request 1 -> perfVar = 2017
ThreadNum 2 -> Iteration 1 -> Request 2 -> perfVar = 2017
ThreadNum 2 -> Iteration 2 -> Request 1 -> perfVar = 2018
ThreadNum 2 -> Iteration 2 -> Request 2 -> perfVar = 2018

Figure 04: Sharing Mode – All Threads

2. Sharing Mode: Current Thread Group

In this mode, Thread Groups use the same set of values but different values are used by each thread within the thread group. To make the statement simple for understanding purpose, 2 copies of CSV files are created at Thread Group level. Each thread within a thread group picks a new value from their own copy of CSV file every time.

Key Points: 
1. Each thread group has the same set of values.
2. Each thread and iteration will have a separate value.
3. The parameter value will be shared at occurrence level too i.e. if more than one parameter occurrences in the same iteration then the same value will be passed.

Thread Group 1:
ThreadNum 1 -> Iteration 1 -> Request 1 -> perfVar = 2011
ThreadNum 1 -> Iteration 1 -> Request 2 -> perfVar = 2011
ThreadNum 2 -> Iteration 1 -> Request 1 -> perfVar = 2012
ThreadNum 2 -> Iteration 1 -> Request 2 -> perfVar = 2012

ThreadNum 1 -> Iteration 2 -> Request 1 -> perfVar = 2013
ThreadNum 1 -> Iteration 2 -> Request 2 -> perfVar = 2013
ThreadNum 2 -> Iteration 2 -> Request 1 -> perfVar = 2014
ThreadNum 2 -> Iteration 2 -> Request 2 -> perfVar = 2014

Thread Group 2:
ThreadNum 1 -> Iteration 1 -> Request 1 -> perfVar = 2011
ThreadNum 1 -> Iteration 1 -> Request 2 -> perfVar = 2011
ThreadNum 2 -> Iteration 1 -> Request 1 -> perfVar = 2012
ThreadNum 2 -> Iteration 1 -> Request 2 -> perfVar = 2012

ThreadNum 1 -> Iteration 2 -> Request 1 -> perfVar = 2013
ThreadNum 1 -> Iteration 2 -> Request 2 -> perfVar = 2013
ThreadNum 2 -> Iteration 2 -> Request 1 -> perfVar = 2014
ThreadNum 2 -> Iteration 2 -> Request 2 -> perfVar = 2014

CSV Data Set Config Sharing Mode
Figure 05: Sharing Mode – Current Thread Group

3. Sharing Mode: Current Thread

In this mode, Threads use the same set of values but different values are used within the iteration. To make the statement simple for understanding purpose, separate copies of CSV files are created at the Thread level. But each iteration within a thread picks a new value from their own copy of CSV file every time.

Key Point: 
1. Each thread has the same set of values.
2. Each iteration will have a separate value.
3. The parameter value will be shared at occurrence level too i.e. if more than one parameter occurrences in the same iteration then the same value will be passed.

Thread Group 1:
ThreadNum 1 -> Iteration 1 -> Request 1 -> perfVar = 2011
ThreadNum 1 -> Iteration 1 -> Request 2 -> perfVar = 2011
ThreadNum 2 -> Iteration 1 -> Request 1 -> perfVar = 2011
ThreadNum 2 -> Iteration 1 -> Request 2 -> perfVar = 2011

ThreadNum 1 -> Iteration 2 -> Request 1 -> perfVar = 2012
ThreadNum 1 -> Iteration 2 -> Request 2 -> perfVar = 2012
ThreadNum 2 -> Iteration 2 -> Request 1 -> perfVar = 2012
ThreadNum 2 -> Iteration 2 -> Request 2 -> perfVar = 2012

Thread Group 2:
ThreadNum 1 -> Iteration 1 -> Request 1 -> perfVar = 2011
ThreadNum 1 -> Iteration 1 -> Request 2 -> perfVar = 2011
ThreadNum 2 -> Iteration 1 -> Request 1 -> perfVar = 2011
ThreadNum 2 -> Iteration 1 -> Request 2 -> perfVar = 2011

ThreadNum 1 -> Iteration 2 -> Request 1 -> perfVar = 2012
ThreadNum 1 -> Iteration 2 -> Request 2 -> perfVar = 2012
ThreadNum 2 -> Iteration 2 -> Request 1 -> perfVar = 2012
ThreadNum 2 -> Iteration 2 -> Request 2 -> perfVar = 2012

CSV Data Set Config Sharing Mode 05
Figure 06: Sharing Mode – Current Thread

4. Sharing Mode: Edit

This mode provides a facility to share the CSV file between the specific thread group only. Let’s consider, there are 4 thread groups and you want to share the test data between Thread Group 1 and Thread Group 4 only. Rest of the thread groups will use the file independently then you need to choose this ‘Edit’ option under the ‘Sharing mode’ config element and write down this statement ‘SharedWithThreadGroup1and4’. Make sure you have specific CSV Data Set for all the thread groups. Refer the figure:

CSV-Data-Set-Config-Sharing-Mode-08
Figure 07: Sharing Mode – Edit

Each CSV Data Set Config will have the following setting:
Thread Group 1: ‘Sharing mode’ = SharedWithThreadGroup1and4’
Thread Group 2: ‘Sharing mode’ = ‘Current Thread’
Thread Group 3: ‘Sharing mode’ = ‘Current Thread’
Thread Group 4: ‘Sharing mode’ = ‘SharedWithThreadGroup1and4’

And, the result is:

CSV-Data-Set-Config-Sharing-Mode-07
Figure 08: CSV Data Set Config – Edit Sharing Mode

A proper use of sharing mode of CSV Data Set Config helps to pass duplicate or unique test data among the different Thread Groups and Threads in the test.


Leave a Reply

Your email address will not be published. Required fields are marked *