-
-
Notifications
You must be signed in to change notification settings - Fork 300
Description
Problem
While debugging a test which uses Eventually and Consistently, I want to know what the test is currently doing. With Kubernetes, I might run "kubectl" in parallel to the running test check some additional things. I run ginkgo -v -focus=<the test>.
Option 1
Manually add log output before each Eventually and Consistently:
By("Waiting for foo")
Eventually(...)
Downsides:
- writing tests is more work
- not very informative (for example, no information how long it's going to wait)
- noisy because the log output is printed also for checks that usually pass quickly after polling once
Option 2
Use --progress-poll-interval=<some low value>.
Downsides:
- very noisy: detailed reports get printed frequently
Option 3
Run under a debugger.
Downsides:
- lot of work
- hard to find relevant information (backtrace, print internals of Gomega)
Proposal
The first time that polling fails in Eventually (whether it's due to an error or the matcher), some message could be logged about it:
Eventually(..).Timeout(10 * time.Second).Should(Be..., "pod should be running")
=>
Waiting 10s to reach expected state "pod should be running". First check did not succeed:
<first few (5?) lines>
Let's keep the tone neutral. This is not an error or failure, therefore "did not succeed" instead of "failed". The practical difference is that the test log viewer in Kubernetes might match the "failed" and emphasize it unnecessarily.
Let's not dump too much of the usual failure. That could be very long. It might also work to not dump the check result when there is a description and only fall back to that when there isn't.
With Consistently it's simpler, as long as Should has an additional description:
Eventually(..).Timeout(10 * time.Second).Should(Be..., "pod should keep running")
=>
Waiting 10s to ensure that state "pod should keep running" remains as expected.
Without description it's less informative because there is no information from the matcher.