Reputation: 185
I want to simulate a user with 2 http request and 1 http request multiple times via csv file. Below is my structure
Test Plan
- Thread Group *[No. of threads = 2, Ramp-up = 1, Loop count = 1]*
- - View Results Tree
- - Simple Controller
- - - http request 1
- - - http request 2
- - - while controller *[condition = ${no} (variable from csv file)]*
- - - - http request 3
- - - - CSV Data set Config *[Recycle on EOF = False, Stop on EOF = False, Sharing Mode = All threads] and CSV file has 3 records*
Expected: 1 user should execute
http request 1, http request 2, http request 3, http request 3, http request 3 (since csv has 3 records)
But can't simulate as per my expectation. Any help would be appreciated. Thanks.
Upvotes: 1
Views: 3010
Reputation: 168002
Amend your While Controller condition to look like:
${__jexl3("${myVar}" != "<EOF>",)}
Put your CSV Data Set Config as a child of the While Controller and configure it as follows:
Add If Controller after the CSV Data Set Config and use the same __jexl3() function as the condition:
That's it, you should be able to run your script and get the number of executions equal to the number of lines in the CSV file:
Upvotes: 1
Reputation: 1821
It was possible to achieve your objective
http request 1, http request 2, http request 3, http request 3, http request 3 (since csv has 3 records)
With following configuration in the CSV Data Set Config
Following condition was set in the While controller.
${__jexl3("${UNAME}"!="<EOF>")}
Where UNAME is a column name
Since the condition is executed in while controller additional condition check was necessary before executing the http request 3
Please see the structure of the control in the following.
Hope this is useful
Also it is possible repeat the test with several iterations with following modifications. Added a JSR223 Sampler for resetting the variable and add text EOF to the end of the CSV file.
Sample JMeter test plan and CSV file are available in the GitHub.
Upvotes: 3