mongo 2.7.2 → 2.8.0.rc0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +1 -3
  4. data/lib/mongo/address.rb +17 -20
  5. data/lib/mongo/address/ipv4.rb +6 -3
  6. data/lib/mongo/address/ipv6.rb +6 -3
  7. data/lib/mongo/address/unix.rb +5 -2
  8. data/lib/mongo/auth.rb +15 -2
  9. data/lib/mongo/auth/cr/conversation.rb +4 -2
  10. data/lib/mongo/auth/ldap/conversation.rb +4 -2
  11. data/lib/mongo/auth/scram.rb +3 -7
  12. data/lib/mongo/auth/scram/conversation.rb +28 -19
  13. data/lib/mongo/auth/user.rb +45 -10
  14. data/lib/mongo/auth/x509/conversation.rb +4 -2
  15. data/lib/mongo/cluster.rb +9 -17
  16. data/lib/mongo/error.rb +2 -0
  17. data/lib/mongo/error/missing_password.rb +29 -0
  18. data/lib/mongo/error/operation_failure.rb +7 -3
  19. data/lib/mongo/error/parser.rb +2 -1
  20. data/lib/mongo/error/sdam_error_detection.rb +54 -0
  21. data/lib/mongo/operation/aggregate/command.rb +1 -16
  22. data/lib/mongo/operation/aggregate/op_msg.rb +1 -1
  23. data/lib/mongo/operation/collections_info.rb +2 -3
  24. data/lib/mongo/operation/delete/command.rb +2 -15
  25. data/lib/mongo/operation/delete/legacy.rb +1 -16
  26. data/lib/mongo/operation/explain/command.rb +1 -16
  27. data/lib/mongo/operation/explain/legacy.rb +1 -16
  28. data/lib/mongo/operation/find/command.rb +1 -16
  29. data/lib/mongo/operation/find/legacy.rb +1 -16
  30. data/lib/mongo/operation/get_more/command.rb +1 -16
  31. data/lib/mongo/operation/indexes/command.rb +1 -16
  32. data/lib/mongo/operation/indexes/legacy.rb +4 -16
  33. data/lib/mongo/operation/list_collections/command.rb +1 -16
  34. data/lib/mongo/operation/map_reduce/command.rb +1 -16
  35. data/lib/mongo/operation/parallel_scan/command.rb +1 -16
  36. data/lib/mongo/operation/result.rb +3 -0
  37. data/lib/mongo/operation/shared/executable.rb +4 -0
  38. data/lib/mongo/operation/shared/polymorphic_lookup.rb +1 -1
  39. data/lib/mongo/operation/shared/polymorphic_result.rb +8 -1
  40. data/lib/mongo/operation/shared/result/aggregatable.rb +0 -5
  41. data/lib/mongo/operation/update/command.rb +2 -15
  42. data/lib/mongo/operation/update/legacy.rb +1 -16
  43. data/lib/mongo/operation/users_info/command.rb +1 -16
  44. data/lib/mongo/retryable.rb +22 -10
  45. data/lib/mongo/server.rb +10 -1
  46. data/lib/mongo/server/app_metadata.rb +7 -2
  47. data/lib/mongo/server/connectable.rb +0 -6
  48. data/lib/mongo/server/connection.rb +86 -135
  49. data/lib/mongo/server/connection_base.rb +133 -0
  50. data/lib/mongo/server/connection_pool.rb +11 -24
  51. data/lib/mongo/server/connection_pool/queue.rb +41 -41
  52. data/lib/mongo/server/description.rb +1 -1
  53. data/lib/mongo/server/monitor.rb +4 -4
  54. data/lib/mongo/server/monitor/connection.rb +26 -7
  55. data/lib/mongo/server/pending_connection.rb +36 -0
  56. data/lib/mongo/server_selector/selectable.rb +9 -1
  57. data/lib/mongo/session.rb +0 -1
  58. data/lib/mongo/socket.rb +23 -6
  59. data/lib/mongo/socket/ssl.rb +11 -18
  60. data/lib/mongo/socket/tcp.rb +13 -14
  61. data/lib/mongo/socket/unix.rb +9 -27
  62. data/lib/mongo/uri.rb +1 -1
  63. data/lib/mongo/version.rb +1 -1
  64. data/spec/integration/auth_spec.rb +160 -0
  65. data/spec/integration/retryable_writes_spec.rb +55 -58
  66. data/spec/integration/sdam_error_handling_spec.rb +115 -0
  67. data/spec/mongo/address/ipv4_spec.rb +4 -0
  68. data/spec/mongo/address/ipv6_spec.rb +4 -0
  69. data/spec/mongo/auth/scram/conversation_spec.rb +6 -5
  70. data/spec/mongo/auth/scram/negotiation_spec.rb +25 -36
  71. data/spec/mongo/auth/scram_spec.rb +2 -2
  72. data/spec/mongo/auth/user_spec.rb +97 -0
  73. data/spec/mongo/client_construction_spec.rb +1 -1
  74. data/spec/mongo/error/operation_failure_spec.rb +125 -1
  75. data/spec/mongo/retryable_spec.rb +17 -8
  76. data/spec/mongo/server/connection_pool/queue_spec.rb +24 -10
  77. data/spec/mongo/server/connection_pool_spec.rb +30 -117
  78. data/spec/mongo/server/connection_spec.rb +147 -25
  79. data/spec/mongo/server/description_spec.rb +0 -14
  80. data/spec/mongo/server/monitor/connection_spec.rb +22 -0
  81. data/spec/mongo/server_selector_spec.rb +1 -0
  82. data/spec/mongo/server_spec.rb +6 -6
  83. data/spec/mongo/socket/ssl_spec.rb +48 -116
  84. data/spec/mongo/socket/tcp_spec.rb +22 -0
  85. data/spec/mongo/socket/unix_spec.rb +9 -9
  86. data/spec/mongo/socket_spec.rb +15 -3
  87. data/spec/spec_tests/server_selection_spec.rb +2 -0
  88. data/spec/support/client_registry.rb +8 -2
  89. data/spec/support/common_shortcuts.rb +20 -1
  90. data/spec/support/constraints.rb +10 -2
  91. data/spec/support/lite_constraints.rb +8 -0
  92. data/spec/support/spec_config.rb +9 -1
  93. metadata +14 -4
  94. metadata.gz.sig +0 -0
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mongo::Socket::TCP do
4
+ require_no_ssl
5
+
6
+ let(:address) { default_address }
7
+
8
+ let!(:resolver) do
9
+ address.send(:create_resolver, {})
10
+ end
11
+
12
+ let(:socket) do
13
+ resolver.socket(5, {})
14
+ end
15
+
16
+ describe '#address' do
17
+ it 'returns the address and tls indicator' do
18
+ addr = socket.send(:socket).remote_address
19
+ expect(socket.send(:address)).to eq("#{addr.ip_address}:#{addr.ip_port} (no TLS)")
20
+ end
21
+ end
22
+ end
@@ -2,15 +2,19 @@ require 'spec_helper'
2
2
 
3
3
  describe Mongo::Socket::Unix do
4
4
 
5
+ let(:path) { "/tmp/mongodb-#{SpecConfig.instance.any_port}.sock" }
6
+
5
7
  let(:socket) do
6
- described_class.new("/tmp/mongodb-#{SpecConfig.instance.any_port}.sock", 5)
8
+ described_class.new(path, 5)
7
9
  end
8
10
 
9
- describe '#connect!' do
10
-
11
- before do
12
- socket.connect!
11
+ describe '#address' do
12
+ it 'returns the path' do
13
+ expect(socket.send(:address)).to eq(path)
13
14
  end
15
+ end
16
+
17
+ describe '#connect!' do
14
18
 
15
19
  after do
16
20
  socket.close
@@ -25,10 +29,6 @@ describe Mongo::Socket::Unix do
25
29
 
26
30
  context 'when the socket is connected' do
27
31
 
28
- before do
29
- socket.connect!
30
- end
31
-
32
32
  after do
33
33
  socket.close
34
34
  end
@@ -6,7 +6,19 @@ describe Mongo::Socket do
6
6
  described_class.new(Socket::PF_INET)
7
7
  end
8
8
 
9
+ describe '#address' do
10
+ it 'raises NotImplementedError' do
11
+ expect do
12
+ socket.send(:address)
13
+ end.to raise_error(NotImplementedError)
14
+ end
15
+ end
16
+
9
17
  describe '#handle_errors' do
18
+ before do
19
+ expect(socket).to receive(:address).and_return('fake-address')
20
+ end
21
+
10
22
  it 'maps timeout exception' do
11
23
  expect do
12
24
  socket.send(:handle_errors) do
