User's Manual: Elements of a Test Plan - Apache JMeter
文章推薦指數: 80 %
The ramp-up period tells JMeter how long to take to "ramp-up" to the full number of threads chosen. If 10 threads are used, and the ramp-up period is 100 ...
Maincontent
Twitter
github
".JMeter
willthencheckthatthetextispresentintheHTTPresponse.IfJMetercannotfindthe
text,thenitwillmarkthisasafailedrequest.
Notethatassertionsapplytoallsamplerswhichareintheirscope.
Torestrictanassertiontoasinglesampler,addtheassertionasachildofthesampler.
Toviewassertionresults,addanAssertionListenertotheThreadGroup.
FailedAssertionswillalsoshowupintheTreeViewandTableListeners,
andwillcounttowardstheerror%ageforexampleintheAggregateandSummaryreports.
3.6ConfigurationElements¶
AconfigurationelementworkscloselywithaSampler.Althoughitdoesnotsendrequests
(exceptforHTTP(S)TestScriptRecorder),itcanaddtoormodifyrequests.
Aconfigurationelementisaccessiblefromonlyinsidethetreebranchwhereyouplacetheelement.
Forexample,ifyouplaceanHTTPCookieManagerinsideaSimpleLogicController,theCookieManagerwill
onlybeaccessibletoHTTPRequestControllersyouplaceinsidetheSimpleLogicController(seefigure1).
TheCookieManagerisaccessibletotheHTTPrequests"WebPage1"and"WebPage2",butnot"WebPage3".
Also,aconfigurationelementinsideatreebranchhashigherprecedencethanthesameelementina"parent"
branch.Forexample,wedefinedtwoHTTPRequestDefaultselements,"WebDefaults1"and"WebDefaults2".
Sinceweplaced"WebDefaults1"insideaLoopController,only"WebPage2"canaccessit.TheotherHTTP
requestswilluse"WebDefaults2",sinceweplaceditintheThreadGroup(the"parent"ofallotherbranches).
Figure1-
TestPlanShowingAccessibilityofConfigurationElements
TheUserDefinedVariablesConfigurationelementisdifferent.
Itisprocessedatthestartofatest,nomatterwhereitisplaced.
Forsimplicity,itissuggestedthattheelementisplacedonlyatthestartofaThreadGroup.
3.7Pre-ProcessorElements¶
APre-ProcessorexecutessomeactionpriortoaSamplerRequestbeingmade.
IfaPre-ProcessorisattachedtoaSamplerelement,thenitwillexecutejustpriortothatsamplerelementrunning.
APre-ProcessorismostoftenusedtomodifythesettingsofaSampleRequestjustbeforeitruns,ortoupdatevariablesthataren'textractedfromresponsetext.
SeethescopingrulesformoredetailsonwhenPre-Processorsareexecuted.
3.8Post-ProcessorElements¶
APost-ProcessorexecutessomeactionafteraSamplerRequesthasbeenmade.
IfaPost-ProcessorisattachedtoaSamplerelement,thenitwillexecutejustafterthatsamplerelementruns.
APost-Processorismostoftenusedtoprocesstheresponsedata,oftentoextractvaluesfromit.
SeethescopingrulesformoredetailsonwhenPost-Processorsareexecuted.
3.9Executionorder¶
Configurationelements
Pre-Processors
Timers
Sampler
Post-Processors(unlessSampleResultisnull)
Assertions(unlessSampleResultisnull)
Listeners(unlessSampleResultisnull)
PleasenotethatTimers,Assertions,Pre-andPost-Processorsareonlyprocessedifthereisasamplertowhichtheyapply.
LogicControllersandSamplersareprocessedintheorderinwhichtheyappearinthetree.
Othertestelementsareprocessedaccordingtothescopeinwhichtheyarefound,andthetypeoftestelement.
[Withinatype,elementsareprocessedintheorderinwhichtheyappearinthetree].
Forexample,inthefollowingtestplan:
Controller
Post-Processor1
Sampler1
Sampler2
Timer1
Assertion1
Pre-Processor1
Timer2
Post-Processor2
Theorderofexecutionwouldbe:
Pre-Processor1
Timer1
Timer2
Sampler1
Post-Processor1
Post-Processor2
Assertion1
Pre-Processor1
Timer1
Timer2
Sampler2
Post-Processor1
Post-Processor2
Assertion1
3.10ScopingRules¶
TheJMetertesttreecontainselementsthatarebothhierarchicalandordered.Someelementsinthetesttreesarestrictlyhierarchical(Listeners,ConfigElements,Post-Processors,Pre-Processors,Assertions,Timers),andsomeareprimarilyordered(controllers,samplers).Whenyoucreateyourtestplan,youwillcreateanorderedlistofsamplerequest(viaSamplers)thatrepresentasetofstepstobeexecuted.Theserequestsareoftenorganizedwithincontrollersthatarealsoordered.Giventhefollowingtesttree:
Exampletesttree
Theorderofrequestswillbe,One,Two,Three,Four.
Somecontrollersaffecttheorderoftheirsubelements,andyoucanreadaboutthesespecificcontrollersinthecomponentreference.
Otherelementsarehierarchical.AnAssertion,forinstance,ishierarchicalinthetesttree.
Ifitsparentisarequest,thenitisappliedtothatrequest.Ifits
parentisaController,thenitaffectsallrequeststhataredescendantsof
thatController.Inthefollowingtesttree:
Hierarchyexample
Assertion#1isappliedonlytoRequestOne,whileAssertion#2isappliedtoRequestsTwoandThree.
Anotherexample,thistimeusingTimers:
complexexample
Inthisexample,therequestsarenamedtoreflecttheorderinwhichtheywillbeexecuted.Timer#1willapplytoRequestsTwo,Three,andFour(noticehoworderisirrelevantforhierarchicalelements).Assertion#1willapplyonlytoRequestThree.Timer#2willaffectalltherequests.
Hopefullytheseexamplesmakeitclearhowconfiguration(hierarchical)elementsareapplied.IfyouimagineeachRequestbeingpassedupthetreebranches,toitsparent,thentoitsparent'sparent,etc.,andeachtimecollectingalltheconfigurationelementsofthatparent,thenyouwillseehowitworks.
TheConfigurationelementsHeaderManager,CookieManagerandAuthorizationmanagerare
treateddifferentlyfromtheConfigurationDefaultelements.
ThesettingsfromtheConfigurationDefaultelementsaremergedintoasetofvaluesthattheSamplerhasaccessto.
However,thesettingsfromtheManagersarenotmerged.
IfmorethanoneManagerisinthescopeofaSampler,
onlyoneManagerisused,butthereiscurrentlynowaytospecifywhichisused.
3.11PropertiesandVariables¶
JMeterpropertiesaredefinedinjmeter.properties(seeGettingStarted-ConfiguringJMeterformoredetails).
Propertiesareglobaltojmeter,andaremostlyusedtodefinesomeofthedefaultsJMeteruses.
Forexamplethepropertyremote_hostsdefinestheserversthatJMeterwilltrytorunremotely.
Propertiescanbereferencedintestplans
-seeFunctions-readaproperty-
butcannotbeusedforthread-specificvalues.
JMetervariablesarelocaltoeachthread.Thevaluesmaybethesameforeachthread,ortheymaybedifferent.
Ifavariableisupdatedbyathread,onlythethreadcopyofthevariableischanged.
ForexampletheRegularExpressionExtractorPost-Processor
willsetitsvariablesaccordingtothesamplethatitsthreadhasread,andthesecanbeusedlater
bythesamethread.
Fordetailsofhowtoreferencevariablesandfunctions,seeFunctionsandVariables
NotethatthevaluesdefinedbytheTestPlanandtheUserDefinedVariablesconfigurationelement
aremadeavailabletothewholetestplanatstartup.
IfthesamevariableisdefinedbymultipleUDVelements,thenthelastonetakeseffect.
Onceathreadhasstarted,theinitialsetofvariablesiscopiedtoeachthread.
Otherelementssuchasthe
UserParametersPre-ProcessororRegularExpressionExtractorPost-Processor
maybeusedtoredefinethesamevariables(orcreatenewones).Theseredefinitionsonlyapplytothecurrentthread.
ThesetPropertyfunctioncanbeusedtodefineaJMeterproperty.
Theseareglobaltothetestplan,socanbeusedtopassinformationbetweenthreads-shouldthatbeneeded.
Bothvariablesandpropertiesarecase-sensitive.
3.12UsingVariablestoparameterisetests¶
Variablesdon'thavetovary-theycanbedefinedonce,andifleftalone,willnotchangevalue.
Soyoucanusethemasshort-handforexpressionsthatappearfrequentlyinatestplan.
Orforitemswhichareconstantduringarun,butwhichmayvarybetweenruns.
Forexample,thenameofahost,orthenumberofthreadsinathreadgroup.
WhendecidinghowtostructureaTestPlan,
makeanoteofwhichitemsareconstantfortherun,butwhichmaychangebetweenruns.
Decideonsomevariablenamesforthese-
perhapsuseanamingconventionsuchasprefixingthemwithC_orK_orusinguppercaseonly
todistinguishthemfromvariablesthatneedtochangeduringthetest.
Alsoconsiderwhichitemsneedtobelocaltoathread-
forexamplecountersorvaluesextractedwiththeRegularExpressionPost-Processor.
Youmaywishtouseadifferentnamingconventionforthese.
Forexample,youmightdefinethefollowingontheTestPlan:
HOSTwww.example.com
THREADS10
LOOPS20
Youcanrefertotheseinthetestplanas${HOST}${THREADS}etc.
Ifyoulaterwanttochangethehost,justchangethevalueoftheHOSTvariable.
Thisworksfineforsmallnumbersoftests,butbecomestediouswhentestinglotsofdifferentcombinations.
Onesolutionistouseapropertytodefinethevalueofthevariables,forexample:
HOST${__P(host,www.example.com)}
THREADS${__P(threads,10)}
LOOPS${__P(loops,20)}
Youcanthenchangesomeorallofthevaluesonthecommand-lineasfollows:
jmeter…-Jhost=www3.example.org-Jloops=13
延伸文章資訊
- 1User's Manual: Elements of a Test Plan - Apache JMeter
The ramp-up period tells JMeter how long to take to "ramp-up" to the full number of threads chose...
- 2Ramp-Up Definition - Investopedia
The term ramp-up refers to when a company substantially increases its output in response to incre...
- 3Ramp-up - Wikipedia
Alternatively, ramp-up describes the period from completed initial product development to maximum...
- 4Ramp-Up Period Definition: 351 Samples - Law Insider
Ramp-Up Period means the period from and including the Effective Date to the earlier of (i) the f...
- 5What Is a Ramp Up Period? - Azcentral