-
Notifications
You must be signed in to change notification settings - Fork 6.5k
fix(test): race condition in kubectl metrics (#23382) #23383
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
Signed-off-by: Michael Crenshaw <[email protected]>
❌ Preview Environment deleted from BunnyshellAvailable commands (reply to this comment):
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #23383 +/- ##
==========================================
- Coverage 60.00% 59.89% -0.12%
==========================================
Files 342 342
Lines 58619 58605 -14
==========================================
- Hits 35176 35102 -74
- Misses 20598 20644 +46
- Partials 2845 2859 +14 ☔ View full report in Codecov by Sentry. |
…oj#23383) Signed-off-by: Michael Crenshaw <[email protected]> Signed-off-by: dsuhinin <[email protected]>
…oj#23383) Signed-off-by: Michael Crenshaw <[email protected]> Signed-off-by: Jonathan Ogilvie <[email protected]>
…oj#23383) Signed-off-by: Michael Crenshaw <[email protected]> Signed-off-by: enneitex <[email protected]>
…oj#23383) Signed-off-by: Michael Crenshaw <[email protected]>
Signed-off-by: Michael Crenshaw <[email protected]> Co-authored-by: Michael Crenshaw <[email protected]>
| func Test_RegisterWithClientGo_race(_ *testing.T) { | ||
| // This test ensures that the RegisterWithClientGo function can be called concurrently without causing a data race. | ||
| go RegisterWithClientGo() | ||
| go RegisterWithClientGo() |
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.
As the test doesn't have any assertion, the 2 goroutines will be terminated as soon as it triggers the second one. Maybe we should somehow add an assertion to make sure both goroutines are executed to the end.
My initial implementation was overly complicated, because I thought I needed a
initiatorfield on the metrics struct.Instead, I can just deal directly with global variables.
This test refactors for simplicity and protects the global var initialization with a sync.Once.
Closes #23382