I have a testplan and the testplan has 2 thread groups. Both the thread groups call almost same http requests. I run the test from the command prompt and generate a html report. But in the report, the html calls are mixed up. Is there a way for me to see the calls per each thread group?
Use __threadGroupName() function as prefix/postfix for your Samplers labels like:
${__threadGroupName} - HTTP Request 1
This way you will get the relevant Thread Group name added to your sampler label:
More information on JMeter Functions concept: Apache JMeter Functions - An Introduction
Related
Is it anyway I can have an if controller above a thread group, like:
TestPlan
-> If controller
----> Thread Group
I.e I just want to execute the if controller once so I can avoid unnecessary execution in the Thread Group?
You can add to Thread group in Number of Threads field get value from property, as:
${__P(GroupANumberOfThreads,0)}
So if you don't have property, for example don't send -JGroupANumberOfThreads=1 in CLI mode Thread group won't get executed
There are following options:
Put everything inside the Thread Group under the If Controller, this way no Samplers will be executed if the condition is not met, but the Thread Group will be still started and all threads will kick off
Set number of threads in the Thread Group to 0, it can be done using __if() function (member of JMeter Custom Functions plugin bundle, can be installed using JMeter Plugins Manager)
You can also consider running your JMeter test using Taurus tool as the wrapper, Taurus provides possibility to completely disable arbitrary test element (including thread groups) using simple declarative YAML syntax
I am new to jMeter so hope you can help me out.
I have a thread group with several HTTP request samplers. I am sending an email every time any sampler fails. The thing is I would like to collect the names + response bodies of the several failed samplers to send in the email.
Can anybody please give an example of how to do it?
The best solution would be using Simple Data Writer listener configured to save only failed requests, there you can choose whatever metrics you need to store:
Another option is using JSR223 test elements and Groovy language to extract the "interesting" fields from the failed requests:
in the above example the sampler gets the label and the body from the previous result and stores them into ${requestName} and ${responseData} JMeter Variables which you can use wherever you want. More information on these prev, vars and other JMeter API shorthands: Top 8 JMeter Java Classes You Should Be Using with Groovy
Need to count samples generated in thread level. I am using 8 thread groups and each thread group contains multiple transaction controller and each transaction controller contains multiple requests. Problem is here that I am able to get the samples to count for each transaction controller but not for thread level.
I am using 8 ultimate thread group in my test plan for load test executing for 1hr.
You could consider adding __threadNum() function somewhere to your Sampler's name
The function will be evaluated in the runtime and resolved into current thread (virtual user) number.
This way you will be able to see how many Samplers did this or that thread execute in a listener of your choice, i.e. in Aggregate Report
Check out Apache JMeter Functions - An Introduction article for more information on JMeter Functions concept.
I am new to jmeter. Writing script as below:
Thread group1: Token generation
Thread group2: Use token created in Thread group1 and call API.
Need to execute Thread group1 after every 10 mins, so that new token is generated and it is used by Thread group2.
Script structure:
In order to implement a 10 minutes "sleep" Add a Flow Control Action sampler (earlier was Test Action) to 1st Thread Group and configure it to Pause the thread for 600000 milliseconds - 10 minutes
In order to pass token value from one Thread Group into another - use __setProperty() function in 1st thread group to convert JMeter Variable into a JMeter Property and __P() function in 2nd thread group to read the token value.
According to JMeter Best Practices you should always be using the latest JMeter version so consider migrating to JMeter 5.0 (or whatever the latest version available at JMeter Downloads page) as soon as possible.
Below solution worked for me:
In Thread group2 call the API.
Then extract the status code using Regular Expression Extractor.
Add if controller.
NOTE: The only drawback is that, when a request fails then only new token is generated.
How can I generate a consolidated summary report for multiple threads under a single test plan in JMeter.
We are able to fetch report individually for each thread group.Is there any chance that we can get consolidated report for all thread groups under single test plan.
If you are getting the report from i.e. Summary Report listener just remove all Summary Report listeners from all Thread Groups and add one at the same level as the Thread Groups
The concept is known as Scoping Rules, i.e.:
If you add a listener as a child of a Sampler - it will be applied to this sampler only
If you add a listener as a child of a Thread Group - it will be applied to all Samplers in the Thread Groups
If you add a listener as a child of the Test Plan - it will be applied to all samplers in the Test Plan
Also be aware that starting from JMeter 3.0 there is a possibility to generate HTML Reporting Dashboard