How to save response for particle users in output folder in JMeter - jmeter

I created one thread group which has 25 users and a total of 3 samplers.
Here I used ${__threadNum} function to saw which user currently running. here request was not sequentially run. and for saving response/output I used listener 'Save Responses to a file' Here I also used counter to save every user outputs separately but problem is that when we check in output folder the saved output and response showed in the Response body are different actually this output is for another user .. so how to create a setup for every user where response and saved output is same

If you do something like:
textual version just in case:
outputFolder/response-for-user-${__threadNum}-iteration-${__jm__Thread Group__idx}.txt
and run your test with 2 users and 2 iterations you will see the following files generated under the outputFolder (it will be created in "bin" folder of your JMeter installation)
response-for-user-1-iteration-0.txt
response-for-user-1-iteration-1.txt
response-for-user-2-iteration-0.txt
response-for-user-2-iteration-1.txt
Also be aware that it's possible to amend JMeter's Results File Configuration so all the request and response details will be written to .jtl results file, add the next lines to user.properties file:
jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.responseHeaders=true
jmeter.save.saveservice.url=true
or alternatively you can save the request and response data by using any Listener, example setup:
More information: How to Save Response Data in JMeter

Related

JMETER nested while loop is stopping at first line of the CSV data file

I have to make a GET call on IDs stored in a CSV while and I have to retry on GET call till it returns 200 response code.
This is what my current structure looks like ..
GET thread group
Once only controller to grab authentication for each thread
While Controller with condition "${__javaScript("${index}"!="<"EOF">")}" to check for end of the CSV
file
CSV data config file (Each file is unique for each thread) , variable name is "index", Recycle on
EOF - False, Stop thread on EOF - True,
sharing mode - current thread
While Controller with condition "${__javaScript(parseInt(vars.get("Response_code"))!=201)}"
User defined variables - Response_code
Http GET request
JSR233 post processor - "vars.put("Response_code",prev.getResponseCode());"
JSR223 post-processor - To write ID returned in successful call to another CSV file
Now I am not getting error or anything .. but I was expecting first while controller to loop through CSV file for each id, then make a GET request for each id and then second while loop would wait for success code but for some reason, GET call is only executing for the first entry in the csv and then exit out of it. What am I missing here?
CSV data config file (Each file is unique for each thread)
this is not how it works, the CSV Data Set Config is being initialized once with the filename resolved at the time of its execution, it doesn't load the new CSV file for each virtual user.
If you're looking for an option of supplying the CSV file name(s) dynamically in the runtime - consider switching to __CSVRead() function. See How to Pick Different CSV Files at JMeter Runtime article for more details.

How to Save all Responses to a file with loop count more that one?

This is a part of my test plan, and the loop count is 2.However only one set of responses generated
even i select "Add timestamp"
so, how to save data base on loop count ?
If you want to have separate files with the responses for each thread (virtual user) and Thread Group iteration you can use
__threadNum() function
${__jm__Thread Group__idx} pre-defined variable as prefix or postfix for the filename
So given the following configuration:
Here is the textual representation just in case:
user-${__threadNum}-loop-${__jm__Thread Group__idx}-response.txt
You will have the following files:
user-1-loop-0-response.txt
user-1-loop-1-response.txt
user-2-loop-0-response.txt
user-2-loop-1-response.txt
More information: Performance Testing: Upload and Download Scenarios with Apache JMeter

Regarding WebDriver Sampler and Config/Listener Folder Path

