Closed julianharty closed 6 years ago
Here's a partial solution, which stops the current sampler from what I can tell and read.
Call
ctx.getEngine().stopTest()
See also:
I'm thinking about adding some sanity checks for various parameters as small functions. Perhaps a regex (much as I prefer not to use them as they can be confusing even to those who write them) would be succinct yet fairly comprehensive. Something to explore in an interactive Groovy environment? (e.g. in IDEA's IntelliJ)
A useful snippet:
...
IsSuccess=false;
SampleResult.setStopTestNow(true);
https://www.blazemeter.com/blog/queen-jmeters-built-componentshow-use-beanshell
https://www.blazemeter.com/blog/scripting-jmeter-assertions-in-groovy-a-tutorial provides and example of parsing JSON and generating a custom assert message based on errors.
Joe created the getParam(...)
method that checks various aspects of parameters used by the Groovy script. This method calls stopTestImmediately()
if it detects problems or the lack of mandatory settings. These changes are an improvement on what we had so I'll close this issue as we're unlikely to make other minor improvements: rework is likely to be needed to make those improvements.
There's minimal error reporting from the Java Sampler, in our case pepper-box. It uses MESSAGE which is set in
Pepper-Box PlainText Config
, for instance. When MESSAGE isn't set or available e.g. if the jmeter test doesn't have a Pepper-box ... Config then the test runs but the write to Kafka fails with a NPE. This is visible injmeter.log
but that's not shown by default.I'd like to rely more on User Defined Variables which would be shared between the Sampler and other code e.g. a JSR223 Script that consumes the data written by the producer(s) i.e. the Sampler(s). However if these aren't configured appropriately or missing then the tests will run but fail trying to interact with Zookeeper and/or Kafka.
Perhaps we could usefully find a way to notify the user that something's broken from within the Sampler code? I'm opening this enhancement issue to track this idea & hope I or perhaps you will find a good way to do so.