-
Notifications
You must be signed in to change notification settings - Fork 126
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
tolerate run
without pass/failed
for benchmarks
#438
base: main
Are you sure you want to change the base?
Conversation
Something in Go 1.20 changed so that there is a `run` event for benchmarks. As before, there is no `pass` or `failed`. This triggers the "test is running and thus must have failed" logic in gotestsum, which causes it to report the benchmark as failed. As this is the behavior of Go (whether it's correct or not...), gotestsum should accept such output. To reduce the risk that genuine problems go undetected, such incomplete benchmarks get reported when a panic was detected (the original motivation for this workaround).
BenchmarkDiscardLogInfoOneArg | ||
BenchmarkDiscardLogInfoOneArg-36 12695464 91.33 ns/op | ||
|
||
DONE 1 tests, 1 failure in 0.000s |
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.
Note that the default format is not informative enough when there was a panic: that panic output is not shown.
Other formats don't have that problem:
$ go run ./ --format=standard-verbose --raw-command cat testjson/testdata/input/go-1-20-panicked-benchmark.out
goos: linux
goarch: amd64
pkg: github.com/go-logr/logr/benchmark
cpu: Intel(R) Core(TM) i9-7980XE CPU @ 2.60GHz
=== RUN BenchmarkDiscardLogInfoOneArg
BenchmarkDiscardLogInfoOneArg
BenchmarkDiscardLogInfoOneArg-36 12695464 91.33 ns/op
PASS
ok github.com/go-logr/logr/benchmark 1.265s
panic: fabricated panic
=== Failed
=== FAIL: github.com/go-logr/logr/benchmark BenchmarkDiscardLogInfoOneArg (unknown)
=== RUN BenchmarkDiscardLogInfoOneArg
BenchmarkDiscardLogInfoOneArg
BenchmarkDiscardLogInfoOneArg-36 12695464 91.33 ns/op
DONE 1 tests, 1 failure in 0.001s
This is unrelated to this PR, I just noticed because the tests use the default format.
@@ -276,6 +281,13 @@ func (p *Package) end() []TestEvent { | |||
continue | |||
} | |||
|
|||
if tc.Test.IsBenchmark() && !p.panicked { |
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.
It's debatable whether this should check for a panic. I opted for staying closer to the current behavior unless a benchmark completed successfully.
Alternatively, the exit code could also be considered - but it is not always available?
Gentle ping... this is kind of urgent because of kubernetes/kubernetes#127245. |
Thank you for the PR! And sorry for the delay. I have been thinking about this change, and I don't think it's quite right. The problem is that benchmarks don't send I think #416 is the right fix for this. The problem is that we're adding an empty event into the |
I added a comment to that issue with some other ideas about a fix. I like your suggestion of looking at the exit status to figure out if we might have failing tests with missing end events, but I'm not sure yet exactly what that could should look like. As a workaround, is it possible to run the benchmarks without |
I got odd results when I tried it - see #416 (comment).
The shell scripts which run the benchmarks don't know that they are running benchmarks 😢 It all depends on what's in the package and which parameters are passed through. The workaround while we try to figure out a solution would be to revert to what Kubernetes was doing previously: run |
@dnephin: ping? Another alternative solution would be a command line option like This might help with flakes, too. As I learned, |
That won't actually help. In contrast to what I expected, the exit code is zero already. It's the |
Something in Go 1.20 changed so that there is a
run
event for benchmarks. As before, there is nopass
orfailed
. This triggers the "test is running and thus must have failed" logic in gotestsum, which causes it to report the benchmark as failed.As this is the behavior of Go (whether it's correct or not...), gotestsum should accept such output. To reduce the risk that genuine problems go undetected, such incomplete benchmarks get reported when a panic was detected (the original motivation for this workaround).
Related-to: #413 (comment)