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

来源:互联网 发布:jira7找不到mysql驱动 编辑:程序博客网 时间:2024/05/10 10:40

  一直在学习性能测试,在虚拟机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);



原创粉丝点击