jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shmuel Krakower <shmul...@gmail.com>
Subject Re: BeanShell PreProcessor doesn't seem to work as I expect
Date Tue, 29 Jul 2014 12:09:50 GMT
Hi
The code refers to previous result object, so it works fine in the
beanshell sampler as it refers to previous http sampler result.

The post processor simply has no previous result object for the first
iteration, as pre/post processors are running in the scope/context of the
parent/current sampler...

www.beatsoo.org - free application performance monitoring from world wide
locations.
On Jul 29, 2014 8:21 AM, "Nigel Donaldson" <ndonaldson@aconex.com> wrote:

> Thanks for responding 'sebb'. For completeness: in my case, does that mean
> that the While controller completely prevents the PreProc. from being run,
> or just that it's run after the While controller and is therefore
> ineffectual for loop control? Cheers.
> ----- Original Message -----
>
> From: "sebb" <sebbaz@gmail.com>
> To: "JMeter Users List" <user@jmeter.apache.org>
> Sent: Tuesday, 29 July, 2014 2:35:29 PM
> Subject: Re: BeanShell PreProcessor doesn't seem to work as I expect
>
> A Pre-Processor is only run just before a sampler.
>
> On 29 July 2014 04:06, Nigel Donaldson <ndonaldson@aconex.com> wrote:
> > I have the following arrangement in a Test Plan:
> >
> > Thread Group
> > - Module Controller
> >
> > where the module references/includes the following:
> >
> > Test Fragment
> > - Transaction Controller
> > -- BeanShell Sampler -or- BeanShell PreProcessor
> > -- While Controller
> > --- HTTP Request
> > --- BeanShell PostProcessor
> > ...
> >
> > The BeanShell Sampler (or PreProcessor) simply initialises a number of
> variables:
> >
> > vars.put("MaxNofAttempts", String.valueOf(bsh.args[0]));
> vars.put("AttemptCount", "0"); vars.put("RC", "0");
> >
> > The While test is:
> >
> > ${__javaScript("${RC}"!="200" && "${RC}"!="500" &&
> "${MaxNofAttempts}">"${AttemptCount}")}
> >
> > The PostProcessor checks the response-code of the HTTP request (which
> may be a meaningful 4xx, leading to an increment of the key variable):
> >
> > vars.put("RC", ctx.getPreviousResult().getResponseCode());
> > if (vars.get("RC").substring(0, 1).equals("4")) {
> vars.put("AttemptCount", String.valueOf(
> Integer.parseInt(vars.get("AttemptCount"))+1 )); }
> >
> >
> > If I use a BeanShell Sampler the arrangement works as expected (ie. up
> to a fixed number of retries upon 4xx response-codes, or flow-through upon
> 200 or 500).
> >
> > However, if I use a BeanShell PreProcessor instead, the While test fails
> (leading to an infinite loop) because the value of the 'AttemptCount'
> variable appears unchanged.
> >
> > I don't understand this. I'd appreciate an explanation and/or
> suggestions. (For what it's worth, I originally had JSR223 elements, with
> the same result).
> >
> > Cheers,
> > Nige
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message