How to use VTS (5281 Views)
Reply
Trusted Contributor
Oliver Lloyd
Posts: 218
Registered: ‎03-12-2009
Message 1 of 21 (5,281 Views)

How to use VTS

Virtual Table Server (VTS) - A quick how to guide.

 

VTS is an unsupported add-on for LoadRunner. It is non-version specific and, to the best of my knowledge, no longer being developed – not for a long time. So it is what it is and no-one has any responsibility to help you with it. But that said, it is a very sturdy, reliable little beast – in all the years I have been using it I have not once come across any bug, or had a crash or in any way had a problem with this tool – it just works.

It is a simple in memory database that can be easily setup and used by LoadRunner to allow data to be dynamically shared, in real time as a scenario is being executed, between different virtual users.

It is the solution for when you want to store data that is being created by a script, for when you want to pass data from one script to another, for when you have data that can only be ‘used’ once and a lot more besides.

 

Installation

Initially this looks messy and there’s precious little advice on how to do this but it’s actually a breeze. You download the file vts2.zip  from here: VTS KB Article

 

You take this file (the zip file - also attached here) 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
  6. That’s it. It’s installed. Simple, no?

Oh, you may need to register a couple of files. I’ve not had to do this for some time now but it is listed as a required step so:

  1. Open a CMD Prompt
  2. Type <regsvr32 “C:\Program Files\HP\LoadRunner\bin\ vtsctls.ocx”> (Only the text inside the brackets…)
  3. Type <regsvr32 “C:\Program Files\HP\LoadRunner\bin\ msflxgrd.ocx”> (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 – maybe use your desktop? – and double-click it.

 

Now you should see two windows pop up that look like some old school VB app with some grid control in the centre.

 

 

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;
}

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);
retun 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.

Oliver
Frequent Advisor
DaveP_1
Posts: 74
Registered: ‎08-19-2010
Message 2 of 21 (5,281 Views)

Re: How to use VTS

As a further example, I use an incremented/decremented single row, single column VTS integer field to record vuser concurrency (increment at logon, decrement at logoff) to good effect. I then read the table value at regular intervals and write out a Data Point.

 

Oliver's text is about as comprehensive a guide as you are likely to find. Excellent!

 

Now, if you want to do the same for MySQL in LoadRunner...   ;-)

Occasional Visitor
Greg-mck
Posts: 1
Registered: ‎03-24-2011
Message 3 of 21 (5,281 Views)

Re: How to use VTS

I second DaveP, excellent piece of work for a quick how to guide on using VTS, thanks for the effort Oliver.

 

Another example which I’ve used it for:

 

We had a project that introduced a new production database restore every 3-4 days into the testing environment (don’t ask), building the 30-40 parameter files in a quick turn around even using SQL queries would take up a day of that time.

 

I finished up using VTS and generic data building scripts to create the data that would be needed at each stage of the SUT ordering process. Some orders at status of 10, 25,50,75 percentage complete.  This allowed me to be up an executing the testing as soon as the restore was completed.  Simply a 5-10 minute window to start getting orders in place.

 

For the real scripts to execute, I simply hooked into the necessary VTS column to pickup the next order number to use.  The SUT orders where created, modified, dispatched, and deleted.  I never needed to rely on the production data.

 

I also developed my own wrapper modules to automatically load up the VTS tables when the scenario is started and unload to flat files when the scenario finished, just like the suggestion DaveP discussed above.  Have a script to keep an eye on the number of active vusers when ‘0’ then unload the VTS tables.  That way I could reuse any orders that weren’t used in the previous scenario run, thus always keeping the data generation ahead of the data consumers.

 

These is a lot of power that can be used with VTS, you are only limited by what you can think of and also like Oliver, if there was a fan club, I’d be in it also.

 

Trusted Contributor
AdiKidron
Posts: 201
Registered: ‎03-21-2011
Message 4 of 21 (5,281 Views)

Re: How to use VTS

For additional information check out this site : http://www.wilsonmar.com/1mercvts.htm by Wilson Mar

JBN
Occasional Visitor
JBN
Posts: 1
Registered: ‎05-17-2011
Message 5 of 21 (5,281 Views)

Re: How to use VTS

Be aware that VTS does not support concurrent requests. Every request to VTS is handled sequentially and it does not contain any queuing mechanism. This means that if 2 vusers make a request to VTS at the same time only one of them will receive a correct response. The other vuser receives an error which can only be seen by manually checking the return code (RC) from the call to VTS.
Trusted Contributor
Oliver Lloyd
Posts: 218
Registered: ‎03-12-2009
Message 6 of 21 (5,281 Views)

Re: How to use VTS