@@ -20,7 +32,7 @@ describe Mongo::Socket do
20
32
  socket.send(:handle_errors) do
21
33
  raise SystemCallError.new('Test error', Errno::ENFILE::Errno)
22
34
  end
23
- end.to raise_error(Mongo::Error::SocketError, 'Errno::ENFILE: Too many open files in system - Test error')
35
+ end.to raise_error(Mongo::Error::SocketError, 'Errno::ENFILE: Too many open files in system - Test error (for fake-address)')
24
36
  end
25
37
 
26
38
  it 'maps IOError and preserves message' do
@@ -28,7 +40,7 @@ describe Mongo::Socket do
28
40
  socket.send(:handle_errors) do
29
41
  raise IOError.new('Test error')
30
42
  end
31
- end.to raise_error(Mongo::Error::SocketError, 'IOError: Test error')
43
+ end.to raise_error(Mongo::Error::SocketError, 'IOError: Test error (for fake-address)')
32
44
  end
33
45
 
34
46
  it 'maps SSLError and preserves message' do
@@ -36,7 +48,7 @@ describe Mongo::Socket do
36
48
  socket.send(:handle_errors) do
37
49
  raise OpenSSL::SSL::SSLError.new('Test error')
38
50
  end
39
- end.to raise_error(Mongo::Error::SocketError, 'OpenSSL::SSL::SSLError: Test error (MongoDB may not be configured with SSL support)')
51
+ end.to raise_error(Mongo::Error::SocketError, 'OpenSSL::SSL::SSLError: Test error (for fake-address) (MongoDB may not be configured with SSL support)')
40
52
  end
41
53
  end
42
54
  end
@@ -46,6 +46,7 @@ describe 'Server Selection' do
46
46
  allow(c).to receive(:unknown?).and_return(topology.unknown?)
47
47
  allow(c).to receive(:app_metadata).and_return(app_metadata)
48
48
  allow(c).to receive(:options).and_return({})
49
+ allow(c).to receive(:server_selection_semaphore).and_return(nil)
49
50
  end
50
51
  end
51
52
 
@@ -101,6 +102,7 @@ describe 'Server Selection' do
101
102
  end
102
103
 
103
104
  context 'No matching server available', if: !spec.server_available? do
105
+ skip_if_linting
104
106
 
105
107
  it 'Raises exception' do
106
108
  expect do
@@ -95,13 +95,19 @@ class ClientRegistry
95
95
  )
96
96
  # Provides an authorized mongo client that retries writes.
97
97
  when 'authorized_with_retry_writes'
98
- global_client('authorized').with(retry_writes: true).tap do |client|
98
+ global_client('authorized').with(
99
+ retry_writes: true,
100
+ server_selection_timeout: 4.97,
101
+ ).tap do |client|
99
102
  client.subscribe(Mongo::Monitoring::COMMAND, EventSubscriber)
100
103
  end
101
104
  # Provides an authorized mongo client that does not retry writes,
102
105
  # overriding global test suite option to retry writes if necessary.
103
106
  when 'authorized_without_retry_writes'
104
- global_client('authorized').with(retry_writes: false).tap do |client|
107
+ global_client('authorized').with(
108
+ retry_writes: false,
109
+ server_selection_timeout: 4.99,
110
+ ).tap do |client|
105
111
  client.subscribe(Mongo::Monitoring::COMMAND, EventSubscriber)
106
112
  end
107
113
  # Provides an unauthorized mongo client on the admin database, for use in
@@ -37,7 +37,7 @@ module CommonShortcuts
37
37
  # the case, this test will fail due to exceeding the general
38
38
  # test timeout eventually.
39
39
  while cluster.servers_list.any? { |server| server.unknown? }
40
- warn "Waiting for unknown servers in #{cluster.servers}"
40
+ warn "Waiting for unknown servers in #{cluster.summary}"
41
41
  sleep 0.25
42
42
  end
43
43
  end
@@ -74,5 +74,24 @@ module CommonShortcuts
74
74
  allow(s).to receive(:description).and_return(description)
75
75
  end
76
76
  end
