Skip to content

Commit 94c44a7

Browse files
committed
RUBY-1279 Call #flush directly in test on periodic executor instead of sleeping
1 parent 9a0c3cd commit 94c44a7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

spec/mongo/cursor_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,15 @@
239239
(1..3).map{ |i| { field: "test#{i}" }}
240240
end
241241

242+
let(:cluster) do
243+
authorized_client.cluster
244+
end
245+
242246
before do
243247
authorized_collection.insert_many(documents)
244-
cursor_reaper.schedule_kill_cursor(cursor.id,
245-
cursor.send(:kill_cursors_op_spec),
246-
cursor.instance_variable_get(:@server))
248+
cluster.schedule_kill_cursor(cursor.id,
249+
cursor.send(:kill_cursors_op_spec),
250+
cursor.instance_variable_get(:@server))
247251
end
248252

249253
after do
@@ -263,12 +267,8 @@
263267
view.instance_variable_get(:@cursor)
264268
end
265269

266-
let(:cursor_reaper) do
267-
authorized_client.cluster.instance_variable_get(:@cursor_reaper)
268-
end
269-
270-
it 'schedules a kill cursors op', unless: sessions_enabled? do
271-
sleep(Mongo::Cluster::PeriodicExecutor::FREQUENCY)
270+
it 'schedules a kill cursors op' do
271+
cluster.instance_variable_get(:@periodic_executor).flush
272272
expect {
273273
cursor.to_a
274274
}.to raise_exception(Mongo::Error::OperationFailure)
@@ -277,7 +277,7 @@
277277
context 'when the cursor is unregistered before the kill cursors operations are executed' do
278278

279279
it 'does not send a kill cursors operation for the unregistered cursor' do
280-
cursor_reaper.unregister_cursor(cursor.id)
280+
cluster.unregister_cursor(cursor.id)
281281
expect(cursor.to_a.size).to eq(documents.size)
282282
end
283283
end

0 commit comments

Comments
 (0)