Friday, September 23, 2016

Virtual Table Server - VTS





Normally we use parameters in load runner scripts to store data but sometimes we faced some issues like one script is generating some data that required in other scripts. Previously for this issue, we used to do all the actions in a single script only or write some code to export that data into one file then use that file.


For solving that issue, HP has introduced a functionality called Virtual Table Server. Virtual Table Server also known as VTS is a tool that shares test data between Virtual Users. It uses a centralized repository to store data and data can be passed to Vusers during the test execution. It maintains a memory database that can be accessed by different machines also on a network.
Virtual Table Server mainly helps scripts that have data dependency generated from other scripts.
For e.g. If a script called “Create_ticket” generates a Ticket ID which is assigned to a particular user, Using VTS, this ticket ID can be inserted into a table during runtime and retrieved by “Close_ticket” script by that particular user.
Below Diagram shows how VTS work during test execution.



How to Install VTS?

HP provides a setup file for VTS in “Additional_Components” folder named Virtual Table Server. By Default it uses 4000 port number that can be configured during installation.
After Installation, VTS can be accessed using the following URL with configured port number. “IP_Address:PortNumber”
·                  IP Address is the IP of the machine. You can also use the host name of that machine instead of IP Address.
·                  Port Number is the port configured during the installation. By Default it is 4000.

Multiple Tables can be created by creating other instances in the options menu.

After Successful Completion, You have to enable “Access from Script”. After that only you can access VTS from load runner scripts.





While enabling access from the script, you can configure the API access port also that Load runner will be using to access VTS.













How to Use VTS using LoadRunner Scripts?

There are predefined methods to access VTS using LoadRunner scripts.
1.       Firstly, you have to connect to VTS using the script by calling below method 
                  a. lrvtc_connect(HostName, PortNo, VTOPT_KEEP_ALIVE);
          Here HostName is the IP or the hostname of the machine in which VTS is installed.
                PortNo is the configured port no to access VTS (Default it is 8888).


2.       For Inserting data into VTS using script during runtime, there are predefined methods for below operations and more:
             Inserting multiple columns value in single Row.
                     lrvtc_send_row1("Column1;Column2","Value1;Value2",";",VTSEND_SAME_ROW);
        Inserting unique values in columns
                     lrvtc_send_if_unique ( char *columnName, char *value );
        Inserting single column value
                     lrvtc_send_message ( char *columnName, char *value );

3.       For Retrieving data from VTS into Load Runner Scripts, There are also predefined methods for following :
             Retrieve all columns data of a row
                       lrvtc_retrieve_row ( );
        Retrieve single column data of a row
                       lrvtc_retrieve_message ( char *columnName );

4.       After Test Execution, you have to disconnect from VTS by using below method
              lrvtc_disconnect();


Advantage of VTS over Parameterization:
1.       Test data can be shared during virtual users during Test execution.
2.       Dependencies can be removed between multiple scripts using VTS.
3.       Data can be imported and exported in CSV format from VTS that can be useful if you want to reuse the data.


Disadvantage of VTS over Parameterization:
1.       Once data is retrieved from VTS, it gets deleted from VTS table.