You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Eric Gandt <er...@fatwire.com> on 2011/05/10 15:54:51 UTC

beanshell and Aggregate Graph, recording errors not working

I have a beanshell that I'm running using the "BeanShell Sampler", it looks
like:

addClassPath("/storage/shared/perf.jar");
importCommands("/");
addClassPath(".");
importCommands("/");

// auto assume that the updfate failed, therefore if anything goes wrong and
we exit for some reason it will have failed
vars.put("IsSuccess", "false");   
vars.put("ResponseMessage", "NOT OK");

// Article Asset creation object
CreateArticleAsset CAA = new CreateArticleAsset("http://" + bsh.args[0] +
":" + bsh.args[1] + "/" + bsh.args[2]);

String responsecode = CAA.editAsset(bsh.args[3]);

//enable for debugging only
print (responsecode);

// return the response code
vars.put("ResponseCode", responsecode);

// last check if wwe got a 200 back if so then and only then are we
successful at updating
if(responsecode.compareTo("200")  == 0) {
    vars.put("IsSuccess", "true");   
    vars.put("ResponseMessage", "OK");
}

//always return the response code
return responsecode;


Now the code executed always returns 200 or 404, yet even when a 404 is
returned and thus IsSuccess is set to "false" and ResponseMessage is "Not
OK" and the ResponseCode is "404" the Aggregate graph still records the run
as successful, which makes monitoring it worthless, as I need to know when
it works and when it fails.

Another related question if a BeanShell script exits, why does jmeter also
exit?


Thanks,
ERIC


--
View this message in context: http://jmeter.512774.n5.nabble.com/beanshell-and-Aggregate-Graph-recording-errors-not-working-tp4384523p4384523.html
Sent from the JMeter - User mailing list archive at Nabble.com.

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


Re: beanshell and Aggregate Graph, recording errors not working

Posted by sebb <se...@gmail.com>.
On 10 May 2011 14:54, Eric Gandt <er...@fatwire.com> wrote:
> I have a beanshell that I'm running using the "BeanShell Sampler", it looks
> like:
>
> addClassPath("/storage/shared/perf.jar");
> importCommands("/");
> addClassPath(".");
> importCommands("/");
>
> // auto assume that the updfate failed, therefore if anything goes wrong and
> we exit for some reason it will have failed
> vars.put("IsSuccess", "false");
> vars.put("ResponseMessage", "NOT OK");
>
> // Article Asset creation object
> CreateArticleAsset CAA = new CreateArticleAsset("http://" + bsh.args[0] +
> ":" + bsh.args[1] + "/" + bsh.args[2]);
>
> String responsecode = CAA.editAsset(bsh.args[3]);
>
> //enable for debugging only
> print (responsecode);
>
> // return the response code
> vars.put("ResponseCode", responsecode);
>
> // last check if wwe got a 200 back if so then and only then are we
> successful at updating
> if(responsecode.compareTo("200")  == 0) {
>    vars.put("IsSuccess", "true");
>    vars.put("ResponseMessage", "OK");
> }
>
> //always return the response code
> return responsecode;
>
>
> Now the code executed always returns 200 or 404, yet even when a 404 is
> returned and thus IsSuccess is set to "false" and ResponseMessage is "Not
> OK" and the ResponseCode is "404" the Aggregate graph still records the run
> as successful, which makes monitoring it worthless, as I need to know when
> it works and when it fails.
>
> Another related question if a BeanShell script exits, why does jmeter also
> exit?

Because the script is run in the context of the JMeter code.
This is necessary to allow access to JMeter variables and methods.

>
> Thanks,
> ERIC
>
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/beanshell-and-Aggregate-Graph-recording-errors-not-working-tp4384523p4384523.html
> Sent from the JMeter - User mailing list archive at Nabble.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