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

Assert that tests close all opened sessions and connections. #196

Merged
merged 3 commits into from
Oct 18, 2019

Conversation

divjotarora
Copy link
Contributor

@divjotarora divjotarora requested review from iwysiu and jyemin October 11, 2019 13:53
mongo/client.go Outdated

// SessionsCheckedOut returns the number of sessions checked out from the client's session pool.
// This method is deprecated and does not have any stability guarantees. It may be removed in the future.
func (c *Client) SessionsCheckedOut() int {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't love this, but I couldn't think of a better way to do this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't think of one either.

Ping @craiggwilson to see if you have any clever ideas.

Copy link
Collaborator

Choose a reason for hiding this comment

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

not really... I don't mind having this here. An alternative would be to add an additional client option (during construction) that takes in a variable location with which to keep track of this information or a callback or something, but that's a whole other ball of wax.

Is this just another name for in progress sessions? If so, I'd probably name it something more akin to that and not even mark it as "deprecated." Just make it something users can check if they want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair. We generally use the deprecated/unstable warnings for functions that expose something in the x package, which this doesn't. I'll remove the deprecation comment in a new commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about ActiveSessions or NumActiveSessions?

#bikeshed

invalidClientOpts := options.Client().SetServerSelectionTimeout(100 * time.Millisecond).SetHosts([]string{"invalid:123"})
invalidClientOpts := options.Client().
SetServerSelectionTimeout(100 * time.Millisecond).SetHosts([]string{"invalid:123"}).
SetConnectTimeout(500 * time.Millisecond).SetSocketTimeout(500 * time.Millisecond)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added SetConnectTimeout and SetSocketTimeout because this test was taking 40 seconds to do the initial heartbeat as it's connecting to an invalid host.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ack

@@ -497,6 +505,19 @@ func (t *T) createTestClient() {
t.failed = append(t.failed, cfe)
},
})
// only specify connection pool monitor if no deployment is given
if clientOpts.Deployment == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check is here because we don't allow specifying topology, server, or connection options if the Deployment option is set.

Copy link
Contributor

@jyemin jyemin left a comment

Choose a reason for hiding this comment

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

LGTM, but let's wait to see if Craig has any thoughts on SessionsCheckedOut.

mongo/client.go Outdated

// SessionsCheckedOut returns the number of sessions checked out from the client's session pool.
// This method is deprecated and does not have any stability guarantees. It may be removed in the future.
func (c *Client) SessionsCheckedOut() int {
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't think of one either.

Ping @craiggwilson to see if you have any clever ideas.

invalidClientOpts := options.Client().SetServerSelectionTimeout(100 * time.Millisecond).SetHosts([]string{"invalid:123"})
invalidClientOpts := options.Client().
SetServerSelectionTimeout(100 * time.Millisecond).SetHosts([]string{"invalid:123"}).
SetConnectTimeout(500 * time.Millisecond).SetSocketTimeout(500 * time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ack

@divjotarora divjotarora merged commit 8cade26 into mongodb:master Oct 18, 2019
@divjotarora divjotarora deleted the godriver1256 branch October 18, 2019 19:15
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.

4 participants