Compare values/data using CSV data set config in JMeter - jmeter

Trying to compare the data/count between source and destination tables (SQL) as below through using CSV config in JMeter. is it possible to implement this way?.
CSV config in JMeter
just want to compare the count between STAGING and DW for all tables. any thoughts on this..?

Just define Variable Names so JDBC Request sampler could store the query execution output into a JMeter Variable like:
In first JDBC Request sampler define "Variable Name" as result1 (replace "SQL Query" with the relevant JMeter Variable name holding the value from the CSV file)
In second JDBC Request sampler define "Variable Name" as result2
That's it, now you will have the count of rows returned from the first JDBC Request sampler as result1_1 and from the second as result2_1
Now you can compare the values using Response Assertion configured like:
in case of mismatch the relevant JDBC Request sampler will be marked as failed and you will be informed about the differences:
More information: Debugging JDBC Sampler Results in JMeter

Related

Jmeter | Load million Telephone numbers from DB and hit 1 rest point using multiple threads

I have a requirement where I have to load 1 million Telephone numbers from database and once that data is retrieved, need to call one REST endpoint using multiple threads. So I will load the data once and once data is loaded, use same dataset to hit rest endpoints concurrently.
I am a newbee to Jmeter and I am not able to figure out how to create thread groups to achieve this.
I would recommend
Using setUp Thread Group to load the data from the database, there add:
JDBC Connection Configuration to specify your database URL, credentials, etc.
JDBC Request Sampler to execute the query and save the results into JMeter Variables
JSR223 Sampler to write the results into a CSV file
Check out How to Retrieve Database Data for API Testing with JMeter article for example implementation.
Using normal Thread Group to create the concurrent requests:
CSV Data Set Config - to load the numbers from the CSV file so each virtual user would use the new number on next iteration
HTTP Request sampler to call your API

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

JMeter: include parameters from csv dataset in results

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}

Jmeter - Is it possible to pass query through variable

Is it possible to pass query through variable? What I need is:
1. Get multiple queries from csv file.
2. Execute them one by one.
3. Store results
Yes you can do it by using CSV Data Set config and Bean shell post processor.
Step 1: Need to read queries from CSV file.
Step 2: Use JDBC request to query the database. I'm assuming that you already created database JDBC pool with the help of JDBC Connection Configuration
Step 3: Use Bean Shell post processor to save the results into a file.
To read queries from the file one by one you can use __StringFromFile() function like:
To store the output you can go for different options,
Save Responses to a file listener if query result is a simple/singe value
If your query result is more complex, i.e. you need to iterate the ResultSet object - you will need to do some scripting, check out Debugging JDBC Sampler Results in JMeter
If your query generates several JMeter Variables you can get them stored into .jtl results file via Sample Variables property.

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