commercetest / pepper-box

Pepper-Box is kafka load generator plugin for jmeter. It produces kafka messages of type plain text (JSON, XML, CSV or any other custom format) as well as java serialized objects.
http://pepperbox.gslab.com/
Apache License 2.0
2 stars 3 forks source link

Can we usefully validate key parameters and abort the test if they're wrong or gone? #8

Closed julianharty closed 6 years ago

julianharty commented 6 years ago

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 in jmeter.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.

julianharty commented 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)

julianharty commented 6 years ago

A useful snippet:

...
IsSuccess=false;
SampleResult.setStopTestNow(true);

https://www.blazemeter.com/blog/queen-jmeters-built-componentshow-use-beanshell

julianharty commented 6 years ago

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.

julianharty commented 6 years ago

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.