-
Notifications
You must be signed in to change notification settings - Fork 891
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
GODRIVER-2876 Automatically clean up mtest resources. #1347
GODRIVER-2876 Automatically clean up mtest resources. #1347
Conversation
931e97d
to
107b807
Compare
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!
mongo/integration/mtest/mongotest.go
Outdated
// Deprecated: Close is now called automatically by [testing.T.Cleanup] at the | ||
// end of a test, so it does not need to be called explicitly. It is safe to | ||
// call multiple times. | ||
func (t *T) Close() { |
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.
Do we still need to expose the Close()
?
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.
No, there is now no use case for calling it. I waffled on un-exporting vs deprecating Close
because we know there are external users of mtest
who would probably be impacted by us un-exporting it. However, mtest
is documented as unstable so we should be able to change it.
I will un-export it.
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.
👍
GODRIVER-2876
Summary
Automatically clean up
mtest
resources by using T.Cleanup.Background & Motivation
Currently all tests must run
defer mt.Close
after callingmtest.New
to make suremtest
cleans up all of the server-side resources it created to run the test. That pattern is error-prone, possibly leading to tests that don't clean up server-side resources.Instead, we should make the cleanup process automatic by using T.Cleanup and deprecate
mt.Close
.