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

RUBY-558 batch size on initial query, RUBY-505 test intervening refresh #163

Closed
wants to merge 4 commits into from
Closed

RUBY-558 batch size on initial query, RUBY-505 test intervening refresh #163

wants to merge 4 commits into from

Conversation

estolfo
Copy link
Contributor

@estolfo estolfo commented Feb 21, 2013

Change to cursor.rb and tests for applying specified batch size to initial query. Get mores have always applied batch size. RUBY-558

Test on cursors iterating with an intervening query that causes a connection refresh in a replica set. RUBY-505 and RUBY-545.

@estolfo
Copy link
Contributor Author

estolfo commented Feb 21, 2013

Yes, it is confirmed that batch size should be applied to the first batch.

@TylerBrock
Copy link
Contributor

What does everyone think about instance_variable_get in a test? I think we should make @pool accesible via an attr_reader.

@gjmurakami-10gen
Copy link
Contributor

I think that instance_variable_get is fine in tests. Making @pool
attr_reader is also fine if you feel a need for public access, but if it's
only for tests, I'd say not as private allows us to change internals
without concern for user expectations.

On Fri, Feb 22, 2013 at 8:10 AM, Tyler Brock notifications@github.comwrote:

What does everyone think about instance_variable_get in a test? I think we
should make @pool https://github.com/pool accesible via an attr_reader.


Reply to this email directly or view it on GitHubhttps://github.com//pull/163#issuecomment-13942432.

{ name : "Gary J. Murakami, Ph.D.",
title : "Lead Engineer and Ruby Evangelist",
company : "10gen (the MongoDB company)",
location : "New York, NY",
email : "gary.murakami@10gen.com",
mobile : "1-908-787-6621",
im : "gjmurakami (AIM)",
twitter : "@GaryMurakami",
blog : "grayghostwriter.blogspot.com",
website : "www.nobell.org",
linkedin : "www.linkedin.com/pub/gary-murakami/1/36a/327" }

@estolfo
Copy link
Contributor Author

estolfo commented Feb 22, 2013

I don't see a problem with using instance_variable_get in a test because it's used to inspect functionality and verify state. It doesn't seem that using it frequently in a test should determine whether a particular variable should be available publicly as providing public access is motivated by an entirely different need.

@estolfo
Copy link
Contributor Author

estolfo commented Feb 22, 2013

This intervening query test is going to only pass when we're lucky and get the same secondary after doing a hard_refresh. I'm going to make a comment to note this but the test can serve as a useful reference point when working on a new connection pool design.

@TylerBrock
Copy link
Contributor

@estolfo we don't want tests that are more brittle than what we already have. Part of that is not testing private interfaces (I also think pool should be part of the public interface).

Regarding hard_refresh... why not just refresh? If for some reason a hard_refresh! is required I wouldn't expect this to work, the member you were querying may have disappeared from the set entirely!

@estolfo
Copy link
Contributor Author

estolfo commented Feb 22, 2013

I used hard_refresh in the test because refresh wouldn't actually do anything as it depends on @refresh_required being true. @refresh_required wouldn't be true in the test. Do you think it would be better to set @refresh_required to true and then do just refresh?
How else do you suggest we check internals if not using instance_variable_get? I think this is very appropriate for a test, as we are supposed to be checking internals.
I'm fine with making pool part of the public interface, but that can be part of a pool_manager overhaul and I don't think it should be done just so that it's available for a test.

@gjmurakami-10gen
Copy link
Contributor

Tyler, I think that it is acceptable to test private interfaces and
internals. The tests are for the benefit of the programmer implementers,
and IMHO whatever is clear or even convenient is good to me.

On Fri, Feb 22, 2013 at 1:11 PM, Tyler Brock notifications@github.comwrote:

@estolfo https://github.com/estolfo we don't want tests that are more
brittle than what we already have. Part of that is not testing private
interfaces (I also think pool should be part of the public interface).

Regarding hard_refresh... why not just refresh? If for some reason a
hard_refresh! is required I wouldn't expect this to work, the member you
were querying may have disappeared from the set entirely!


Reply to this email directly or view it on GitHubhttps://github.com//pull/163#issuecomment-13960120.

{ name : "Gary J. Murakami, Ph.D.",
title : "Lead Engineer and Ruby Evangelist",
company : "10gen (the MongoDB company)",
location : "New York, NY",
email : "gary.murakami@10gen.com",
mobile : "1-908-787-6621",
im : "gjmurakami (AIM)",
twitter : "@GaryMurakami",
blog : "grayghostwriter.blogspot.com",
website : "www.nobell.org",
linkedin : "www.linkedin.com/pub/gary-murakami/1/36a/327" }

@TylerBrock
Copy link
Contributor

Its fine, we just added it a day ago to the driver, it didn't exist in 1.8.2 so we wouldn't change expectations for anyone and I think there may be external benefit to determining what pool a socket came from. That being said, I'm ok with not making that public if everyone dislikes that, keep it as is if you would like. Gary is correct in saying this is acceptable even if in this particular case I disagree.

However, hard_refresh! here is definitely incorrect and you should use a mock to make refresh_required true to test regular refresh.

There is only one scenario under which I would say committing an intermittently failing test is acceptable and that is with a fix for it. In this case, the test is incorrect I don't expect that to pass ever after a hard_refresh! and tracking this down at a later time will become a nightmare.

@brndnblck
Copy link
Contributor

I don't think it makes sense to make an attr_reader for @pool just for the test. However, if adding that to the public interface makes sense (I'm unclear on what purpose that would serve, not sure that it does make sense) then yes these tests should be modified.

As it stands right now, I'd say its fine to use instance_variable_get here.

@ajdavis
Copy link
Member

ajdavis commented Feb 22, 2013

FYI, the PyMongo tests check private variable values all over the place and
it's worked ok for us.

On Fri, Feb 22, 2013 at 9:54 AM, Emily notifications@github.com wrote:

I don't see a problem with using instance_variable_get in a test because
it's used to inspect functionality and verify state. It doesn't seem that
using it frequently in a test should determine whether a particular
variable should be available publicly as providing public access is
motivated by an entirely different need.


Reply to this email directly or view it on GitHubhttps://github.com//pull/163#issuecomment-13946684.

@TylerBrock
Copy link
Contributor

Ok. The test is still testing the wrong thing though...

I spoke with emily about hard_refresh! being irrelevant and untestable, she's going to stub refresh_required so that it always returns true and can use refresh.

@brndnblck
Copy link
Contributor

Looks good Emily. Ship it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants