[eggPlant Performance] IP Spoofing

Tom MiseurTom Miseur ForumAdmin, Member admin
IP Spoofing with eggPlant Performance

In most situations, the application you are testing will use login credentials as a means of working out who is doing what on its systems. For example, say you log in to a website as Fred. When you subsequently add an item of interest to your eBasket, the server knows to put that item in Fred's basket rather than anyone else's who may also be using the site at that point in time. This is why it is important to ensure each VU in your performance tests receives its own set of credentials to use. However, some applications go a step further and also require the originating IP address to be unique.

This presents an issue for performance testing, as by default each VU will simply use the host machine's IP address. If you are using just a single injector machine for your tests - like localhost - then as far as the server is concerned, all of the load is originating from that single IP address. This also has implications for Load Balancing (see the bottom of this post).

Half of the battle is working out whether or not one actually needs to IP spoof. If all of the following conditions are true, then chances are you do need multiple IP addresses:

-> Your script works fine for a single user, multiple iterations

-> You have ensured that each VU is using its own set of credentials

-> As soon as you introduce a second VU to your test, the first VU receives an error

-> Increasing the VU count makes no difference; only a single user is ever active at any one point in time

The key indicator occurs when you attempt to use multiple VUs and a previously logged-in user suddenly appears to be facing the login screen at some unexpected point in the script's execution.

The process for dealing with this situation is as follows:

1. Request one or more IP addresses from your network administrator (you will likely need 1 IP address per VU)

2. Ensure you are using a static IP address on the injector(s) - you will only be able to add more IP addresses if you are using a static address

3. Add the requested IP addresses to your injector(s). Instructions can be found here

4. Ensure that all the VU groups in your test are set to use the Internal HTTP Handler. This gives eggPlant Performance full control over the IP stack, making it possible to modify the originating IP address (this is not possible with the default WinHTTP Handler)

5. Add the following code to your custom VU's Pre() method:

C#:
protected override void Pre()
{
     //do not remove following line
     base.Pre();

     // Put any code that needs to execute at the start of the test here

     string ipAddress = GetString("ipAddress"); // make sure to create this data file

     WebBrowser.LocalIpEndPoint = new IpEndPoint(ipAddress);
}
Java:
@Override
public void pre() throws Exception
{
     //do not remove following line
     super.pre();

     // Put any code that needs to execute at the start of the test here

     String ipAddress = getString("ipAddress"); // make sure to create this data file!

     getWebBrowser().setLocalIpEndPoint(new IpEndPoint(ipAddress));
}
As long as you then create a data table containing the list of available IP addresses and assign that data at the Test Level (to ensure each VU gets its own row), your VUs should subsequently appear as originating from those IP addresses.

When it comes to Load Balancing and the "round-robin" algorithm, the number of IP addresses required simply has to match the actual number of servers behind the load balancer. For example, if there are 6 web servers, you will need 6 IP addresses (assuming that the load is split evenly between the 6 injectors).

Stay tuned for more eggPlant Performance hints & tips!
Sign In or Register to comment.