mongo 2.16.0.alpha1 → 2.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3112358aa696aa5d05305642f004ad5b32bbab28162dea03b96572ed546fc932
4
- data.tar.gz: fa983d69caf1b98e44b035fd43d264df4e2c76fa1cb0761d8798e83af2173f92
3
+ metadata.gz: 2708181386dc2ec2ea46e5ffe3f96967c3ea1e23dfd6f0d6d6ef15fbbde3877a
4
+ data.tar.gz: 017f64d2a62cc0215b6234cef24c8f0be74f75ed5fa688d32155047dbd56a7e0
5
5
  SHA512:
6
- metadata.gz: c38dca4384567fa492f8ecea2b357c4e72178bb70fcf1a1da9b3b932c56848f209e3c637ad5c40cb95bcb8b9e0a8017e389ea95e610cf45078108fff5bcbf49a
7
- data.tar.gz: 8b2fe87f2f589c2af5ebb67a195d981cc4cf0c08c19f7090cbffe35fe270d56cd0ea6d6fa9dd304c444a8480b0793bba639787e7545bc84e18dd42fd9b7f22e3
6
+ metadata.gz: 2488655223e41488f275a7c8d1cd8b4c416a44a92c31cba63ab3fca21b27ec8f545b5feaa953aefb50035dbc68fe47db4f3aebb97fcb1de4e0e5fc6e3b186014
7
+ data.tar.gz: 671ae924600e906df4a2c209b7c491be445ef5c7c7030f6869fa991c53bd49a7cb728a718c8667b5c948022fb2912d45af437c1cf5b82f8b7ec0f0c849916045
checksums.yaml.gz.sig CHANGED
Binary file
@@ -115,11 +115,14 @@ module Mongo
115
115
  end
116
116
  command.update(view_options)
117
117
  command.update(Utils.slice_hash(options, :collation))
118
+
118
119
  # Read preference isn't simply passed in the command payload
119
- # (it may need to be converted to wire protocol flags)
120
- # so remove it here and hopefully it's handled elsewhere.
121
- # If not, RUBY-2706.
122
- command.delete(:read)
120
+ # (it may need to be converted to wire protocol flags).
121
+ # Ideally it should be removed here, however due to Mongoid 7
122
+ # using this method and requiring :read to be returned from it,
123
+ # we cannot do this just yet - see RUBY-2932.
124
+ #command.delete(:read)
125
+
123
126
  command.merge!(Options::Mapper.transform_documents(options, MAPPINGS))
124
127
  command
125
128
  end
@@ -248,7 +248,20 @@ module Mongo
248
248
  end
249
249
 
250
250
  def initial_query_op(session)
251
- Operation::MapReduce.new(map_reduce_spec(session))
251
+ spec = map_reduce_spec(session)
252
+ # Read preference isn't simply passed in the command payload
253
+ # (it may need to be converted to wire protocol flags).
254
+ # Passing it in command payload produces errors on at least
255
+ # 5.0 mongoses.
256
+ # In the future map_reduce_command should remove :read
257
+ # from its return value, however we cannot do this right now
258
+ # due to Mongoid 7 relying on :read being returned as part of
259
+ # the command - see RUBY-2932.
260
+ # Delete :read here for now because it cannot be sent to mongos this way.
261
+ spec = spec.dup
262
+ spec[:selector] = spec[:selector].dup
263
+ spec[:selector].delete(:read)
264
+ Operation::MapReduce.new(spec)
252
265
  end
253
266
 
254
267
  def valid_server?(server)
@@ -110,7 +110,7 @@ module Mongo
110
110
  if new_description.topology_version
111
111
  @topology_version = new_description.topology_version
112
112
  end
113
- rescue Mongo::Error => exc
113
+ rescue IOError, SocketError, SystemCallError, Mongo::Error => exc
114
114
  stop_requested = @lock.synchronize { @stop_requested }
115
115
  if stop_requested
116
116
  # Ignore the exception, see RUBY-2771.
@@ -123,6 +123,9 @@ module Mongo
123
123
  log_prefix: options[:log_prefix],
124
124
  bg_error_backtrace: options[:bg_error_backtrace],
125
125
  )
126
+
127
+ # Avoid tight looping in push monitor - see RUBY-2806.
128
+ sleep(0.5)
126
129
  end
127
130
 
128
131
  def check
data/lib/mongo/version.rb CHANGED
@@ -20,5 +20,5 @@ module Mongo
20
20
  # The current version of the driver.
21
21
  #
22
22
  # @since 2.0.0
23
- VERSION = '2.16.0.alpha1'.freeze
23
+ VERSION = '2.16.2'.freeze
24
24
  end
@@ -157,6 +157,13 @@ RSpec.configure do |config|
157
157
  end
158
158
 
159
159
  if SpecConfig.instance.active_support?
160
+ require "active_support/version"
161
+ if ActiveSupport.version >= Gem::Version.new(7)
162
+ # ActiveSupport wants us to require ALL of it all of the time.
163
+ # See: https://github.com/rails/rails/issues/43851,
164
+ # https://github.com/rails/rails/issues/43889, etc.
165
+ require 'active_support'
166
+ end
160
167
  require "active_support/time"
161
168
  require 'mongo/active_support'
162
169
  end
@@ -865,4 +865,20 @@ describe Mongo::Collection::View::MapReduce do
865
865
  end
866
866
  end
867
867
  end
868
+
869
+ describe '#map_reduce_spec' do
870
+ context 'when read preference is given' do
871
+ let(:view_options) do
872
+ { read: {mode: :secondary} }
873
+ end
874
+
875
+ context 'selector' do
876
+ # For compatibility with released versions of Mongoid, this method
877
+ # must return read preference under the :read key.
878
+ it 'contains read preference' do
879
+ map_reduce_spec[:selector][:read].should == {'mode' => :secondary}
880
+ end
881
+ end
882
+ end
883
+ end
868
884
  end
@@ -136,6 +136,28 @@ describe Mongo::Server::Monitor::Connection do
136
136
  end
137
137
  end
138
138
 
139
+ describe '#connect!' do
140
+
141
+ let(:options) do
142
+ SpecConfig.instance.test_options.merge(
143
+ app_metadata: monitor_app_metadata,
144
+ )
145
+ end
146
+
147
+ context 'when address resolution fails' do
148
+ let(:connection) { described_class.new(server.address, options) }
149
+
150
+ it 'propagates the exception' do
151
+ connection
152
+
153
+ expect(Socket).to receive(:getaddrinfo).and_raise(SocketError.new('Test exception'))
154
+ lambda do
155
+ connection.connect!
156
+ end.should raise_error(SocketError, 'Test exception')
157
+ end
158
+ end
159
+ end
160
+
139
161
  describe '#check_document' do
140
162
  context 'with API version' do
141
163
  let(:meta) do
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ require 'spec_helper'
5
+
6
+ describe Mongo::Server::PushMonitor do
7
+ before(:all) do
8
+ ClientRegistry.instance.close_all_clients
9
+ end
10
+
11
+ let(:address) do
12
+ default_address
13
+ end
14
+
15
+ let(:listeners) do
16
+ Mongo::Event::Listeners.new
17
+ end
18
+
19
+ let(:monitor_options) do
20
+ {}
21
+ end
22
+
23
+ let(:monitor_app_metadata) do
24
+ Mongo::Server::Monitor::AppMetadata.new(
25
+ server_api: SpecConfig.instance.ruby_options[:server_api],
26
+ )
27
+ end
28
+
29
+ let(:cluster) do
30
+ double('cluster').tap do |cluster|
31
+ allow(cluster).to receive(:run_sdam_flow)
32
+ allow(cluster).to receive(:heartbeat_interval).and_return(1000)
33
+ end
34
+ end
35
+
36
+ let(:server) do
37
+ Mongo::Server.new(address, cluster, Mongo::Monitoring.new, listeners,
38
+ monitoring_io: false)
39
+ end
40
+
41
+ let(:monitor) do
42
+ register_background_thread_object(
43
+ Mongo::Server::Monitor.new(server, listeners, Mongo::Monitoring.new,
44
+ SpecConfig.instance.test_options.merge(cluster: cluster).merge(monitor_options).update(
45
+ app_metadata: monitor_app_metadata,
46
+ push_monitor_app_metadata: monitor_app_metadata))
47
+ )
48
+ end
49
+
50
+ let(:topology_version) do
51
+ Mongo::TopologyVersion.new('processId' => BSON::ObjectId.new, 'counter' => 1)
52
+ end
53
+
54
+ let(:check_document) do
55
+ {hello: 1}
56
+ end
57
+
58
+ let(:push_monitor) do
59
+ described_class.new(monitor, topology_version, monitor.monitoring,
60
+ **monitor.options.merge(check_document: check_document))
61
+ end
62
+
63
+ describe '#do_work' do
64
+ it 'works' do
65
+ lambda do
66
+ push_monitor.do_work
67
+ end.should_not raise_error
68
+ end
69
+
70
+ context 'network error during check' do
71
+ it 'does not propagate the exception' do
72
+ push_monitor
73
+
74
+ expect(Socket).to receive(:getaddrinfo).and_raise(SocketError.new('Test exception'))
75
+ lambda do
76
+ push_monitor.do_work
77
+ end.should_not raise_error
78
+ end
79
+
80
+ it 'throttles checks' do
81
+ push_monitor
82
+
83
+ start = Mongo::Utils.monotonic_time
84
+
85
+ expect(Socket).to receive(:getaddrinfo).and_raise(SocketError.new('Test exception'))
86
+ lambda do
87
+ push_monitor.do_work
88
+ end.should_not raise_error
89
+
90
+ expect(Socket).to receive(:getaddrinfo).and_raise(SocketError.new('Test exception'))
91
+ lambda do
92
+ push_monitor.do_work
93
+ end.should_not raise_error
94
+
95
+ elapsed = Mongo::Utils.monotonic_time - start
96
+ elapsed.should > 0.5
97
+ end
98
+ end
99
+ end
100
+
101
+ end
data/spec/runners/auth.rb CHANGED
@@ -48,7 +48,7 @@ module Mongo
48
48
  attr_reader :tests
49
49
 
50
50
  def initialize(test_path)
51
- @spec = YAML.load(File.read(test_path))
51
+ @spec = ::Utils.load_spec_yaml_file(test_path)
52
52
  @description = File.basename(test_path)
53
53
  end
54
54
 
@@ -32,7 +32,7 @@ module Mongo
32
32
  #
33
33
  # @since 2.6.0
34
34
  def initialize(test_path)
35
- @spec = YAML.load(File.read(test_path))
35
+ @spec = ::Utils.load_spec_yaml_file(test_path)
36
36
  @description = File.basename(test_path)
37
37
  @spec_tests = @spec['tests']
38
38
  @collection_name = @spec['collection_name']
data/spec/runners/cmap.rb CHANGED
@@ -40,7 +40,7 @@ module Mongo
40
40
  #
41
41
  # @param [ String ] test_path The path to the file.
42
42
  def initialize(test_path)
43
- @test = YAML.load(File.read(test_path))
43
+ @test = ::Utils.load_spec_yaml_file(test_path)
44
44
 
45
45
  @description = @test['description']
46
46
  @pool_options = ::Utils.snakeize_hash(process_options(@test['poolOptions']))
@@ -204,7 +204,7 @@ module Mongo
204
204
  #
205
205
  # @since 2.1.0
206
206
  def initialize(test_path)
207
- @spec = YAML.load(File.read(test_path))
207
+ @spec = ::Utils.load_spec_yaml_file(test_path)
208
208
  @data = @spec['data']
209
209
  @tests = @spec['tests']
210
210
  end
@@ -100,7 +100,7 @@ module Mongo
100
100
  #
101
101
  # @since 2.0.0
102
102
  def initialize(test_path)
103
- @spec = YAML.load(File.read(test_path))
103
+ @spec = ::Utils.load_spec_yaml_file(test_path)
104
104
  @description = File.basename(test_path)
105
105
  end
106
106
 
@@ -12,9 +12,7 @@ module Mongo
12
12
  #
13
13
  # @since 2.0.0
14
14
  def initialize(test_path)
15
- contents = File.read(test_path)
16
-
17
- @spec = YAML.load(contents)
15
+ @spec = ::Utils.load_spec_yaml_file(test_path)
18
16
  @description = File.basename(test_path)
19
17
  @data = BSON::ExtJSON.parse_obj(@spec['data'])
20
18
  @tests = @spec['tests']
@@ -100,7 +100,7 @@ module Mongo
100
100
  #
101
101
  # @since 2.1.0
102
102
  def initialize(test_path)
103
- @spec = YAML.load(File.read(test_path))
103
+ @spec = ::Utils.load_spec_yaml_file(test_path)
104
104
  @description = File.basename(test_path)
105
105
  @data = @spec['data']
106
106
  end
@@ -13,7 +13,7 @@ module ReadWriteConcernDocument
13
13
  #
14
14
  # @since 2.0.0
15
15
  def initialize(test_path)
16
- @spec = YAML.load(File.read(test_path))
16
+ @spec = ::Utils.load_spec_yaml_file(test_path)
17
17
  @description = File.basename(test_path)
18
18
  end
19
19
 
data/spec/runners/sdam.rb CHANGED
@@ -77,7 +77,7 @@ module Mongo
77
77
  #
78
78
  # @since 2.0.0
79
79
  def initialize(test_path)
80
- @test = YAML.load(File.read(test_path))
80
+ @test = ::Utils.load_spec_yaml_file(test_path)
81
81
  @description = @test['description']
82
82
  @uri_string = @test['uri']
83
83
  @uri = URI.new(uri_string)
@@ -64,7 +64,7 @@ module Mongo
64
64
  #
65
65
  # @since 2.0.0
66
66
  def initialize(test_path)
67
- @test = YAML.load(File.read(test_path))
67
+ @test = ::Utils.load_spec_yaml_file(test_path)
68
68
  @description = "#{@test['topology_description']['type']}: #{File.basename(test_path)}"
69
69
  @heartbeat_frequency = @test['heartbeatFrequencyMS'] / 1000 if @test['heartbeatFrequencyMS']
70
70
  @read_preference = @test['read_preference']
@@ -28,7 +28,7 @@ module Mongo
28
28
  #
29
29
  # @since 2.0.0
30
30
  def initialize(test_path)
31
- @test = YAML.load(File.read(test_path))
31
+ @test = ::Utils.load_spec_yaml_file(test_path)
32
32
  @description = "#{File.basename(test_path)}: avg_rtt_ms: #{@test['avg_rtt_ms']}, new_rtt_ms: #{@test['new_rtt_ms']}," +
33
33
  " new_avg_rtt: #{@test['new_avg_rtt']}"
34
34
  @average_rtt = @test['avg_rtt_ms'] == 'NULL' ? nil : @test['avg_rtt_ms'].to_f / 1000
@@ -208,12 +208,20 @@ module Unified
208
208
  else
209
209
  raise
210
210
  end
211
+ rescue Interrupt
212
+ raise
211
213
  rescue => e
212
- if store_errors
214
+ if store_failures
215
+ STDERR.puts "Error: #{e.class}: #{e} (reporting as failure)"
216
+ entities.get(:failure_list, store_failures) << {
217
+ error: "#{e.class}: #{e}",
218
+ time: Time.now.to_f,
219
+ }
220
+ elsif store_errors
213
221
  STDERR.puts "Error: #{e.class}: #{e}"
214
222
  entities.get(:error_list, store_errors) << {
215
223
  error: "#{e.class}: #{e}",
216
- observedAt: Time.now.to_f,
224
+ time: Time.now.to_f,
217
225
  }
218
226
  else
219
227
  raise
@@ -6,7 +6,7 @@ module Unified
6
6
  class TestGroup
7
7
  def initialize(path, **opts)
8
8
  if String === path
9
- data = YAML.load(File.read(path))
9
+ data = ::Utils.load_spec_yaml_file(path)
10
10
  else
11
11
  data = path
12
12
  end
@@ -209,7 +209,12 @@ module Mrss
209
209
  @server_version = build_info['version']
210
210
  @enterprise = build_info['modules'] && build_info['modules'].include?('enterprise')
211
211
 
212
- @server_parameters = client.use(:admin).command(getParameter: '*').first
212
+ @server_parameters = begin
213
+ client.use(:admin).command(getParameter: '*').first
214
+ rescue => e
215
+ STDERR.puts("WARNING: Failed to obtain server parameters: #{e.class}: #{e.message}")
216
+ {}
217
+ end
213
218
 
214
219
  if !sharded_ish? && short_server_version >= '3.4'
215
220
  rv = @server_parameters['featureCompatibilityVersion']
@@ -55,7 +55,7 @@ FROM <%= base_image %>
55
55
  # Ruby runtime dependencies: libyaml-0-2
56
56
  # Compiling ruby libraries: gcc make
57
57
  # Compiling pyhton packages: python2.7-dev
58
- # JRuby: openjdk-8-jre-headless
58
+ # JRuby: openjdk-8-jdk-headless
59
59
  # Server dependencies: libsnmp30 libcurl3/libcurl4
60
60
  # Determining OS we are running on: lsb-release
61
61
  # Load balancer testing: haproxy
@@ -104,11 +104,11 @@ FROM <%= base_image %>
104
104
  <% end %>
105
105
 
106
106
  <% if distro =~ /debian10/ %>
107
- <% packages << 'openjdk-11-jre-headless' %>
107
+ <% packages << 'openjdk-11-jdk-headless' %>
108
108
  <% elsif distro =~ /ubuntu1404/ %>
109
109
  # Ubuntu 14.04 only has openjdk 7, this is too old to be useful
110
110
  <% else %>
111
- <% packages << 'openjdk-8-jre-headless' %>
111
+ <% packages << 'openjdk-8-jdk-headless' %>
112
112
  <% end %>
113
113
 
114
114
  # ubuntu1404, ubuntu1604: libcurl3
@@ -15,7 +15,7 @@ describe 'DNS Seedlist Discovery' do
15
15
 
16
16
  SEED_LIST_DISCOVERY_TESTS.each do |test_path|
17
17
 
18
- spec = YAML.load(File.read(test_path))
18
+ spec = ::Utils.load_spec_yaml_file(test_path)
19
19
 
20
20
  test = Mongo::ConnectionString::Test.new(spec)
21
21
 
@@ -13,7 +13,7 @@ class SpecConfig
13
13
  @uri_options = {}
14
14
  @ruby_options = {}
15
15
  if ENV['MONGODB_URI']
16
- @mongodb_uri = Mongo::URI.new(ENV['MONGODB_URI'])
16
+ @mongodb_uri = Mongo::URI.get(ENV['MONGODB_URI'])
17
17
  @uri_options = Mongo::Options::Mapper.transform_keys_to_symbols(@mongodb_uri.uri_options)
18
18
  if ENV['TOPOLOGY'] == 'load-balanced'
19
19
  @addresses = @mongodb_uri.servers
@@ -595,4 +595,35 @@ module Utils
595
595
  end
596
596
  end
597
597
  end
598
+
599
+ module_function def load_spec_yaml_file(path)
600
+ permitted_classes = [
601
+ BigDecimal,
602
+ Date,
603
+ Time,
604
+ Range,
605
+ Regexp,
606
+ Symbol,
607
+ BSON::Binary,
608
+ BSON::Code,
609
+ BSON::CodeWithScope,
610
+ BSON::DbPointer,
611
+ BSON::Decimal128,
612
+ BSON::Int32,
613
+ BSON::Int64,
614
+ BSON::MaxKey,
615
+ BSON::MinKey,
616
+ BSON::ObjectId,
617
+ BSON::Regexp::Raw,
618
+ BSON::Symbol::Raw,
619
+ BSON::Timestamp,
620
+ BSON::Undefined,
621
+ ]
622
+ if RUBY_VERSION < '2.6'
623
+ YAML.safe_load(File.read(path), permitted_classes, [], true)
624
+ else
625
+ # Here we have Ruby 2.6+ that supports the new syntax of `safe_load``.
626
+ YAML.safe_load(File.read(path), permitted_classes: permitted_classes, aliases: true)
627
+ end
628
+ end
598
629
  end
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- ��������.��ݎ�Z�}��9�/��"�@���> u��)�D;:#a i;��g�[�W4��
2
- _�"�XA�G �w����>�{*�U��)��-y�?��Y�P2��^r�4T�6���*|C�d_��S�J�}�@ �s��=��c��+n�L�k�> ����(��vPk�cXT�j!9��fx��(\���6IGe�6�)�g<�T�egf�9�e
1
+ ��li'#���X�aBY�-�TRM�ZA�k�xe���#֑��Kt2-����z�}er;����_3XM�4�k��D�����6��@��9�'����d�����)I>�Ua9��$�m�^e�7���P�P���,��w0��2E1�m�o�*��d��wF_��o"Y������!i��#�sJ���_A��(�l��l��Da*D[�Y+��B���T����t���