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

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



评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值