Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #134 from nelhage/test-secondary-getmore

Add a failing test case around cursors and secondary reads.
  • Loading branch information...
commit 04da941da960344ad9437ff37bc966053f4f4ddf 2 parents 0bc7df8 + d5e8222
@brandonblack brandonblack authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 test/replica_set/query_test.rb
View
21 test/replica_set/query_test.rb
@@ -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 }
Please sign in to comment.
Something went wrong with that request. Please try again.