Virtual Table Server (VTS)
The Virtual Table Server (VTS) service maintains a database accessible by several clients (load generator) on the same network.
With VTS, several load generators can obtain values from a single common pool of values. One Vuser can create key values (such as a new customer ID), and any number of other Vusers can immediately use that value.
There are several versions of VTS. The VTS3 comes with LoadRunner 11.52 was completely rewritten to exchange data using REST JSON from a Node.JS server encapsulated in a 64-bit executable.
VTS2 was a 32-bit Windows program and uses an in-memory database.
Installation
Download the file vts2.zip from here: VTS KB Article (HP support login required.) and
copy it to your Controller and each and every LG that you intend to run any
script referencing VTS on – basically your whole farm. For each machine do
this:
1. Right click the zip
file
2. Select ‘Extract to’
3. Browse to the
directory where LoadRunner is installed (eg. C:\Program Files\HP\LoadRunner)
4. Choose this folder
and the location to extract the zip file to.
5. Unzip it
1. Open a CMD Prompt
2. Type (Only the text
inside the brackets…)
3. Type (Only the text
inside the brackets…)
Running VTS
Now you have it
installed, think about where you want to run it. Think of each little VTS as a
server (they are essentially). So they need to run on a machine that is
available to every LG that want s to use it – ie. You have to have network
connectivity. You could just use your Controller box but it’s nice to have a
separate box for VTS as it can use up a lot of memory and, potentially, network
bandwidth.
Once you have a
machine in mind, go there and do this:
1. Open a new notepad
document
2. Type this:
ECHO ON
CD
"C:\Program Files\HP\LoadRunner\bin\"
START
vtconsole -port 9999 -launch
START
vtconsole -port 9992 –launch
Save this
notepad file as ‘START_VTS.bat’. You can use another name if you like but the
.bat part is key.
Find the file where
you saved it – and double-click it.
Now you should see two
windows pop up with grid control in
the center.
I used two VTS servers
here to highlight that you can do this – and probably will want to. Each
separate server has it’s own PORT number which is how you reference it and you
can open lots if you want – think of them as tables in a DB but in reality they
are each their own mini database sitting in memory.
Later, when you have
started to use VTS, you will appreciate that you can enhance this START_VTS
.bat file by using additional params. Eg. –file [FILENAME] will allow you to
open the VTS table and pre-populate it with existing data. This data can either
be something you have exported from VTS earlier or just plain old delimited
text. The new command would look like this:
START vtconsole -port 9999 –launch – file
\\MACHINENAME\DIRECTORY\file.csv
You can also setup VTS
to export it’s current data to a file and also to periodically update this
file. Just select Options > Export / Import.
Connecting to VTS
Now it is running, you can create a script that uses it. First of all you need to copy this to the vuser_init() section.
#include "as_web.h"
#include "vts2.h"
vuser_init()
{
return 0;
}
Then you need to load the VTS dll and include a reference to the table itself, a bit like this:
vuser_init()
{
lr_load_dll("vtclient.dll");
lrvtc_connect( “[MACHINE_NAME/IP]”,9999,0);
return 0;
}
Then you need to load the VTS dll and include a reference to the table itself, a bit like this:
vuser_init()
{
lr_load_dll("vtclient.dll");
lrvtc_connect( “[MACHINE_NAME/IP]”,9999,0);
return 0;
}
Note. MACHINE_NAME/IP is where you have the VTS server(s) running.
For best practice you can improve this code to look like this:
#include "as_web.h"
#include "vts2.h"
vuser_init()
{
PVCI pvci = 0;
int rc = 0;
char *VtsServer = “{VTS_SERVER}”;
lr_load_dll(“vtclient.dll”);
pvci = lrvtc_connect( VtsServer,9944,0);
rc = vtc_get_last_error(pvci);
if( rc != 0 ) {
lr_message(“Connection to VTS %s failed”, VtsServer);
return -1;
}
return 0;
}
Note. {VTS_SERVER} is the name of the machine running VTS.
So you have VTS up and running and your script connects to it. Now you just need to use it.
Using VTS
VTS comes with a document listing all the functions and I am not about to repeat this here, so I attached it. That said, the documentation is poor and contains errors, so beware.
In essence you can write, read, read unique, read a whole row and write a whole row. Think of it like a dat file but the difference is you can read and write to this dat file as the scripts are being executed and all scripts can share the same data.
But you CANNOT query VTS. You can’t say give me all data where CAT_ID=3 or anything like that. Just: give me the next CAT_ID.
When you read data from VTS it has a handy feature where you can read and remove the data from the table – you don’t have to do this but it is generally useful as more often than not you are using VTS because you have context sensitive data that can only be ‘used’ once, or perhaps one at a time. Something like this.
So, how to do all this:
Let’s say you have Script A that is creating orders and Script B that is paying them. Script A would connect to VTS Port 8888 and write data, Script B would also connect to VTS Port 8888 but it would read data.
It would look like this:
Script A
Action()
{
[Do some stuff here to create a new user]
//Now write out the relevant data to VTS
lrvtc_send_row1(“password;email”, “hello123;{p_UniqueUsername}@MYDOMAIN.com”, “;”, VTSEND_SAME_ROW);
return 0;
}
Script B
Action()
{
lrvtc_retrieve_row("email;password",";");
[Do some stuff here using this email and password]
Return 0;
}
Notice that when I wrote the data to VTS I was able to use a parameter {p_UniqueUsername} – this is worth remembering, it’s pretty essential. I also made the example use two columns and thus the retrieve_row function. Also by using ‘retrieve’ row I am removing that row from the table.
You could also have a script that starts by removing a row from a table, then it does some stuff with it, and then it writes it back when it is finished. This enables you to prevent two scripts working on the same record at the same time.
You could also have multiple VTS tables representing ‘states’ of data. For example. An insurance quote needs to be created by a ‘clerk user’ then validated by a ‘super user’ then authorised by a ‘auth user’ – whatever – the point is you have one record going through multiple states and rather than one long script where you have to log in and out multiple times to complete the journey, you use VTS to manage the data.
Finally, something to think about when using multiple tables like this is that sometimes you might find a VTS table empty. In this scenario you need to code a do, while loop that polls the VTS table looking for a record before carrying on. This prevents the script failing and, if you code the loop well, it will prevent over loading your system artificially.
Conclusion
Anyone with data that can only be used once, with data that they want to pass between scripts or with data that they generate during the run that they want to keep, should use VTS. Basically that’s pretty much anyone using LR.
The Virtual Table Server (VTS) service maintains a database accessible by several clients (load generator) on the same network.
With VTS, several load generators can obtain values from a single common pool of values. One Vuser can create key values (such as a new customer ID), and any number of other Vusers can immediately use that value.
There are several versions of VTS. The VTS3 comes with LoadRunner 11.52 was completely rewritten to exchange data using REST JSON from a Node.JS server encapsulated in a 64-bit executable.
VTS2 was a 32-bit Windows program and uses an in-memory database.
Installation
Running VTS
Now you have it installed, think about where you want to run it. Think of each little VTS as a server (they are essentially). So they need to run on a machine that is available to every LG that want s to use it – ie. You have to have network connectivity. You could just use your Controller box but it’s nice to have a separate box for VTS as it can use up a lot of memory and, potentially, network bandwidth.
CD "C:\Program Files\HP\LoadRunner\bin\"
START vtconsole -port 9999 -launch
START vtconsole -port 9992 –launch
#include "as_web.h"
#include "vts2.h"
{
return 0;
}
vuser_init()
{
lr_load_dll("vtclient.dll");
lrvtc_connect( “[MACHINE_NAME/IP]”,9999,0);
}
vuser_init()
{
lr_load_dll("vtclient.dll");
lrvtc_connect( “[MACHINE_NAME/IP]”,9999,0);
}
#include "as_web.h"
#include "vts2.h"
{
PVCI pvci = 0;
int rc = 0;
char *VtsServer = “{VTS_SERVER}”;
lr_load_dll(“vtclient.dll”);
pvci = lrvtc_connect( VtsServer,9944,0);
rc = vtc_get_last_error(pvci);
if( rc != 0 ) {
lr_message(“Connection to VTS %s failed”, VtsServer);
return -1;
}
return 0;
}
Action()
{
[Do some stuff here to create a new user]
lrvtc_send_row1(“password;email”, “hello123;{p_UniqueUsername}@MYDOMAIN.com”, “;”, VTSEND_SAME_ROW);
return 0;
}
Action()
{
lrvtc_retrieve_row("email;password",";");
}