You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Ronan Klyne <ro...@groupbc.com> on 2007/09/04 16:57:46 UTC

Handling errors gracefully in sets of pages

Greetings all,

I have a web application with many available actions to be performed.
For this example, I'll need to perform actions A and B.
Each action involves several pages - let's say A1, A2, A3 and B1, B2, B3.
If A[n] fails, there is no point trying A[n+1], and I would like to be
able to tell JMeter this. Can I do something akin to the following?

Try
 + A1
 + A2
 + A3
Catch
 + Handle the problem.

Thanks in advance,

	Ronan

-- 
Ronan Klyne
Business Collaborator Developer
Tel: +44 (0)870 163 2555
ronan.klyne@groupbc.com
www.groupbc.com

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


Re: Handling errors gracefully in sets of pages

Posted by sebb <se...@gmail.com>.
On 11/09/2007, Ronan Klyne <ro...@groupbc.com> wrote:
> sebb wrote:
> > On 10/09/2007, Ronan Klyne <ro...@groupbc.com> wrote:
> >> sebb wrote:
> >>> By the way, BeanShell tends to leak more memory if the script is on
> >>> the screen; using a file seems better. Best is probably to define the
> >>> script as a method in a startup file and then invoke from a file or
> >>> the screen.
> >> Does this just apply to Samplers? I ask because there I see no option to
> >> source pre/post-processors from files. In this situation, would it help
> >> to keep leaks to a minimum if I had a single line of script on screen
> >> calling a function?
> >
> > No - all the BeanShell test elements now have their own initial files
> > - see jmeter.properties in 2.3RC4.
>
> Sorry, not quite what I meant to ask...
> I saw a text field in the UI panel for a beanshell sampler which allowed
> me to specify a file name. I couldn't see a similar option for
> pre/post-processors, and was wondering if just putting a function call
> in the script field would be as efficient?

It should be more efficient than including the code on the screen, but
perhaps not as efficient as using a file.

Some of the beanshell GUIs don't have file fields; they could/should
be added in a later release.

>
>        # r
>
> --
> Ronan Klyne
> Business Collaborator Developer
> Tel: +44 (0)870 163 2555
> ronan.klyne@groupbc.com
> www.groupbc.com
>
> ---------------------------------------------------------------------
> 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


Re: Handling errors gracefully in sets of pages

Posted by Ronan Klyne <ro...@groupbc.com>.
sebb wrote:
> On 10/09/2007, Ronan Klyne <ro...@groupbc.com> wrote:
>> sebb wrote:
>>> By the way, BeanShell tends to leak more memory if the script is on
>>> the screen; using a file seems better. Best is probably to define the
>>> script as a method in a startup file and then invoke from a file or
>>> the screen.
>> Does this just apply to Samplers? I ask because there I see no option to
>> source pre/post-processors from files. In this situation, would it help
>> to keep leaks to a minimum if I had a single line of script on screen
>> calling a function?
> 
> No - all the BeanShell test elements now have their own initial files
> - see jmeter.properties in 2.3RC4.

Sorry, not quite what I meant to ask...
I saw a text field in the UI panel for a beanshell sampler which allowed
me to specify a file name. I couldn't see a similar option for
pre/post-processors, and was wondering if just putting a function call
in the script field would be as efficient?

	# r

-- 
Ronan Klyne
Business Collaborator Developer
Tel: +44 (0)870 163 2555
ronan.klyne@groupbc.com
www.groupbc.com

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


Re: Handling errors gracefully in sets of pages

Posted by sebb <se...@gmail.com>.
On 10/09/2007, Ronan Klyne <ro...@groupbc.com> wrote:
> sebb wrote:
> > By the way, BeanShell tends to leak more memory if the script is on
> > the screen; using a file seems better. Best is probably to define the
> > script as a method in a startup file and then invoke from a file or
> > the screen.
>
> Does this just apply to Samplers? I ask because there I see no option to
> source pre/post-processors from files. In this situation, would it help
> to keep leaks to a minimum if I had a single line of script on screen
> calling a function?

No - all the BeanShell test elements now have their own initial files
- see jmeter.properties in 2.3RC4.

>        # r
>
> --
> Ronan Klyne
> Business Collaborator Developer
> Tel: +44 (0)870 163 2555
> ronan.klyne@groupbc.com
> www.groupbc.com
>
> ---------------------------------------------------------------------
> 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


Re: Handling errors gracefully in sets of pages

