Sie sind auf Seite 1von 11

How to do remote testing the 'proper way'?

Answer: Here are a few notes to help you on your way. You have: 1. Your application server. You shouldn't run anything on this machine that you wouldn't have running on it in your proposed or actual production environment (if you are running anything else, including JMeter, you will e adding load to the server and thus tainting your results!. ". #ne or more machines running $meter%server (the JMeter&ngine!. You want these machines to e reasona ly close (networ' wise! to the application server. (y )reasona ly close) * mean on the same &thernet segment or at least with no low speed lin's etween them. +he JMeter ,ser Manual provides reasona le information a out doing this. -. . single machine running the JMeter /,* that you use to control the machines running the JMeter&ngine. 0hile you are developing your scripts and for only moderate levels of user testing (assuming you are )close) to the application server! you do not need to involve any JMeter&ngine machines. +he reason you have these are to: 1. &liminate the impact of slow networ' connections when you are not )close) to the application server. ". &1ecute more test threads than your local machine is capa le of handling. 2ote that if the /,* is running multiple remote servers, it can easily ecome a ottle% nec', especially if a lot of listeners are eing used. 3emove all unnecessary listeners efore running stress tests. 3unning JMeter in non%/,* ( atch! mode is prefera le, as this uses far fewer resources. +he output log files can e merged after the test run and used to create overall test statistics. (456 files can $ust e appended to each other7 8M9 output files need a it of editting to maintain well%formedness.! *f there are several nodes running the JMeter test plan, it is a good idea to try and ensure that their cloc's are synchronised, as this ma'es it easier to analyse the data later.

How to run JMeter test plan programatically, such as from an Ant script?
Answer: :uic' answer, go here: http:;;www.programmerplanet.org;ant%$meter;. * have permission from the author of this ant tas' to add it to JMeter's distri ution, which * will do as soon as * have the time. (*t should now e in the e1tras folder!.

How can I do stress testing of EJBs?


Answer: You can use the Java6ampler classes to write your own class that runs your &J('s, and then JMeter will ta'e over the threading and reporting. +his, however, is not ideal. 6omeone needs to write a good &J( 6ampler implementation for JMeter (hint, hint!.

hy do H!!" #$$ redirects appear as errors ? Is there a way to ma%e them appear as H!!" &'' ()
Answer: :uic' answer: +hey appear as an error ecause -<" => "<<, at least in v 1.?.1. 9ong answer: try using v1.@341, the code in H++A6ampler seems to ta'e into account the result code for the redirect instead of the redirect result code.

How do I parameteri*e my JMeter test cases?


Answer: Aarameters can e set at oth the +est Alan and +hread /roup levels. .t the +est Alan level, parameters can e used as constants to minimiBe changes throughout the test plan when a server or port changes, for e1ample. C2.(. functions are not currently supported at +est Alan level.D 0ithin +hread /roups, the ,ser Aarameters Are%Arocessor can e used to set different parameters for each simulated user. 2ote: if only one user (i.e. ,serE1! is defined, the value will e used for all threads. Functions .3& supported here. 6ee later F.:s for more information. +he following e1ample parameteriBes the pet category from the Java Aet 6tore. +han's to $0e Hosting.net for allowing us to run the e1ample on their server. 1. 6tart JMeter ". 4lic' the .dd utton to add the following user defined varia les to the +est Alan node: 1. server: www.$ oss.$we hosting.net ". port: ?< -. protocol: http -. .dd a +hread /roup to the +est Alan setting: 1. 2um er of +hreads: " ". 4lear the forever chec' o1 -. 9oop 4ount: 1 G. .dd 4onfig &lement H H++A 4oo'ie Manager to +hread /roup

I. .dd Are Arocessors H ,ser Aarameters to +hread /roup J. 4lic' .dd ,ser to add an additional user to the ,ser Aarameters K. 4lic' .dd 5aria le and set name to category, ,serE1 to L#/6 and ,serE" to F*6H ?. .dd 6ampler H H++A 3eMuest to +hread /roup with the following settings: 1. 6erver 2ame or *A: NOserverP ". Aort 2um er: NOportP -. Arotocol: NOprotocolP G. Aath: ;estore;control;category @. 4lic' the .dd utton to add a parameter to the reMuest: 1. 2ame: categoryEid ". 5alue: NOcategoryP 1<. .dd 9istener H 5iew 3esults +ree to +hread /roup 11. 6ave 1". 3un H 6tart 0hen you view the results in the 5iew 3esults +ree, you can see the NOcategoryP value was replaced with the value from the ,ser Aarameters. &ach thread will use the category from the ,ser Aarameter setting automatically. *f there are more than two threads, they will reuse the values in these settings, so the third thread would use L#/6.

How do I ma%e parameters dynamic, reacting to the uni+ue ser,er responses of each test run?
Answer: You can use the 3egular &1pression Aost Arocessor to e1tract a value from a response, and then reuse this response in another reMuest. 9oo'ing at the previous Muestion in this F.:, you could e1tract the product id from the result and use it in the following reMuest: 1. 9oad +est Alan created in previous F.: Muestion ". .dd Aost Arocessor H 3egular &1pression &1tractor to thread /roup with following values: 1. 3eference 2ame: product ". 3egular &1pression: productEid>(QwR%QwR%QwR! -. +emplate: N1N G. Match 2o.: < (6etting this parameter to < returns a random match! -. 4opy the H++A 3eMuest we created in the previous Muestion and paste to the thread group after the previous H++A 3eMuest G. 4hange the following values: 1. Aath: ;estore;control;product

". .dd Aarameter and set name to productEid, value to NOproductP I. 6ave +est Alan J. 3un H 6tart 0hen you view the results in the 5iew 3esults +ree, you can see the NOproductP value was replaced with the value e1tracted y the regular e1pression.

How do I pass parameters into my !est scripts? I want to -e a-le to use the same script to test with different num-ers of threads and loops, and I don't want to ha,e to change the script each time.
Answer:as e1plained a ove, you can use functions and varia les $ust a out anywhere in the test plan. 6o if you want to pass in a value a run%time, $ust use the property(! function, which reads the value of a JMeter property. *n order to define the property so JMeter can read it, define it on the command line as follows:
jmeter -Jproperty_name=property_value

For e1ample:
jmeter -Jhost2=www.zzzyy.com -Jhost1=www.jmeter-rules.net

+hese values can then e read in the test plan using: OOO NO property(host1!P and

NOproperty(host"!P PPP

2ote: +hread /roups are slightly different from other test elements, ecause their settings have to e determined efore the test starts. +his means that you cannot use varia les defined in a ,ser Aarameters form. (ut the property(! function wor's in +hread /roups, and you can use varia les defined on the +est Alan. For e1ample, you could define the +estAlan varia le: +H3&.L6 NOA(threads,1<!P and then use NO+H3&.L6P in the +hread/roup test element.

&lsewhere, you can use function calls, or varia le references to ,ser Aarameters (which in turn could e functions!, or varia le references to varia les set up y functions earlier in the test. +here's more than one way to do it. 6uppose you want to e a le to vary the num er of threads in a test plan. 4hoose a suita le property name, say group1.threads. 3eplace the thread count in the /,* (or the JM8, if you're feeling rave=! with the following function call:
${__property(group1.threads !

+hen, when starting JMeter, define the property on the command line:
jmeter -Jgroup1.threads=12"#$

*t can e useful to put default settings into the $meter property file, so you only need to supply differences on the command line. OOO S defaults in $meter.properties

group1.threads>1< group1.loops>1<< group1.rampup>1< PPP

+hen $ust do $meter %Jgroup1.loops>1<<< for e1ample. 5ersions of JMeter after 1.@.1 have a new version of the property(! function which allows a default value to e supplied, in case the property is not found:
${__property(group2.threads%%de&aultvalue !

+here is also a shorthand version called A(!, which you can use as follows:
${__'(group2.threads%1(( !

if you omit the value, it defaults to 1

How do I use e$ternal data files to define ,aria-les in my !est scripts?


Answer:+he 465 Lata 6et 4onfig element is the est way to do this, as it can create multiple varia les from a single data file. Answer:.nother way to do this is to create a ,ser Aarameters Are%Arocessor in which you list all the values that you want to read from files. You can then use the varia le names later in the script.

For e1ample: 1. 6tart JMeter ". .dd a +hread /roup to the +est Alan 1. set the appropriate num er of threads and iterations -. .dd Are Arocessors H ,ser Aarameters to +hread /roup G. 4lic' .dd 5aria le 1. 6et ,pdate once per iteration ". 6et the 2ame to the name of the varia le (e.g. .44#,2+*L! -. 6et the value (under ,serE1! to ${_)tr*ng+rom+*le(accounts.dat P I. .dd 6ampler H H++A 3eMuest to +hread /roup: J. 4lic' the .dd utton to add a parameter to the reMuest: 1. 2ame: accountEid ". 5alue: NO.44#,2+*LP K. .dd 9istener H 5iew 3esults +ree to +hread /roup ?. 6ave @. create the file accounts.dat containing one line per account id. *f it is not in the in directory, then modify the 6tringFromFile parameter accordingly, e.g. $
{_)tr*ng+rom+*le(..,testdata,accounts.dat ! or $ {_)tr*ng+rom+*le(,home,user,testdata,accounts.dat ! or $ {_)tr*ng+rom+*le(-.,wor/,data,accounts.dat P

1<. 3un H 6tart &ach iteration, the .44#,2+*L varia le will e set to the ne1t line in the file, and the H++A 3eMuest will use its value to set the accountEid parameter. 0hen the end of the file is reached, 6tringFromFile starts reading again at the eginning. 2.(. *f using such a script in client%server mode, ma'e sure that any data files are copied to the appropriate place on the server host, as the files will e opened y the server process, not the client.

I'm ha,ing difficulty getting JMeter to wor% with //0 1H!!"/2. hat's the pro-lem?
Answer: 4hec' out the documentation item ".".G. [A lot of people struggle with this, either because of private certs or whatever - I'm looking for a page that details common trip-ups and solutions for them. - MikeStover

I'm ha,ing difficulty -uilding Jmeter from 3etBeans I4E. It is loo%ing for a org.apache.log.Hierarchy, which log util is it loo%ing for?
Answer: Ma'e sure to mount all of the $ars in the li folder.

Has anyone out there used JMeter as part of 5unit testing? I'd li%e to thin% that -y using assertions with a custom J6nit listener JMeter could -e run in as part of functional testing.
Answer: *t's a great idea to write some glue etween JMeter and J,nit for $ust this purpose. *t doesn't e1ist currently, though there is an .nt tas' for JMeter that you might find useful.

7an JMeter record H!!"/ re+uests using the recording pro$y?


Answer:2o. JMeter would never e a le to decipher the encrypted reMuests the rowser sends. 669 Aro1ies create a tunnel from the rowser to the destination server ut do not and cannot read the messages. 4hec' out (ad(oy for a possi le solution.

How can I display the response te$t my assertation runs against?


Answer:You can display your server's response te1t in the 5iew 3esults +ree listener.

Is there a JM8 /chema94!4 a,aila-le?


Answer:2o. Lon't plan on having one either at this point. 4hanges would e too freMuent to realistically 'eep up with.

hat happens with redirects when asserting H!!" responses?


Answer:.ssertions aren't smart enough to do the right thing with redirected reMuests % currently the -<" response would e asserted against. You can get around this y recording your test plans and leaving )follow redirects) off.

.lternatively, the latest JMeter release (after 1.@.1! has an option to allow the redirects to e handled y the Java li ary routines. &arlier versions of Java did not support redirects properly, ut if you want to try, $ust define the following JMeter property:
011')ampler.delegate2ed*rects=true

JMeter will then not see the redirects at all.

I',e set the 70A//"A!H, -ut JMeter is not pic%ing up my Jars


Answer:+he 49.66A.+H varia le is ignored when using the %$ar flag. For some further information on this, see:How the Java launcher finds user classes JMeter currently 'nows to loo' for $ars;classes in two places only:

li ;e1t, where the .pacheJMeterER.$ar files live li , where the -rd party $ar files live

.dditional $ars should normally e placed in the li directory7 however, if you have written an add%on for JMeter itself, that should e put in the li ;e1t directory. *f you want your $ar file to e availa le to all Java applications, it can e placed in the J5M e1tensions directory .nother possi le solution is to ta'e a copy of the $meter startup script, and replace: jar 345pacheJ6eter47.jar with org.apache.jmeter.8ew9r*ver after adding .pacheJMeter.$ar to the classpath

hat "attern matching 1rege$en2 does JMeter support?


Answer:JMeter includes the pattern matching software .pache Ja'arta #3#. 6ee 3egular&1pressions for more details and e1amples

I want to use :Monitor ;esults< of JMeter


4urrently * am using 0.6 I.< .pplication 6erver . For TMonitor 3esultsU , JMeter shows the e1ample for +#M4.+ I.< 0e 6erver. TUUU( Followings from JMeter doc !

.dd the H++A 3eMuest to the +hread /roup element (.dd %%H 6ampler %%H H++A 3eMuest!. +hen, select the H++A 3eMuest element in the tree and edit the following properties!: 4hange the 2ame field to )6erver 6tatus). &nter the *A address or Hostname &nter the port num er 6et the Aath field to );manager;status) if you're using +omcat. .dd a reMuest parameter named )8M9) in uppercase. /ive it a value of )true) in lowercase. 4hec' ),se as Monitor) at the ottom of the sampler TUUUU Alease let me 'now how * can set TMonitor 3esultsU of JMeter in 0.6I.<. +o use the JMeter Monitor for *(M 0.6I.<, you will need to port the status servlet from +omcatI to 0.6. Your other option is to write your own status servlet and output the data in the correct format. +omcatI includes the schema for the status data. *f you have any further Muestion, feel free to email the $meter%user mailing list.

JMeter %eeps getting =(ut of Memory= errors. can I do?

hat

+his is usually caused y including memory intensive listeners in your stress test. 9isteners li'e )5iew +ree 3esults) are useful for de ugging your test, ut they are too memory intensive to remain in your test when you ramp up the num er of simulated users and iterations. +he est listeners to use for a long%term, high%load test are .ggregate 9istener, /raph 9istener, and 6pline 9istener. *n addition, you can instruct the J5M to use more memory y editing the $meter;$meter. at files for linu1;windows. 0ithin these files, find a section that sets values for the Heap:

set H&.A>%8ms"IJm %8m1"IJm

Feel free to change these values. 8ms indicates the starting 3.M the $vm will ta'e, and 8m1 will e the ma1imum it is allowed (for the H&.A!.

4oes JMeter process dynamic pages 1e.g. Ja,ascript and applets2


2o. JMeter does not process Javascript or applets em edded in H+M9 pages. JMeter can download the relevant resources (some em edded resources are downloaded automatically if the correct options are set!, ut it does not process the H+M9 and e1ecute any Javascript functions.

*f the page uses Javascript to uild up a ,39 or su mit a form, you can use the Aro1y 3ecording facility to create the necessary sampler. *f this is not possi le, then manual inspection of the code may e needed to determine what the Javascript is doing.

hat a-out -ac%ward compati-ility ?


Answer: JMeter ".1 uses a new format. (ut you can set values to ".< to save to old format. You should ta'e a loo' at !meter.properties in your in directory. You can uncomment those lines (remove S character! and restart $meter :
: )ave test plans and test logs *n 2.( &ormat :&*le_&ormat=2.( : Just test plans (jm; :&*le_&ormat.testplan=2.( : Just test logs (jtl :&*le_&ormat.testlog=2.(

You can also ta'e a loo' at this mail archive from dev list. More informations a out: Jm1+estAlan or Jtl+est9og

How do I ensure each http re+uest for 5sp is within one 5sessionid ?
Just insert a http coo'ie manager. *t will automatically handle the session for all the reMuest within the threadgroup treating it li'e one session. 0ithout http coo'ie manager, each reMuest is a new session as no session state is 'ept. $sessionid is only shown for the very first reMuest, su seMuent reMuest will not see the $sessionid. to use a varia le in $meter is NOname of varia leP. +his is very useful when dealing with $sp form logins, as the first reMuest is to login to the system and su seMuent reMuest is to do load testing on the target page. +his will prevent redirection ac' into login page.

How do I ensure the remote 5meter ser,er can communicate with the master client?
6ometimes $ava;rmi doesn't determine the correct *A address of your client. For e1ample if you are communicating over a vpn under linu1, the ppp interface is the *A that you want to use, ut $ava may end up using the eth1 interface. *f this is the case, you will see a connect e1ception in the $meter%server log, which will mention an *A address different

than the one you want it to use. You can force rmi to use a different *A address than the one it loo's up y setting a system property: %L$ava.rmi.server.hostname>1@".1J?.I.J

Das könnte Ihnen auch gefallen