JMeter Unique once feature - jmeter

I want to use Unique once setting in JMeter as used in load runner for a project.
The data are provided through a CSV file and are parameterized.
If the script is ran with multiple users then also the data should be unique, meaning one data can be used only once.

Users in JMeter equal Threads so just use CSV Data Set Config to read your CSV
Sharing mode All threads - (the default) the file is shared between all the threads.

You can consider using HTTP Simple Table Server plugin, it has KEEP option, if you set it to FALSE once record is read from the source file it will be removed guaranteeing uniqueness even if you run your tests in Distributed Mode.
You can install HTTP Simple Table Server plugin using JMeter Plugins Manager

I have come up with the solution for "Unique Once Vuser setting in jMeter"
1) Create excel and insert data in excel column wise i.e. horizontally insert all the data.
2) Use below code in place of your unique parameter.
${__CSVRead(filePath,${__threadNum})}
So it will pick unique data for each thread.
Thread_1 Iteration_1 --- Data from col 1
Thread_1 Iteration_2 --- Data from col 1
Thread_1 Iteration_3 --- Data from col 1
Thread_2 Iteration_1 --- Data from col 2
Thread_2 Iteration_2 --- Data from col 2
Thread_2 Iteration_3 --- Data from col 2

Although every answer works perfectly fine, but just a different way using if control.
CSV Data Set Config settings :
if controller validation code : ${__groovy(${__jm__Thread Group__idx} == 0,)}
In this if controller we keep a JSR223 sampler and in that we can have one or more line of following code : vars.put("VarName",vars.get("CSV_input"))
where we replace VarName : with the variable name we want to use in the script and CSV_input with the the variable name from CSV Data Set Config input

Related

Randomize user name with associated job id for user

In my test plan I have two CSV files, one is with user name,password and other one with user name with multiple JOB_Id .
The the JOB_Id is being used for one post call and one get call.
Requirement: When I logged in with the specific user I want the randomly associated JOB_Id should be selected from the other CSV file associated to that User (in the example I have only selected 8 JOB_Id but during run it would be more than 100). How to do it?
Here is my samples CSV files.
User Details Files :
JOB_Id File:
Test Plan:
CSV Data Set Config is initialized when the test starts, if you want to get JOB IDs from another file dynamically - you need to switch to __CSVRead() function
Example setup:
CSV file 1, usernames.csv:
perfuser0001
perfuser0002
CSV file 2, job ids
perfuser0001.csv
perfuser0001-job-id-1
perfuser0001-job-id-2
perfuser0002.csv
perfuser0002-job-id-1
perfuser0002-job-id-2
Demo:
More information: How to Pick Different CSV Files at JMeter Runtime
Also since JMeter 3.1 you're supposed to be using JSR223 Test Elements and Groovy language for scripting so please consider migrating from Beanshell on next available opportunity.

Jmeter interactions with UI and Database inserts simultaneosly

When we create a Jmeter script through Blazemeter/third party script recorder and there are some insert/update and delete functions on UI involve in records. Just want to know when we run same JMeter script with 100 users, Do those new records get inserted/update/delete in database as well ? If yes, then what should be remaining 99 users data if there are unifications on UI.
When you record the user action it results into hard-coded values so if you add foo line in the UI it gets added to the database.
When you replay the test with 1 user depending on your application implementation
either another foo line will get added to the database
or you will get an error regarding this entry is present already
When you run the same test with 100 users the result will be the same, to wit:
either you will have 100 identical new/updated entries
or you will have 100 errors
So I would suggest doing some parameterization of your tests so each thread (virtual user) would operate its own unique data, like:
have a CSV file with credentials for 100 users which can be read using CSV Data Set Config
when you add an entry you can also consider adding an unique prefix or postfix to this like:
current virtual user number via __threadNum() function
current iteration via ${__jm__Thread Group__idx} pre-defined variable
current timestamp via __time() function
unique GUID-like structure via __UUID() function
etc.

How can I add static values in a column in grafana/influxdb

I'm using grafana, influxdb and jmeter. I have this table.
I need to add a column that says "Base Line" with a value different for each request name. I have tried the following:
- Grafana does not seem to have a way to add static values for columns, or a query equivalent of sql for "select 'value' as 'columnName'"
- I tried creating a new time series for static data (base lines) and do a join of the results from jmeter with the series I created, but I get this error:
error parsing query: found AS, expected ;
I'm having a hard time trying to create an extra column with fixed data for each request... my last resort is to modify or create a jmeter plugin for that matter, but before going for that, there might be something I could be missing.
The easiest solution I can think of is adding a Dummy Sampler which will be doing nothing but "sleeping" for specified amount of time which is your "baseline".
JMeter's Backend Listener will collect this sampler metrics and you will either see a straight horizontal line identifying your baseline in the chart or the baseline value in the table or will be able to aggregate as a vertical column.
You can install Dummy Sampler using JMeter Plugins Manager

Jmeter Multiple CSV files

I wanna use 2 CSV files. One CSV file with user id nd passwords.And second CSV file, containing data for adding different producers(agents) against each user.
I mean user id 1 should take 1st row of producer data, user id2 shall take 2nd row of producer data and so on. IS this possible in jmeter and how?
Put user 1, password 1 and other data in the same row which needs to be used. Make sure you CSV is having the headers and do not put any thing in the "Variable Names" of CSV Dataset config.
Now, when you run with multiple thread, 1st thread will pick 1st row and then move to the second row. Other threads will also do the same.
Hope it helps.
You can use multiple csv's but then you have to maintain login and other test data binding. So, it is better to put it in one.

How to do data driven testing using jMeter if the values are present in the body not in parameters

I know using of data driven in jMeter by passing the values in parameters, but my concern is how to the data driven testing when the values are sending in request of a body. Any help will be appreciated
You can use CSV Data Set Config, Add > Config Element > CSV Data Set Config
In the CSV file you can set the value for the parameters.
example csv file
Provide csv file path in CSV Data Set Config
Imported CSV file will be the data to perform data driven testing for login page, where first row of the csv file is variable name and rest is test data.
Set the number of thread user under Thread Group same as number of rows present in the csv file.
Have you tried fill body like this?
MyVariable is user defined variable

Resources