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

上一篇 / 下一篇  2011-08-11 10:45:38 / 个人分类:测试

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

  1. vuser_init()  
  2. {  
  3.   
  4.     lr_save_string("192.168.159.144","IP");  
  5.     return 0;  
  6. }  


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

  1. web_url("forum.php_3",   
  2.     "URL=http://{IP}/bbs/forum.php?mod=forumdisplay&fid=38",   
  3.     "Resource=0",   
  4.     "RecContentType=text/html",   
  5.     "Referer=http://{IP}/bbs/forum.php",   
  6.     "Snapshot=t122.inf",   
  7.     "Mode=HTML",   
  8.     LAST);  


TAG:

 

评分:0

我来说两句

Open Toolbar