资源描述
LoadRunner Quick TutorialLR78-SLIDES-01A大纲oLoad runner介绍o规划o编写脚本 脚本录制、调试、优化脚本录制、调试、优化o场景设计场景设计 用户数、场景类型、场景计划、运行设置、实时监控用户数、场景类型、场景计划、运行设置、实时监控o场景执行场景执行 调试场景、小压力运行、调试场景、小压力运行、100%负载测试、压力测试负载测试、压力测试o结果分析结果分析 常用指标观察、生成测试报告常用指标观察、生成测试报告第一节LoadRunner介绍介绍为什么要进行压力测试oThe failure of a mission-critical application can be costlyoAssure performance and functionality under real-world conditionsoLocate potential problems before your customers dooReduce development timeoReduce infrastructure costs压力测试分类Find out whether the system can handle the expected load upon deployment under real-world conditions.Find the applications breaking point.Apply testing that measures whether the applications environment is properly configured to handle expected or potentially unexpected high transaction volumes.Load TestingStress TestingFind the stability of the system with respect to handling large amounts of data over extended time periods.Volume TestingFind the behavior and performance of each tier.Component Testing压力测试目标举例pApplication response timeHow long does it take to complete atask?p Configuration sizingWhich configuration provides thebest performance level?p AcceptanceIs the system stable enough to gointo production?p RegressionDoes the new version of the softwareadversely affect response time?p ReliabilityHow stable is the system under aheavy work load?p Capacity planningAt what point does degradation inperformance occur?p Bottleneck identificationWhat is the cause of degradation inperformance?p Product evaluationWhat is the best server for 100users?TestersLoad GenerationSystem Under TestDoyouhavethetestingresources?TestingpersonnelClientmachinesHowdoyousynchronizeusers?Howdoyoucollectandanalyzeresults?Howdoyouachievetestrepeatability?Everybody,clicktheSEARCHbuttonagain手工测试的问题CoordinatorDatabaseserverApplicationserverLoadRunner解决方案OvercomesresourcelimitationsProvidesmeaningfulresultswithanalysistoolsAllowsrepeatabletestswithscriptedactionsAnalysisRunsmanyVusersonfewmachinesReplacestesterswithVirtualUsersControllermanagesVirtualUsersDatabaseserverControllerVusersVirtualUserloadgeneratorApplicationserverLoad GenerationSystem Under TestLoadRunner的实现方法LoadRunner is a complete solution to conduct automated load testing before,during,and after application deployment.LoadRunner allows you to.ScaleIdentifyDiagnosethe application to a predetermined capacity.business processes or system components having trouble.a problem to pinpoint the root cause.LRVUGENVuser Script Recorder records Vuser scripts that simulate the steps of real users using the application.LR CONTROLLERThe Controller is an administrative center for creating,maintaining and executing Scenarios.The Controller assigns Vusers and load generators to Scenarios,starts and stops load tests and performs other administrative tasks.LRANALYSIS LR Analysis provides graphs and reports.These graphs and reports summarize the system performance.LoadRunner 组件LoadRunner 支持的环境 Web:HTTP(S)CORBAWAPCOMRMILDAPWinsockStreamingFTPIIOPPOP3iModeRealPlayerMS MediaVoice XMLSMTPDatabases:OracleMS SQLServerDB2 SybaseInformixODBCMiddlewareProtocols:CORBACOMEJBsTUXEDOJoltJDBCMQSeriesPlatforms:NT,2000,XPSunHPIBMLinuxERP/CRM:Oracle Apps.SAPSiebelPeopleSoftClarifyBaanLegacy:32705250VT100Internet/IntranetDatabaseserverAppserversWebserversClients什么是 Scenario?scriptsrun-timesettingsloadgeneratorsreal-timemonitorsvirtualusersElements of a ScenarioScenarioAscenarioisafilethatdefineswhichVuserstoexecute,thenumberofVuserstorun,thegoalsofthetest,whichcomputerhoststheVusersandtheconditionsunderwhichtoruntheloadtest.LoadRunner的工作方式DatabaseserverAppserversWebserversLR CONTROLLER LOAD GENERATOR 2 (NY)LRANALYSIS LOAD GENERATOR 1 (SF)1.Create scenarios and assign them to load generators.2.Generates load and sends performance data to controller.3.Access the reports and graphs.2.Generates load and sends performance data to controller.Performance metrics硬件配置需求Win NTWin 2000 Win XP500 MBWin NTWin 2000 Win XP UNIXDepends on the number of Vusers and runtime settings.Win NTWin 2000 Win XP200 MB Operating SystemFree Hard Disk Space256 MB256 MB256 MBMemoryAnalysisLoad GeneratorControllerLR Components压力测试流程DefineGoalsAnalyzesystemGatherSystemUsageDataRecordScriptsandturnscriptsintoVusersbyaddingtestdataanduserbehaviorCreateScenariosbasedonyourgoalsExecuteScenariosfortestingfirst,running100%andoverloadingAnalyzeresultsdataandpinpointbottlenecksFinetunesystembasedonanalysisdataandre-runthescenarioTweakSystemBasedonAnalysisPlan Load Test1Create Virtual Users2Scenario Creation3Scenario Execution4Results Analysis5Rerunning the scenario indicates whether performance has improved and whether goals have been achieved.压力测试是一项团队工作ManagesthetestapplicationimplementationforallphasesofloadtestingProvidesexpertiseonthebusinessfunctionalityoftheapplicationundertestforplanningphaseTeam MemberMain ResponsibilityProjectManagerFunctionalExpertCreatesthemulti-userloadonthesystemforallphasesofloadtestingLoadRunnerExpertAnalyzesandtunestheapplicationserverforresultsanalysisphaseApplicationServerPerformanceBasisExpertAnalyzesandtunesthedatabaseserverforresultsanalysisphaseDatabasePerformanceBasisExpertLoadRunner 团队工作TweakSystemBasedonAnalysisPlan Load Test1Create Virtual Users2Scenario Creation3Scenario Execution4Results Analysis5LRExpertFunctionalExpertProjectManagerLRExpertFunctionalExpertProjectManagerLRExpertLRExpertSysAdminServerExpert(s)SysAdminServerExpert(s)LRExpert返回大纲返回大纲第二节 规划规划在创建脚本之前要进行充分的规划Plan Load Test1Create Virtual Users2Scenario Creation3Scenario Execution4Results Analysis5Goals,business processes,user type,user behaviors,input data,system profiling,scenario design,and LoadRunner installation规划阶段的内容1.建立负载测试的目标 制定出可以用数量衡量的目标标准2.分析被测系统的业务运行状况确定要录制哪些商业流程(business processes)确定业务高峰的负载情况和时间把需要测试的BP的操作步骤形成正式文档准备测试数据3.收集系统的技术信息 确定系统的架构 确定系统各部件的软件情况,使用什么样的数据库服务器?Web服务器?以帮助我们在合理的时间内确定系统瓶颈本次培训使用的Demo软件Start Programs Mercury ToursBefore you access thetraining application:Invoke the ApacheServer(Start Programs StartServer)返回大纲返回大纲第三节编写脚本编写脚本录制Web脚本的方法1.运行VuGen,创建新的脚本4.开始录制5.进行正常的业务流程的操作6.当业务操作完毕后,按Stop Recording将录制结束7.保存脚本2.选择创建Web(HTTP/HTML)protocol的脚本3.设定录制选项 Recording Options.DEMO 老师将会演示如何录制脚本设定录制选项 Recording Options Recording Browser Recording Proxy Advanced CorrelationDEMO Recording Options 两种不同查看脚本的方式TreeViewScriptViewTree view has icons for the recorded user stepsEach Tree View icon represents a C statement viewable in Script View DEMO Tree and Script View Icon and usage examples什么时候选择不同的录制方式?This is default mode.If problem encountered with form submission or with link clicking then record with URL option checked under HTML Advanced HTML Recording:URL Recording:Records a separate request for each object requested from the server.Gives best control over traffic.脚本的目录结构C:web_project-Scripts-Action1.cvuser_init.cvuser_end.cLab1Script2.usrAs soon as the script is saved,these are the folders that you will seeLab1Script2设置回放的运行时刻设置Run-time SettingsRun LogicPacingLogThink TimeMiscellaneousSpeed SimulationBrowser EmulationProxyPreferencesContentCheckAvailable for all protocols.Specific to Web.DEMO Run-time Settings 运行脚本Click the Run button to play back the script.The Execution log lists all messages once the script has stopped running.DEMO Running a script and how to set results directory 常用的调试脚本的工具Test Results windowExecution LogSnapshot Results window Page View Server Response Client RequestRun-Time ViewerDEMO Available debugging tool options本节总结o本节介绍了常用的录制选项o本节介绍了两种录制Web协议脚本的方法o本节介绍了运行时刻的各种设定o本节介绍了一般选项的设定o本节介绍了进行调试脚本的基本工具ActionAsetofrecordeduseractionsinaVuserthatallowsyoutoemulateaparticularusertaskthroughscriptiteration.什么是Action?在Web脚本里面使用多个ActionA Web Vuser(script):Search for a CDOrder the CDLog inGo to checkoutvuser_initRun onceActionRun 3 timesvuser_endRun onceSearch for a DVDOrder the DVDAction1Run 5 timesSearch for a book Order the book Action2Run 4 timesthenthenthenthen使用多个 Action的典型例子最典型的情况是用户登录一次,进行多次业务,然后退出系统:nRecord Login user steps in vuser_initnRecord selecting an item in the first section called ActionnRecord placing items in shopping cart user steps in Action1nRecord Checkout and Logout user steps in vuser_endInternetWebserverDBserver如何把不同的操作录制到多个 Actions中?Action list1.Start recording2.Select action file3.Record users steps in the appropriate action file4.Repeat steps 2 and 3 as necessary5.Stop recordingDEMO Adding creating LR Actions 注意设定好开始和结束的状态Always end at this page if the next iteration is Sign-On or Register.根据测试目标来确定脚本的Action Emulate three types of users where 50%of the users are logging in,25%are searching and the remaining 25%are booking tickets?Load Testing Goal:Record one script with all three business processes under separate actions and apply weighting.Suggested method:DEMO Creating Weighting如何衡量操作的响应时间?How can I isolatea measurement ofjust the Sign-inresponse time?STEP 1 Start ApplicationSTEP 2 Type username and passwordSTEP 3 Click on Sign-In buttonSTEP 4 Wait for confirmationSTEP 5 Select a departure and arrival citiesSTEP 6 Enter datesSTEP 7 Enter credit card detailsSTEP 8 Click on Submit 什么是Transaction?LoadRunnerTransactionGivesanend-to-endmeasurementoftimeelapsedintheexecutionofoneormorestepsinabusinessprocess.UserWebServerRequest(Transaction starts)Response(Transaction ends)Sign-In transaction took 8 secLoadRunner的Transactions测量什么内容?LoadRunner transactions measure the transmission and response time between client and server.Transaction开始和结束按钮CommoniconsandusageexamplesStart Transaction SetstartingpointformeasurementEnd TransactionSetendpointformeasurementTransaction的状态nLR_AUTO (default)-use this to detect the transaction status automaticallynLR_PASS/LR_FAIL/LR_STOP use these when you want to set the transaction status manually in the codeTransactions中的思考时间如何处理?Think timesMay reduce accuracy of transaction measurementsCan be filtered out of Analysis graphs通过检查运行日志来确定Transaction的执行结果Transactions的相关设定参数化的概念 Recorded ScriptSelect San FranciscoParameterized ScriptSelect Selection is hard coded and will select San Francisco on every runSelection is parameterized and will select different city on every run为什么要引入“参数化”?REAL USERSVaried input to the applicationStatic input to the applicationRecorded script(Virtual Users)To Emulate real-world behavior and to create realistic results什么时候需要参数化?STEP 1 Start ApplicationSTEP 2Type username and passwordSTEP 3 Click on Sign-In buttonSTEP 4Wait for confirmationSTEP 5Select a departure and arrival citiesSTEP 6 Enter datesSTEP 7Enter credit card detailsSTEP 8Click on Submit Unique constraintData dependencyData cachingDate constraint如何参数化输入数据 1 Determine which fields to parameterize.2 Replace recorded values with parameters.3 Decide which parameter type to use.4 Create the data file.5 Populate the data file.6 Choose the data access method and the number ofiterations.7 Run the Vuser and analyze the results to verify correct execution.DEMO How to parameterize a input data 参数的类型 Internal DataData FilesMaster DataUser Generated Data External DataUser-Defined Functions Specifying the source for the parameter data.There are three types:File类型参数的数据访问方式SequentialRandomUniqueSame line as Select next tells LoadRunner in what order to use data from the file(data source)如何查看脚本执行时参数的值?To see parameter data in the Execution Log,select Extendedlog and Parameter substitution in the Run-time Settings数据个数和Run Logic的关系To test all data using the Sequential access method,Number of Iterations should equal the number of rows in the data file 什么是检查点 Checkpoint?CheckpointAcheckpointisastepinaVuserscriptwhichverifieswhetheravisualcueappearedasexpected.Verification always results in a PASS or FAIL status在大并发用户压力的情况下验证脚本是否执行成功是负载测试的基本要求Success.Business process complete.Failure.Business process failed.One Vuser running the scriptScript run under load with many concurrent VusersIncrease in load Low load What indicates the ticket was purchased successfully?确定脚本执行成功的标准 LoginSelect departure and arrival citiesSelect departure and arrival datesSelect flightPurchase ticketContinue ShoppingThere was an error while generating your order!Your itinerary was booked!Thank you for choosing Mercury Tours.通过界面的某些信息来确定脚本是否执行成功Flight confirmation image and text appear after pressing the Secure Purchase button.Image ConfirmationText Confirmation(2)On playback,compare the actual value on the application to the saved expected value.(3)Send the comparison result(the status)as either PASS Test requirement#5 successful.OR FAIL Test requirement#5 failed.(1)Capture the information needed to perform verification.检查点的基本内容 ExpectedValueActualValuePASSIFLoadRunner提供的文本检查点Checkpoint IconsTextVuGen allows you to add Checkpoints for verification automatically and also programmatically.A text check is a search for a specified text string on a Web page.Adds web_reg_find function to the script.关联的基本概念介绍 RecordingWebServerLogin(User Name jojo Password bean)Response(SessionID12345)1.Log in User Name jojo Password bean2.Your sessionid123453.Request for product info4.Product info foundResponseProduct infoVuGen ScriptRequestforproductinfo(SessionID12345)Dynamic data is hard-coded in the script关联的基本概念介绍-Playing BackWebServerLogin(User Name jojo Password bean)Response(SessionID23456)1.Login User Name jojo Password bean2.Your sessionid123453.Request for product info4.Product info foundResponseERROR SessionID 12345 has expiredLogin again to get product infoVuGen ScriptRequestforproductinfo(SessionID12345)Reusing recorded dynamic data will cause errors when you replay the script关联的基本概念介绍-SolutionWebServerLogin(User Name jojo Password bean)Response(SessionID23456)Requestforproductinfo()ResponseHere is the requested product info1.2.Your 3.4.Correlated VuGen ScriptRecorded dynamic data must be correlated using parameters关联是一个原理性的问题213关联是一个原理性的问题,在任何协议的脚本中都存在关联是开发脚本的最耗时,最烦琐的一个过程.因为每个被测系统都不同 为了减轻关联的工作量,LoadRunner提供了一些自动化关联的辅助工具手工关联的基本步骤1.Play back the script and determine if error is due to correlation.2.Determine which dynamic values to correlate.3.Find the left boundary,right boundary and occurrence of the dynamic value.4.Add a web_reg_save_param function and the arguments to the script,above the step which requests the page with the value to capture.5.Parameterize the dynamic value in the script every time it occurs.6.Verify correct execution.关联的第一步:脚本回放失败Q:Why did the step creation fail?1.Make a note of which step failed.2.Investigate the Execution Log.通过WDiff查看脚本变化的内容 There are five differences highlighted.确定哪些动态信息需要关联Name=buyFlights.x,Value=52,ENDITEM,Name=buyFlights.x,Value=23,ENDITEM,Name=buyFlights.y,Value=15,ENDITEM,Name=buyFlights.y,Value=17,ENDITEM,lr_think_time(2);lr_think_time(1);lr_think_time(7);lr_think_time(11);Name=flight_210,Value=on,ENDITEM,Name=flight_206,Value=on,ENDITEM,Name=removeSelected.x,Value=101,ENDITEM,Name=removeSelected.x,Value=80,ENDITEM,Name=removeSelected.y,Value=13,ENDITEM,Name=removeSelected.y,Value=10,ENDITEM,lr_think_time(1);12345ThesevaluesrepresentthescreenlocationsofmouseclicksTheyareusedbythescriptbutdonotneedtobecorrela
展开阅读全文