-
Notifications
You must be signed in to change notification settings - Fork 896
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
Conversation
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 { |
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.
I don't love this, but I couldn't think of a better way to do this.
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.
I can't think of one either.
Ping @craiggwilson to see if you have any clever ideas.
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.
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.
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.
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.
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.
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) |
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.
Added SetConnectTimeout
and SetSocketTimeout
because this test was taking 40 seconds to do the initial heartbeat as it's connecting to an invalid host.
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.
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 { |
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.
This check is here because we don't allow specifying topology, server, or connection options if the Deployment
option is set.
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, 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 { |
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.
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) |
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.
Ack
GODRIVER-1256