Using Shared Data Server (SDS) for Test Control Ramp-Up Control

Stress Testing
In this post I will explain how to use Facilita Forecast Shared Data Server (SDS) to control user ramp-up  whilst executing a  Load  Test.
Two occasions come to mind where this may come in useful:

  1. You need to find a breaking point, but you would like to have fine grained control of user ramp-up. E.g. 100 users in first minute, if it all works fine then keep adding users and pause after each increase.
  2. You need to first see if system works OK with X users. After that run the actual test, but you don’t want to restart the test.

So let’s first start by setting up SDS at VirtualUser level, this only connects to SDS server once.
We need to add this to VirtualUser.h:

public:
   // Gets a command for this user from SDS
   void getCommand();
private:
   // SharedData server
   SharedData sharedData;

Next  I will initialise a connection in the VirtualUser::pre() method and close this in VirtualUser::post() method:

void VirtualUser::pre() {
   try {
       // Trying to connect to Shared Data Server
       sharedData.connect(getString("SDS_IP", "localhost"), getInt("SDS_Port", 5099));
   } catch (FatalCommunicationException e) {
       // Connection failed, so we will stop this script
       error("Failed to connect to Shared Data Server");
       exitVU(false);
   }
}
void VirtualUser::post() {
  sharedData.close();
}

Now the part that controls the user limit for specific group. We will GenF20 be using group name as the key and value will be the current limit of concurrent users. We will need to add this as the first script of workflow. It will repeat this cycle for as long as current user’s index is higher than user limit. I put in a  10 second pause between checks, but you can change this to what ever suits you best.

while (true) {
   try {
      // Getting user limit from SDS fopr this group
      string limit = getVU().sharedData.get(getVU().getName());
      // Comparing to current user index
      if (atoi(limit.c_str()) < getVU().getIndex()) {
         writeMessage("Reached user limit (" + limit + ")!");
         // Sleeping 10 seconds
         pause(10 * 1000);
         continue;
      }
      break;
   } catch (Exception e) {
   }
}

Using this example there are two issues:

  1. To stop the tests you need to abort the test if there are still users waiting for user limit to increase. You can stop the test and wait for all other users to stop and after that abort to stop the waiting users. I will talk about how this can be overcome in a future posts [TODO: Insert link here].
  2. When you lower the user limit, users with indexes over limit will not  stop running.  See my previous article  Using Shared Data Server (SDS) for Test Control – Individual User Control. I shall cover more on this topic later on.

Leave a Reply

Your email address will not be published. Required fields are marked *