Can we parameterize Thread schedule details like Start Thread count, Initial delay etc. in Ultimate thread Group using csv/txt files? - jmeter

We are trying to parameterize Thread schedule details like Start Thread count, Initial delay etc.
Since we have 50+ thread groups and handling them has become an issue.
Would like to know if Jmeter has any unknown feature for this or a workaround to achieve this?
Can we parameterize these values from a csv/txt file?\
Note: We have 50+ thread groups, hence using ${__CSVRead} and retrieve different values didn't work out.
Have tried out ${__CSVRead} but since we need different values for each thread, this isn't working out.

I can only think of "known" feature - using either user.properties file or a custom .properties file, i.e.
thread.group.1.start.threads=10
thread.group.1.initial.delay=5
thread.group.2.start.threads=50
thread.group.1.initial.delay=20
etc.
and you will be able to use __P() function in the Ultimate Thread Group to read the values from the .properties file:
If you put the values into user.properties file - you won't need to do anything else, the file will be picked up automatically, if you decide going for the custom .properties file - you will need to pass it via -q command-line argument:
jmeter -q /path/to/your/thread/group.properties -n t .....
More information:
Configuring JMeter
Apache JMeter Properties Customization Guide
Full list of command-line options

Related

JMeter tests in Non-GUI mode are not trustworthy

The test scripts on GUI works perfect but not in the non-GUI mode.Image showing Terminal test execution
Explanation:
I have 3 thread groups in the test plan, where the first Thread Group creates 3 .csv files and are expected to feed the data in the CSV files into the second Thread Group.
For few test runs, Non-GUI mode worked great but then, the tests Intermittently like this [Terminal showing test run], doesn't create the CSV files at all and also,
sometimes, third Thread Group doesn't execute at all.
The problem I noticed is:
During the NOn-GUI tests the files are not been creating, so that's the reason the next Thread groups weren't able to pick up and use the variables inside CSV file and also
The second One could be: I'm saving folder and file paths in the
${__setProperty(prop_folder_Path,${File_Path})} and getting the prop.
${__property(prop_folder_Path)} in another Thread Group -> Sometimes this property function Doesn't work and files are saving in /bin Directory
Is there a way to use ${__property(prop_folder_Path)} value in BeanShell POStProcessor ?
I believe whatever works in the GUI should work same in the Non-GUI too, AM I right?
I Just noticed that output files are creating in /bin folderas shown here while running the tests in NOn-GUI
Any suggestions to fix this. Thank you
My expectation is that your ".csv" files creation fails somewhere somehow therefore 2nd thread group is not able to operate due to missing files.
JMeter doesn't have any build-in functionality to write something into the file so I think you implemented some custom logic using i.e. JSR223 Scripting which doesn't work. The reasons could be in:
If you're running JMeter from another folder the .csv files can be created in a different location, try using full paths just in case.
Non-GUI mode tends to be faster than GUI mode so it might be the case of multithreading issue i.e. when multiple threads are trying to write data into the same file concurrently and clash or produce not well-formed data.
In both cases the answer will live in jmeter.log file, check it for any suspicious entries and fix the causes.
In general using files to pass data between thread groups is not the best idea, I would recommend doing it in-memory instead, for example:
In 1st Thread Group use __setProperty() function to convert your data which you store in CSV file into JMeter Properties like:
${__setProperty(foo,bar,)}
In 2nd Thread Group use __P() function to read the data like:
${__P(foo,)}
More information: Knit One Pearl Two: How to Use Variables in Different Thread Groups

Jmeter wont read csv file with line feed properly

I have a thread which writes data to a csv file and data looks like this in that file, as you see below each data is separated by a , then line feed.
ApiKey
20a145260241463194bf84f43952da9c:dut8ghdt+iQrsmYEgKzHzF1It79aWRIjb/d1wM8U3WE=,
93,
d0e29bb7-476d-4a52-9527-e5d9bb0ac34a
In another thread I am trying to read the data so I have done the following. Added a "CSV Data Set Config" with correct filename variables X,Y,Z and my Delimiter I have tried all these A=,n or B=n or C=n, I am not able to get Y and Z properly. What am I doing wrong?
Synchronization of data between thread groups using CSV files is not the best idea as you will have to implement a form or read/write lock to ensure that only one thread is writing data to the CSV file at a time and that will cause throughput degradation.
So I would recommend going for one of the following solutions:
Use __setProperty() function to convert the data from JMeter Variables into JMeter Properties. JMeter Properties are global for the whole JVM therefore they can be accessed from another Thread Group(s). See Knit One Pearl Two: How to Use Variables in Different Thread Groups article for more information.
Use Inter-Thread Communication plugin which implements FIFO queue so you can block threads in 2nd thread group unless data from 1st thread group is available. You can install Inter-Thread Communication Plugin using JMeter Plugins Manager
Both approaches are in-memory therefore you will not need to store data in interim files.

