-
Notifications
You must be signed in to change notification settings - Fork 2.1k
test/cli-plugins: Attempt to make TestConnectAndWait less flaky #5932
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5932 +/- ##
==========================================
- Coverage 59.33% 59.28% -0.05%
==========================================
Files 358 358
Lines 29783 29830 +47
==========================================
+ Hits 17672 17685 +13
- Misses 11142 11173 +31
- Partials 969 972 +3 🚀 New features to boost your workflow:
|
Benehiko
left a comment
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.
This test might still flake now and again. It's impossible to know exactly how the Go runtime will start/cleanup the goroutine.
go test -race -run=TestConnectAndWait/connect_goroutine_exits_after_EOF -count=10000 -failfast -v ./cli-plugins/socket/...
...
=== RUN TestConnectAndWait/connect_goroutine_exits_after_EOF
socket_test.go:192: timeout hit after 500ms: waiting for connect goroutine to spawn
--- FAIL: TestConnectAndWait (0.50s)
--- FAIL: TestConnectAndWait/connect_goroutine_exits_after_EOF (0.50s)
FAIL
FAIL github.com/docker/cli/cli-plugins/socket 7.490s
FAIL88fbbcc to
36a6b7e
Compare
36a6b7e to
413bb2b
Compare
|
Hmm right, I think we can still make it a little bit stable by locking the test goroutine to its own thread. $ go test -run=TestConnectAndWait/connect_goroutine_exits_after_EOF -count=1000000 ./cli-plugins/socket/...
--- FAIL: TestConnectAndWait (0.50s)
--- FAIL: TestConnectAndWait/connect_goroutine_exits_after_EOF (0.50s)
socket_test.go:196: timeout hit after 500ms: waiting for connect goroutine to spawn
--- FAIL: TestConnectAndWait (0.51s)
--- FAIL: TestConnectAndWait/connect_goroutine_exits_after_EOF (0.51s)
socket_test.go:196: timeout hit after 500ms: waiting for connect goroutine to spawn
FAIL
FAIL github.com/docker/cli/cli-plugins/socket 461.944s
FAIL2 flakes per million runs still seems much better, while still keeping the test. |
cli-plugins/socket/socket_test.go
Outdated
| // relying on goroutine numbers to ensure correct behaviour | ||
| t.Run("connect goroutine exits after EOF", func(t *testing.T) { | ||
| runtime.LockOSThread() | ||
| defer runtime.LockOSThread() |
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'm guessing this was meant to be
| defer runtime.LockOSThread() | |
| defer runtime.UnlockOSThread() |
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.
Doh!
- Add runtime.Gosched() calls to encourage goroutine scheduling - Increase the timeout from 10ms to 500ms - Use poll.WaitOn with appropriate delays to ensure the goroutine has spawned before checking - Lock the test goroutines to its own thread Signed-off-by: Paweł Gronowski <[email protected]>
413bb2b to
0ce8989
Compare
|
With |
thaJeztah
left a comment
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.
nice!
LGTM
spawned before checking
- How to verify it
Signed-off-by: Paweł Gronowski [email protected]