Beanshell pre-processor problems
I'm using a Beanshell pre-processor for the first time and having some issues. Any help would be welcome.
I'm using the preprocessor to read the current state of two JMeter variables, then using those to generate a random number via Java, and then assign that random number back to a third JMeter variable. This seems to work fine.
Next I have a while controller that is gated by the value of the JMeter variable set by the pre-processor, (e.g. While "loop" > 0). In the loop I use an http sampler to query a page, then a Beanshell post-processor to decrement the "loop" variable. Seems pretty straightforward--and the decrementing is working fine in other parts of the test plan.
However, the while loop is always running longer than it should based on the value set by the pre-processor. When I insert Debug samplers at various places, I see the that the "loop" variable is changing all the time--even though the pre-processor is only accessed once. The initial assignment of "loop" might be 18, and if anything, it should only decrease by 1 each pass through. When I check "loop" variable at different points in a loop, its value is changing, 18 might become 25. At the extreme, I can check the variable value via a debug sampler and see the value is X, execute a http sampler that doesn't reference the variable at all, and immediately do another debug sample and see the value changed.
Re: Beanshell pre-processor problems
As far as i understand the plan you have implemented, it seems the Beanshell pre-processor is getting executed every time the loop executes. This is changing the value everytime.
I would suggest placing this Beanshell pre-processor under a Once Only Logic Controller, which would be executed in the first iteration, only. Hopefully, then your post-processor will reduce the value of the variable generated in the first iteartion, and may solve your problem.
Let us know, if it works.
Thanks & Regards