JMETER - change the server name of the request dynamically


Tell me, please, what and in what way I should use logic controllers to solve the task (for example):- make 16 requests so that first 3 of them reach one host and each 4-th request is sent to another host (e.g. 3 -; 1 -; 3 -; 1 - and so on). 


1. add the thread group to the plan with 4 users

2. Add 1 user defined variable called index
Set the default value to 1.

3. Add a while controller

Set the condition to the controller so that it iterates while index < 5.

4. Add 1 HTTP sampler

Leave all fields empty.
The server name (domain) will be set in a BeanShell pre-processor.

5. Add a BeanShell pre-processor

It runs before the HTTP sampler runs and sets the server name of the HTTP sampler based on the value of the index variable.

The index value is increased after the domain name is set

6. Add a View Results Tree listener

7. Enable the log and run the load test

You will see 16 requests in the listener (4 users x 4 requests per user) and 16 domains in the log (12 for and 4 for

Share this