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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -1
- data/Rakefile +39 -4
- data/lib/mongo/address.rb +1 -1
- data/lib/mongo/collection.rb +5 -0
- data/lib/mongo/collection/view/readable.rb +4 -0
- data/lib/mongo/cursor.rb +15 -3
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/operation/collections_info/command.rb +5 -0
- data/lib/mongo/operation/collections_info/result.rb +16 -1
- data/lib/mongo/operation/find/result.rb +10 -0
- data/lib/mongo/server/description.rb +8 -1
- data/lib/mongo/session.rb +2 -1
- data/lib/mongo/version.rb +1 -1
- data/spec/README.md +7 -0
- data/spec/integration/bson_symbol_spec.rb +4 -2
- data/spec/integration/change_stream_spec.rb +1 -1
- data/spec/integration/connection_pool_populator_spec.rb +1 -1
- data/spec/integration/cursor_reaping_spec.rb +1 -1
- data/spec/integration/fork_reconnect_spec.rb +56 -1
- data/spec/integration/query_cache_transactions_spec.rb +29 -18
- data/spec/integration/sdam_error_handling_spec.rb +17 -0
- data/spec/integration/sdam_events_spec.rb +8 -5
- data/spec/integration/transactions_examples_spec.rb +17 -7
- data/spec/lite_spec_helper.rb +5 -3
- data/spec/mongo/auth/user_spec.rb +1 -1
- data/spec/mongo/bulk_write_spec.rb +2 -2
- data/spec/mongo/client_construction_spec.rb +3 -3
- data/spec/mongo/client_encryption_spec.rb +16 -10
- data/spec/mongo/client_spec.rb +7 -0
- data/spec/mongo/cluster/topology/replica_set_spec.rb +1 -1
- data/spec/mongo/cluster/topology/sharded_spec.rb +1 -1
- data/spec/mongo/cluster/topology/single_spec.rb +1 -1
- data/spec/mongo/cluster/topology/unknown_spec.rb +1 -1
- data/spec/mongo/cluster/topology_spec.rb +1 -1
- data/spec/mongo/collection/view/change_stream_resume_spec.rb +1 -1
- data/spec/mongo/collection/view/readable_spec.rb +36 -0
- data/spec/mongo/collection_spec.rb +12 -0
- data/spec/mongo/crypt/binary_spec.rb +1 -6
- data/spec/mongo/crypt/binding/binary_spec.rb +1 -6
- data/spec/mongo/crypt/binding/context_spec.rb +2 -7
- data/spec/mongo/crypt/binding/helpers_spec.rb +1 -6
- data/spec/mongo/crypt/binding/mongocrypt_spec.rb +2 -7
- data/spec/mongo/crypt/binding/status_spec.rb +1 -6
- data/spec/mongo/crypt/binding/version_spec.rb +1 -6
- data/spec/mongo/crypt/data_key_context_spec.rb +1 -1
- data/spec/mongo/crypt/status_spec.rb +1 -6
- data/spec/mongo/database_spec.rb +64 -0
- data/spec/mongo/monitoring/event/server_closed_spec.rb +1 -1
- data/spec/mongo/monitoring/event/server_opening_spec.rb +1 -1
- data/spec/mongo/monitoring/event/topology_changed_spec.rb +1 -1
- data/spec/mongo/monitoring/event/topology_closed_spec.rb +1 -1
- data/spec/mongo/monitoring/event/topology_opening_spec.rb +1 -1
- data/spec/mongo/operation/delete/op_msg_spec.rb +3 -3
- data/spec/mongo/operation/insert/command_spec.rb +2 -2
- data/spec/mongo/operation/insert/op_msg_spec.rb +3 -3
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +1 -1
- data/spec/mongo/operation/update/command_spec.rb +2 -2
- data/spec/mongo/operation/update/op_msg_spec.rb +3 -3
- data/spec/mongo/query_cache_spec.rb +1 -0
- data/spec/mongo/server/app_metadata_shared.rb +2 -2
- data/spec/mongo/server/connection_spec.rb +1 -1
- data/spec/mongo/server/description_spec.rb +18 -0
- data/spec/mongo/server_selector_spec.rb +2 -2
- data/spec/mongo/socket/ssl_spec.rb +3 -3
- data/spec/runners/change_streams/test.rb +1 -1
- data/spec/runners/crud/test_base.rb +0 -19
- data/spec/runners/server_selection.rb +1 -1
- data/spec/runners/transactions/test.rb +2 -2
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/constraints.rb +303 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +175 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +149 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/stress/fork_reconnect_stress_spec.rb +1 -1
- data/spec/support/constraints.rb +0 -270
- data/spec/support/utils.rb +19 -0
- metadata +956 -952
- metadata.gz.sig +0 -0
- data/spec/support/child_process_helper.rb +0 -78
- data/spec/support/lite_constraints.rb +0 -165
- data/spec/support/spec_organizer.rb +0 -129
@@ -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: '
|
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
|
data/spec/mongo/database_spec.rb
CHANGED
@@ -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
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
170
|
+
require_no_linting
|
171
171
|
|
172
172
|
let(:expected_global_args) do
|
173
173
|
global_args.dup.tap do |args|
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
162
|
+
require_no_linting
|
163
163
|
|
164
164
|
let(:expected_global_args) do
|
165
165
|
global_args.dup.tap do |args|
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|