I am engaged on efficiency testing a multi-tenant utility utilizing Apache JMeter. I wish to simulate load coming from three completely different shoppers, the place every consumer’s knowledge is saved in a separate CSV file. The load must be distributed like this:
- Shopper 1: 60%
- Shopper 2: 30%
- Shopper 3: 10%
All CSV information have the identical construction (columns), however comprise completely different knowledge per consumer.
My Purpose:
I need every thread to randomly and proportionally decide knowledge from the suitable CSV file based mostly on the chances above and use it within the HTTP requests with out knowledge overlap or inconsistency.
What I Tried:
Strategy 1: Dynamically set file path utilizing a variable
My Jmeter Take a look at Plan construction is,
Take a look at Plan
|-- Person Outlined Variables
|-- CSV Information Set Config
|-- Stepping Thread Group
|-- |-- JSR223 PreProcessor
|-- |-- HTTP Request Sampler 1
|-- |-- HTTP Request Sampler 2
|-- |-- HTTP Request Sampler n
|-- View End result Tree
|-- Abstract Report
Within the Take a look at Plan, I’ve a variable path outlined in Person Outlined Variables as:
path = D:/jmeter/undertaking
I then set the Filename in CSV Information Set Config to ${csvFile}.
Inside a JSR223 PreProcessor, I attempted setting the csvFile variable like this:
def randomValue = Math.random()
if (randomValue < 0.6) {
vars.put('csvFile', "${path}/file1.csv")
} else if (randomValue < 0.9) {
vars.put('csvFile', "${path}/file2.csv")
} else {
vars.put('csvFile', "${path}/file3.csv")
}
The problem is, despite the fact that csvFile will get set appropriately within the JSR223 PreProcessor, the CSV Information Set Config does not decide up the worth dynamically.
Strategy 2: Dynamically set file path utilizing a variable and place the CSV Information Set Config after the JSR223 PreProcessor
My Jmeter Take a look at Plan construction is,
Take a look at Plan
|-- Person Outlined Variables
|-- Stepping Thread Group
|-- |-- JSR223 PreProcessor
|-- |-- CSV Information Set Config
|-- |-- HTTP Request Sampler 1
|-- |-- HTTP Request Sampler 2
|-- |-- HTTP Request Sampler n
|-- View End result Tree
|-- Abstract Report
Nonetheless the end result is similar as in Strategy 1.
I believe it is as a result of execution order, as JMeter processes the CSV Information Set Config earlier than the PreProcessor runs.
My Query:
What’s the appropriate method in JMeter to:
- Dynamically and proportionally distribute threads throughout a number of CSV information
- Guarantee clear separation of information per thread (no variable conflicts)
- Keep away from knowledge overlap or race situations between threads
Notice: I can not share precise screenshots or undertaking information as a consequence of employer restrictions, however I am in search of a JMeter-safe and scalable option to simulate this type of weighted load throughout shoppers utilizing separate CSV information or something different suggestion for tackling this concern.
Any concepts or suggestions for managing this successfully?
