Monday, 14 April 2014

VTS(VIrtual Table Server) Enhancements in LR 12.0

VTS IN LR 12.00

         In LoadRunner 12.00, the VTS enhancements include multi-instance support, TruClient native support, sample data, etc. Another small handy feature is supporting database APIs in different protocols, which can be used as an alternative to VTS.

Multi-instance Support

         The old 2.x version of VTS is a Windows application, and users can run multiple instances on a single machine. Each process will listen to a TCP port, and each will serve one data table. The VTS in LoadRunner 11.52 is web-based and run as a Windows service, however it can only serve one table per machine. We added this feature to the new VTS in LR 12.00 in response to customers' requests.

       There are two ways to launch multiple instances of the VTS on the same machine - from the command line, and from the web UI.

      For the VTS instances that are running on one machine, there are two types, which have some slight differences between them:
  • Main Instance: This is the instance that always run when the VTS service starts. It behaves the same as the VTS in LR 11.52. There can be only one main instance per machine, and user can create additional named instances from main instance UI.
  • Named Instance: There can be multiple named instances, as long as they have different names and ports, both of which should be unique across all instances.
The differences are:
  1. A named instance will only use one port, and the port is for both API access and Admin UI display.
  2. You cannot create other named instances on this Admin UI.
  3. The title of the Admin UI changed to ‘VTS - <Instance Name>’, so that the user can easily identify the instance from the tab, as follows:
p1.png

Here are some short descriptions on the two ways to manage instances.

1. Command-Line Mode
The command tool (vtscmd.js) is a JavaScript file that runs with node.exe, which can be found in the same folder. The following is the screen of the command mode.
p2.png


In the new version we will allow users to run the following commands:

  • node vtscmd /start /port 4001 /name <InstanceName>
  • node vtscmd /import file1.csv /port 4001 /delimiter \t

The first line starts a new instance and the second line imports the data file into the VTS table that listens on the same port. "/delimiter" is optional and by default uses ",".  The VTS Windows service should already be started when you run commands, and the command tool should be used on the same machine that runs the VTS service. All of the commands will communicate with the VTS service, so after launching the instances, they can survive the user logging out and machine restarts.

There are demo .bat files in the VTS installation folder, to show how to launch new instances of VTS and how to stop them. You can find them under folder "\Program Files\HP\VTS\web\samples". One limitation of this release is that when you try to stop the VTS instances, the process may still be running until you stop the VTS service. If instances are still running, it will block you from creating another instance with the same name or port. To make the ‘stop’ action take effect, you can restart the Windows service, with the command “net stop vtsservice” followed by “net start vtsservice”.

2. UI Mode
The user can also manage VTS instances from the main instance’s UI, with the File menu Options -> Other Instances. There are two dialogs, one to start new instances and the other to stop instances.
p3.png

Now one machine may run multiple instances of VTS, including one main instance and multiple named instances. In 12.00, API access of all instances will be enabled or disabled together, and only from the main instance UI. The following UI has been updated to reflect the change. Notice the tooltip indicates that "Enable/Disable API Access" action will affect all running instances:
p4.png

One more tip - the VTS runs on the node.js engine, and is written in JavaScript. Therefore, if you feel curious, you can open Task Manager to check how many node.exe processes running, to find out how many VTSs are running.
  
VTS Support in TruClient
In LR 11.52, the user needs to write VTS API calls in a C function, and then use it in TruClient scripts, which is not very convenient. As of 12.00, VTS JavaScript APIs are available in TruClient which can be used directly in TruClient steps. You can add "Evaluate JavaScript" step in the TruClient Sidebar, and add some code similar to the following:
TC.vtcConnect("localhost",8080,"myVTSAlias");
…
TC.vtcGetCell("columnName1",1, "myVTSAlias");
TC.vtcAddCell("columnName2", 1, "myVTSAlias");

Some Other Improvements
Sample data
Sample data has been added to VTS, for example, Customers and Employees, so that users can create sample scripts with data out-of-the-box. Just click the menu Options -> Import Samples to import the sample data table. If you have your own csv files and want to access them often, you can also put them under the samples folder, and the files will also displays on the menu.

Installation
The installation package contains both 32-bit version and 64-bit versions. If you have 64-bit windows, it will install the 64-bit version automatically, otherwise it will install the 32-bit version. The 64-bit version is expected to be more scalable because it uses 64-bit node.js. If you want to install VTS silently, you can run a command like "SetupVTS.exe /s /a /s". There’re actually 2 operations here – extraction files and then installation. Hence the “/s” appears twice, one for each stage.

Step Toolbox
The VTS API can be found in the VuGen Toolbox, so if you don't want to remember the long API names, you can drag and drop from the toolbox to use them.

Database API Support
Although database APIs have nothing to do with VTS, they can be used to make calls to databases in your script, allowing you to use databases as the shared parameter server. Before LR 12.00, there were several database APIs in the Web Service protocol:
  • lr_db_connect
  • lr_db_disconnect
  • lr_db_executeSQLStatement
  • lr_db_dataset_action
  • lr_checkpoint
  • lr_db_getvalue
But they can only be used when web service protocol is used. As of LR 12.00, we migrated them to all of the other C language protocols, e.g. Web HTTP/HTML, Flex, etc. You will notice that they appear on the Step Toolbox of VuGen, so you can design the database steps just as you did in the Web Service protocol.

Some More Information
There are some trouble-shooting tips, not necessarily related to LR 12.00 but worth mentioning here.
  • Some scripts use "lrvtc_update_message_ifequals" heavily and users have noticed that the API becomes slow when there is a lot of data. The cause is there is no index on the column. Just like databases, when there is no index on the column, checking uniqueness of a value will scan all the data. The solution is to add an index to this column. This can be achieved by either the Admin UI or lrvtc_ensure_index API in the script. Note that deleting the entire column will also delete the index, so the next time you create a column of the same name, you need to build index again.
  • If you wants to trouble shoot issues with VTS, you can check the log files. To troubleshoot remotely, you can also read the log file from the web URL http://<server>:4000/data/diag/log. Accessing the log remotely is by default turned off, but you can turn it on by changing the setting "enableDiag" to true in the configure.json file and restarting the service.
  • One common misunderstanding is the return value of the lrvtc_connect API. Unlike another similar API vtc_connect, which returns a handle, lrvtc_connect return the status code of connection. So vtc_connect returns non-zero when connecting successfully, while lrvtc_connect returns zero upon success. 
Some customers requested VTS support for Java and .NET protocols. They are still not available in 12.00 yet, but we will consider adding support in a future release. But until that happens, users can implement it themselves using the VTS Communication Spec, which can be found on HP Live Network, at HP LoadRunner and HP Performance Center > Other Files > VTS3 Communication Specification.

 The transport is in pure JSON format, which is well supported in most programming languages and it will not be difficult for you to write your own VTS client APIs in different languages. By writing your own client, you can also use VTS as the integration component, to allow the LoadRunner testing script to work with other testing tools at the same time.

No comments:

Post a Comment