I’m testing my load balancing server, where I have two machines as server and one machine as balancer. I want to know which machine fails at the end of the test and how many times. I request the same file in both servers which just contains “machine1” and “machine2”.
The load balancing algorithm used is round robin.
When I’m testing my server with JMeter I receive that body as “response data”, and I have created a regular expression(Regular expression Extractor) to try to count how many times I receive “Machine2” and “Machine1” but doesn’t work.
So at the end of 500 request for example, I want to know how many times Machine2 and Machine1 appears in that Responde data.
Can anyone help me?
Thank
2
Answers
You can use Regular Expression Extractor as child of your request,
Use Regular Expression for finding, with
|
as Or condition:Use Template
$1$
and put Match No. value as-1
. created variable putmachine
for exampleThis will save number of occurrences in special variable end with
_matchNr
so you can use:The easiest way would be dynamically changing sampler name depending on response body.
Put the following code into “Script” area
That’s it, the above script will substitute your sampler name with the response data, this way you will be able to figure out the number of samplers hitting this or that endpoint using listeners like Aggregate Report
Demo:
Don’t forget to add DNS Cache Manager to your test plan as in some cases JMeter can hit only one address due to caching of the DNS responses so all your load will go to a single host instead of being distributed across the cluster nodes