mongo 2.14.0.rc1 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +1 -1
  4. data/Rakefile +39 -4
  5. data/lib/mongo/address.rb +1 -1
  6. data/lib/mongo/collection.rb +5 -0
  7. data/lib/mongo/collection/view/readable.rb +4 -0
  8. data/lib/mongo/cursor.rb +15 -3
  9. data/lib/mongo/database/view.rb +1 -1
  10. data/lib/mongo/operation/collections_info/command.rb +5 -0
  11. data/lib/mongo/operation/collections_info/result.rb +16 -1
  12. data/lib/mongo/operation/find/result.rb +10 -0
  13. data/lib/mongo/server/description.rb +8 -1
  14. data/lib/mongo/session.rb +2 -1
  15. data/lib/mongo/version.rb +1 -1
  16. data/spec/README.md +7 -0
  17. data/spec/integration/bson_symbol_spec.rb +4 -2
  18. data/spec/integration/change_stream_spec.rb +1 -1
  19. data/spec/integration/connection_pool_populator_spec.rb +1 -1
  20. data/spec/integration/cursor_reaping_spec.rb +1 -1
  21. data/spec/integration/fork_reconnect_spec.rb +56 -1
  22. data/spec/integration/query_cache_transactions_spec.rb +29 -18
  23. data/spec/integration/sdam_error_handling_spec.rb +17 -0
  24. data/spec/integration/sdam_events_spec.rb +8 -5
  25. data/spec/integration/transactions_examples_spec.rb +17 -7
  26. data/spec/lite_spec_helper.rb +5 -3
  27. data/spec/mongo/auth/user_spec.rb +1 -1
  28. data/spec/mongo/bulk_write_spec.rb +2 -2
  29. data/spec/mongo/client_construction_spec.rb +3 -3
  30. data/spec/mongo/client_encryption_spec.rb +16 -10
  31. data/spec/mongo/client_spec.rb +7 -0
  32. data/spec/mongo/cluster/topology/replica_set_spec.rb +1 -1
  33. data/spec/mongo/cluster/topology/sharded_spec.rb +1 -1
  34. data/spec/mongo/cluster/topology/single_spec.rb +1 -1
  35. data/spec/mongo/cluster/topology/unknown_spec.rb +1 -1
  36. data/spec/mongo/cluster/topology_spec.rb +1 -1
  37. data/spec/mongo/collection/view/change_stream_resume_spec.rb +1 -1
  38. data/spec/mongo/collection/view/readable_spec.rb +36 -0
  39. data/spec/mongo/collection_spec.rb +12 -0
  40. data/spec/mongo/crypt/binary_spec.rb +1 -6
  41. data/spec/mongo/crypt/binding/binary_spec.rb +1 -6
  42. data/spec/mongo/crypt/binding/context_spec.rb +2 -7
  43. data/spec/mongo/crypt/binding/helpers_spec.rb +1 -6
  44. data/spec/mongo/crypt/binding/mongocrypt_spec.rb +2 -7
  45. data/spec/mongo/crypt/binding/status_spec.rb +1 -6
  46. data/spec/mongo/crypt/binding/version_spec.rb +1 -6
  47. data/spec/mongo/crypt/data_key_context_spec.rb +1 -1
  48. data/spec/mongo/crypt/status_spec.rb +1 -6
  49. data/spec/mongo/database_spec.rb +64 -0
  50. data/spec/mongo/monitoring/event/server_closed_spec.rb +1 -1
  51. data/spec/mongo/monitoring/event/server_opening_spec.rb +1 -1
  52. data/spec/mongo/monitoring/event/topology_changed_spec.rb +1 -1
  53. data/spec/mongo/monitoring/event/topology_closed_spec.rb +1 -1
  54. data/spec/mongo/monitoring/event/topology_opening_spec.rb +1 -1
  55. data/spec/mongo/operation/delete/op_msg_spec.rb +3 -3
  56. data/spec/mongo/operation/insert/command_spec.rb +2 -2
  57. data/spec/mongo/operation/insert/op_msg_spec.rb +3 -3
  58. data/spec/mongo/operation/read_preference_op_msg_spec.rb +1 -1
  59. data/spec/mongo/operation/update/command_spec.rb +2 -2
  60. data/spec/mongo/operation/update/op_msg_spec.rb +3 -3
  61. data/spec/mongo/query_cache_spec.rb +1 -0
  62. data/spec/mongo/server/app_metadata_shared.rb +2 -2
  63. data/spec/mongo/server/connection_spec.rb +1 -1
  64. data/spec/mongo/server/description_spec.rb +18 -0
  65. data/spec/mongo/server_selector_spec.rb +2 -2
  66. data/spec/mongo/socket/ssl_spec.rb +3 -3
  67. data/spec/runners/change_streams/test.rb +1 -1
  68. data/spec/runners/crud/test_base.rb +0 -19
  69. data/spec/runners/server_selection.rb +1 -1
  70. data/spec/runners/transactions/test.rb +2 -2
  71. data/spec/shared/LICENSE +20 -0
  72. data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
  73. data/spec/shared/lib/mrss/constraints.rb +303 -0
  74. data/spec/shared/lib/mrss/lite_constraints.rb +175 -0
  75. data/spec/shared/lib/mrss/spec_organizer.rb +149 -0
  76. data/spec/spec_helper.rb +3 -1
  77. data/spec/stress/fork_reconnect_stress_spec.rb +1 -1
  78. data/spec/support/constraints.rb +0 -270
  79. data/spec/support/utils.rb +19 -0
  80. metadata +956 -952
  81. metadata.gz.sig +0 -0
  82. data/spec/support/child_process_helper.rb +0 -78
  83. data/spec/support/lite_constraints.rb +0 -165
  84. data/spec/support/spec_organizer.rb +0 -129
