gotestsum: Passing tests reported as failures in summary
We are using gotestsum
to run our testing for Knative, and digging into some recent “failures”, I can’t really make sense of why gotestsum
is reporting them as failed.
The failure log I have been digging through can be downloaded from here, the file you want is “build-log.txt” (it is large).
In this test run I see the following summary:
=== Skipped
=== SKIP: test/e2e TestProbeWhitelist (0.00s)
probe_whitelist_test.go:38: RequestAuthentication dropped the regex support. We need to rewrite this test. See https://github.com/istio/istio/issues/16585
=== Failed
=== FAIL: test/conformance/api/v1alpha1 TestContainerExitingMsg/http (unknown)
=== FAIL: test/conformance/api/v1alpha1 TestContainerExitingMsg/tcp (unknown)
However, if I scan back through the test logs, I see that all of the flavors of TestContainerExitingMsg
have passed, here’s one cluster:
--- PASS: TestContainerExitingMsg (0.00s)
--- PASS: TestContainerExitingMsg/http (40.29s)
--- PASS: TestContainerExitingMsg/tcp (172.49s)
I’ve been trying to make sense of the pieces of information here, but basically all I’ve managed so far is that (unknown)
seems to tell us that the elapsed time is unknown, which seems to point to a TestCase terminated by the end()
method here.
Any pointers would be appreciated. 🙏
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 20 (7 by maintainers)
I got a similar issue, here is the info
--- PASS
is not in a new linewhen change the ouput line in test case from
fmt.Printf("%s", "OK")
tofmt.Printf("%s\n", "OK")
everything is fine
so maybe gotestsum can handle this situation.
In my case, I managed to fix the passing-tests-but-reported-as-failed issue after adding a newline to stdin buffer read:
as otherwise output was “corrupted”.
Before:
After:
I’ve worked with some projects that have a similar problem with logs and output. If you aren’t running tests in parallel you can set the global logger to write to a buffer, and only print logs from the buffer when a test ends (or when a test fails). Then reset the logger back to the default afterward.
Another options would be to always set the log output to
ioutil.Discard
, although that might make test failures harder to debug. I’m not sure if setting the output toos.Stderr
would help, or if that has the same problem.It would be nice if the go toolchain changed how the test binaries write framing events. If they were sent to a file or pipe then stdout/stderr would not mess with the tests results.
Perfect! Here’s what I’m seeing:
For some reason,
test2json
hasOutput
events for the tests passing, but it never sent anAction: pass
event for those 2 sub tests in theknative.dev/serving/test/conformance/api/v1
package.From what I can tell, this is a new
test2json
bug that I haven’t seen before. Maybe related to parallel test. If it is not happening on every run, it may have to do with the ordering of the tests. I haven’t looked at the golang issue tracker to see if this issue has been reported already.