You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Jason Frank <j_...@yahoo.com> on 2008/02/27 21:32:48 UTC

JMeter functions -- where to invoke them in a test?

I love the capabilities and flexibility of JMeter but I have to say, it is very frustrating trying to figure out how to do certain things.  I probably just don't know exactly where to look, but I've searched a bunch of spots and haven't been able to figure it out.

I am trying to use JMeter to simulate a bunch of users for my web site.  Among other things, one thing I want to do is simulate both logged-in and anonymous users.  They can do many of the same things, so I want to just have some logic that handles the differences within a single thread group.  In my user-defined variables, I have set a variable called "loginProbability" and set it 20.  Then, I have an IfController that uses this as the test condition:

${__Random(1, 100, login)} <= ${loginProbability}

Underneath that IfController, I do an HTTP post to the login page.  And I am trying to save the results of the call to __Random inside the variable "login" for future reference.  The random part works fine -- approximately 20% of the time, a thread will pass the test and login.  What I am struggling with, is how to use the "login" saved variable in later tests, to know if a thread is logged in.  For example, at the end of a thread's activity, I want it to log out but only if it was logged in.  So I made another IfController, and this time I use the test condition:

${login} <= ${loginProbability}

trying to take advantage of the stored "login" variable from the first call to Random.  This does not work.  No one ever falls into that IfController.  Probably I am doing something stupid, but I can't see what it is.

When I search around for help with JMeter functions, I see people talking about using the __log function to debug, and a "java test" sampler to see variable values.  I am confused about where I can put such things in my test plan.  I don't see a way to just add a "function call controller", for example, such that I could put a call to __log in there.  And I don't seem to have a Java Test sampler in my menu of samplers.  I am using JMeter 2.3.1 on Linux, in case that matters.  Here is an example of a thread that refers to using __log and Java Test sampler to debug:

http://www.mail-archive.com/jmeter-user@jakarta.apache.org/msg05550.html





      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: JMeter functions -- where to invoke them in a test?

Posted by David Brown <da...@davidwbrown.name>.
Hello Jason, I just rolled off a gig where I had to build a scaled down model of and existing Production set of applications and their servlet containers (Tomcat and JBoss). To get a good representation of all the links  including logins with userids and passwords I used the Http Proxy Recording Workbench to collect all of the links and their request params correctly. Download the JMeter PDF:

http://wiki.apache.org/jakarta-jmeter/

Next I created a distributed test to emulate many machines at different network locations. The distributed test is master/slave. This means once you have your JMeter Test Plan working for a single local machine and a singel remote machine you can then ramp up the Test Plan to a serious level and depending on your applications' parameters and your hardware you will eventually be able to get the application to begin dropping transactions or even fail (pushing the jet fighter envelope concept). The only caveat is you can only have multiple users per slave machine if you use multiple ThreadGroups (one user per ThreadGroup). The upside to the slave machines is any type of hardware as preferable will do-the-job (laptops old towers, any OS: Linux, XP, whatever).

Download the JMeter PDF about distributed testing at the same place and be sure to read:

http://jakarta.apache.org/jmeter/usermanual/remote-test.html

HTH.



Jason Frank wrote ..
> I love the capabilities and flexibility of JMeter but I have to say, it is very
> frustrating trying to figure out how to do certain things.  I probably just don't
> know exactly where to look, but I've searched a bunch of spots and haven't been
> able to figure it out.
> 
> I am trying to use JMeter to simulate a bunch of users for my web site.  Among
> other things, one thing I want to do is simulate both logged-in and anonymous users.
> They can do many of the same things, so I want to just have some logic that handles
> the differences within a single thread group.  In my user-defined variables, I
> have set a variable called "loginProbability" and set it 20.  Then, I have an IfController
> that uses this as the test condition:
> 
> ${__Random(1, 100, login)} <= ${loginProbability}
> 
> Underneath that IfController, I do an HTTP post to the login page.  And I am trying
> to save the results of the call to __Random inside the variable "login" for future
> reference.  The random part works fine -- approximately 20% of the time, a thread
> will pass the test and login.  What I am struggling with, is how to use the "login"
> saved variable in later tests, to know if a thread is logged in.  For example,
> at the end of a thread's activity, I want it to log out but only if it was logged
> in.  So I made another IfController, and this time I use the test condition:
> 
> ${login} <= ${loginProbability}
> 
> trying to take advantage of the stored "login" variable from the first call to
> Random.  This does not work.  No one ever falls into that IfController.  Probably
> I am doing something stupid, but I can't see what it is.
> 
> When I search around for help with JMeter functions, I see people talking about
> using the __log function to debug, and a "java test" sampler to see variable values.
> I am confused about where I can put such things in my test plan.  I don't see a
> way to just add a "function call controller", for example, such that I could put
> a call to __log in there.  And I don't seem to have a Java Test sampler in my menu
> of samplers.  I am using JMeter 2.3.1 on Linux, in case that matters.  Here is
> an example of a thread that refers to using __log and Java Test sampler to debug:
> 
> http://www.mail-archive.com/jmeter-user@jakarta.apache.org/msg05550.html
> 
> 
> 
> 
> 
>       ____________________________________________________________________________________
> Never miss a thing.  Make Yahoo your home page. 
> http://www.yahoo.com/r/hs
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org