@@ -1,9 +1,4 @@
1
- require 'mongo'
2
- require 'support/lite_constraints'
3
-
4
- RSpec.configure do |config|
5
- config.extend(LiteConstraints)
6
- end
1
+ require 'lite_spec_helper'
7
2
 
8
3
  describe 'Mongo::Crypt::Binding' do
9
4
  describe 'mongocrypt_status_t binding' do
@@ -1,9 +1,4 @@
1
- require 'mongo'
2
- require 'support/lite_constraints'
3
-
4
- RSpec.configure do |config|
5
- config.extend(LiteConstraints)
6
- end
1
+ require 'lite_spec_helper'
7
2
 
8
3
  describe 'Mongo::Crypt::Binding' do
9
4
  require_libmongocrypt
@@ -188,7 +188,7 @@ describe Mongo::Crypt::DataKeyContext do
188
188
  end
189
189
 
190
190
  context 'with valid endpoint' do
191
- let(:options) { { master_key: { region: 'us-east-2', key: 'arn', endpoint: 'endpoint/to/kms' } } }
191
+ let(:options) { { master_key: { region: 'us-east-2', key: 'arn', endpoint: 'kms.us-east-2.amazonaws.com:443' } } }
192
192
 
193
193
  it 'does not raise an exception' do
194
194
  expect do
@@ -1,9 +1,4 @@
1
- require 'mongo'
2
- require 'support/lite_constraints'
3
-
4
- RSpec.configure do |config|
5
- config.extend(LiteConstraints)
6
- end
1
+ require 'lite_spec_helper'
7
2
 
8
3
  describe Mongo::Crypt::Status do
9
4
  require_libmongocrypt
@@ -2,6 +2,19 @@ require 'spec_helper'
2
2
 
3
3
  describe Mongo::Database do
4
4
 
5
+ shared_context 'more than 100 collections' do
6
+ let(:client) do
7
+ root_authorized_client.use('many-collections')
8
+ end
9
+
10
+ before do
11
+ 120.times do |i|
12
+ client["coll-#{i}"].drop
13
+ client["coll-#{i}"].create
14
+ end
15
+ end
16
+ end
17
+
5
18
  describe '#==' do
6
19
 
7
20
  let(:database) do
@@ -228,6 +241,20 @@ describe Mongo::Database do
228
241
  end
229
242
  end
230
243
  end
244
+
245
+ context 'when there are more than 100 collections' do
246
+ include_context 'more than 100 collections'
247
+
248
+ let(:collection_names) do
249
+ client.database.collection_names.sort
250
+ end
251
+
252
+ it 'lists all collections' do
253
+ collection_names.length.should == 120
254
+ collection_names.should include('coll-0')
255
+ collection_names.should include('coll-119')
256
+ end
257
+ end
231
258
  end
232
259
 
233
260
  describe '#list_collections' do
@@ -391,6 +418,25 @@ describe Mongo::Database do
391
418
  end
392
419
  end
393
420
  end
