博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

使用loadrunner做性能测试 经验总结二

Posted on 2011-05-11 20:52  xshy  阅读(479)  评论(0编辑  收藏  举报

问题:项目使用了Ajax技术,有些请求的参数巨多,主要是一些坐标对,对于跨域访问,使用了jsonp协议,但是发送请求使用Get方式,就会对请求长度有限制,浏览器在处理这种超过最大限制的请求时,是将一个请求分为两部分,相当于发两次请求。loadrunner在录制时,忠实地将这两个请求记录为两个web_url。记录下来的脚本如下所示:

web_url("commonhandler_4",
                "URL=http://www.mydomain.com/iserver/commonhandler?mapName=【。。。。此处省去若干参数串】&sectionCount=2&sectionIndex=0&jsonpUserID=1305099187125",
                "Resource=0",
                "Referer=http://www.mydomain.com/map/",
                "Mode=HTTP",
                LAST);

        web_url("commonhandler_5",
                "URL=http://www.mydomain.com/iserver/commonhandler?method=Search&t=1305099187125&jsonp=sm_callbacks[13050991871255502]&sectionCount=2&sectionIndex=1&jsonpUserID=1305099187125",
                "Resource=0",
                "Referer=http://www.mydomain.com/map/",
                "Snapshot=t336.inf",
                "Mode=HTTP",
                LAST);

这个脚本在重放时,虽然显示成功,但是却得不到返回结果,而且服务器端也没有接收到请求,结果日志如下:

Starting iteration 1.
Warning -27077: The "vuser_init" section contains web function(s) when the "Simulate a new user on each iteration" Run-Time Setting is ON.  This may produce unpredictable results with multiple iterations          [MsgId: MWAR-27077]
Starting action Action.
Action.c(6): web_url("commonhandler_4") was successful, 0 body bytes, 102 header bytes          [MsgId: MMSG-26386]
Action.c(16): web_url("commonhandler_5") was successful, 0 body bytes, 102 header bytes          [MsgId: MMSG-26386]
Ending action Action.

 

考虑一下,觉得问题应该和这个一个请求,分两个web_url有关系,每一个url都是不完整的。试过很多种方法后,最后总算找出一个行得通的方案:

两个请求合并为一个请求,这个请求中包含两个请求的参数,去掉jsonp相关的参数,和web服务器用来识别分段请求的两个参数sectionCount、sectionIndex。只保留服务器应用程序中用到的参数。这样,重放成功,服务端也得到了完整的请求。

这种方法为什么能行得通,还是一头雾水,看来还需要对loadrunner、浏览器对于http协议的支持继续深入研究。