What is Virtual Table Server in HP LoadRunner?
Virtual Table Server is a tool that enables sharing of test data and parameters between LoadRunner VUsers. Usually performance testers use parameterization in their scripts, but in VTS it acts as centralized repository to store data which can be shared between VUsers during the test execution.
- Create a C language script as shown below:
int rc = 0;
char *VtsServer = "192.168.0.100";
int nPort = 8888;
PVCI2 pvci = 0;
vuser_init()
{
pvci = lrvtc_connect(VtsServer,nPort,VTOPT_KEEP_ALIVE);
lr_log_message("pvci=%d\n", pvci);
return 0;
}
- In Action.c, add some code to retrieve one column from the server and remove from the server at the same time. You can run the action multiple iterations, and it will retrieve one:
char * cname; //column name
int ret;
RetrieveMessage()
{
lr_start_transaction("retrieve_column");
rc = lrvtc_retrieve_messages1("cname",";");
lr_log_message("lrvtc_retrieve_messages1 rc=%d\n", rc);
lr_log_message("cname is %s", lr_eval_string("{cname}"));
lr_end_transaction("retrieve_column", LR_AUTO);
}
Action()
{
RetrieveMessage();
return 0;
}
- In vuser_end.c, add API call to close the VTS handle:
vuser_end()
{
lrvtc_disconnect();
return 0;
}
You can test it in VuGen and then run it in Controller.
Turn on the API access port before you execute the script.
Like the old VTS, the new one uses 8888 as the port for API to access.
It is turned off by default, Navigate to the administrative UI to enable it.
No comments:
Post a Comment