421
+
422
+ context 'when there are more than 100 collections' do
423
+ include_context 'more than 100 collections'
424
+
425
+ let(:collections) do
426
+ client.database.list_collections
427
+ end
428
+
429
+ let(:collection_names) do
430
+ # 2.6 server prefixes collection names with database name
431
+ collections.map { |info| info['name'].sub(/^many-collections\./, '') }.sort
432
+ end
433
+
434
+ it 'lists all collections' do
435
+ collections.length.should == 120
436
+ collection_names.should include('coll-0')
437
+ collection_names.should include('coll-119')
438
+ end
439
+ end
394
440
  end
395
441
 
396
442
  describe '#collections' do
@@ -541,6 +587,24 @@ describe Mongo::Database do
541
587
  end
542
588
  end
543
589
  end
590
+
591
+ context 'when there are more than 100 collections' do
592
+ include_context 'more than 100 collections'
593
+
594
+ let(:collections) do
595
+ client.database.collections
596
+ end
597
+
598
+ let(:collection_names) do
599
+ collections.map(&:name).sort
600
+ end
601
+
602
+ it 'lists all collections' do
603
+ collections.length.should == 120
604
+ collection_names.should include('coll-0')
605
+ collection_names.should include('coll-119')
606
+ end
607
+ end
544
608
  end
545
609
 
546
610
  describe '#command' do
@@ -24,7 +24,7 @@ describe Mongo::Monitoring::Event::ServerClosed do
24
24
  end
25
25
 
26
26
  describe '#summary' do
27
- skip_if_linting
27
+ require_no_linting
28
28
 
29
29
  it 'renders correctly' do
