JMeter/Blazemeter capabilities - jmeter

I am a Load Runner tester and would like to know how below requirements can be done in Jmeter.
Data parameterization - How can we implement unique and random data parameterization in Jmeter.
how do we get vuser id value for each virtual users in a Thread group?
If we need to initialize/load any data during vuser initialization (vuser_init() in load Runner) , how can we do it? Also, how do we call any function when vuser is ending, like vusr_end() in LoadRunner.

In Core JMeter:
For Data parameterization, use CSV DataSet , it will pick columns from CSV file and expose them as JMeter Variables you can use with ${varName}
To get user id, use jmeter function __threadNum()
There is no strict equivalent, for vuser_init you can use a Once Only Controller. For vuser_end, there is no equivalent

For parameterization:
CSV Data Set Config - for sequential data
Random CSV Data Set Config - for random data
HTTP Simple Table Server - for unique and random data, suitable for Distributed Testing (basically equivalent of the Virtual Table Server)
__threadNum()
Normally it is being done in:
vuser_init() - setUp Thread Group
vuser_end() - tearDown Thread Group

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

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 run all the API's in thread which will fetch the first value from CSV after one iteration it should fetch the second value from csv

I have a script which has Login API which fetch the first values from CSV file after other API's run which should run with the same user, after running all the API in thread again it should fetch the second value from csv.
I have done with the entire setup but while running the script it's randomly fetch the value from csv
assuming you are using multiple Thread Group. if yes then look for sharing mode in CSV Data Set Config. link with help you to understand sharing mode
https://www.blazemeter.com/blog/csv-data-set-config-in-sharing-mode-made-easy
For Single Thread Group use sharing mode as Current thread in CSV Data Set Config

How Can i avoid repeated/duplicate test data or to avoid already executed data without deleting in CSV file?

We have a constrain in our application, For test data providing in JMeter execution (using CSV Data Set Config element) we are not supposed to provide duplicate test data and it won't accept in all the fields. So we kept unique test data (upto 8K data for 8k concurrent users) for all the fields in CSV format.
Here I have a manual intervention, After each test execution (i.e) 100 users, 1000 users up to 8000 users) we need to delete each row (WRT to users in thread group) in CSV file else the duplicate data will be fetching for next execution and result will be failed.
Here my questions is,
1. How Can i avoid repeated/duplicate test data or to avoid already executed data without deleting in CSV file.
2. During JMeter test execution with CSV files, How can we specify to take the data from the respective rows. For example 101th row, 1001th row & 7999th row (which contains 8000 rows of data)?
The easiest option will be using HTTP Simple Table Server, its READ command has KEEP=FALSE attribute so you will be able to feed your test with the unique data without having to physically remove it from the original CSV file.
You can install HTTP Simple Table Server plugin using JMeter Plugins Manager:
In general if your test doesn't need to be repeatable instead of keeping the data in the CSV file you can consider generating it on the fly using such JMeter Functions as:
__Random()
__RandomString()
__RandomDate()
__UUID()
etc.

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