how to increment the number in jmeter body whenever we run jmeter run - jmeter

i want to increment the batch number in my jmeter body whenever i run the jmeter run
say for example im running 1 request it should be like bleow
'batch_number_1_2022-09-27_1'
also if i run 2 request it would be , batch number remains the same for that run only counter changes fo as many request we trigger
'batch_number_1_2022-09-27_1'
'batch_number_1_2022-09-27_2'
now when i run the jmeter 2nd time again it should be like below(batch number should be incremented)
'batch_number_2_2022-09-27_1'
and so on like below for everytime when i trigger jmeter run
'batch_number_3_2022-09-27_1'
|
|
|
|
'batch_number_n_2022-09-27_1'

Take a look at Counter configuration element or __counter() function, the first one generates an incremented number on each iteration, the latter one each time it's being called.
So if you amend your payload to look something like:
batch_number_1_2022-09-27_${__counter(,)}
you will get the incremented postfix
More information: How to Use a Counter in a JMeter Test

Related

How to keep certain thread delay between requests and store correlation id for all the request during load test

May i know how to achieve this scenario in JMeter.
Requirement 1 : Request 1 should execute for 15 mins, once 15 mins crossed request 2 should execute and request 1 to be stopped.
Requirement 2 : In request 1, we need to capture all dynamic value and store it some place and same dynamic value we should use it as request body for request 2. We like to run large numbers of users. Not sure, how to store all the response in some files or other alternatives.
Ex : Request 1 - > Trigger -> Store response somewhere(15 min run & 100 iteration) - stopped
Request 2 - > Trigger after 15 min - Execute request with above 100 iteration response)
Either take a look at Runtime Controller, using this guy you can choose how long its child(ren) will be run or just put your requests 1 and 2 into separate Thread Groups
If you want to store full responses into a file take a look at:
Post-Processors to capture the required part of the response into a JMeter Variable
Sample Variables property to tell JMeter to save this variable into .jtl results file
Flexible File Writer if you want to write the values into a separate file

Incremental variable in each iteration/loop in Jmeter Tests

I have below setup for my test plan:
In POST http request, I am sending a variable myCount set to value 0.
As per above configuration,
this test will run 100 times but everytime the value of myCount is sending 0.
I want it in incremental
for example: for loop 1 value set to 1, for loop 2 value should set 2.
Please let me know how can I achieve this.
Also, I would like to know in Taurus as well.
Thread Group has a pre-defined variable which returns the current iteration number, it's ${__jm__Thread Group__idx}
if you want the counting to start from 1 - go for __intSum() function
There is __counter() function which generates an incremented number each time it's being called
There is Counter configuration element which does the same but you have additional possibility to control the number format, i.e. if you need 0001 instead of just 1 or you plan to re-use the generated variable value later on within the bounds of same request or iteration. More information: How to Use a Counter in a JMeter Test
With regards to Taurus - in case of JMeter executor it supports all the approaches mentioned above

JMETER - How can I pass 2 condition in a while loop on Jmeter

How can I pass 2 condition in a while loop on Jmeter. The conditions are
The request should run in loop till "Pass" response comes.
While loop should run only for 1 minute.
Condition 1 is working fine. However condition 2 is unable to implement.
I have tried running the While Loop inside a Runtime Controller. But the issue is, if the response "Pass" comes before 1 min, the rest of the test stops.
Tried other way round (Runtime inside While Loop) leading to numerous execution of the request, even after receiving "Pass" response.
Will appreciate any leads on this. Thanks
Add a JSR223 Sampler just before the While Controller and store the current time into a JMeter Variable using the following code:
SampleResult.setIgnore()
vars.putObject('whileLoopStart', System.currentTimeMillis())
Use the following __groovy() function as the While Controller's condition:
${__groovy(!vars.get('your_variable').equals('Pass') && ((System.currentTimeMillis() - vars.getObject('whileLoopStart')) < 60000),)}
This way the While Controller will run until:
either your_variable is not equal to Pass
or 60 seconds pass
whatever comes the first
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
This could be another solution.
You can achieve the desired outcome with the following components.
Runtime Controller
If Controller
Flow Control Action
Set the Runtime (duration) in the Runtime Controller
Set the first condition you already have in While Controller in the If Controller
Click the Break Current Loop to exist from the Run Time controller

JMeter test works differently from CLI than GUI - why?

I'm creating a small test using JMeter. So far I have one Thread Group that executes an HTTP request, waits for 10 seconds, then executes an other HTTP Request and checks what was returned. If I start 100 such threads with 1 second ramp-up period from the JMeter GUI, it works fine, I get the expected values and the whole test finishes in 22 seconds. However, when I start the very same jmx file from the command line, the test runs for more than 120 seconds and some threads (at the last run, 36 out of the 100) don't get the expected value. This might indicate a bug in the system I test, but I don't understand why the test takes that long time from the CLI and why I get errors from the CLI. What is the difference between running the test from the GUI and from the CLI? Does the CLI run the tests "more parallel"? By the way, this is the command line I'm using:
/home/nar/apache-jmeter-3.3/bin/jmeter -n -t test_transactions.jmx -l test_transactions.out
I'm afraid I cannot share the test plan, but I can share the "outline":
+ Thread Group
+ CSV Data Set Config
+ HTTP Request
| + JSON Extractor
+ Constant timer
+ HTTP Request
| + JSON Extractor
| + Response Assertion
+ View Results Tree
+ Save Responses to a file
+ View Results in Table
+ Summary Report
The Constant timer waits for 10 seconds. The first HTTP Request sends in some data and initiates a computation, the second checks the result.
I think you should disable the following listeners in non gui test:
View Results Tree
Save Responses to a file
View Results in Table
Summary Report
After disable you still have result using -l test_transactions.out which you can later view using GUI mode with Browse button in your Listener
In non GUI you can also generate dashboard report if you want by adding -e -o /path/dashboardfolder
It actually does indicate the bug in the system under test. The reason is that you must run JMeter in non-GUI mode as GUI creates huge overhead in terms of resources consumption, especially when you're using Listeners, especially if one of them is View Results Tree.
So my expectation is that in non-GUI mode you're basically creating more immense load which your application cannot handle. You can check this out using i.e. Active Threads Over Time and Transactions Per Second listeners.

JMeter and random variable along with if controller

i want to control my sampler execution by using a random variable . I have a sequence of hits login,welcome,Bla,log out . i want the log out to be performed for 6/10 requests and let others do not login(so to speak 6 requests will perform the whole sequence including log out, 4 of them will perform will not perform log out ).How to achieve the same in JMETER
I have added a random variable rand and set it between 1-10 at the beginning of the thread group .Then just above Logout sampler i placed an IF controller were i check ${rand}>4 . How ever i always get all sequence executed . Please suggest what am i doing wrong
Your approach is a little bit weird, my expectation is that the problem is in the following areas:
Your IF Controller condition is wrong (check jmeter.log file for any suspicious entries)
Your random variable setting is wrong, i.e. it has the same value for all virtual users (threads) so they will either be executed all or none
So I would recommend using Throughput Controller or Switch Controller in order to set up this 60/40 distribution.
See Running JMeter Samplers with Defined Percentage Probability article for more details.
Random Variable in Jmeter is saved in long format be default so
${rand} > 4 won't work. You need to change
Condition to ${rand} > 4.0
or change Random Variable Output format to 00 (2 digits)
see Manual
This was accomplished by creating a combination of config element- random variable and an IF controller
1) a random variable was created with Minim and maxim value to meet above condition
2) and IF controller was able to check ${myrand}>4;
This had derived the desired result - thank you all

Resources