junit.docx
《junit.docx》由会员分享,可在线阅读,更多相关《junit.docx(25页珍藏版)》请在冰点文库上搜索。
junit
LoadTestingWebApplicationsusing
Microsoft’sWebApplicationStressTool
ByRickStrahlhttp:
//www.west-
LastUpdated:
10/17/2018
Microsoft'sWebApplicationStressToolprovidesaneasywaytosimulatelargenumbersofusersagainstyourWebapplication.Thistoolmakesitpossibletomakeintelligentdecisionsabouthardwareandsoftwareloadincurredbyyourapplicationandhowmuchtrafficagivenmachineorgroupofmachinescanhandle.InthisarticleRickshowshowthetoolworksandhowtoproperlyinterprettheperformancedataitgenerates.
FreeDownloadfrom:
Requires:
WindowsNT4.0SP4orWindows2000
BuildingWebapplicationshasnowbecomeafairlycommonscenariofordevelopersbuildingnewapplicationsorupdatingandWebenablingexistingapplications.AsapplicationsmovetotheWebintoaserverbasedenvironmentitbecomesincreasinglyimportanttobeabletogaugetheperformanceandloadcapabilityofanapplication.Developersmustbeabletoanswerhardquestionsabouthowmuchtrafficagivensitewillbeabletohandleandmakeintelligentchoicesofhardware,softwareandoftentimesevendesignapproachoftheapplicationtomakesuretheapplicationwillbeabletohandleanonslaughtofcustomersontheWebsite.Weshouldallbesoluckytohavetoworryabouttheproblemofbeingtoosuccessful!
Butit'softensurprisingtofindhowmanyWebsiteshittheirlimitsandcatchtheoperatorsoffguard.AnoverloadedWebsiteisamajorproblemandoncehappeningtheproblemoftencan'tbeaddressedrapidly.Aquickfixtypicallyinvolvesaddingadditionalhardwarethatmustbepurchased,installedandconfigured–aprocessthatmaytakedaysorevenweeks.Beingpreparedandunderstandingthelimitsofanapplicationandmanagingadvertisingtobringtraffictoasiteinmeasuredspurtsiscrucialtothesuccessoflargeandevennotsolargecommercialsites.
Additionally,it'simportanttounderstandthattoday'stoolsoftenmakeitmucheasiertobuildWebapplicationsthanthetoolsfromevenayearago.Todaywehavepowerfulscriptingengines,easyaccesstoCOMcomponentswecanwriteinhighlevellanguagesandWebserversthatself-configureforthemostpart.Butalongwiththeeaseofusealsocomesmoreoverheadandresourceloadontheserveranditbecomesevenmoreimportanttolookatloadissuesrightfromthestartofapplicationdevelopment.Loadtestingshouldbeperformedintheinitialdesignphasestogetagoodideawhatoverheadtheapplicationcomponentsincurontheserver.Constantmonitoringshouldbeperformedasdevelopmentcontinuesonalwayskeepingacloseeyeonhowwellthesoftwareplatforminrelationtothehardwareitwillberunningon.
Theproblemisthatoftentimesthesescalabilityquestionssuchas'Howmuchtrafficcanwehandleonourparticularhardware?
'arenoteasilyansweredbecauseit’shardtomeasureperformanceofWebapplicationsoutsidetheactualenvironmentthattheywillberunningin.EventheprocessoftestingWebapplicationsseemsdaunting:
TherearesomanypiecesinvolvedfromaWebbrowserclient,theWebserver,thebackendapplicationandthebackenddatabaseserver.ThebottomlineisthattheonlywaytorealisticallytesttheloadcapabilitiesofaWebapplicationisinacloseapproximationofaliveenvironment,whichmeansactually'running'theWebapplication.
IntroducingtheWebApplicationStressTool
So,howdowe'run'aWebapplicationrealistically?
Theansweristhatyouhavetosimulatemanyclientssimultaneouslyhittingyoursite.Tothisend,Microsofthasreleasedaneasytouse,yetverypowerfulandflexibletoolcalledtheWebApplicationStresstool(WAS),whichprovidesthisfunctionalityinafreelydownloadableapplicationservice.
Figure1–TheWebApplicationStresstoolprovidesasimpleinterfacetocapture,configure,runanddisplaytheresultfromrunningastresstest.InthisviewthecapturedWeblinksthatwillbeaccessedbytheWebclientwhenrunningthetestarelisted.
WASrequiresWindowsNTorWindows2000asthetoolrunsasanNTService.Forrealisticperformancetesting,it'salsorecommendedthatyourunthestresstestingtoolfromaseparatemachineotherthantheWebserver.TheactualrequestgeneratorcanbefairlyresourceintensivewhilegeneratingtheWebrequestsandthisoverheadcanaffectperformanceoftheWebsiteundermaxloads.However,eventhoughthedocumentationstatestwomachinesarearequirementyoucancertainlyrunWASonthesamemachineastheWebserver,butdon'texpect100%accurateresultsespeciallywhenyou'retestingatthetopendloadforthehardwareyou'rerunningon.
TheuserinterfaceofWASisstraightforwardwithalistofscriptsandsublistsofthepropertiesfortheparticularscriptontheleftandadataviewontheright.Thedataviewdependsontheselectedscriptoption.Themostimportantviewsarethedefaultview(seeFigure1)thatshowsyouallselectedlinksandtheserveryou'retestingandtheSettingsview,whichconfigureshowthelinksareexecutedagainsttheserverandatwhatloadlevel.Otheroptionsallowyoutoconfigureuserswithusernamesandpasswords(optional)sinceyoucansimulatelargenumbersofclientsthismaybenecessaryforsitessecuredwithsomelevelofauthentication.Youcanevenconfigurespecificpre-existingCookievaluesforeachuserifyouhaveto.Inshort,therearealotofoptionsformostHTTPscenariosavailable,eventhoughmostoftheseareunlikelytobeutilizedintypicaltests.It'sthereforyouifyouneedthecontroltocustomizeyourtests.
Onceatesthasbeencompletedthere'sareportviewwhereyoucanviewtheresultsofthetest,whichprovidesathoroughsummaryofthetestjustperformedincludinginformationabouttotalhitsandhitspersecondasawhole,hitsforindividualpages,failuresandresponsecodesaswellasbandwidthbreakouts.
Figure2–Thereportpageprovidesasummaryofthetestrunincludingtotalnumberofrequests,requestspersecondandfailures.There'salsoadditionaldetailabouteachlinkandaveragerequesttimesofeachlink.
GettingstartedwithWAS
TheconceptbehindWASissimple:
YoucreateatestscriptbycapturingabrowsersessionusingInternetExplorerbasicallywalkingthroughyourapplication,asatypicaluserwoulddo.AsyoudothisWAScapturesthecontentofalltheseWebrequests.WAScaptureseverything:
Hyperlinkclicks,Formsubmissions,RedirectlinksandAuthenticationinfo–everythingneededtocapturetheuser'ssessionthroughyoursite.
Figure3–TheBrowserRecorderletsyouuseyourbrowsertocreatescripts.Therecordercapturesalllinks,HTMLformsubmissionsandevenCookies,RedirectsandAuthenticationinformation.
Creatingascriptisveryeasy:
YoucanusetheBrowserRecordertocaptureabrowsersessionandhaveWASgenerateatestscriptfromcapturedlinks.Amanualmodeisalsoavailabletoallowyoutomanuallyaddlinksandinformationabouteachlink.
AsyoucanseeinFigure3thereareafewoptionsyoucanchoosefortheBrowserRecorder:
Capturedelay,andrecordcookiesandhostheaders.Thedelaybetweenrequestswillresultamorerealistictestintermsofhowpeopleareactuallynavigatingasite,givingyouamoreaccuratepictureofhowusersonasitemaptoconnectionsontheWebserver.Ifyourgoalistofindthelimitsofyoursiteleavethisoptionunchecked.Ifyouwanttosimulateaspecificusernumberscenariogoaheadandcapturethedelayasitprovidesamorerealisticviewofthebrowsingscenario.I'lltalkmoreaboutthisdelaywhenwelookattheloadoptionsforthetest.
TheRecordbrowsercookiesandRecordhostheaderoptionsallowyoutocaptureaspecificusersession,ratherthandynamicallytrackingthisinformationatthetimeoftherequest,thelatterofwhichishowatypicalbrowserwouldbehave.Typicallyyou'llwanttoleavethoseoptionsuncheckedtolettheWASclientcreatecookiesandhostheadersjustlikeauseronyoursitewould.However,ifyouhavepersistentstateinformationforyoursite(suchasauserprofileorotherinfothatisconnectedtoapermanentcookie)makesurethatyouclearthecookiebeforeyourunyourteststosimulateanewusercomingtothesiteandgoingthroughthestepsofconfiguringtherequireduserstate.Forexample,onmyWebStoresiteuserssetupauserprofilewhentheyplaceanorder.TheprofileisrecoveredwhentheyreturntothesiteandtrackedwithaCookie.IfIneverwentthroughandsetupmyprofileinformationWASwouldnotbeabletoactuallyprocessanorderbecausetheprofileinformationwouldbemissingandnotgetfilledout.
IfyoutypicallyrequireuserswithanestablishedcookieandprofilethenmakesurethatyoudochecktheCapturebrowsercookieoption.
Note:
ThecurrentversionoftheWASBrowserRecorderdoesnotsupportHTTPS/SSLrequestsatthistime.TocapturerequestssecurerequestsyouhavetotemporarydisableSSL(临时禁用SSL).IfyouhavetohaveSSLforaccuratetesting,youcanthenmanuallychangetheindividualrequestsinthelinklistandenableSSLoperationonthem.
WhenyouclickNext|Finishonthebrowserrecorderyou'llbewhiskedintoIEandyou'rereadytocapturerequestsinyourbrowser.InmycaseIranatestagainstmyWestWindWebStoreonmydevelopmentmachinestartingwiththehomepageandtypingthatlinkintothebrowser'saddressline.AfterthatI'moffonmydevsiteandwithWAScapturinglinks.ThissitehappenstobeWebstoreapplicationthatreliesonCookiestotrackusers,handlesprofileinformationforcustomersandsecureorderprocessingviaHTT