Dave, mySQL for LoadRunner? It's all here: query-mysql-with-loadrunner.

 

All kudos to Stuart M.

Oliver
Frequent Advisor
DaveP_1
Posts: 74
Registered: ‎08-19-2010
Message 7 of 21 (5,272 Views)

Re: How to use VTS

Oliver

Sorry, been away from the group for a while - missed your post. Thanks a bunch - really interesting.

 

Regards

Dave

Valued Contributor
Deb_1
Posts: 136
Registered: ‎09-01-2010
Message 8 of 21 (5,260 Views)

Re: How to use VTS

Hi Oliver,

 

Thanks for this information. I had never used it before but it looked to match my requirements where I need to write and retrive generated IDs and numbers etc. Currently I am writing out puts to a shared flat file and then reading it.

 

So to give it a try, I followed the steps and set up a VTS server on local machine. Basically using same machine as vugen and VTS server .. so connection to the VTS server is staright forward .. no netwwork inbetween .. it's all in my machine 

 

However when I run the vugen script .. it'e getting failed to connect to VTS server as it says .. code I copied from the example given by you and changed the server to my loacl IP/machine address..

 

Not sure what could be the issue . can you please give me some hint 

 

I am using LR 9.52 and my machine OS is Win XP with Intel Core 2 DUO procesor..

 

Here is snapshot of log ...

 

Starting iteration 1.

Starting action Action.

Connection to VTS 10.zz.xx.yy failed

 

Thanks

Thanks
Deb
Frequent Advisor
DaveP_1
Posts: 74
Registered: ‎08-19-2010
Message 9 of 21 (5,257 Views)

Re: How to use VTS

Hi Deb

 

You may have missed a step - VTS has been around since Adam was lad, so it works for all versions.

 

Have you registered the dlls?

 

Start the VTS:

start vtconsole.exe -launch -port 8885 -file C:\LR_VTS\<Your Data File>.dat
Check that you can see the VTS on your screen - with your data if there is any.

 

Put this in globals.h:

#include "vts2.h" // with existing includes (if no globals.h, put where other includes reside)

 

PVCI pvci = 0; // with global variables


put in vuser_init:

int rc;
    // Load the client VTS DLL
    rc = lr_load_dll("vtclient.dll");
    if (rc != 0)
    {
        lr_error_message("lr_load_dll rc:%d", rc);
        lr_exit(LR_EXIT_VUSER,LR_FAIL);
    }

    // ************************************************
    // Test data input VTS connection before continuing
    // ************************************************
    pvci = vtc_connect(127.0.01, 8885, VTOPT_KEEP_ALIVE);
    rc = vtc_get_last_error(pvci);
    vtc_disconnect(pvci);

    if(rc != 0)
    {
        lr_error_message ("VTS connection failed");
        lr_exit(LR_EXIT_VUSER, LR_FAIL);
    }
    // ************************************************


This should indicate where the problem lies.

Valued Contributor
Deb_1
Posts: 136
Registered: ‎09-01-2010
Message 10 of 21 (5,231 Views)

Re: How to use VTS

 

Hi Dave,

 

Thanks for the information but still stuck with the issue. 

 

I have done exactly what explained by Oliver and in the VTS document 

 

Registered the msflxgrd and  vtsctls.ocx and it was succeeded as shows the message

 

Then I tried the below commands, though I am able to launch the VTS interface, can not see any data (whether dat or CSV file). Though I have data in the files, VTS server shows empty. Attached the screen shot

 

C:\Program Files\HP\LoadRunner\bin>START vtconsole -port 9999 -launch -file C:\Program Files\VTS\Installation.csv

C:\Program Files\HP\LoadRunner\bin>START vtconsole -por 8885 -launch -file C:\Program Files\VTS\Installation.csv


However I modified the script in vugen but it went to below condition and exited, means not able top connect


I have attached step by step screenshot  in the attached doc.  Can have a look and let me what going wrong?


Seems stuck here with no clue. Appreciate any help

 

-Deb


Thanks
Deb
Trusted Contributor
Oliver Lloyd
Posts: 218
Registered: ‎03-12-2009
Message 11 of 21 (5,224 Views)

Re: How to use VTS

Seems like you have two issues.

 

1. There is a space in the directory path to your data file. Now, I know that Windows does this, it uses 'Program Files', but it's one of the world's mysteries why Microsoft thought using spaces in directory names was a good idea. Almost as strange as using the backslash and not forward slash but that's another discussion.

 

So, sure, it is possible to accomodate spaces, in your case you can simply enclose the path in quotes. But it tends to lead to problems later - and this, at first glance, seems to be show. Instead, try to develop the habit of using underscores. Oh, and keep everything in lowercase while you're at it.

 

