mongo 2.10.5 → 2.11.0.rc0
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 +0 -0
- data/CONTRIBUTING.md +1 -1
- data/lib/mongo.rb +2 -0
- data/lib/mongo/address.rb +4 -0
- data/lib/mongo/address/validator.rb +99 -0
- data/lib/mongo/auth.rb +7 -2
- data/lib/mongo/auth/user.rb +1 -7
- data/lib/mongo/background_thread.rb +135 -0
- data/lib/mongo/bulk_write/transformable.rb +3 -3
- data/lib/mongo/client.rb +74 -16
- data/lib/mongo/cluster.rb +193 -41
- data/lib/mongo/cluster/periodic_executor.rb +31 -43
- data/lib/mongo/cluster/sdam_flow.rb +26 -3
- data/lib/mongo/cluster/srv_monitor.rb +127 -0
- data/lib/mongo/collection/view/readable.rb +3 -5
- data/lib/mongo/collection/view/writable.rb +3 -3
- data/lib/mongo/cursor/builder/get_more_command.rb +1 -4
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +5 -23
- data/lib/mongo/cursor/builder/op_get_more.rb +2 -2
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +5 -24
- data/lib/mongo/error.rb +1 -0
- data/lib/mongo/error/auth_error.rb +1 -1
- data/lib/mongo/error/connection_check_out_timeout.rb +7 -8
- data/lib/mongo/error/invalid_address.rb +24 -0
- data/lib/mongo/error/notable.rb +2 -2
- data/lib/mongo/error/operation_failure.rb +3 -3
- data/lib/mongo/error/pool_closed_error.rb +11 -4
- data/lib/mongo/event.rb +1 -1
- data/lib/mongo/grid/file.rb +0 -5
- data/lib/mongo/grid/file/chunk.rb +0 -2
- data/lib/mongo/grid/fs_bucket.rb +13 -15
- data/lib/mongo/grid/stream/write.rb +3 -9
- data/lib/mongo/loggable.rb +5 -1
- data/lib/mongo/monitoring.rb +1 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +7 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +11 -3
- data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +11 -3
- data/lib/mongo/monitoring/event/cmap/pool_closed.rb +11 -3
- data/lib/mongo/monitoring/event/cmap/pool_created.rb +12 -3
- data/lib/mongo/monitoring/unified_sdam_log_subscriber.rb +62 -0
- data/lib/mongo/operation/shared/executable.rb +5 -10
- data/lib/mongo/operation/shared/sessions_supported.rb +1 -5
- data/lib/mongo/protocol/get_more.rb +1 -2
- data/lib/mongo/protocol/kill_cursors.rb +13 -6
- data/lib/mongo/protocol/serializers.rb +4 -20
- data/lib/mongo/retryable.rb +9 -34
- data/lib/mongo/semaphore.rb +1 -1
- data/lib/mongo/server.rb +113 -42
- data/lib/mongo/server/connection.rb +12 -5
- data/lib/mongo/server/connection_pool.rb +250 -40
- data/lib/mongo/server/connection_pool/populator.rb +58 -0
- data/lib/mongo/server/description.rb +9 -2
- data/lib/mongo/server/monitor.rb +68 -93
- data/lib/mongo/server/monitor/connection.rb +2 -0
- data/lib/mongo/server_selector/selectable.rb +13 -5
- data/lib/mongo/session.rb +0 -13
- data/lib/mongo/srv.rb +17 -0
- data/lib/mongo/srv/monitor.rb +96 -0
- data/lib/mongo/srv/resolver.rb +130 -0
- data/lib/mongo/srv/result.rb +126 -0
- data/lib/mongo/srv/warning_result.rb +35 -0
- data/lib/mongo/uri.rb +45 -55
- data/lib/mongo/uri/srv_protocol.rb +89 -42
- data/lib/mongo/version.rb +1 -1
- data/mongo.gemspec +3 -4
- data/spec/README.md +6 -1
- data/spec/enterprise_auth/kerberos_spec.rb +7 -6
- data/spec/integration/change_stream_examples_spec.rb +0 -4
- data/spec/integration/client_construction_spec.rb +14 -2
- data/spec/integration/connect_single_rs_name_spec.rb +2 -2
- data/spec/integration/connection_pool_populator_spec.rb +296 -0
- data/spec/integration/connection_spec.rb +31 -22
- data/spec/integration/cursor_reaping_spec.rb +1 -2
- data/spec/integration/docs_examples_spec.rb +0 -4
- data/spec/integration/heartbeat_events_spec.rb +17 -15
- data/spec/integration/reconnect_spec.rb +144 -1
- data/spec/integration/retryable_writes_errors_spec.rb +0 -4
- data/spec/integration/retryable_writes_spec.rb +36 -36
- data/spec/integration/sdam_error_handling_spec.rb +31 -25
- data/spec/integration/sdam_events_spec.rb +2 -6
- data/spec/integration/server_monitor_spec.rb +28 -0
- data/spec/integration/server_selector_spec.rb +7 -5
- data/spec/integration/srv_monitoring_spec.rb +360 -0
- data/spec/integration/step_down_spec.rb +4 -6
- data/spec/lite_spec_helper.rb +22 -0
- data/spec/mongo/address/validator_spec.rb +51 -0
- data/spec/mongo/auth/cr_spec.rb +1 -29
- data/spec/mongo/auth/ldap_spec.rb +1 -29
- data/spec/mongo/auth/scram/conversation_spec.rb +0 -2
- data/spec/mongo/auth/scram/negotiation_spec.rb +1 -1
- data/spec/mongo/auth/scram_spec.rb +1 -29
- data/spec/mongo/auth/user/view_spec.rb +1 -36
- data/spec/mongo/auth/user_spec.rb +0 -12
- data/spec/mongo/auth/x509_spec.rb +1 -29
- data/spec/mongo/bulk_write_spec.rb +2 -2
- data/spec/mongo/client_construction_spec.rb +56 -15
- data/spec/mongo/client_spec.rb +31 -27
- data/spec/mongo/cluster/periodic_executor_spec.rb +16 -0
- data/spec/mongo/cluster/srv_monitor_spec.rb +214 -0
- data/spec/mongo/cluster/topology/replica_set_spec.rb +16 -11
- data/spec/mongo/cluster/topology/sharded_spec.rb +12 -9
- data/spec/mongo/cluster/topology/single_spec.rb +20 -11
- data/spec/mongo/cluster_spec.rb +45 -29
- data/spec/mongo/collection/view/map_reduce_spec.rb +14 -9
- data/spec/mongo/collection/view/readable_spec.rb +0 -16
- data/spec/mongo/collection_spec.rb +0 -44
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +2 -4
- data/spec/mongo/cursor/builder/op_get_more_spec.rb +2 -4
- data/spec/mongo/cursor_spec.rb +27 -7
- data/spec/mongo/monitoring/event/cmap/connection_checked_in_spec.rb +10 -3
- data/spec/mongo/monitoring/event/cmap/connection_checked_out_spec.rb +10 -3
- data/spec/mongo/monitoring/event/cmap/pool_closed_spec.rb +10 -3
- data/spec/mongo/monitoring/event/cmap/pool_created_spec.rb +10 -3
- data/spec/mongo/operation/delete/op_msg_spec.rb +17 -8
- data/spec/mongo/operation/insert/op_msg_spec.rb +50 -35
- data/spec/mongo/operation/update/op_msg_spec.rb +14 -7
- data/spec/mongo/retryable_spec.rb +52 -31
- data/spec/mongo/server/app_metadata_spec.rb +0 -8
- data/spec/mongo/server/connection_auth_spec.rb +5 -2
- data/spec/mongo/server/connection_pool/populator_spec.rb +101 -0
- data/spec/mongo/server/connection_pool_spec.rb +256 -107
- data/spec/mongo/server/connection_spec.rb +22 -33
- data/spec/mongo/server/description_spec.rb +42 -4
- data/spec/mongo/server/monitor/connection_spec.rb +22 -11
- data/spec/mongo/server/monitor_spec.rb +66 -107
- data/spec/mongo/server_spec.rb +82 -60
- data/spec/mongo/session/session_pool_spec.rb +1 -5
- data/spec/mongo/session_spec.rb +0 -4
- data/spec/mongo/socket/ssl_spec.rb +2 -2
- data/spec/mongo/srv/monitor_spec.rb +211 -0
- data/spec/mongo/srv/result_spec.rb +54 -0
- data/spec/mongo/uri/srv_protocol_spec.rb +30 -15
- data/spec/mongo/uri_spec.rb +125 -4
- data/spec/spec_helper.rb +6 -0
- data/spec/spec_tests/auth_spec.rb +39 -0
- data/spec/spec_tests/cmap_spec.rb +55 -8
- data/spec/spec_tests/connection_string_spec.rb +6 -31
- data/spec/spec_tests/data/auth/connection-string.yml +297 -0
- data/spec/spec_tests/data/cmap/pool-checkout-error-closed.yml +4 -1
- data/spec/spec_tests/data/cmap/pool-create-with-options.yml +1 -0
- data/spec/spec_tests/data/command_monitoring/insertMany.yml +1 -1
- data/spec/spec_tests/data/connection_string/invalid-uris.yml +20 -0
- data/spec/spec_tests/data/connection_string/valid-auth.yml +16 -0
- data/spec/spec_tests/data/connection_string/valid-warnings.yml +26 -30
- data/spec/spec_tests/data/transactions/abort.yml +3 -3
- data/spec/spec_tests/data/transactions/error-labels.yml +3 -3
- data/spec/spec_tests/data/transactions_api/callback-retry.yml +3 -3
- data/spec/spec_tests/data/uri_options/auth-options.yml +1 -1
- data/spec/spec_tests/max_staleness_spec.rb +7 -2
- data/spec/spec_tests/retryable_reads_spec.rb +0 -31
- data/spec/spec_tests/sdam_monitoring_spec.rb +12 -12
- data/spec/spec_tests/sdam_spec.rb +4 -7
- data/spec/spec_tests/server_selection_spec.rb +6 -2
- data/spec/spec_tests/transactions_spec.rb +0 -2
- data/spec/spec_tests/uri_options_spec.rb +4 -2
- data/spec/stress/connection_pool_stress_spec.rb +203 -0
- data/spec/stress/connection_pool_timing_spec.rb +181 -0
- data/spec/support/auth.rb +113 -0
- data/spec/support/background_thread_registry.rb +63 -0
- data/spec/support/client_registry.rb +11 -2
- data/spec/support/cluster_config.rb +65 -46
- data/spec/support/cluster_tools.rb +2 -2
- data/spec/support/cmap.rb +13 -14
- data/spec/support/cmap/verifier.rb +4 -5
- data/spec/support/command_monitoring.rb +0 -5
- data/spec/support/common_shortcuts.rb +101 -1
- data/spec/support/constraints.rb +25 -0
- data/spec/support/dns.rb +13 -0
- data/spec/support/event_subscriber.rb +0 -7
- data/spec/support/json_ext_formatter.rb +5 -1
- data/spec/support/lite_constraints.rb +22 -6
- data/spec/support/local_resource_registry.rb +34 -0
- data/spec/support/sdam_monitoring.rb +115 -0
- data/spec/support/spec_config.rb +20 -6
- data/spec/support/spec_setup.rb +2 -2
- data/spec/support/transactions.rb +1 -1
- data/spec/support/transactions/test.rb +1 -1
- data/spec/support/utils.rb +1 -16
- metadata +685 -659
- metadata.gz.sig +0 -0
- data/lib/mongo/event/description_changed.rb +0 -52
- data/spec/integration/bson_symbol_spec.rb +0 -34
- data/spec/integration/crud_spec.rb +0 -45
- data/spec/integration/get_more_spec.rb +0 -32
- data/spec/integration/grid_fs_bucket_spec.rb +0 -48
- data/spec/integration/retryable_errors_spec.rb +0 -265
- data/spec/integration/size_limit_spec.rb~12e1e9c4f... RUBY-2242 Fix zlib compression (#2021) +0 -98
- data/spec/mongo/cursor/builder/op_kill_cursors_spec.rb +0 -56
- data/spec/runners/sdam/verifier.rb +0 -88
data/spec/integration/size_limit_spec.rb~12e1e9c4f... RUBY-2242 Fix zlib compression (#2021)
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'BSON & command size limits' do
|
4
|
-
let(:max_document_size) { 16*1024*1024 }
|
5
|
-
|
6
|
-
before do
|
7
|
-
authorized_collection.delete_many
|
8
|
-
end
|
9
|
-
|
10
|
-
# This test uses a large document that is significantly smaller than the
|
11
|
-
# size limit. It is a basic sanity check.
|
12
|
-
it 'allows user-provided documents to be 15MiB' do
|
13
|
-
document = { key: 'a' * 15*1024*1024, _id: 'foo' }
|
14
|
-
|
15
|
-
authorized_collection.insert_one(document)
|
16
|
-
end
|
17
|
-
|
18
|
-
# This test uses a large document that is significantly larger than the
|
19
|
-
# size limit. It is a basic sanity check.
|
20
|
-
it 'fails single write of oversized documents' do
|
21
|
-
document = { key: 'a' * 17*1024*1024, _id: 'foo' }
|
22
|
-
|
23
|
-
lambda do
|
24
|
-
authorized_collection.insert_one(document)
|
25
|
-
end.should raise_error(Mongo::Error::MaxBSONSize, /The document exceeds maximum allowed BSON object size after serialization/)
|
26
|
-
end
|
27
|
-
|
28
|
-
# This test checks our bulk write splitting when documents are not close
|
29
|
-
# to the limit, but where splitting is definitely required.
|
30
|
-
it 'allows split bulk write of medium sized documents' do
|
31
|
-
# 8 documents of 4 MiB each = 32 MiB total data, should be split over
|
32
|
-
# either 2 or 3 bulk writes depending on how well the driver splits
|
33
|
-
documents = []
|
34
|
-
1.upto(8) do |index|
|
35
|
-
documents << { key: 'a' * 4*1024*1024, _id: "in#{index}" }
|
36
|
-
end
|
37
|
-
|
38
|
-
authorized_collection.insert_many(documents)
|
39
|
-
authorized_collection.count_documents({}).should == 8
|
40
|
-
end
|
41
|
-
|
42
|
-
# This test ensures that document which are too big definitely fail insertion.
|
43
|
-
it 'fails bulk write of oversized documents' do
|
44
|
-
documents = []
|
45
|
-
1.upto(3) do |index|
|
46
|
-
documents << { key: 'a' * 17*1024*1024, _id: "in#{index}" }
|
47
|
-
end
|
48
|
-
|
49
|
-
lambda do
|
50
|
-
authorized_collection.insert_many(documents)
|
51
|
-
end.should raise_error(Mongo::Error::MaxBSONSize, /The document exceeds maximum allowed BSON object size after serialization/)
|
52
|
-
authorized_collection.count_documents({}).should == 0
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'allows user-provided documents to be exactly 16MiB' do
|
56
|
-
# The document must contain the _id field, otherwise the server will
|
57
|
-
# add it which will increase the size of the document as persisted by
|
58
|
-
# the server.
|
59
|
-
document = { key: 'a' * (max_document_size - 28), _id: 'foo' }
|
60
|
-
expect(document.to_bson.length).to eq(max_document_size)
|
61
|
-
|
62
|
-
authorized_collection.insert_one(document)
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'fails on the server when a document larger than 16MiB is inserted' do
|
66
|
-
document = { key: 'a' * (max_document_size - 27), _id: 'foo' }
|
67
|
-
expect(document.to_bson.length).to eq(max_document_size+1)
|
68
|
-
|
69
|
-
lambda do
|
70
|
-
authorized_collection.insert_one(document)
|
71
|
-
end.should raise_error(Mongo::Error::OperationFailure, /object to insert too large/)
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'fails in the driver when a document larger than 16MiB+16KiB is inserted' do
|
75
|
-
document = { key: 'a' * (max_document_size - 27 + 16*1024), _id: 'foo' }
|
76
|
-
expect(document.to_bson.length).to eq(max_document_size+16*1024+1)
|
77
|
-
|
78
|
-
lambda do
|
79
|
-
authorized_collection.insert_one(document)
|
80
|
-
end.should raise_error(Mongo::Error::MaxBSONSize, /The document exceeds maximum allowed BSON object size after serialization/)
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'allows bulk writes of multiple documents of exactly 16 MiB each' do
|
84
|
-
if SpecConfig.instance.compressors
|
85
|
-
pending "RUBY-2234"
|
86
|
-
end
|
87
|
-
|
88
|
-
documents = []
|
89
|
-
1.upto(3) do |index|
|
90
|
-
document = { key: 'a' * (max_document_size - 28), _id: "in#{index}" }
|
91
|
-
expect(document.to_bson.length).to eq(max_document_size)
|
92
|
-
documents << document
|
93
|
-
end
|
94
|
-
|
95
|
-
authorized_collection.insert_many(documents)
|
96
|
-
authorized_collection.count_documents({}).should == 3
|
97
|
-
end
|
98
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mongo::Cursor::Builder::OpKillCursors do
|
4
|
-
|
5
|
-
let(:reply) do
|
6
|
-
Mongo::Protocol::Reply.allocate.tap do |reply|
|
7
|
-
allow(reply).to receive(:cursor_id).and_return(8000)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
let(:result) do
|
12
|
-
Mongo::Operation::Result.new(reply)
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:view) do
|
16
|
-
Mongo::Collection::View.new(
|
17
|
-
authorized_collection,
|
18
|
-
{},
|
19
|
-
tailable: true,
|
20
|
-
max_time_ms: 100
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:cursor) do
|
25
|
-
Mongo::Cursor.new(view, result, authorized_primary)
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:builder) do
|
29
|
-
described_class.new(cursor)
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#specification' do
|
33
|
-
|
34
|
-
let(:specification) do
|
35
|
-
builder.specification
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'includes the cursor ids' do
|
39
|
-
expect(specification[:cursor_ids]).to eq([BSON::Int64.new(8000)])
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'includes the database name' do
|
43
|
-
expect(specification[:db_name]).to eq(SpecConfig.instance.test_db)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'includes the collection name' do
|
47
|
-
expect(specification[:coll_name]).to eq(TEST_COLL)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '.get_cursors_list' do
|
52
|
-
it 'returns integer cursor ids' do
|
53
|
-
expect(described_class.get_cursors_list(builder.specification)).to eq([8000])
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
module Sdam
|
2
|
-
class Verifier
|
3
|
-
include RSpec::Matchers
|
4
|
-
|
5
|
-
def verify_sdam_event(expected_events, actual_events, i)
|
6
|
-
expect(expected_events.length).to be > i
|
7
|
-
expect(actual_events.length).to be > i
|
8
|
-
|
9
|
-
expected_event = expected_events[i]
|
10
|
-
actual_event = actual_events[i]
|
11
|
-
|
12
|
-
actual_event_name = Utils.underscore(actual_event.class.name.sub(/.*::/, ''))
|
13
|
-
actual_event_name = actual_event_name.to_s.sub('topology_changed', 'topology_description_changed') + '_event'
|
14
|
-
expect(actual_event_name).to eq(expected_event.name)
|
15
|
-
|
16
|
-
send("verify_#{expected_event.name}", expected_event, actual_event)
|
17
|
-
end
|
18
|
-
|
19
|
-
def verify_topology_opening_event(expected, actual)
|
20
|
-
expect(actual.topology).not_to be nil
|
21
|
-
end
|
22
|
-
|
23
|
-
def verify_topology_description_changed_event(expected, actual)
|
24
|
-
verify_topology_matches(expected.data['previousDescription'], actual.previous_topology)
|
25
|
-
verify_topology_matches(expected.data['newDescription'], actual.new_topology)
|
26
|
-
end
|
27
|
-
|
28
|
-
def verify_topology_matches(expected, actual)
|
29
|
-
expected_type = ::Mongo::Cluster::Topology.const_get(expected['topologyType'])
|
30
|
-
expect(actual).to be_a(expected_type)
|
31
|
-
|
32
|
-
expect(actual.replica_set_name).to eq(expected['setName'])
|
33
|
-
|
34
|
-
expected['servers'].each do |server|
|
35
|
-
desc = actual.server_descriptions[server['address'].to_s]
|
36
|
-
expect(desc).not_to be nil
|
37
|
-
verify_description_matches(server, desc)
|
38
|
-
end
|
39
|
-
|
40
|
-
actual.server_descriptions.keys.each do |address_str|
|
41
|
-
expect(
|
42
|
-
expected['servers'].any? { |server| server['address'] == address_str }
|
43
|
-
).to be true
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def verify_server_opening_event(expected, actual)
|
48
|
-
expect(actual.address.to_s).to eq(expected.data['address'])
|
49
|
-
end
|
50
|
-
|
51
|
-
def verify_server_description_changed_event(expected, actual)
|
52
|
-
verify_description_matches(expected.data['previousDescription'], actual.previous_description)
|
53
|
-
verify_description_matches(expected.data['newDescription'], actual.new_description)
|
54
|
-
end
|
55
|
-
|
56
|
-
def verify_description_matches(expected, actual)
|
57
|
-
case expected['type']
|
58
|
-
when 'Standalone'
|
59
|
-
expect(actual).to be_standalone
|
60
|
-
when 'RSPrimary'
|
61
|
-
expect(actual).to be_primary
|
62
|
-
when 'RSSecondary'
|
63
|
-
expect(actual).to be_secondary
|
64
|
-
when 'RSArbiter'
|
65
|
-
expect(actual).to be_arbiter
|
66
|
-
when 'Mongos'
|
67
|
-
expect(actual).to be_mongos
|
68
|
-
when 'Unknown', 'PossiblePrimary'
|
69
|
-
expect(actual).to be_unknown
|
70
|
-
when 'RSGhost'
|
71
|
-
expect(actual).to be_ghost
|
72
|
-
when 'RSOther'
|
73
|
-
expect(actual).to be_other
|
74
|
-
end
|
75
|
-
|
76
|
-
expect(actual.address.to_s).to eq(expected['address'])
|
77
|
-
expect(actual.arbiters).to eq(expected['arbiters'])
|
78
|
-
expect(actual.hosts).to eq(expected['hosts'])
|
79
|
-
expect(actual.passives).to eq(expected['passives'])
|
80
|
-
expect(actual.primary_host).to eq(expected['primary'])
|
81
|
-
expect(actual.replica_set_name).to eq(expected['setName'])
|
82
|
-
end
|
83
|
-
|
84
|
-
def verify_server_closed_event(expected, actual)
|
85
|
-
expect(actual.address.to_s).to eq(expected.data['address'])
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|