收藏 分享(赏)

LoadRunner案例分析.doc

上传人:HR专家 文档编号:11406874 上传时间:2020-04-17 格式:DOC 页数:14 大小:27.15KB
下载 相关 举报
LoadRunner案例分析.doc_第1页
第1页 / 共14页
LoadRunner案例分析.doc_第2页
第2页 / 共14页
LoadRunner案例分析.doc_第3页
第3页 / 共14页
LoadRunner案例分析.doc_第4页
第4页 / 共14页
LoadRunner案例分析.doc_第5页
第5页 / 共14页
点击查看更多>>
资源描述

1、LoadRunner案例分析(一) 来源: 作者: 日期:2008-06-16 【聚杰网测试工具】LoadRunner案例分析(一) 昨天和Zee兄交流的时候,探讨了最近无忧测试论坛上的两个问题,我们俩的看法基本一致。第一个问题:是如何利用LoadRunner判断HTTP服务器的返回状态。 两种方法,第一种方法是利用LR的内置函数web_get_int_property, 如下是一个简单的例子: Action.cint HttpRetCode;web_url(”my_home”, “URL=http:/my_home”, “TargetFrame=_TOP”, LAST);HttpRetCod

2、e = web_get_int_property(HTTP_INFO_RETURN_CODE);if (HttpRetCode = 200)lr_log_message(”The scrpt successfully accessed the My_home home page”);elselr_log_message(”The scrpt failed to access the My_home home page “); 另外一种就是最原始的办法,也是Zee兄这种高手才最先想到的,自己取HTTP服务器的数据,然后利用关联函数分析啊。 (果然是高啊)。 其实所有的东西都可以从服务器的返回取,

3、然后自己动手解析,呵呵。 举个不太恰当的例子: 你需要一套家具,可以去家具市场挑,当然也可以自己买木材原料和工具,动手加工。 那才是最合乎自己需要的。第二个问题:动态数据参数化的问题。其实第一次看到这个问题,我没有马上反应过来,后来仔细想想, 明白了。 就是需要参数化的数据不是静态的,是动态的。 比如从数据库中选出来的。针对这个问题,我跟Zee兄弟的看法一致,应该提前从数据源(比如数据库)把数据选取出来,然后在执行的时候直接进行参数化的选取。 反之,如果在程序执行期间,进行数据的选取,将可能带来数据库服务器的强大压力,因为参加并发执行的每个虚拟用户都去数据库搜刮一下,对数据库将是多么严峻的考验

4、啊。朋友或者同事之间的探讨是加深对问题理解和增加知识面,扩展视野最直接的途径和方法,加强沟通,keep in touch.LoadRunner案例分析(二)昨天在广州交流会开始之前,一个朋友问起这样一个问题:他们公司的系统上线以后,用户分布在各个不同的地区,而且接入系统的方式和带宽也不同,这种情况下进行性能测试,如何保证更加真实的模拟用户行为?用LoadRunner可以做到吗?回答当然是肯定的,其实这些都是简单问题的组合,这样的问题考察的也是你对工具的熟悉和掌握程度。在VUGen里面,是可以通过RTS (runTimeSetting)来模拟一个单个用户更加真实的行为,比如思考时间,网络带宽,是

5、否清除cache等等。同样的设置也可以在场景中进行设置。而且LoadRunner提供设置不同用户组不同RunTimeSetting的功能。以达到模拟不同用户行为的更加真实组合。假设有三种不同带宽的用户,而且上传和下载的带宽也有所不同,那么可以录制两个脚本,分别模拟上传和下载的用户行为,再Controller里面,建立六个不同的脚本组,脚本组的用户数可以按照绝对或者百比分的方法分布。比如100,50,200用户或者20%,40%,40%等,这取决于你的业务模型。然后设置不同的带宽和分布情况。这样不同用户组的虚拟用户模拟出来的就是不同带宽的用户实际接入情况。就可以满足之前的问题的要求LoadRun

6、ner案例分析(三) 来源: 作者: 日期:2008-06-16 【聚杰网测试工具】LoadRunner案例分析(三) 把昨天的功课补了,本来打算昨天分析一个典型案例,可惜太忙了。所以这么说。以前一直没有解决的问题,利用LoadRunner测试一个应用的时候,需要验证域用户,所以即使录制成功,每次回放的时候都提示错误,用户名和密码不对,对此耿耿于怀了很久。今天居然解决了。解决方法就是一个简单的函数调用: web_set_user,此函数的解释和用法如下: The web_set_user function is a Service function that specifies a login

7、 string and password for a Web server or proxy server. It can be called more than once if several proxy servers require authentication. web_set_user overrides the run-time proxy authentication settings for user name and password.When you log onto a server that requires user and password validation,

