-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
connect/proxy: fix a few problems with tests #10146
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These tests run in under 10ms, t.Parallel provides no value and makes debuging failures more difficult.
github-actions
bot
added
theme/connect
Anything related to Consul Connect, Service Mesh, Side Car Proxies
and removed
theme/testing
Testing, and related enhancements
labels
Apr 28, 2021
dnephin
added
the
pr/no-changelog
PR does not need a corresponding .changelog entry
label
Apr 28, 2021
rboyer
reviewed
Apr 28, 2021
We noticed that TestUpstreamListener would deadlock sometimes when run with the race detector. While debugging this issue I found and fixed the following problems. 1. the net.Listener was not being closed properly when Listener.Stop was called. This caused the Listener.Serve goroutine to run forever. Fixed by storing a reference to net.Listener and closing it properly when Listener.Stop is called. 2. call connWG.Add in the correct place. WaitGroup.Add must be called before starting a goroutine, not from inside the goroutine. 3. Set metrics config EnableRuntimeMetrics to `false` so that we don't start a background goroutine in each test for no reason. There is no way to shutdown this goroutine, and it was an added distraction while debugging these timeouts. 5. two tests were calling require.NoError from a goroutine. require.NoError calls t.FailNow, which MUST be called from the main test goroutine. Instead use t.Errorf, which can be called from other goroutines and will still fail the test. 6. `assertCurrentGaugeValue` wass breaking out of a for loop, which would cause the `RWMutex.RUnlock` to be missed. Fixed by calling unlock before `break`. The core issue of a deadlock was fixed by hashicorp/go-metrics#124.
dnephin
force-pushed
the
dnephin/connect-proxy-test-deadlock
branch
from
April 28, 2021 21:22
d8b7c75
to
d18a03b
Compare
rboyer
approved these changes
Apr 28, 2021
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
🍒 If backport labels were added before merging, cherry-picking will start automatically. To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/358670. |
mikemorris
pushed a commit
that referenced
this pull request
May 5, 2021
…eadlock connect/proxy: fix a few problems with tests
mikemorris
pushed a commit
that referenced
this pull request
May 5, 2021
…eadlock connect/proxy: fix a few problems with tests
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
pr/no-changelog
PR does not need a corresponding .changelog entry
theme/connect
Anything related to Consul Connect, Service Mesh, Side Car Proxies
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We noticed that
TestUpstreamListener
would deadlock sometimes when runwith the race detector (example). While debugging this issue I found and fixed the
following problems.
called. This caused the Listener.Serve goroutine to run forever.
Fixed by storing a reference to net.Listener and closing it properly
when Listener.Stop is called.
before starting a goroutine, not from inside the goroutine.
false
so that we don'tstart a background goroutine in each test for no reason. There is no
way to shutdown this goroutine, and it was an added distraction while
debugging these timeouts.
require.NoError calls t.FailNow, which MUST be called from the main
test goroutine. Instead use t.Errorf, which can be called from other
goroutines and will still fail the test.
assertCurrentGaugeValue
was breaking out of a for loop, whichwould cause the
RWMutex.RUnlock
to be missed. Fixed by callingunlock before
break
.The core issue of a deadlock was fixed by hashicorp/go-metrics#124. If that merges soon I will include the vendor update in this PR.