-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve threshold parsing and errors #961
Comments
For the new threshold parsing code, we might consider this library: https://github.com/PaesslerAG/gval I saw it when researching the jsonpath libraries @robingustafsson mentioned in #992, the second one is based on it. |
We stumbled on a k6 demo presentation and spotted a somewhat connected issue, using Ideally, this should have resulted in a configuration error before the script even started, since combining these things doesn't make sense. Unfortunately, because of the current laizes-faire threshold implementation, the script ran successfully 😞 . In the demo they quickly noticed that there was an issue, since they were expecting an error. But in a real test setup, a k6 user might set up a threshold slightly incorrectly like that, and then run their script in a CI with the potentially false assurance that their system performs below the specified thresholds... Thanks, @cajames, for your very good demo! I guess us using it as a mini case study probably wasn't its original purpose, but it was very useful for us nonetheless 😅 Feel free to ping us here or on Slack if you have seen any other bugs or if you have suggestions for improving k6 in any way! |
Hey @na--, thanks for watching!
Yep, I had chalked it up to me passing the wrong configuration, but if k6 did throw an error on startup in the case of threshold misconfiguration, that'd be a great dev experience!
Happy it could be a helpful case study. :)
And will do! Thanks. Really like what you guys have created! |
#1832 (or something like it) is a prerequisite for the current issue. |
Not sure if this is the right place to mention this, but currently thresholds defined for specific scenarios are not triggered. See this forum post. This doesn't seem to require the overhaul of #1832, so should I create a new issue for it? |
This is not "true". VUs and VUsMax are being emitted completely independently of scenarios or anything else: But it will be nice if VUs and VUsMax were actually emitted by the executors and were tagged accordingly. I think we discussed this around #1007 , I don't know if there is an issue |
Yeah, we discussed something like that, but never got around to implementing it, since it would have delayed #1007 even more, and since it would have been a minor breaking change. I can see a benefit of emitting |
The scope of the initial definition is now covered in export let options = {
thresholds: {
"http_req_duration": [
// this never fails...
"avg=123",
// this only emits a warnings every second
"throw new Error('wat')",
// this is never reached... but if it was, it will only emit a warning as well
"test>=500",
],
},
}; Would result in k6 failing before start with
|
Currently, threshold calculations are actually executed in mini JavaScript runtimes: https://github.com/loadimpact/k6/blob/master/stats/thresholds.go
That's hard to beat for flexibility, but in the long term, we probably should transition to a simple DSL that's easy to parse and verify. It will likely be needed for things like the distributed execution anyway, but it will definitely be useful for reducing user errors and confusion. For example, here are some thresholds that are wrong, but won't actually abort the k6 execution:
As a short-term fix, we likely should make the thresholds stop the script when there are errors. And it's worth investigating if we can make the values we set in the VM consts, so using
=
instead of==
produce an error.The text was updated successfully, but these errors were encountered: