|
1790 | 1790 | it 'returns a new View' do
|
1791 | 1791 | expect(new_view).not_to be(view)
|
1792 | 1792 | end
|
| 1793 | + |
| 1794 | + context 'when sending to server' do |
| 1795 | + let(:subscriber) { Mrss::EventSubscriber.new } |
| 1796 | + |
| 1797 | + before do |
| 1798 | + authorized_collection.client.subscribe(Mongo::Monitoring::COMMAND, subscriber) |
| 1799 | + end |
| 1800 | + |
| 1801 | + let(:event) do |
| 1802 | + subscriber.single_command_started_event('find') |
| 1803 | + end |
| 1804 | + |
| 1805 | + it 'is sent to server' do |
| 1806 | + new_view.to_a |
| 1807 | + event.command.slice('noCursorTimeout').should == {'noCursorTimeout' => true} |
| 1808 | + end |
| 1809 | + end |
| 1810 | + |
| 1811 | + context 'integration test' do |
| 1812 | + require_topology :single |
| 1813 | + |
| 1814 | + # The number of open cursors with the option set to prevent timeout. |
| 1815 | + def current_no_timeout_count |
| 1816 | + root_authorized_client |
| 1817 | + .command(serverStatus: 1) |
| 1818 | + .documents |
| 1819 | + .first |
| 1820 | + .fetch('metrics') |
| 1821 | + .fetch('cursor') |
| 1822 | + .fetch('open') |
| 1823 | + .fetch('noTimeout') |
| 1824 | + end |
| 1825 | + |
| 1826 | + it 'is applied on the server' do |
| 1827 | + # Initialize collection with two documents. |
| 1828 | + new_view.collection.insert_many([{}, {}]) |
| 1829 | + |
| 1830 | + expect(new_view.count).to be == 2 |
| 1831 | + |
| 1832 | + # Initial "noTimeout" count should be zero. |
| 1833 | + states = [current_no_timeout_count] |
| 1834 | + |
| 1835 | + # The "noTimeout" count should be one while iterating. |
| 1836 | + new_view.batch_size(1).each { states << current_no_timeout_count } |
| 1837 | + |
| 1838 | + # Final "noTimeout" count should be back to zero. |
| 1839 | + states << current_no_timeout_count |
| 1840 | + |
| 1841 | + # This succeeds on: |
| 1842 | + # commit aab776ebdfb15ddb9765039f7300e15796de0c5c |
| 1843 | + # |
| 1844 | + # This starts failing with [0, 0, 0, 0] from: |
| 1845 | + # commit 2d9f0217ec904a1952a1ada2136502eefbca562e |
| 1846 | + expect(states).to be == [0, 1, 1, 0] |
| 1847 | + end |
| 1848 | + end |
1793 | 1849 | end
|
1794 | 1850 |
|
1795 | 1851 | describe '#projection' do
|
|
0 commit comments