0
votes

I am testing a clustered application, and want to define a different thread to test each machine in the cluster. I have a thread group with two HTTP Requests, a login that is done once, and a POST that is repeated many times. I set up a CSV Data Set Config to configure the Server Name and Port Number for the HTTP Requests. A HTTP Cookie Manager holds the login cookie resulting from the login request.

The problem is that for each time a HTTP Request runs the CSV file is read again. Often the same thread reads hostname and port values, and the login cookie is then not sent because it only applies to the original machine the thread logged into.

Is there any way to get make the CSV Data Set Config only read once per thread? Or perhaps some other way to set the hostname/port on a per thread basis instead of a per request basis like I am doing now?

2

2 Answers

0
votes

I believe default settings of the CSV Data Set Config provide what you're looking for:

CSV Distribution

Other option is to distribute the threads using If Controller like:

  • If Controller, condition: (${__threadNum} % 2 == 0)
    • HTTP Request for even threads
  • If Controller, condition: (${__threadNum} % 2 != 0)
    • HTTP Request for odd threads

Both options use __threadNum() function which basically returns the number of current thread, maybe you'll be able to test your approach or come up with a better one knowing this.


In general testing clustered applications by hitting different hosts separately isn't the best idea. End user usually accesses such applications via software of hardware Load Balancer so he sees single hostname or IP address. The load balancer distributes the requests between servers using various algorithms.

I think this is the situation you need to simulate and it is better to add DNS Cache Manager to your test plan so each thread could resolve hostname on its own.

0
votes

You can use HTTP request Defaults. Update your Server IP, Port and protocol details. All the HTTP requests in Thread Group will take the default ip, port etc from the HTTP request Defaults.

Check here for more details

enter image description here