-
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
Fix/1443 remove js runtime from threshold calculation #2400
Fix/1443 remove js runtime from threshold calculation #2400
Conversation
…_the_js_runtime_from_threshold_calcultations"" This reverts commit 22a0db3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from:
- the one thing that leads to nil pointer exceptions that I did actually fix in my patch
- the tests not calling
Parse
-which probably would've caught1
I think this okay 👍
985d033
to
49cb3d9
Compare
4190426
to
7fe6d03
Compare
This commit ensures that thresholds parsing is a separate step, done only when the `--no-threshold` flag is not set. Note that this commit deactivates tests that assumed `Thresholds.UnmarshalJSON` to effectively parse the thresholds.
7fe6d03
to
69a2169
Compare
// If parsing the threshold expressions failed, consider it as an | ||
// invalid configuration error. | ||
if !runtimeOptions.NoThresholds.Bool { | ||
for _, thresholds := range conf.Options.Thresholds { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we move this loop to the conf.options.ValidateTreshholds
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is probably a small enough change to be done, but given that we are trying to get it merged before the release - I vote for leaving this for the next PR in the next release that will either way add a bunch of Validation.
} | ||
|
||
// Otherwise, attempt to parse a percentile expression | ||
if strings.HasPrefix(input, tokenPercentile+"(") && strings.HasSuffix(input, ")") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we change the logical condition to, we can benefit from the early return with the error that strictly follows from the check, like:
if !strings.HasPrefix(input, tokenPercentile+"(") || !strings.HasSuffix(input, ")") {
return "", null.Float{}, fmt.Errorf("failed parsing method from expression")
}
And this change also reduces the nesting of the ifs, which improves readability.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - I am going to make some more manual tests but hopefully we don't need to change anything to get this in v0.37.0 and make other non necessary fixes for v0.38.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, keeping my comments for the following PRs 👍
Thanks everyone, for your input 🎉 |
This Pull Request does the following:
--no-thresholds
option of therun
commandThresholds.Parse
method. Calls it as part of therun
commandthresholds_test.go
which assumedUnmarshalJSON
would parse thresholdsThis PR acts as a tentative to address the minimum scope necessary to merge Thresholds parsing safely to master. It will need to lead to further refactors and improvements both in k6 itself, and in our internal infrastructure.
Reviewers can safely ignore the merge commit, as it was already approved in #2251. Reviewers should focus on the last commit only.