8、VuGen records a web_set_user statement containing the login details. However, there are some more stringent, authentication methods for which VuGen is unable to insert web_set_user statements. See User Authentication for more detail. In such cases, you can add web_set_user into your scrpt manually.W

9、hen you run the scrpt, LoadRunner automatically submits the user authorization along with every subsequent request to that server. At the end of the scrpt, LoadRunner resets the authorization.This function is supported for all Web Vusers, and for WAP Vusers running in HTTP mode only. It is not suppo

10、rted for WAP Vusers running in Wireless Session Protocol (WSP) replay mode.Example 3The following example was inserted manually by the user into the scrpt as the Web server “mansfield” uses NTLM authentication. VuGen cannot record NTLM or Digest authentication. Note that for NTLM authentication the

11、domain name “mansfield” followed by a double backslash must be prepended to the user name:web_set_user(“mansfield/freddy”, “XYZ”, “mansfield:80); 原来一直没有想到域的设置,结果一直不行,现在可以了。另外一个问题跟之前这个有关系,那就是验证码的问题,之前曾经看过段念(关河大侠)的关于验证码的是三个解决方案,这里是第四种解决方案。对于一些比较简单有规律的验证码可以搞定。对于复杂的比如有干扰的,或者没有规律的则参考关大侠的其他解决方案。这个应用经过源代码分

12、析,发现每次客户端请求过来的验证码都可以取到,格式如下固定,是四个数字的组合。经过多次尝试发现如下规律:验证码如下: 52|52|52|51|46|47|49|55|对应界面的验证码是: 6039规律是第2,5,8,9位的值减去46对应的即是验证码有了这个规律,就可以通过关联提前取得服务器的验证码,然后通过简单的计算,得到结果。详细代码如下: #include web_api.hAction() / char* str = “52|52|52|51|46|47|49|55|”;char result64;int num1;int num2;int num3;int num4;int temp1

13、;int temp2;int temp3;int temp4;web_set_user(”XXXXDomain/szXXXX”,lr_decrypt(”46246a2633f042c67758b9ddc2b863038aa063c03d7e”),“XXXX.XXXX:8080);web_reg_save_param(”check”, “LB=Image=”, “RB=/”, LAST);web_url(”Register”,“URL=http:/XXXX.XXXX:8080/xx/main/Register”,“Resource=0,“RecContentType=text/html”,“Re

14、ferer=”,“Snapshot=t1.inf”,“Mode=HTML”,LAST);lr_think_time( 6 );sscanf(lr_eval_string(”check”), “%d|%d|%d|%d|%d|%d|%d|%d”, &temp1, &num1, &temp2, &temp3, &num2, &temp4, &num3, &num4);num1 -= 46;num2 -= 46;num3 -= 46;num4 -= 46;sprintf(result, “%d%d%d%d”, num1, num2, num3, num4);lr_log_message(”getval

15、ue : %s”, result);web_submit_form(”Register;jsessionid=6726009A7D21963602B166D91C883413,“Snapshot=t2.inf”,ITEMDATA,“Name=Register.reason”, “Value= “, ENDITEM,“Name=set_attach”, “Value=result”, ENDITEM,LAST);return 0; LoadRunner案例分析(四) 来源: 作者: 日期:2008-06-16 【聚杰网测试工具】LoadRunner案例分析(四) 最近在论坛上看到几次这样的问题,

16、今天突然想起来,觉得比较典型,有必要分析一下。这个问题的具体描述大概是这样的:在web应用下,模拟十个用户并发进行数据的添加,结果每次执行全部成功,但是数据却不是十条,每次数据不一样,但是都比十小。乍一看,可能是数据参数化的问题,其实仔细想想,道理其实很简单。是数据库的问题。大多数的数据库都有记录锁的问题,第一次的数据操作没有commit之前,第二次对同样表进行的操作可能就没有办法成功。所以每次数据的条数都达不到十条。但是为什么每次都不一样呢?这个问题也容易解释,因为每次的操作服务器的响应时间是不同的,所以不同虚拟用户的提交时间也不是不同的,这样一来,就导致每次提交成功的数据量不一致。导致每次

17、结果的条数可能是不同的。其实这个问题,跟LoadRunner的使用并没多大关系,而主要是对数据库的了解和应用执行机制的了解。如何解决这个问题,我现在还没有好的思路,是否对应用程序写数据库的过程作一些改进?大家可以一起探讨LoadRunner案例分析(五) 来源: 作者: 日期:2008-06-16 【聚杰网测试工具】LoadRunner案例分析(五) 最近被一个代理的问题搞的纠缠不清。我这个人其实很多时候是不求甚解的那种。自打上次跟Zee版主交流了以后,很受打击,惭愧的要命。打算以后改改这个毛病。凡是要探个究竟,正所谓惩前毖后,治病救人嘛。问题是这样的,VUGen里面录制的脚本,回放的时候出错