While trying to write Webdriver sampler with Config/listener element ,I have below issue ,Could any team assist me for the same?
1:- In config /listener element/webdriver browser setup file , if we want to enter some value from external resource (' or if we want to save summary report in PC, Is there any procedure to give unique path that can be run in any workstation /pc/ any directory after giving file name only because if we execute in other station or move file in other directory, everytime we need to change file location?Could you please guide me for the same?
While writing webdriver sampler request,I am able to execute script but i am getting below error in log viewer window and also wanted to break functionality as very small unit label for one webdriver sampler request{launch site/login successfully,validate record, logout} so after searching on google , i used sub sample start or samplestart function multiple time , but i am not getting label name in view tree listener result after setting one jmeter property. Could you please guide me for the same?
3:- Could we run three thread group at same time(all three thread run at same time) or some interval (first and sec run on same time but third start after 10 minute)
Thanks you for giving valuable time in advance?
Thanks Amit
You can give only the filename and JMeter will look for the CSV file and write results file into JMeter's "bin" folder (or the place where you launched JMeter from). You can also use __P() function to parameterize the file name or even path, for example if you do set your CSV Data Set Config like:
${__P(testdata,TestData.csv)}
you will be able to override the path using -J command-line argument like:
jmeter -Jtestdata=/path/to/somefile.csv
If you don't provide the property, default value of TestData.csv will be used. More information: Apache JMeter Properties Customization Guide
You're getting this "Invalid call sequence" error because you have duplicate WDS.sampleResult.sampleStart() function call, just remove one of them and that would be it.
Add a Constant Timer as a child of the first request or Flow Control Action sampler at the beginning of the Thread Group 3 and configure them to sleep for 600000 milliseconds.

JMeter - Hitting specific endpoints based on user credentials via multiple CSV files

My JMeter test:
Iterate over a CSV file (logins.csv) with login credentials, and their unique identifier user a CsvDataSetConfig
Sign in
Based on the login credentials (unique identifier from logins.csv), identify and load a second file in the format of <user_identifier>_invoices.csv which then has the necessary path to view an invoice for that user.
Simplified test setup:
ThreadGroup
> CsvDataSetConfig - file: logins.csv, variables: user_identifier,email,password, sharing_mode: all threads
> `SignIn` TransactionController using email and password from above CSV file to login via series of HTTP Requests
> UserParameters - USER_IDENTIFIER,INVOICE_CSV_FOR_USER
> BeanShellSampler
props.setProperty("USER_IDENTIFIER", vars.get("user_identifier"));
props.setProperty("INVOICE_CSV_FOR_USER","${__P(USER_IDENTIFIER)}_invoices.csv");
> WhileController - condition: ${__javaScript("${invoice-id}" != "<EOF>",)}
> CsvDataSetConfig - file: ${__P(INVOICE_CSV_FOR_USER,)}, variables: invoice-id, sharing_mode: current thread
> `ViewInvoice` TransactionController with HTTP Request to url `../${invoice-id}`
# logins.csv
c7beaa99c6d99fa7754fc2213f9b17b8,foo#example.com,password321
9c8466bee65e39c9d3cf715e42933c3b,bar#example.com,password456
# c7beaa99c6d99fa7754fc2213f9b17b8_invoices.csv
f54eca1cbbba4a97c1dc459e0ba64970
0024f2cdf28dd7ebf3606988fd229afd
# 9c8466bee65e39c9d3cf715e42933c3b_invoices.csv
64f725fdeb2980b28bdf5e02076a55cd
60ac45a12ea3d6b59c2cb82f27da1722
Problem:
In local JMeter, seeing requests to invoice urls being made with incorrect invoice-id for the business. So seems the parameters are not being treat correctly between threads.
In BlazeMeter, seeing the content of the while controller never being hit.
I've tried loop controllers, having 50 rows per _invoices.csv file, but not got anywhere with that either. I also originally started off with
User Defined Variables rather than User Parameters, but the latter seems to be what I should be using for this use case.
Threads are running at the same time and sharing JMeter properties.
In your test plan each thread sets the property USER_IDENTIFIER. So this and other property can/will be overriden by different thread(s) and create inconsistency.
I suggest you save (and get) in variables which aren't shared by threads:
vars.put("USER_IDENTIFIER", vars.get("user_identifier"));
vars.put("INVOICE_CSV_FOR_USER"," ${USER_IDENTIFIER}_invoices.csv");
Also about beanshell, JMeter advice to change to JSR223
Since JMeter 3.1, we advise switching from BeanShell to JSR223 Test Elements (see JSR223 section below for more details), and switching from __Beanshell function to __groovy function.

How to do load-testing for 100 concurrent users login with unique username and passwords using Jmeter?

My test plan scenario is to do load-testing for 100 concurrent users login to website.
I have created Threadgroup with Number of threads as 100.
Created CSV file which contains 100 users login details (unique usernames and passwords).
Under Sign in sample added a “User Parameter” from Thread Group -> PreProcessors to it. Added variables using __CSVRead function which reads values from file test.csv.
Selected the login sample and changed the values of userid and password to ${A} and ${B}.
Is this the right way to do or is there any alternative way to achieve this?
If this works for you and works as you expect, that's enough.
But looks like CSV Data Set Config is more suitable and easier to use for multi-user scenarios than __CSVRead function:
Thread Group
Number of Threads: N // count of your test-threads (users)
Loop Count: 1
CSV Data Set Config
Filename: [path to your csv-file with usernames / passwords]
Variable Names: username,pwd // extracted values can be referred as ${username}, ${pwd}
Recycle on EOF? False
Stop thread on EOF? True
Sharing mode: Current thread group
. . .
HTTP Request // your http call
. . .
As per documentation:
The function is not suitable for use with large files, as the entire
file is stored in memory. For larger files, use CSV Data Set Config
element or StringFromFile.
Pretty detailed guides available here:
How to use a CSV file with JMeter
Using CSV DATA SET CONFIG

Resources