@@ -51,16 +51,16 @@ def setup_client(read=:primary)
51
51
@db = @client . db ( MONGO_TEST_DB )
52
52
@db . drop_collection ( "cursor_tests" )
53
53
@coll = @db . collection ( "cursor_tests" )
54
+ insert_docs
54
55
55
56
# Setup Direct Connections
56
57
@primary = Mongo ::MongoClient . new ( *@client . manager . primary )
57
58
end
58
59
59
60
def insert_docs
60
61
@n_docs = 102 # batch size is 101
61
- @object_id = BSON ::ObjectId . new
62
62
@n_docs . times do |i |
63
- @coll . insert ( { "x" => @object_id } , :w => 3 )
63
+ @coll . insert ( { "x" => i } , :w => 3 )
64
64
end
65
65
end
66
66
@@ -84,6 +84,8 @@ def set_read_client_and_tag(read)
84
84
def route_query ( read )
85
85
read_opts = { :read => read }
86
86
read_opts [ :tag_sets ] = [ { :node => @tag } ] unless read == :primary
87
+ object_id = BSON ::ObjectId . new
88
+ read_opts [ :comment ] = object_id
87
89
88
90
# set profiling level to 2 on client and member to which the query will be routed
89
91
@client . db ( MONGO_TEST_DB ) . profiling_level = :all
@@ -92,7 +94,7 @@ def route_query(read)
92
94
node . db ( MONGO_TEST_DB ) . profiling_level = :all
93
95
end
94
96
95
- @cursor = @coll . find ( { "x" => @object_id } , read_opts )
97
+ @cursor = @coll . find ( { } , read_opts )
96
98
@cursor . next
97
99
98
100
# on client and other members set profiling level to 0
@@ -103,7 +105,7 @@ def route_query(read)
103
105
end
104
106
# do a query on system.profile of the reader to see if it was used for the query
105
107
profiled_queries = @read . db ( MONGO_TEST_DB ) . collection ( 'system.profile' ) . find ( {
106
- 'ns' => "#{ MONGO_TEST_DB } .cursor_tests" , "query.x " => @ object_id } )
108
+ 'ns' => "#{ MONGO_TEST_DB } .cursor_tests" , "query.$comment " => object_id } )
107
109
108
110
assert_equal 1 , profiled_queries . count
109
111
end
@@ -113,7 +115,6 @@ def route_query(read)
113
115
def cursor_get_more_test ( read = :primary )
114
116
set_read_client_and_tag ( read )
115
117
10 . times do
116
- insert_docs
117
118
# assert that the query went to the correct member
118
119
route_query ( read )
119
120
docs_count = 1
@@ -134,7 +135,6 @@ def cursor_get_more_test(read=:primary)
134
135
def kill_cursor_test ( read = :primary )
135
136
set_read_client_and_tag ( read )
136
137
10 . times do
137
- insert_docs
138
138
# assert that the query went to the correct member
139
139
route_query ( read )
140
140
cursor_id = @cursor . cursor_id
@@ -153,7 +153,6 @@ def kill_cursor_test(read=:primary)
153
153
154
154
def assert_cursors_on_members ( read = :primary )
155
155
set_read_client_and_tag ( read )
156
- insert_docs
157
156
# assert that the query went to the correct member
158
157
route_query ( read )
159
158
cursor_id = @cursor . cursor_id
0 commit comments