jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nigel Donaldson <ndonald...@aconex.com>
Subject BeanShell PreProcessor doesn't seem to work as I expect
Date Tue, 29 Jul 2014 03:06:44 GMT
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 


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