77
+
78
+ def make_protocol_reply(payload)
79
+ Mongo::Protocol::Reply.new.tap do |reply|
80
+ reply.instance_variable_set('@flags', [])
81
+ reply.instance_variable_set('@documents', [payload])
82
+ end
83
+ end
84
+
85
+ def make_not_master_reply
86
+ make_protocol_reply(
87
+ 'ok' => 0, 'code' => 10107, 'errmsg' => 'not master'
88
+ )
89
+ end
90
+
91
+ def make_node_recovering_reply
92
+ make_protocol_reply(
93
+ 'ok' => 0, 'code' => 91, 'errmsg' => 'shutdown in progress'
94
+ )
95
+ end
77
96
  end
78
97
  end
@@ -80,6 +80,14 @@ module Constraints
80
80
  end
81
81
  end
82
82
 
83
+ def require_no_ssl
84
+ before do
85
+ if SpecConfig.instance.ssl?
86
+ skip "SSL enabled"
87
+ end
88
+ end
89
+ end
90
+
83
91
  def require_local_tls
84
92
  before do
85
93
  unless SpecConfig.instance.ssl? && !SpecConfig.instance.ci?
@@ -130,7 +138,7 @@ module Constraints
130
138
 
131
139
  def require_auth
132
140
  before do
133
- unless ENV['AUTH'] == 'auth' || ClusterConfig.instance.auth_enabled?
141
+ unless ENV['AUTH'] == 'auth' || SpecConfig.instance.user || ClusterConfig.instance.auth_enabled?
134
142
  skip "Auth required"
135
143
  end
136
144
  end
@@ -138,7 +146,7 @@ module Constraints
138
146
 
139
147
  def require_no_auth
140
148
  before do
141
- if ENV['AUTH'] == 'auth' || ClusterConfig.instance.auth_enabled?
149
+ if ENV['AUTH'] == 'auth' || SpecConfig.instance.user || ClusterConfig.instance.auth_enabled?
142
150
  skip "Auth not allowed"
143
151
  end
144
152
  end
@@ -28,6 +28,14 @@ module LiteConstraints
28
28
  end
29
29
  end
30
30
 
31
+ def require_linting
32
+ before do
33
+ unless Mongo::Lint.enabled?
34
+ skip "Linting is not enabled"
35
+ end
36
+ end
37
+ end
38
+
31
39
  # Some tests will fail if linting is enabled:
32
40
  # 1. Tests that pass invalid options to client, etc. which the linter
33
41
  # rejects.
@@ -148,6 +148,14 @@ class SpecConfig
148
148
 
149
149
  # Option hashes
150
150
 
151
+ def auth_options
152
+ {
153
+ user: user,
154
+ password: password,
155
+ auth_source: auth_source,
156
+ }
157
+ end
158
+
151
159
  def ssl_options
152
160
  if ssl?
