您的位置:首页 > 其它

loadrunner使用lr_save_string()函数保存服务器IP地址

2011-08-11 10:30 411 查看
  一直在学习性能测试,在虚拟机ubuntu上搭建了php的环境,然后装了一个discuz。用loadrunner录制好脚本后,服务器的IP都是写死的,一旦重启服务器,虚拟机的IP地址就可能发生变化。这时候就需要参数化服务器的IP地址。我使用的是lr_save_string()方法。下面是官方文档中它的介绍。

int lr_save_string( const char *param_value, const char *param_name);

The lr_eval_string function returns the input string after evaluating any embedded parameters. If the string argument contains only a parameter, the function returns the current value of the parameter.

Embedded parameters must be in brackets. 

使用很简单,只要在vuser_init()中使用就ok了。

vuser_init()
{

lr_save_string("192.168.159.144","IP");
return 0;
}


然后在其它地方使用IP参数,如下:

web_url("forum.php_3",
"URL=http://{IP}/bbs/forum.php?mod=forumdisplay&fid=38",
"Resource=0",
"RecContentType=text/html",
"Referer=http://{IP}/bbs/forum.php",
"Snapshot=t122.inf",
"Mode=HTML",
LAST);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息