Posted by Ronan Klyne <ro...@groupbc.com>.
sebb wrote:
> By the way, BeanShell tends to leak more memory if the script is on
> the screen; using a file seems better. Best is probably to define the
> script as a method in a startup file and then invoke from a file or
> the screen.

Does this just apply to Samplers? I ask because there I see no option to
source pre/post-processors from files. In this situation, would it help
to keep leaks to a minimum if I had a single line of script on screen
calling a function?

	# r

-- 
Ronan Klyne
Business Collaborator Developer
Tel: +44 (0)870 163 2555
ronan.klyne@groupbc.com
www.groupbc.com

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


Re: Handling errors gracefully in sets of pages

Posted by sebb <se...@gmail.com>.
On 05/09/07, Ronan Klyne <ro...@groupbc.com> wrote:
> > By the way, BeanShell tends to leak more memory if the script is on
> > the screen; using a file seems better. Best is probably to define the
> > script as a method in a startup file and then invoke from a file or
> > the screen.
>
> Aaah... That's a very useful bit of info - I'm seeing memory usage
> hitting 1Gb for a 10 thread test, so this could be the solution...
>
> Out of curiosity, would if be feasible to implement try/catch-like
> behaviour in JMeter? If so, I'd find it useful enough that I may even
> end up writing it. (I just don't want to spend lots of time learning
> about the JMeter code base to discover that it's not possible/really silly)
>

Sorry, no idea.

The thread control part of JMeter is rather complicated - it looks
simple enough in the JMeterThread class, but there are a lot of subtle
interactions between the controller classes that it calls.

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


Re: Handling errors gracefully in sets of pages

Posted by Ronan Klyne <ro...@groupbc.com>.
> By the way, BeanShell tends to leak more memory if the script is on
> the screen; using a file seems better. Best is probably to define the
> script as a method in a startup file and then invoke from a file or
> the screen.

Aaah... That's a very useful bit of info - I'm seeing memory usage
hitting 1Gb for a 10 thread test, so this could be the solution...

Out of curiosity, would if be feasible to implement try/catch-like
behaviour in JMeter? If so, I'd find it useful enough that I may even
end up writing it. (I just don't want to spend lots of time learning
about the JMeter code base to discover that it's not possible/really silly)

	# r

-- 
Ronan Klyne
Business Collaborator Developer
Tel: +44 (0)870 163 2555
ronan.klyne@groupbc.com
www.groupbc.com

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


Re: Handling errors gracefully in sets of pages

Posted by sebb <se...@gmail.com>.
On 06/09/07, Ronan Klyne <ro...@groupbc.com> wrote:
> sebb wrote:
> > On 06/09/07, Ronan Klyne <ro...@groupbc.com> wrote:
> >>> By the way, BeanShell tends to leak more memory if the script is on
> >>> the screen; using a file seems better. Best is probably to define the
> >>> script as a method in a startup file and then invoke from a file or
> >>> the screen.
> >>>
> >> I'm trying to do this, but I can't make it work.
> >> I am using a Simple Config Element to set both
> >> 'beanshell.preprocessor.init' and 'beanshell.postprocessor.init' to be
> >> 'BC\funcs.bsh'. I then try to invoke one of these functions from the
> >> screen, and get an error in jmeter.log saying "Typed variable
> >> declaration" (And quoting a bit of the code).
> >> Should it be working when I do this?
> >
> > No, you need to set them as properties before starting JMeter, e.g. in
> > jmeter.properties (or user.properties).
>
> Wouldn't that make these functions accessible to all of my test plans?

Yes.

If you use different directories for the different projects, try
adding a user.properties file to each (I think that overrides the one
in bin, but check first).

> I'd prefer to keep the project specific stuff out of other projects if
> possible - is this possible?

Yes:
* local user.properties (if that works)
* use an additional properties file (-q)
* define the properties on the command-line (-J)

>        # r
>
> --
> Ronan Klyne
> Business Collaborator Developer
> Tel: +44 (0)870 163 2555
> ronan.klyne@groupbc.com
> www.groupbc.com
>
> ---------------------------------------------------------------------
> 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


Re: Handling errors gracefully in sets of pages

Posted by Ronan Klyne <ro...@groupbc.com>.
sebb wrote:
> On 06/09/07, Ronan Klyne <ro...@groupbc.com> wrote:
>>> By the way, BeanShell tends to leak more memory if the script is on
>>> the screen; using a file seems better. Best is probably to define the
>>> script as a method in a startup file and then invoke from a file or
>>> the screen.
>>>
>> I'm trying to do this, but I can't make it work.
>> I am using a Simple Config Element to set both
>> 'beanshell.preprocessor.init' and 'beanshell.postprocessor.init' to be
>> 'BC\funcs.bsh'. I then try to invoke one of these functions from the
>> screen, and get an error in jmeter.log saying "Typed variable
>> declaration" (And quoting a bit of the code).
>> Should it be working when I do this?
> 
> No, you need to set them as properties before starting JMeter, e.g. in
> jmeter.properties (or user.properties).

Wouldn't that make these functions accessible to all of my test plans?
I'd prefer to keep the project specific stuff out of other projects if
possible - is this possible?

	# r

-- 
Ronan Klyne
Business Collaborator Developer
Tel: +44 (0)870 163 2555
ronan.klyne@groupbc.com
www.groupbc.com

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


Re: Handling errors gracefully in sets of pages

Posted by sebb <se...@gmail.com>.
On 06/09/07, Ronan Klyne <ro...@groupbc.com> wrote:
> > By the way, BeanShell tends to leak more memory if the script is on
> > the screen; using a file seems better. Best is probably to define the
> > script as a method in a startup file and then invoke from a file or
> > the screen.
> >
>
> I'm trying to do this, but I can't make it work.
> I am using a Simple Config Element to set both
> 'beanshell.preprocessor.init' and 'beanshell.postprocessor.init' to be
> 'BC\funcs.bsh'. I then try to invoke one of these functions from the
> screen, and get an error in jmeter.log saying "Typed variable
> declaration" (And quoting a bit of the code).
> Should it be working when I do this?

No, you need to set them as properties before starting JMeter, e.g. in
jmeter.properties (or user.properties).

You should also use / rather than \ in pathnames.

S
>        # r
>
> --
> Ronan Klyne
> Business Collaborator Developer
> Tel: +44 (0)870 163 2555
> ronan.klyne@groupbc.com
> www.groupbc.com
>
> ---------------------------------------------------------------------
> 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


Re: Handling errors gracefully in sets of pages

Posted by Ronan Klyne <ro...@groupbc.com>.
> By the way, BeanShell tends to leak more memory if the script is on
> the screen; using a file seems better. Best is probably to define the
> script as a method in a startup file and then invoke from a file or
> the screen.
> 

I'm trying to do this, but I can't make it work.
I am using a Simple Config Element to set both
'beanshell.preprocessor.init' and 'beanshell.postprocessor.init' to be
'BC\funcs.bsh'. I then try to invoke one of these functions from the
screen, and get an error in jmeter.log saying "Typed variable
declaration" (And quoting a bit of the code).
Should it be working when I do this?

	# r

-- 
Ronan Klyne
Business Collaborator Developer
Tel: +44 (0)870 163 2555
ronan.klyne@groupbc.com
www.groupbc.com

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


Re: Handling errors gracefully in sets of pages

Posted by sebb <se...@gmail.com>.
On 05/09/07, Ronan Klyne <ro...@groupbc.com> wrote:
> sebb wrote:
> > Not easily.
> >
> > You could try using the If Controller
> >
> >  http://jakarta.apache.org/jmeter/usermanual/component_reference.html#If_Controller
> >  with the condition
> >
> > ${JMeterThread.last_sample_ok}" == "true" (check if last sample succeeded)
> >
> > e.g.
> >
> > A1
> > If OK
> > + A2
> > If OK
> > + A3
> > If not OK
> > + handle error
> >
> > but this quickly becomes a bit tedious to code if there are lots of samplers.
>
> True...
>
> > If you can use a single sampler with variables read from a file, then
> > you might be able to use a looping controller (or While Controller)
> > instead. This would be harder to set up, but easier to extend once it
> > was working. This only works if the samplers all need the same number
> > of parameters, though you could get clever and use a Switch Controller
> > to select between samplers with different numbers of parameters...
>
> This is looking like way forward. It has given me an unexpeceted concern
> though:
> In one place in my code I have a single sampler with this code in a
> BeanShell pre-processor to vary the parameter names and numbers:
>
> while (en.hasMoreElements()) {
>        user = en.nextElement();
>        reason = chosen.get(user);
>        sampler.addArgument("response_type", reason);
>        sampler.addArgument("issued_users", user);
>        sampler.addArgument("resptype_" + user, reason);
>        sampler.addArgument("comment_" + user, "");
>        sampler.addArgument("group_id_" + user, "0");
>        sampler.addArgument("due_date_" + user, "");
> }
>
> Am I to infer from your comment that this is unwise?

No, that should be fine.

I just meant that it is not possible to have optional parameters on
the HTTP sampler dialogue - even if the name and value both resolve to
blanks, the sampler will still generate a parameter.

[I think there was once an idea to skip the parameter creation if the
name and value were both blank, but this was not implemented...]

By the way, BeanShell tends to leak more memory if the script is on
the screen; using a file seems better. Best is probably to define the
script as a method in a startup file and then invoke from a file or
the screen.

>        # r
>
> --
> Ronan Klyne
> Business Collaborator Developer
> Tel: +44 (0)870 163 2555
> ronan.klyne@groupbc.com
> www.groupbc.com
>
> ---------------------------------------------------------------------
> 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


Re: Handling errors gracefully in sets of pages

Posted by Ronan Klyne <ro...@groupbc.com>.
sebb wrote:
> Not easily.
> 
> You could try using the If Controller
> 
>  http://jakarta.apache.org/jmeter/usermanual/component_reference.html#If_Controller
>  with the condition
> 
> ${JMeterThread.last_sample_ok}" == "true" (check if last sample succeeded)
> 
> e.g.
> 
> A1
> If OK
> + A2
> If OK
> + A3
> If not OK
> + handle error
> 
> but this quickly becomes a bit tedious to code if there are lots of samplers.

True...

> If you can use a single sampler with variables read from a file, then
> you might be able to use a looping controller (or While Controller)
> instead. This would be harder to set up, but easier to extend once it
> was working. This only works if the samplers all need the same number
> of parameters, though you could get clever and use a Switch Controller
> to select between samplers with different numbers of parameters...

This is looking like way forward. It has given me an unexpeceted concern
though:
In one place in my code I have a single sampler with this code in a
BeanShell pre-processor to vary the parameter names and numbers:

while (en.hasMoreElements()) {
	user = en.nextElement();
	reason = chosen.get(user);
	sampler.addArgument("response_type", reason);
	sampler.addArgument("issued_users", user);
	sampler.addArgument("resptype_" + user, reason);
	sampler.addArgument("comment_" + user, "");
	sampler.addArgument("group_id_" + user, "0");
	sampler.addArgument("due_date_" + user, "");
}

Am I to infer from your comment that this is unwise?

	# r

-- 
Ronan Klyne
Business Collaborator Developer
Tel: +44 (0)870 163 2555
ronan.klyne@groupbc.com
www.groupbc.com

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


Re: Handling errors gracefully in sets of pages

Posted by sebb <se...@gmail.com>.
Not easily.

You could try using the If Controller

 http://jakarta.apache.org/jmeter/usermanual/component_reference.html#If_Controller
 with the condition

${JMeterThread.last_sample_ok}" == "true" (check if last sample succeeded)

e.g.

A1
If OK
+ A2
If OK
+ A3
If not OK
+ handle error

but this quickly becomes a bit tedious to code if there are lots of samplers.

If you can use a single sampler with variables read from a file, then
you might be able to use a looping controller (or While Controller)
instead. This would be harder to set up, but easier to extend once it
was working. This only works if the samplers all need the same number
of parameters, though you could get clever and use a Switch Controller
to select between samplers with different numbers of parameters...

I recommend using the Java Request sampler for testing ideas such as
this, as it does not need a server. Or 2.3RC3 allows the HTTP Samplers
to use the "file" protocol to read from HTML files.

On 04/09/07, Ronan Klyne <ro...@groupbc.com> wrote:
> Greetings all,
>
> I have a web application with many available actions to be performed.
> For this example, I'll need to perform actions A and B.
> Each action involves several pages - let's say A1, A2, A3 and B1, B2, B3.
> If A[n] fails, there is no point trying A[n+1], and I would like to be
> able to tell JMeter this. Can I do something akin to the following?
>
> Try
>  + A1
>  + A2
>  + A3
> Catch
>  + Handle the problem.
>
> Thanks in advance,
>
>        Ronan
>
> --
> Ronan Klyne
> Business Collaborator Developer
> Tel: +44 (0)870 163 2555
> ronan.klyne@groupbc.com
> www.groupbc.com
>
> ---------------------------------------------------------------------
> 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