153
161
  {
@@ -190,7 +198,7 @@ class SpecConfig
190
198
  # means the test suite hangs for about 4 seconds before
191
199
  # failing.
192
200
  # Server selection timeout of 1 is insufficient for evergreen.
193
- server_selection_timeout: 2,
201
+ server_selection_timeout: ssl? ? 4.01 : 2.01,
194
202
  wait_queue_timeout: 2,
195
203
  connect_timeout: 3,
196
204
  max_idle_time: 5
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.2
4
+ version: 2.8.0.rc0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Brock
@@ -31,7 +31,7 @@ cert_chain:
31
31
  bMYVwXXhV8czdzgkQB/ZPWHSbEWXnmkze1mzvqWBCPOVXYrcnL9cnEl/RoxtS1hr
32
32
  Db6Ac6mCUSYfYHBWpWqxjc45n70i5Xi1
33
33
  -----END CERTIFICATE-----
34
- date: 2019-03-21 00:00:00.000000000 Z
34
+ date: 2019-02-27 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bson
@@ -172,6 +172,7 @@ files:
172
172
  - lib/mongo/error/max_message_size.rb
173
173
  - lib/mongo/error/mismatched_domain.rb
174
174
  - lib/mongo/error/missing_file_chunk.rb
175
+ - lib/mongo/error/missing_password.rb
175
176
  - lib/mongo/error/missing_resume_token.rb
176
177
  - lib/mongo/error/multi_index_drop.rb
177
178
  - lib/mongo/error/need_primary_server.rb
@@ -179,6 +180,7 @@ files:
179
180
  - lib/mongo/error/no_srv_records.rb
180
181
  - lib/mongo/error/operation_failure.rb
181
182
  - lib/mongo/error/parser.rb
183
+ - lib/mongo/error/sdam_error_detection.rb
182
184
  - lib/mongo/error/session_ended.rb
183
185
  - lib/mongo/error/socket_error.rb
184
186
  - lib/mongo/error/socket_timeout_error.rb
@@ -379,6 +381,7 @@ files:
379
381
  - lib/mongo/server/app_metadata.rb
380
382
  - lib/mongo/server/connectable.rb
381
383
  - lib/mongo/server/connection.rb
384
+ - lib/mongo/server/connection_base.rb
382
385
  - lib/mongo/server/connection_pool.rb
383
386
  - lib/mongo/server/connection_pool/queue.rb
384
387
  - lib/mongo/server/context.rb
@@ -387,6 +390,7 @@ files:
387
390
  - lib/mongo/server/monitor.rb
388
391
  - lib/mongo/server/monitor/app_metadata.rb
389
392
  - lib/mongo/server/monitor/connection.rb
393
+ - lib/mongo/server/pending_connection.rb
390
394
  - lib/mongo/server/round_trip_time_averager.rb
391
395
  - lib/mongo/server_selector.rb
392
396
  - lib/mongo/server_selector/nearest.rb
@@ -413,6 +417,7 @@ files:
413
417
  - spec/README.md
414
418
  - spec/atlas/atlas_connectivity_spec.rb
415
419
  - spec/enterprise_auth/kerberos_spec.rb
420
+ - spec/integration/auth_spec.rb
416
421
  - spec/integration/bulk_insert_spec.rb
417
422
  - spec/integration/change_stream_examples_spec.rb
418
423
  - spec/integration/change_stream_spec.rb
@@ -428,6 +433,7 @@ files:
428
433
  - spec/integration/operation_failure_code_spec.rb
429
434
  - spec/integration/reconnect_spec.rb
430
435
  - spec/integration/retryable_writes_spec.rb
436
+ - spec/integration/sdam_error_handling_spec.rb
431
437
  - spec/integration/sdam_events_spec.rb
432
438
  - spec/integration/server_description_spec.rb
433
439
  - spec/integration/server_selector_spec.rb
@@ -583,6 +589,7 @@ files:
583
589
  - spec/mongo/session_spec.rb
584
590
  - spec/mongo/session_transaction_spec.rb
585
591
  - spec/mongo/socket/ssl_spec.rb
592
+ - spec/mongo/socket/tcp_spec.rb
586
593
  - spec/mongo/socket/unix_spec.rb
587
594
  - spec/mongo/socket_spec.rb
588
595
  - spec/mongo/uri/srv_protocol_spec.rb
@@ -964,9 +971,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
964
971
  version: '0'
965
972
  required_rubygems_version: !ruby/object:Gem::Requirement
966
973
  requirements:
967
- - - ">="
974
+ - - ">"
968
975
  - !ruby/object:Gem::Version
969
- version: '0'
976
+ version: 1.3.1
970
977
  requirements: []
971
978
  rubygems_version: 3.0.1
972
979
  signing_key:
@@ -1032,11 +1039,13 @@ test_files:
1032
1039
  - spec/integration/reconnect_spec.rb
1033
1040
  - spec/integration/client_connectivity_spec.rb
1034
1041
  - spec/integration/bulk_insert_spec.rb
1042
+ - spec/integration/auth_spec.rb
1035
1043
  - spec/integration/command_spec.rb
1036
1044
  - spec/integration/change_stream_spec.rb
1037
1045
  - spec/integration/time_zone_querying_spec.rb
1038
1046
  - spec/integration/heartbeat_events_spec.rb
1039
1047
  - spec/integration/docs_examples_spec.rb
1048
+ - spec/integration/sdam_error_handling_spec.rb
1040
1049
  - spec/mongo/cursor_spec.rb
1041
1050
  - spec/mongo/collection_spec.rb
1042
1051
  - spec/mongo/server/round_trip_time_averager_spec.rb
@@ -1093,6 +1102,7 @@ test_files:
1093
1102
  - spec/mongo/monitoring/event/secure_spec.rb
1094
1103
  - spec/mongo/monitoring/event/topology_opening_spec.rb
1095
1104
  - spec/mongo/socket/unix_spec.rb
1105
+ - spec/mongo/socket/tcp_spec.rb
1096
1106
  - spec/mongo/socket/ssl_spec.rb
1097
1107
  - spec/mongo/server_selector_spec.rb
1098
1108
  - spec/mongo/address/ipv6_spec.rb
metadata.gz.sig CHANGED
Binary file