18、,错误信息是:Net An. Warning ( 218: 9f0) Request Connection: Remote Server 66.102.7.147:80 (Service=) Failed attempt #3. Unable to connect to remote server: rc = -1 , le = 0)Net An. Error ( 218: 9f0) Request Connection: Remote Server 66.102.7.147:80 (Service=) NOT PROXIED! (REASON: Unable to connect to re

19、mote server: rc = -1 , le = 0)重新安装了LoadRunner,结果同样。从错误的表面看是代理的问题,但是本机上网不需要任何代理。也没有设置任何的代理。搜了一下,发现了问题的解决方法。其实挺搞笑的。居然是杀毒软件的问题。下面是详细的讨论经过(英文的,大家将就看,看不懂就查查辞典)= Ive installed LR on a new machine and Im encountering an error at record time. This is the error as recorded against loading the Google home pag

20、e, along with the three warnings that proceed it:Net An. Warning ( 218: 9f0) Request Connection: Remote Server 66.102.7.147:80 (Service=) Failed attempt #1. Unable to connect to remote server: rc = -1 , le = 0)Net An. Warning ( 218: 9f0) Request Connection: Remote Server 66.102.7.147:80 (Service=) F

21、ailed attempt #2. Unable to connect to remote server: rc = -1 , le = 0)Net An. Warning ( 218: 9f0) Request Connection: Remote Server 66.102.7.147:80 (Service=) Failed attempt #3. Unable to connect to remote server: rc = -1 , le = 0)Net An. Error ( 218: 9f0) Request Connection: Remote Server 66.102.7

22、.147:80 (Service=) NOT PROXIED! (REASON: Unable to connect to remote server: rc = -1 , le = 0)Ive reinstalled LR twice with the same results.One other thing Ive noticed is that under Run-time Settings, the browser emulation was set to IE 4 and no O/S. I installed LR on a second machine and the setti

23、ng is IE 6/NT 5.1. The recorder also worked as expected. However this is an older box and Id rather not use it.The Mercury forums point to possible spyware, but the new machine is clean. If anyone has any information it would be most appreciated. 1. What version of LoadRunner or PerformanceCenter ar

24、e you using? 8.1.0.02. What is the protocol you are recording? HTTP/HTML2.1 If HTML - are you using HTML-Advanced with URLs or, NO2.2 URL mode with Concurrent groups, or NO2.3 URL mode without Concurrent groups? NO3. Which LoadRunner/PerformanceCenter feature or service packs are you using? None4. W

25、hat kind of LoadRunner license do you have - Subscrption, Perpetual, Virtual User days, or Evaluation? (choose the one that fits your license model) Evaluation4.1 If subscrption, is subscrption current or expired?5. What platform(s) and Operating Systems? Include version and service packs. IE 6.0 SP

26、2 and XP SP 26. If you have filed a service request with Mercury, what have they told you at this point with respect to your issue?Ill be filing an SR today.Thanks,DanDan, since you are using the evaluation version, please turn your questions to your field sales engineer for HP|Mercury or your VAR f

27、or assistance prior to your sale. It is their job to make sure all engineering issues are addressed prior to your purchase of LoadRunner, just as it is the sales representatives job to make sure all organizational and logistical issues are addressed prior to your purchase. If your VAR or vendor sale

28、s engineer is unresponsive to your inquiries, then seek a new representative to work with. However, it has been my experience that a slight threat to go with another vendor that can better support your environment tends to light the fire under most sales types, particularly with a product like LoadR

29、unner that easily can exceed $100,000.00 USD when optioned out.Thank you for your interest in evaluating LoadRunner prior to your purchase.James Pulley=Thanks for the suggestion.The controller license is purchased and this is the machine designated for activation. Im dealing with Mercury on this iss

30、ue as well.This is not the first time Ive had installation issues with a Mercury product and Im sure it wont be the last. As I mentioned this is a new laptop so maybe that has something to do with it. But Ive seen one other post in this forum describing my same problem and there was no resolution so

31、 Im not optimistic that this will be resolved quickly.If Mercury/HP provides a solution Ill post it here.=A Mercury engineer provided a workaround for this recording error. Under Tools - Recording Options - Network - Port Mapping, the capture level was changed from Socket Level Data to WinINet level

32、 data。When I get the fix for Socket Level Data recording error on this PC, Ill post it here.Dan=Thanks, Dan. You may not know it, but it all too rare for people to come back and post solutions, so we are truly grateful.=Thanks for that Peter. I find it worthwhile to post resolutions as I hope they c