2. It is failing to connect in your script because you are using port 8885 and your server is running on port 8888.

Oliver
Valued Contributor
Deb_1
Posts: 136
Registered: ‎09-01-2010
Message 12 of 21 (5,213 Views)

Re: How to use VTS

Hi Oliver,

 

Yes after moving the data file direct under C:\, now I can see data in VTS console. Thanks for suggestion 

 

However I can not connect to VTS server from my LR script .. I have no clue what is happening .. it cant be so difficult to connect to VTS server ..  To make sure i have no firewall problem inbetween, went to services and disabled Windows Firewall/Internet Conenction Setting (ICS) service, but still no luck 

 

So I just down load the example scripts VTS_Main_Example or VTS_Main_Example_retrieve from HP site, changed the IP address and run with complete log .. can see it's still not able to connect VTS server.  error I am getting 

 

Action1.c(39): ******************** The VTS Handle is : 29772840

Action1.c(47): ******************** VTS Error - Send Return Code = -10003

 

Any more help??

 

Thanks

Deb

Thanks
Deb
Valued Contributor
Deb_1
Posts: 136
Registered: ‎09-01-2010
Message 13 of 21 (5,209 Views)

Re: How to use VTS

Ignore my earlier post for not able to connect to VTS server thru LR scripts.. i did not start the server by clicking Start button on VTS console before running the script ..:-(
A classic fundamental mistake !!

Anyway thanks to Oliver and Dave for suggesting so many things
Thanks
Deb
Occasional Contributor
krishnasqa
Posts: 5
Registered: ‎07-22-2011
Message 14 of 21 (5,192 Views)

Re: How to use VTS

Hi all,

 

I am having a problem, I have the following statements in my start_vts.bat file, but I am unable to see any data when I invoke it. Could you please advise if there is any how I can fix this.

 

ECHO ON
CD "C:\Program Files\HP\Virtual User Generator\bin\"
START vtconsole -port 9999 -launch - file c:\myfile.csv

Occasional Contributor
krishnasqa
Posts: 5
Registered: ‎07-22-2011
Message 15 of 21 (5,175 Views)

Re: How to use VTS

Hi all,

 

I am having a problem, I have the following statements in my start_vts.bat file, but I am unable to see any data when I invoke it. Could you please advise if there is any how I can fix this.

 

ECHO ON
CD "C:\Program Files\HP\Virtual User Generator\bin\"
START vtconsole -port 9999 -launch - file c:\myfile.csv



Trusted Contributor
Oliver Lloyd
Posts: 218
Registered: ‎03-12-2009
Message 16 of 21 (5,172 Views)

Re: How to use VTS

Remove the errorneous space. You can't just go around typing random spaces into your code and expect it to work!

Oliver
Occasional Visitor
ishreddy
Posts: 3
Registered: ‎03-12-2012
Message 17 of 21 (4,622 Views)

Re: How to use VTS

Hi,

Does VTS work for Java VUser? Can some one share sample code and supporting JARs files?

I was able to connect and run the example script for C VUser. Looking for Jvascript code.

 

Thanks,

Sreehari

Occasional Visitor
chasgrot
Posts: 1
Registered: ‎03-13-2013
Message 18 of 21 (3,386 Views)

Re: How to use VTS

Is it possible to set export options in the bat file? i.e. Save to file xxxx every nn seconds. Or is it something that can only be set once VTS is running?

Frequent Advisor
DaveP_1
Posts: 74
Registered: ‎08-19-2010
Message 19 of 21 (3,374 Views)

Re: How to use VTS

I'm fairly sure that you can't.

Be careful when setting the output file if you started VTS with an input file. It sometimes defaults to the input filename. If you accept, it will overwrite your input data without so much as a by your leave.

Occasional Visitor
Sumit_Khaitan
Posts: 1
Registered: ‎08-22-2013
Message 20 of 21 (1,769 Views)

Re: How to use VTS

I do also have the same query "How to use VTS with Java Vuser/Protocol"

Occasional Visitor
SOA_QA
Posts: 1
Registered: 3 weeks ago
Message 21 of 21 (136 Views)

Re: How to use VTS

First of all, thank you very much for providing all this information. I am able to install and register above mentioned file. However, when i am running a script, i am getting below error :

In file included from c:\users\374898\desktop\vts_2_10\vts_example_scripts\vts_main_example\\combined_VTS_Main_Example.c:3:
Action1.c:10: vts2.h: No such file or directory

 

I know this is very basic error and i have tried lots of thing, but i am getting any idea how can i fix this?

 

Your help is really appreciated!!

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.