File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 143143 end
144144 end
145145 end
146+
147+ context 'when a non-exhausted cursor goes out of scope' do
148+
149+ let ( :docs ) do
150+ 103 . times . collect { |i | { a : i } }
151+ end
152+
153+ let ( :periodic_executor ) do
154+ cluster . instance_variable_get ( :@periodic_executor )
155+ end
156+
157+ let ( :cluster ) do
158+ authorized_client . cluster
159+ end
160+
161+ let ( :cursor ) do
162+ view = authorized_collection . find
163+ view . to_enum . next
164+ cursor = view . instance_variable_get ( :@cursor )
165+ end
166+
167+ around do |example |
168+ authorized_collection . insert_many ( docs )
169+ periodic_executor . stop!
170+ cluster . schedule_kill_cursor ( cursor . id , cursor . send ( :kill_cursors_op_spec ) ,
171+ cursor . instance_variable_get ( :@server ) )
172+ periodic_executor . flush
173+ example . run
174+ periodic_executor . run!
175+ end
176+
177+ it 'schedules the kill cursor op' do
178+ expect {
179+ cursor . to_a
180+ } . to raise_exception ( Mongo ::Error ::OperationFailure )
181+ end
182+ end
146183end
You can’t perform that action at this time.
0 commit comments