Using Shared Data Server (SDS) for Test Control – Individual User Control

Facilita Forecast: I will kick off my series of SDS centric posts with how to use this service for individual user control.
There may be an occasion that you have to stop one or several users because they have failed or are performing actions that are interfering with other virtual users; making your test invalid. The Facilita Forecast Test Controller does not support any way to stop individual users at run-time so we can use the Shared Data Server to achieve this.
Initially start the SDS server and verify the required injectors can connect.
For the example I will be using, the SDS server will reside on the same machine as the Test Controller and Injector Machine.
I will be using the Shared Variables from the SDS, for the key I will use Virtual User index and the value will be the command to this particular user. If you have more than one group I recommend you add the group name as prefix/suffix for key.
Next we need to write some code. First to create a sharedData variable and make a connection to server. This only has to be done once – so I will add this to the VirtualUser.h file:

    // Gets a command for this user from SDS
    void getCommand();
    // 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 <a href="">vigrx walmart</a> 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");
void VirtualUser::post() {

Now add a check to see if current VU has received any new commands. I have placed this in the VirtualUser::getCommand() method:

void VirtualUser::getCommand() {
    string command;
    try {
        // Get command from SDS. Key in SDS is the same as this user’s index.
        command = sharedData.get(str(getVU().getIndex()));
        // Act on this command. In this case we will stop the script.
        if (command == "stop") {
    } catch (Exception e) {

In this example the only command we are concerned about is a stop, but this can easily be extended to accommodate many more  commands and responses.
Now we need to add a call to this method at places that we think may need this. I will add to the start of all scripts, just to be safe.
Now for the SDS server side: Whenever we want some user to do some action that we have enabled, we need to create a value with key that is equal to VU index that will be executing this command. In my example I will want for VU Nr. 13 to stop, so I will be adding new value to SDS shared variables – 13:stop.

We now can stop users we would like to while a load test is executing. In my next article I will explain how to control the ramp-up of users using SDS.

Leave a Reply

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