JMeter - Passing the number of threads to multiple thread groups

I have a file where I specify the number of threads for each Thread Group.
My goal is to run concurrently all Thread Groups with the number of threads read from the file.
My current algorithm: I have the first Thread Group in the Test Plan called Setup.
I read the data file to the local variables.
With the BeanShell Sampler, I convert those variables into the properties variables.
In each Thread Group, the number of threads is defined via the properties variable.
If I run the Thread Groups consecutively, there are no problems.
But I need to run them in parallel. I imagine that the Thread Group can try to run before the Setup group finishes reading the number of threads for that group. Then that group will never run.
I appreciate any thoughts and suggestions.
You can define the number of threads via JMeter properties in at least 2 more ways:
In user.properties file (the file is located in JMeter's "bin" folder, JMeter restart will be required to pick the properties up)
threads=100
Or you can do the same via -J command-line argument, i.e. start JMeter as:
jmeter -Jthreads=100 -n -t ....
In your Thread Groups you can refer the property via __P() function like:
${__P(threads)}
It is also possible to have "default" value which will be used in case of "threads" property will not be defined:
${__P(threads,50)}
References:
Full list of command-line options
Apache JMeter Properties Customization Guide
My current algorithm: I have the first Thread Group in the Test Plan
called Setup. I read the data file to the local variables. With the
BeanShell Sampler, I convert those variables into the properties
variables. In each Thread Group, the number of threads is defined via
the properties variable.
You could use Property File Reader. This will get loaded before any thread group starts. So you would not face any issue.
If you do not like Property File Reader, whatever you do - reading the data file and converting them into properties - do that in setUp Thread Group.
It will get executed before any thread group starts

Jmeter Ultimate thread group - Populating the user details from a csv

I am trying to replay production logs where the User count varies every second. Currently, I am using Jmeter - Ultimate thread group where we can definethe user scenario. Is there a way, we can populate the user details(Number of Users, Initial delay, etc) from a csv file into the ultimate thread group (I may need to fill in for abt an hour).
Thanks,
Praveen
Maybe it's possible by adding a "CSV Data Set Config" to your thread group - although I'm not sure how to loop through the csv values in one table.
But the easier way (as hinted at in the Ultimate Thread Group docs) is to add threads_schedule to your user.properties file. Just add to the last line
threads_schedule=\
spawn(15,1s,1s,1s,1s) \
spawn(40,1s,3s,1s,2s)
You could use a special file you load on jMeter startup, using a -q UTG.properties commandline argument. The backslashes escape the newlines, so it's almost like csv - you could export a csv from excel and do a pretty simple find and replace to add spawn( and )\ to the beginning and end of each line.

Using Variable for Thread group Ramp up time

how to configure the thread group ramp up time with a jmeter variable, I tried for both number of threads and ramp up time. No of threads is working fine, but ramp up time takes the default value 1 and the variable value doesn't take effect, Appreciate any help
You cannot use variables in Thread Group setting as Thread Groups are initialised during startup, before any variables are read.
If you need to make number of threads and/or ramp-up period configurable use __P() function like:
${__P(threads,)}
${__P(rampup,)}
Aforementioned threads and rampup properties can be defined in several ways:
If you run JMeter in command-line non-GUI mode you can pass the properties via -J command line key as
jmeter -Jthreads=50 -Jrampup=30 -n -t /path/to/your/testplan.jmx
The same approach will work for GUI mode, however it is not recommended to use GUI for load test execution as it is quite resource consuming and may ruin your test.
You can define these properties in user.properties file (located in /bin folder of your JMeter installation) as:
threads=50
rampup=30
After restart JMeter will pick the properties up and you will be able to refer them via __P() function as described above.
See Apache JMeter Properties Customization Guide for comprehensive information on various JMeter properties and ways of working with them
There is no reason why it works for # of threads but doesn't work for ramp-up time. I've been using configurable properties for both with success.
1 is the default value in JMeter if variable can't be resolved properly. You likely made a typo. To investigate the problem, you may want to use 'Property Display' element (right-click WorkBench / Add / Non-Test Element / Property Display).
If this doesn't help, please post link to the screenshot of thread group, and relevant part of your config where you define the ramp-up time variable.
EDIT : example
This is the way I usually work with configurable properties stored in external files (and it works for ramp-up as well):
define user defined variable on test plan level, e.g. someVarName is ${__P(someVarName)}
then use this var e.g. in ramp-up as ${someVarName}
You cannot use variables for those values, only properties:
http://jmeter.apache.org/usermanual/functions.html
Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.

Resources