JMeter: include parameters from csv dataset in results - jdbc

I have a JDBC test suite that I run with JMeter, and I want to run that over many user accounts.
I'm doing that with a CSV dataset that includes all the accountIds I want to test, then I inject the accountId into my SQL queries to run the queries over all of the accounts I want to test (with ${ACCOUNTID}).
It's working great, the queries are actually done over all the accounts I want to test.
However, I would like to know the response time per account. Currently I'm not getting the accountId back in the result, so I can't filter my results by account. Is there a way to get that variable value to the JTL?

You can either run JMeter as follows:
jmeter -Jsample_variables=ACCOUNTID -n -t test.jmx -l result.jtl
Or add the next line to user.properties file to make the change permanent
sample_variables=ACCOUNTID
In both cases you will get an extra column in .jtl results file having ACCOUNTID variable value for each and every request.
More information:
Sample Variables
JMeter Properties Reference
Apache JMeter Properties Customization Guide

You can add variable name to Sampler name so it will aggregate requests per account id. Set Sampler as:
My Sampler ${ACCOUNTID}

Related

Jmeter How to use different user variables for each thread (each thread. not thread group)

I want to use 100 concurrent users in one thread group in Jmeter. but I want to each thread to use different user login password. how to achieve that?
full credit to Apache Jmeter documentation:
Some test plans need to use different values for different users/threads. For example, you might want to test a sequence that requires a unique login for each user. This is easy to achieve with the facilities provided by JMeter.
For example:
Create a text file containing the user names and passwords, separated by commas. Put this in the same directory as your test plan.
Add a CSV DataSet configuration element to the test plan. Name the variables USER and PASS.
Replace the login name with ${USER} and the password with ${PASS} on the appropriate samplers
The CSV Data Set element will read a new line for each thread.
UPDATE documentation link
https://jmeter.apache.org/usermanual/best-practices.html
There are multiple options depending on where do you want to keep the credentials.
The most commonly used approach is storing login/password combinations in the CSV file and using CSV Data Set Config for reading them. By default each JMeter thread will read the next line from the file on each iteration
If your credentials are in the database you can use JDBC PreProcessor
If you plan to run your test in Distributed Mode and don't want to worry about copying test data to all slave machines - there are HTTP Simple Table Server and Redis Data Set Config
More information: JMeter Parameterization - The Complete Guide

How to identify which request from Jmeter was slowest?

We are running performance tests using JMeter. In the Aggregate report we are able to view the minimum and maximum times. We now want to identify exactly which request from JMeter took the maximum time that was reported, so that we can perform a root cause analysis. So, how do we identify that request in JMeter?
If you run JMeter in command-line non-GUI mode like
jmeter -n -t test.jmx -l result.csv
it will generate CSV file containing all samplers statistics so if you sort by elapsed column in the timeStamp column using MS Excel or equivalent you will see the Unix timestamp so you can figure out the exact time when the "longest" request was fired:
Another option is adding a unique identifier like number of current thread, number of iteration, URL, whatever
it can be done using JMeter Functions or Pre-Defined Variables

How to get row count for a sql query executed in JDBC request in Jmeter in summary report

We are executing SQL queries on Jmeter JDBC request and able to get proper response on executions. However, our project team would like to see row count of each execution in result reports along with elapsed time, latency etc.
How to get row count for a sql query executed in JDBC request in Jmeter? Also, how to get the row count value appended to columns in Summary report.csv file?
With regards to row count - you already have it. I.e. in the below setup I defined the result variable myVar
When my query is being executed JMeter stores the number of returned rows into myVar_# variable
Now if I want to display the variable within the .jtl results file I need to add the following line to user.properties file:
sample_variables=myVar_#
Next time I run my JMeter test in command-line non-gui mode like:
jmeter -n -t test.jmx -l result.csv
I see the number of rows returned by the SQL query in the myVar_# column:
References:
Sample Variables
Debugging JDBC Sampler Results in JMeter

How to use data from .csv file for Ultimate thread group

I have a use case where 10000 users are hitting the API sequentially.
first 1000 users/sec are hitting an API then they hold for 10-15 seconds and again another 2000 users are going to access the api.
Issue is i have an api <path>/user_id/${userId} and i have 10000 user ids stored in a .csv file
how fetch the file for every 1000 users at first set and 2000 users in the next?
I have added CSV Data set Config and i have the .csv file path
Below screenshot is my .csv set config.
Beanshell error
GetUserID API
Ashu
To pick first 1000 userIds for first 1000 threads and and next 2000 userids for next 2000 threads and so on follow this steps
Create a csv file with only userIds(Do not mention the column name in csv).
To the JMeter test plan add a simple thread group and bean shell sampler to the thread group.
Add the following code to the beanshell sampler
above code will add UserIds to JMeter properties.
now to pick userIds use
${__P(user_id_${__longSum(${__threadNum},-1,)})}
I have created a sample test plan to pick only first 10 values from csv for the first minute and pick next 10 for the next minute you can see the screenshot here
I would recommend run the tests in cloud.
Please follow this link to know more

How to set up a large amount of request data for a jMeter load test

I want to simulate a few hundred http request each with a different token and userId which I have in a database table.
What's the best way of setting up a jMeter load test to do this?
You can use JDBC Sampler to extract you data from DB to create a CSV and a JSR223 Sampler using groovy (add groovy-all.jar in jmeter/lib folder) to write the extracted values to a CSV file.
Then in the real plan , use CSV DataSet Config using the generated file.
Depending on how you want to use the dataset, you will play with Sharing mode attribute.
If you want to do both steps within the same plan you can use a Setup thread Group that will contain the JDBC Sampler part to write the CSV File, this will use 1 thread and then
the other part in regular Thread Group that will use the number of users you need.
One way is to put all your parameters into a csv file and use CSV Data Set Config in jmeter. Right click on the thread you have created - add- Config Element- CSV Data Set Config. Remember you need to set the Number of Threads(users) to match the number of users in your CSV file.

Resources