30
30
  expect(topology).to receive(:server_descriptions).and_return({
@@ -24,7 +24,7 @@ describe Mongo::Monitoring::Event::ServerOpening do
24
24
  end
25
25
 
26
26
  describe '#summary' do
27
- skip_if_linting
27
+ require_no_linting
28
28
 
29
29
  it 'renders correctly' do
30
30
  expect(topology).to receive(:server_descriptions).and_return({
@@ -28,7 +28,7 @@ describe Mongo::Monitoring::Event::TopologyChanged do
28
28
  end
29
29
 
30
30
  describe '#summary' do
31
- skip_if_linting
31
+ require_no_linting
32
32
 
33
33
  it 'renders correctly' do
34
34
  expect(prev_topology).to receive(:server_descriptions).and_return({
@@ -24,7 +24,7 @@ describe Mongo::Monitoring::Event::TopologyClosed do
24
24
  end
25
25
 
26
26
  describe '#summary' do
27
- skip_if_linting
27
+ require_no_linting
28
28
 
29
29
  it 'renders correctly' do
30
30
  expect(topology).to receive(:server_descriptions).and_return({
@@ -24,7 +24,7 @@ describe Mongo::Monitoring::Event::TopologyOpening do
24
24
  end
25
25
 
26
26
  describe '#summary' do
27
- skip_if_linting
27
+ require_no_linting
28
28
 
29
29
  it 'renders correctly' do
30
30
  expect(topology).to receive(:server_descriptions).and_return({
@@ -72,7 +72,7 @@ describe Mongo::Operation::Delete::OpMsg do
72
72
 
73
73
  describe 'write concern' do
74
74
  # https://jira.mongodb.org/browse/RUBY-2224
75
- skip_if_linting
75
+ require_no_linting
76
76
 
77
77
  context 'when write concern is not specified' do
78
78
 
@@ -99,7 +99,7 @@ describe Mongo::Operation::Delete::OpMsg do
99
99
 
100
100
  describe '#message' do
101
101
  # https://jira.mongodb.org/browse/RUBY-2224
102
- skip_if_linting
102
+ require_no_linting
103
103
 
104
104
  context 'when the server supports OP_MSG' do
105
105
 
@@ -152,7 +152,7 @@ describe Mongo::Operation::Delete::OpMsg do
152
152
 
153
153
  context 'when an implicit session is created and the topology is then updated and the server does not support sessions' do
154
154
  # Mocks on features are incompatible with linting
155
- skip_if_linting
155
+ require_no_linting
156
156
 
157
157
  let(:expected_global_args) do
158
158
  global_args.dup.tap do |args|
@@ -63,7 +63,7 @@ describe Mongo::Operation::Insert::Command do
63
63
 
64
64
  describe 'write concern' do
65
65
  # https://jira.mongodb.org/browse/RUBY-2224
66
- skip_if_linting
66
+ require_no_linting
67
67
 
68
68
  context 'when write concern is not specified' do
69
69
 
@@ -90,7 +90,7 @@ describe Mongo::Operation::Insert::Command do
90
90
 
91
91
  describe '#message' do
92
92
  # https://jira.mongodb.org/browse/RUBY-2224
93
- skip_if_linting
93
+ require_no_linting
94
94
 
95
95
  context 'when the server does not support OP_MSG' do
96
96
  max_server_version '3.4'
@@ -72,7 +72,7 @@ describe Mongo::Operation::Insert::OpMsg do
72
72
 
73
73
  describe 'write concern' do
74
74
  # https://jira.mongodb.org/browse/RUBY-2224
75
- skip_if_linting
75
+ require_no_linting
76
76
 
77
77
  context 'when write concern is not specified' do
78
78
 
@@ -99,7 +99,7 @@ describe Mongo::Operation::Insert::OpMsg do
99
99
 
100
100
  describe '#message' do
101
101
  # https://jira.mongodb.org/browse/RUBY-2224
102
- skip_if_linting
102
+ require_no_linting
103
103
 
104
104
  context 'when the server supports OP_MSG' do
105
105
  min_server_fcv '3.6'
@@ -167,7 +167,7 @@ describe Mongo::Operation::Insert::OpMsg do
167
167
 
168
168
  context 'when an implicit session is created and the topology is then updated and the server does not support sessions' do
169
169
  # Mocks on features are incompatible with linting
170
- skip_if_linting
170
+ require_no_linting
171
171
 
172
172
  let(:expected_global_args) do
173
173
  global_args.dup.tap do |args|
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Mongo::Operation::SessionsSupported do
4
4
  # https://jira.mongodb.org/browse/RUBY-2224
5
- skip_if_linting
5
+ require_no_linting
6
6
 
7
7
  let(:selector) do
8
8
  BSON::Document.new(name: 'test')
@@ -69,7 +69,7 @@ describe Mongo::Operation::Update::Command do
69
69
 
70
70
  describe 'write concern' do
71
71
  # https://jira.mongodb.org/browse/RUBY-2224
72
- skip_if_linting
72
+ require_no_linting
73
73
 
74
74
  context 'when write concern is not specified' do
75
75
 
@@ -96,7 +96,7 @@ describe Mongo::Operation::Update::Command do
96
96
 
97
97
  describe '#message' do
98
98
  # https://jira.mongodb.org/browse/RUBY-2224
99
- skip_if_linting
99
+ require_no_linting
100
100
 
101
101
  context 'when the server does not support OP_MSG' do
102
102
  max_server_version '3.4'
@@ -78,7 +78,7 @@ describe Mongo::Operation::Update::OpMsg do
78
78
 
79
79
  describe 'write concern' do
80
80
  # https://jira.mongodb.org/browse/RUBY-2224
81
- skip_if_linting
81
+ require_no_linting
82
82
 
83
83
  context 'when write concern is not specified' do
84
84
 
@@ -105,7 +105,7 @@ describe Mongo::Operation::Update::OpMsg do
105
105
 
106
106
  describe '#message' do
107
107
  # https://jira.mongodb.org/browse/RUBY-2224
108
- skip_if_linting
108
+ require_no_linting
109
109
 
110
110
  context 'when the server supports OP_MSG' do
111
111
  min_server_fcv '3.6'
@@ -159,7 +159,7 @@ describe Mongo::Operation::Update::OpMsg do
159
159
 
160
160
  context 'when an implicit session is created and the topology is then updated and the server does not support sessions' do
161
161
  # Mocks on features are incompatible with linting
162
- skip_if_linting
162
+ require_no_linting
163
163
 
164
164
  let(:expected_global_args) do
165
165
  global_args.dup.tap do |args|
@@ -149,6 +149,7 @@ describe Mongo::QueryCache do
149
149
 
150
150
  before do
151
151
  allow(result).to receive(:cursor_id) { 0 }
152
+ allow(result).to receive(:namespace) { 'db.coll' }
152
153
  allow(view).to receive(:limit) { nil }
153
154
  end
154
155
 
@@ -10,7 +10,7 @@ shared_examples 'app metadata document' do
10
10
 
11
11
  it 'includes operating system information' do
12
12
  document[:client][:os][:type].should == 'linux'
13
- if BSON::Environment.jruby?
13
+ if BSON::Environment.jruby? || RUBY_VERSION >= '3.0'
14
14
  document[:client][:os][:name].should == 'linux'
15
15
  else
16
16
  document[:client][:os][:name].should == 'linux-gnu'
@@ -19,7 +19,7 @@ shared_examples 'app metadata document' do
19
19
  end
20
20
 
21
21
  context 'mri' do
22
- only_mri
22
+ require_mri
23
23
 
24
24
  it 'includes Ruby version' do
25
25
  document[:client][:platform].should start_with("Ruby #{RUBY_VERSION}")
@@ -774,7 +774,7 @@ describe Mongo::Server::Connection do
774
774
  context 'when the message is a command' do
775
775
  # Server description is frozen when linting is enabled, which is
776
776
  # incompatible with expectations set on it in this test
777
- skip_if_linting
777
+ require_no_linting
778
778
 
779
779
  let(:selector) do
780
780
  # The driver allows up to 16KiB for command overhead on top of
@@ -27,6 +27,7 @@ describe Mongo::Server::Description do
27
27
  'logicalSessionTimeoutMinutes' => 7,
28
28
  'operationTime' => 1,
29
29
  '$clusterTime' => 1,
30
+ 'connectionId' => 11,
30
31
  'ok' => 1
31
32
  }
32
33
  end
@@ -757,6 +758,23 @@ describe Mongo::Server::Description do
757
758
  end
758
759
  end
759
760
 
761
+ context 'when the configs match, but have different connectionId values' do
762
+
763
+ let(:description) do
764
+ described_class.new(address, replica)
765
+ end
766
+
767
+ let(:other) do
768
+ described_class.new(address, replica.merge(
769
+ 'connectionId' => 12
770
+ ))
771
+ end
772
+
773
+ it 'returns true' do
774
+ expect(description == other).to be(true)
775
+ end
776
+ end
777
+
760
778
  context 'when the configs do not match' do
761
779
 
762
780
  let(:description) do
@@ -196,7 +196,7 @@ describe Mongo::ServerSelector do
196
196
  end
197
197
 
198
198
  describe "#select_server" do
199
- skip_if_linting
199
+ require_no_linting
200
200
 
201
201
  context 'when #select_in_replica_set returns a list of nils' do
202
202
 
@@ -498,7 +498,7 @@ describe Mongo::ServerSelector do
498
498
  end
499
499
 
500
500
  describe '#filter_stale_servers' do
501
- skip_if_linting
501
+ require_no_linting
502
502
 
503
503
  include_context 'server selector'
504
504
  let(:name) do
@@ -338,7 +338,7 @@ describe Mongo::Socket::SSL, retry: 3 do
338
338
  end
339
339
 
340
340
  context 'mri' do
341
- only_mri
341
+ require_mri
342
342
 
343
343
  context 'when a bad certificate is provided' do
344
344
 
@@ -625,7 +625,7 @@ describe Mongo::Socket::SSL, retry: 3 do
625
625
  context 'bundled with intermediate cert' do
626
626
 
627
627
  # https://github.com/jruby/jruby-openssl/issues/181
628
- only_mri
628
+ require_mri
629
629
 
630
630
  let(:ssl_options) do
631
631
  SpecConfig.instance.test_options.merge(
@@ -670,7 +670,7 @@ describe Mongo::Socket::SSL, retry: 3 do
670
670
  context 'bundled with intermediate cert' do
671
671
 
672
672
  # https://github.com/jruby/jruby-openssl/issues/181
673
- only_mri
673
+ require_mri
674
674
 
675
675
  let(:ssl_options) do
676
676
  SpecConfig.instance.test_options.merge(
@@ -70,7 +70,7 @@ module Mongo
70
70
  if ClusterConfig.instance.server_version < '4.4' &&
71
71
  global_client.cluster.servers.length > 1
72
72
  then
73
- mongos_each_direct_client do |client|
73
+ ::Utils.mongos_each_direct_client do |client|
74
74
  client.database.command(flushRouterConfig: 1)
75
75
  end
76
76
  end
@@ -45,25 +45,6 @@ module Mongo
45
45
  raise "Unknown target #{operation.object}"
46
46
  end
47
47
  end
48
-
49
- # If the deployment is a sharded cluster, creates a direct client
50
- # to each of the mongos nodes and yields each in turn to the
51
- # provided block. Does nothing in other topologies.
52
- def mongos_each_direct_client
53
- if ClusterConfig.instance.topology == :sharded
54
- client = ClientRegistry.instance.global_client('basic')
55
- client.cluster.next_primary
56
- client.cluster.servers.each do |server|
57
- direct_client = ClientRegistry.instance.new_local_client(
58
- [server.address.to_s],
59
- SpecConfig.instance.test_options.merge(
60
- connect: :sharded
61
- ).merge(SpecConfig.instance.auth_options))
62
- yield direct_client
63
- direct_client.close
64
- end
65
- end
66
- end
67
48
  end
68
49
  end
69
50
  end