Skip to content
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

Merged
merged 2 commits into from
Aug 14, 2023

Conversation

matthewdale
Copy link
Collaborator

@matthewdale matthewdale commented Aug 4, 2023

GODRIVER-2876

Summary

Automatically clean up mtest resources by using T.Cleanup.

Background & Motivation

Currently all tests must run defer mt.Close after calling mtest.New to make sure mtest 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.

@matthewdale matthewdale marked this pull request as ready for review August 8, 2023 16:40
@matthewdale matthewdale requested a review from a team as a code owner August 8, 2023 16:40
@matthewdale matthewdale requested review from qingyang-hu and blink1073 and removed request for a team August 8, 2023 16:40
Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines 190 to 193
// 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() {
Copy link
Collaborator

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()?

Copy link
Collaborator Author

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.

Copy link
Collaborator

@qingyang-hu qingyang-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@matthewdale matthewdale merged commit 6a788f9 into mongodb:master Aug 14, 2023
1 check failed
@b1ron b1ron mentioned this pull request Aug 28, 2023
Clement-Jean added a commit to Clement-Jean/grpc-go-course that referenced this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants