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

Add a failing test case around cursors and secondary reads. #134

Merged
merged 1 commit into from Nov 19, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions test/replica_set/query_test.rb
Expand Up @@ -44,6 +44,27 @@ def test_query
end
end

# Create a large collection and do a secondary query that returns
# enough records to require sending a GETMORE. In between opening
# the cursor and sending the GETMORE, do a :primary query. Confirm
# that the cursor reading from the secondary continues to talk to
# the secondary, rather than trying to read the cursor from the
# primary, where it does not exist.
def test_secondary_getmore
200.times do |i|
@coll.save({:a => i}, :safe => {:w => 3})
end
as = []
# Set an explicit batch size, in case the default ever changes.
@coll.find({}, { :batch_size => 100, :read => :secondary }) do |c|
c.each do |result|
as << result['a']
@coll.find({:a => result['a']}, :read => :primary).map
end
end
assert_equal(as.sort, 0.upto(199).to_a)
end

def benchmark_queries
t1 = Time.now
10000.times { @coll.find_one }
Expand Down