第一个web压力测试例子

上一篇 / 下一篇  2015-10-08 10:00:13 / 个人分类:LoadRunner

/*
*     web 端口 压力测试
*     URL = http://192.168.**.**/
*
*/

Action()
{
   
// 创建一个集合点
   lr_rendezvous("rendezvous");

// 添加 事务  (这一步可以直接通过VuGer 插入事务来确定)
    lr_start_transaction("frist_transaction");
// 思考/停留 1 秒  (可以不要)
   lr_think_time(1);

// 加载 相应的 网页/GET 资源
   web_url("first web_url ",
    "URL=http://192.168.**.**/", 
"Resource=0",                  //Resource表示该对象是否是Non-HTML Resource。
"RecContentType=text/html",   //RecContentType表示录制对象的MYME type
"Referer=",                   // 利用 referer 访问 head 头文件 
"Snapshot=t1.inf",            // 关联文件
"Mode=HTML",                  // 样式 
    EXTRARES, 
    "Url=/cas/css/login.css","Referer=http://192.168.**.**/cas/login?service=http%3A%2F%2F192.168.**.**%2F", ENDITEM, 
    "Url=/cas/images/01.jpg","Referer=http://192.168.**.**/cas/login?service=http%3A%2F%2F192.168.**.**%2F", ENDITEM, 
    "Url=/cas/images/bg.jpg","Referer=http://192.168.**.**/cas/login?service=http%3A%2F%2F192.168.**.**%2F", ENDITEM, 
    "Url=/cas/images/bg2.jpg","Referer=http://192.168.**.**/cas/login?service=http%3A%2F%2F192.168.**.**%2F", ENDITEM,
    "Url=/cas/images/logo1.png","Referer=http://192.168.**.**/cas/login?service=http%3A%2F%2F192.168.**.**%2F", ENDITEM, 
    "Url=/cas/images/line.jpg","Referer=http://192.168.**.**/cas/login?service=http%3A%2F%2F192.168.**.**%2F", ENDITEM, 
    "Url=/cas/images/input.jpg", "Referer=http://192.168.**.**/cas/login?service=http%3A%2F%2F192.168.**.**%2F", ENDITEM, 
    LAST)

//获取 响应资源 大小,并输出
  lr_out_message("first web_url 响应大小 = %d",web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE));


// 结束 事务
   lr_end_transaction("end_frist_transaction");

    return();
}


注意:
Int Web_url(const char *name, const char * url, <Lists of Attributes>, [EXTRARES,<Lists of Resource Attributes>,LAST)
返回值 成功时返回LR_PASS (0),失败时返回 LR_FAIL (1)。
参数: Name:VuGen中树形视图中显示的名称,在自动事务处理中也可以用做事务的名称。
url:页面url地址。
List of Attributes
EXTRARES:分隔符,标记下一个参数是资源属性的列表了。
List of Resource Attributes
LAST:属性列表结束的标记符。
说明 Web_url根据函数中的URL属性加载对应的URL,不需要上下文。
只有VuGen处于URL-based或者HTML-based(此时A script. containing explicit URLs only选项被选中时)的录制模式时,web_url才会被录制到。
可以使用web_url 模拟从FTP服务器上下载文件。web_url 函数会使FTP服务器执行文件被真实下载时的操作。除非手工指定了"FtpAscii=1",下载会以二进制模式完成。
在录制选项中,Toos—Recording Option下,Recording选项中,有一个Advanced HTML选项,可以设置是否录制非HTML资源,只有选择了“Record within the current script. step”时,List of Resource Attributes才会被录制到。非HTML资源的例子是gif和jpg图象文件。
通过修改HTTP头可以传递给服务器一些附加的请求信息。使用HTTP头允许请求中包含其他的内容类型(Content_type),象压缩文件一样。还可以只请求特定状态下的web页面。
所有的Web Vusers ,HTTP模式下的WAP Vusers或者回放模式下的Wireless Session Protocol(WSP),都支持web_url函数。







TAG: 压力测试

 

评分:0

我来说两句

Open Toolbar