|
1186 | 1186 | it 'returns a new View' do
|
1187 | 1187 | expect(new_view).not_to be(view)
|
1188 | 1188 | end
|
| 1189 | + |
| 1190 | + context 'when sending to server' do |
| 1191 | + let(:subscriber) { Mrss::EventSubscriber.new } |
| 1192 | + |
| 1193 | + before do |
| 1194 | + authorized_collection.client.subscribe(Mongo::Monitoring::COMMAND, subscriber) |
| 1195 | + end |
| 1196 | + |
| 1197 | + let(:event) do |
| 1198 | + subscriber.single_command_started_event('find') |
| 1199 | + end |
| 1200 | + |
| 1201 | + it 'is sent to server' do |
| 1202 | + new_view.to_a |
| 1203 | + event.command.slice('noCursorTimeout').should == {'noCursorTimeout' => true} |
| 1204 | + end |
| 1205 | + end |
| 1206 | + |
| 1207 | + context 'integration test' do |
| 1208 | + require_topology :single |
| 1209 | + |
| 1210 | + # The number of open cursors with the option set to prevent timeout. |
| 1211 | + def current_no_timeout_count |
| 1212 | + root_authorized_client |
| 1213 | + .command(serverStatus: 1) |
| 1214 | + .documents |
| 1215 | + .first |
| 1216 | + .fetch('metrics') |
| 1217 | + .fetch('cursor') |
| 1218 | + .fetch('open') |
| 1219 | + .fetch('noTimeout') |
| 1220 | + end |
| 1221 | + |
| 1222 | + it 'is applied on the server' do |
| 1223 | + # Initialize collection with two documents. |
| 1224 | + new_view.collection.insert_many([{}, {}]) |
| 1225 | + |
| 1226 | + expect(new_view.count).to be == 2 |
| 1227 | + |
| 1228 | + # Initial "noTimeout" count should be zero. |
| 1229 | + states = [current_no_timeout_count] |
| 1230 | + |
| 1231 | + # The "noTimeout" count should be one while iterating. |
| 1232 | + new_view.batch_size(1).each { states << current_no_timeout_count } |
| 1233 | + |
| 1234 | + # Final "noTimeout" count should be back to zero. |
| 1235 | + states << current_no_timeout_count |
| 1236 | + |
| 1237 | + # This succeeds on: |
| 1238 | + # commit aab776ebdfb15ddb9765039f7300e15796de0c5c |
| 1239 | + # |
| 1240 | + # This starts failing with [0, 0, 0, 0] from: |
| 1241 | + # commit 2d9f0217ec904a1952a1ada2136502eefbca562e |
| 1242 | + expect(states).to be == [0, 1, 1, 0] |
| 1243 | + end |
| 1244 | + end |
1189 | 1245 | end
|
1190 | 1246 |
|
1191 | 1247 | describe '#projection' do
|
|
0 commit comments