当前位置:文档之家› LoadRunner案例分析

LoadRunner案例分析

LoadRunner案例分析(一)来源:作者:日期:2008-06-16 【聚杰网测试工具】LoadRunner案例分析(一)昨天和Zee兄交流的时候,探讨了最近无忧测试论坛上的两个问题,我们俩的看法基本一致。

第一个问题:是如何利用LoadRunner判断HTTP服务器的返回状态。

两种方法,第一种方法是利用LR的内置函数web_get_int_property,如下是一个简单的例子:{int HttpRetCode;web_url(”my_home”, “URL=, “TargetFrame=_TOP”, LAST);HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);if (HttpRetCode == 200)lr_log_message(”The scrīpt successfully accessed the My_home home page”);elselr_log_message(”The scrīpt failed to access the My_home home page “);}另外一种就是最原始的办法,也是Zee兄这种高手才最先想到的,自己取HTTP服务器的数据,然后利用关联函数分析啊。

(果然是高啊)。

其实所有的东西都可以从服务器的返回取,然后自己动手解析,呵呵。

举个不太恰当的例子:你需要一套家具,可以去家具市场挑,当然也可以自己买木材原料和工具,动手加工。

那才是最合乎自己需要的。

第二个问题:动态数据参数化的问题。

其实第一次看到这个问题,我没有马上反应过来,后来仔细想想,明白了。

就是需要参数化的数据不是静态的,是动态的。

比如从数据库中选出来的。

针对这个问题,我跟Zee兄弟的看法一致,应该提前从数据源(比如数据库)把数据选取出来,然后在执行的时候直接进行参数化的选取。

反之,如果在程序执行期间,进行数据的选取,将可能带来数据库服务器的强大压力,因为参加并发执行的每个虚拟用户都去数据库搜刮一下,对数据库将是多么严峻的考验啊。

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

在VUGen里面,是可以通过RTS (runTimeSetting)来模拟一个单个用户更加真实的行为,比如思考时间,网络带宽,是否清除cache等等。

同样的设置也可以在场景中进行设置。

而且LoadRunner提供设置不同用户组不同RunTimeSetting的功能。

以达到模拟不同用户行为的更加真实组合。

假设有三种不同带宽的用户,而且上传和下载的带宽也有所不同,那么可以录制两个脚本,分别模拟上传和下载的用户行为,再Controller里面,建立六个不同的脚本组,脚本组的用户数可以按照绝对或者百比分的方法分布。

比如100,50,200用户或者20%,40%,40%等,这取决于你的业务模型。

然后设置不同的带宽和分布情况。

这样不同用户组的虚拟用户模拟出来的就是不同带宽的用户实际接入情况。

就可以满足之前的问题的要求LoadRunner案例分析(三)来源:作者:日期:2008-06-16 【聚杰网测试工具】LoadRunner案例分析(三)把昨天的功课补了,本来打算昨天分析一个典型案例,可惜太忙了。

所以这么说。

以前一直没有解决的问题,利用LoadRunner测试一个应用的时候,需要验证域用户,所以即使录制成功,每次回放的时候都提示错误,用户名和密码不对,对此耿耿于怀了很久。

今天居然解决了。

解决方法就是一个简单的函数调用: web_set_user,此函数的解释和用法如下:The web_set_user function is a Service function that specifies a login 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, 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 scrīpt manually.When you run the scrīpt,LoadRunner automatically submits the user authorization along with every subsequent request to that server. At the end of the scrīpt, LoadRunner resets the authorization.This function is supported for all Web Vusers, and for WAP Vusers running in HTTP mode only. It is not supported for WAP Vusers running in Wireless Session Protocol (WSP) replay mode.Example 3The following example was inserted manually by the user into the scrīpt as the Web server “mansfield” uses NTLM authentication. VuGen cannot record NTLM orDigest authentication. Note that for NTLM authentication the domain name “mansfield” followed by a double backslash must be prepended to the user name:web_set_user (“mansfield46246a2633f042c063c6726009A91C2008-06-162008-06-16Warning ( 218:9f0)] Request Connection: Remote Server @ :80 (Service=) Failed attempt #3. Unable to connect to remote server: rc = -1 , le = 0)[Net An. Error ( 218: 9f0)] Request Connection: Remote Server @ :80 (Service=) NOT PROXIED!(REASON: Unable to connect to remote server: rc = -1 ,le = 0)重新安装了LoadRunner,结果同样。

从错误的表面看是代理的问题,但是本机上网不需要任何代理。

也没有设置任何的代理。

搜了一下,发现了问题的解决方法。

其实挺搞笑的。

居然是杀毒软件的问题。

下面是详细的讨论经过(英文的,大家将就看,看不懂就查查辞典)==================================================I‘ve installed LR on a new machine and I’m encountering an error at record time. This is the error as recorded against loading the Google home page, along with the three warnings that proceed it:[Net An. Warning ( 218: 9f0)] Request Connection: Remote Server @ :80 (Service=) Failed attempt #1. Unable to connect to remote server: rc = -1 ,le = 0)[Net An. Warning ( 218: 9f0)] Request Connection: Remote Server @ :80 (Service=) Failed attempt #2. Unable to connect to remote server: rc = -1 ,le = 0)[Net An. Warning ( 218: 9f0)] Request Connection: Remote Server @ :80 (Service=) Failed attempt #3. Unable to connect to remote server: rc = -1 ,le = 0)[Net An. Error ( 218: 9f0)] Request Connection: Remote Server @ :80 (Service=) NOT PROXIED!(REASON: Unable to connect to remote server: rc = -1 ,le = 0)I‘ve reinstalled LR twice with the same results.One other thing I‘ve 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 setting is IE 6/NT . The recorder also worked as expected. However this is an older box and I’d 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 are you using 8.1.0.02. What is the protocol you are recording HTTP/HTMLIf HTML - are you using HTML-Advanced with URLs or, NOURL mode with Concurrent groups, or NOURL mode without Concurrent groups NO3. Which LoadRunner/PerformanceCenter feature or service packs are you using None4. What kind of LoadRunner license do you have - Subscrīption, Perpetual,Virtual User days, or Evaluation (choose the one that fits your license model)EvaluationIf subscrīption, is subscrīption current or expired5. What platform(s) and Operating Systems Include version and service packs. IE SP2 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 issueI‘ll 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 for 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 representative‘s job to make sure all organizational and logistical issues are addressed prior to your purchase. If your VAR or vendor sales 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 LoadRunner that easily can exceed $100, 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. I‘m dealing with Mercury on this issue as well.This is not the first time I‘ve had installation issues with a Mercury product and I’m sure it won‘t be the last. As I mentioned this is a new laptop so maybe that has something to do with it. But I’ve seen one other post in this forum describing my same problem and there was no resolution so I‘m not optimistic that this will be resolved quickly.If Mercury/HP provides a solution I‘ll 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 data’。

相关主题