33、an help others.So I solved my problem. Digging into the process explorer pointed to the biolsp.dll from Wave Systems. I Googled it and found several discussion forums indicating it causes problems with other applications as well. The patch download link on the Wave website was dead. I dont need bio

34、security on my Dell so I uninstalled the whole program group. VUGEN is now working as expected.Good luck to all,Dan=so let me get this straightyou have to disable the bio security on the computer to get it to work? Seems like an interesting problem if you are required to have the security on as a co

35、mpany policy.=Thats a great point jamesso and I agree; this wasnt the solution I was looking for. Unfortunately there is more going on here. We aquired a term license with Mercury/HP and it activated the virtual users two weeks ago, even though the installation on the controller did not go as planne

36、d. But Im at the point now where weve already burnt too much and cant afford to burn any more of the license. I have to get back on track with the client so Im going with this for now.Regards,Dan=So the term license started before you could actually get a controller working to use them。hmmm. Is HP f

37、lexible enough to own this problem and give you time that you lost?=Time will tell jamesso. I do want that time back and I am looking for consideration, but at this point Im not optimistic.I dont mind saying at this point that I was unhappy with being tied to a start date to begin with. This is the

38、first time Ive worked with a term license from HP and I would be very happy if it is my last. In my previous term engagements I used Segue/Borland. With their model I activated the license the day I was ready which got the project more value, more flexibility, and less waste.=Hi Dan,i had same probl

39、em with new LR 8.1 installation with trial 10 days licensesand my friend with 8 years LR experience say me possible solution(99%):you need to disable(sometimes uninstall) any antivirus software during installation process (LR need to notify USER before starting installation process, but i not find i

40、t),after restart the PC you can to enable AV again.Try and Enjoyloadrunner8.1一次简单的实践来源: 作者: 日期:2008-06-16 【聚杰网测试工具】loadrunner8.1一次简单的实践 一、分析应该系统 1.硬件环境: 硬件名称 CPU 内存 硬盘 服务器 Pentium(R) 4 2.66 GHz(双核) 1G 80G WEB服务器 赛扬1.7GHz 256M 40G 测试机器 Pentium(R) 4 2.66 GHz 760M 80G 2.软件环境: 硬件名称 操作系统 应用软件 版本 数据库服务器 W

41、indowsXP sp2 Oracle 9i.0.1.0.0 WEB服务器 Windows2000 sp4 WebLogic 8.1 测试机器 WindowsXP sp2 8.1 3.网络环境: 采用局域网; 4.系统、应用软件配置环境: 操作系统、Oracle、WebLogic各参数采用默认设置;二、压力测试的对象及目标 1.测试对象: 教学平台课程通知部分; 2.测试目标: 测试得到点击通知时的最大并发人数; 三、压力测试过程 1.录入脚本、增强脚本 前提:采用WEB(HTTP/HTML)协议录入脚本; 录入脚本并通过验证回放; 在课程通知处插入集合点,为了实现并发访问课程的目的; 集合点

42、:是一个并发访问的点,在LoadRunner中可以通过在提交数据操作前面加入集合点,这样当虚拟用户运行到提交数据的集合点时,LoadRunner 就会检查同时有多少用户运行到集合点,如果不到事先定义人数,LoadRunner就会命令已经到集合点的用户在此等待,当在集合点等待的用户达到事先定义的人数时,LoadRunner 命令这些人同时去提交数据,并发访问的目的。 在课程通知处插入检查点,以验证访问的页面里的文字的准确性; 此处因为是访问类的脚本,一定要添加检查点,以保证在测试时结果的正确性。因为LR只要检测到网页的响应,就认为是pass而并不管当前网页内容的正确性。在进行压力测试时,为了检查

43、Web服务器返回的网页是否正确,VuGen允许我们插入Text/Imag 检查点,这些检查点验证网页上是否存在指定的Text或者Image,还可以测试在比较大的压力测试环境中,被测的网站功能是否保持正确。 2.创建、运行负载测试场景 前提:采用手动场景运行虚拟用户;因为是测试课程通知部分,所以首先要保证登录用户全部正确到达集合点!这是测试的前提! 四、分析结果 测试用例1(场景1): 用户登录教学平台,总共150个用户,加载行为:启动15个Vuser(每5秒钟); 用户点击课程; 用户点击课程通知,所有用户并发一次操作; 校对弹出通知页面文字的准确性。 测试结果: 本测试用例是验证150人能否正常登录,并且是否能到达集合点,并能过一次运行! 运行时,与是先假设的完全一样,150人顺利登录,正常到达集合点,并正确通过一次运行!没有错误信息产生! 测试用例2(场景2): 用户登录教学平台,总共150个用户,加载行为:启动15个Vuser(每5秒钟); 用户点击课程; 用户点击课程通知,所有用户

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 学术论文 > 管理论文

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报