mongo 2.13.0.beta1 → 2.14.0
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -5
- data/Rakefile +50 -9
- data/lib/mongo.rb +13 -2
- data/lib/mongo/address.rb +1 -1
- data/lib/mongo/address/ipv4.rb +1 -1
- data/lib/mongo/address/ipv6.rb +1 -1
- data/lib/mongo/auth/aws/request.rb +31 -5
- data/lib/mongo/bulk_write.rb +18 -0
- data/lib/mongo/caching_cursor.rb +74 -0
- data/lib/mongo/client.rb +238 -31
- data/lib/mongo/cluster.rb +56 -20
- data/lib/mongo/cluster/sdam_flow.rb +13 -10
- data/lib/mongo/cluster/topology/replica_set_no_primary.rb +3 -2
- data/lib/mongo/cluster/topology/sharded.rb +1 -1
- data/lib/mongo/cluster/topology/single.rb +2 -2
- data/lib/mongo/collection.rb +66 -24
- data/lib/mongo/collection/view.rb +24 -20
- data/lib/mongo/collection/view/aggregation.rb +25 -4
- data/lib/mongo/collection/view/builder/find_command.rb +38 -18
- data/lib/mongo/collection/view/explainable.rb +27 -8
- data/lib/mongo/collection/view/iterable.rb +72 -12
- data/lib/mongo/collection/view/readable.rb +19 -3
- data/lib/mongo/collection/view/writable.rb +55 -5
- data/lib/mongo/crypt/encryption_io.rb +6 -6
- data/lib/mongo/cursor.rb +16 -3
- data/lib/mongo/database.rb +37 -4
- data/lib/mongo/database/view.rb +18 -3
- data/lib/mongo/distinguishing_semaphore.rb +55 -0
- data/lib/mongo/error.rb +5 -0
- data/lib/mongo/error/invalid_read_concern.rb +28 -0
- data/lib/mongo/error/invalid_server_auth_host.rb +22 -0
- data/lib/mongo/error/invalid_session.rb +2 -1
- data/lib/mongo/error/operation_failure.rb +11 -5
- data/lib/mongo/error/server_certificate_revoked.rb +22 -0
- data/lib/mongo/error/sessions_not_supported.rb +35 -0
- data/lib/mongo/error/unsupported_option.rb +14 -12
- data/lib/mongo/event/base.rb +6 -0
- data/lib/mongo/grid/file.rb +5 -0
- data/lib/mongo/grid/file/chunk.rb +2 -0
- data/lib/mongo/grid/fs_bucket.rb +15 -13
- data/lib/mongo/grid/stream/write.rb +9 -3
- data/lib/mongo/index/view.rb +3 -0
- data/lib/mongo/lint.rb +2 -1
- data/lib/mongo/logger.rb +3 -3
- data/lib/mongo/monitoring.rb +38 -0
- data/lib/mongo/monitoring/command_log_subscriber.rb +10 -2
- data/lib/mongo/monitoring/event/command_failed.rb +11 -0
- data/lib/mongo/monitoring/event/command_started.rb +37 -2
- data/lib/mongo/monitoring/event/command_succeeded.rb +11 -0
- data/lib/mongo/monitoring/event/server_closed.rb +1 -1
- data/lib/mongo/monitoring/event/server_description_changed.rb +27 -4
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +9 -2
- data/lib/mongo/monitoring/event/server_heartbeat_started.rb +9 -2
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +9 -2
- data/lib/mongo/monitoring/event/server_opening.rb +1 -1
- data/lib/mongo/monitoring/event/topology_changed.rb +1 -1
- data/lib/mongo/monitoring/event/topology_closed.rb +1 -1
- data/lib/mongo/monitoring/event/topology_opening.rb +1 -1
- data/lib/mongo/monitoring/publishable.rb +6 -3
- data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +9 -1
- data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +1 -1
- data/lib/mongo/operation.rb +2 -0
- data/lib/mongo/operation/aggregate/result.rb +9 -8
- data/lib/mongo/operation/collections_info/command.rb +5 -0
- data/lib/mongo/operation/collections_info/result.rb +18 -1
- data/lib/mongo/operation/delete/bulk_result.rb +2 -0
- data/lib/mongo/operation/delete/result.rb +3 -0
- data/lib/mongo/operation/explain/command.rb +4 -0
- data/lib/mongo/operation/explain/legacy.rb +4 -0
- data/lib/mongo/operation/explain/op_msg.rb +6 -0
- data/lib/mongo/operation/explain/result.rb +3 -0
- data/lib/mongo/operation/find/legacy/result.rb +2 -0
- data/lib/mongo/operation/find/result.rb +13 -0
- data/lib/mongo/operation/get_more/result.rb +3 -0
- data/lib/mongo/operation/indexes/result.rb +5 -0
- data/lib/mongo/operation/insert/bulk_result.rb +5 -0
- data/lib/mongo/operation/insert/result.rb +5 -0
- data/lib/mongo/operation/list_collections/result.rb +5 -0
- data/lib/mongo/operation/map_reduce/result.rb +10 -0
- data/lib/mongo/operation/parallel_scan/result.rb +4 -0
- data/lib/mongo/operation/result.rb +35 -6
- data/lib/mongo/operation/shared/bypass_document_validation.rb +1 -0
- data/lib/mongo/operation/shared/causal_consistency_supported.rb +1 -0
- data/lib/mongo/operation/shared/collections_info_or_list_collections.rb +2 -0
- data/lib/mongo/operation/shared/executable.rb +1 -0
- data/lib/mongo/operation/shared/idable.rb +2 -1
- data/lib/mongo/operation/shared/limited.rb +1 -0
- data/lib/mongo/operation/shared/object_id_generator.rb +1 -0
- data/lib/mongo/operation/shared/result/aggregatable.rb +1 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +1 -0
- data/lib/mongo/operation/shared/specifiable.rb +1 -0
- data/lib/mongo/operation/shared/write.rb +1 -0
- data/lib/mongo/operation/shared/write_concern_supported.rb +1 -0
- data/lib/mongo/operation/update/legacy/result.rb +7 -0
- data/lib/mongo/operation/update/result.rb +8 -0
- data/lib/mongo/operation/users_info/result.rb +3 -0
- data/lib/mongo/protocol/message.rb +47 -10
- data/lib/mongo/protocol/msg.rb +34 -1
- data/lib/mongo/protocol/query.rb +36 -0
- data/lib/mongo/protocol/serializers.rb +5 -2
- data/lib/mongo/query_cache.rb +242 -0
- data/lib/mongo/retryable.rb +8 -1
- data/lib/mongo/server.rb +15 -4
- data/lib/mongo/server/app_metadata.rb +27 -3
- data/lib/mongo/server/connection.rb +4 -4
- data/lib/mongo/server/connection_base.rb +38 -12
- data/lib/mongo/server/connection_common.rb +2 -2
- data/lib/mongo/server/connection_pool.rb +3 -0
- data/lib/mongo/server/description.rb +13 -1
- data/lib/mongo/server/monitor.rb +76 -44
- data/lib/mongo/server/monitor/connection.rb +57 -9
- data/lib/mongo/server/pending_connection.rb +14 -4
- data/lib/mongo/server/push_monitor.rb +173 -0
- data/{spec/runners/transactions/context.rb → lib/mongo/server/push_monitor/connection.rb} +9 -14
- data/lib/mongo/server_selector.rb +0 -1
- data/lib/mongo/server_selector/base.rb +583 -1
- data/lib/mongo/server_selector/nearest.rb +1 -6
- data/lib/mongo/server_selector/primary.rb +1 -6
- data/lib/mongo/server_selector/primary_preferred.rb +7 -10
- data/lib/mongo/server_selector/secondary.rb +1 -6
- data/lib/mongo/server_selector/secondary_preferred.rb +1 -7
- data/lib/mongo/session.rb +7 -1
- data/lib/mongo/socket.rb +26 -12
- data/lib/mongo/socket/ocsp_cache.rb +97 -0
- data/lib/mongo/socket/ocsp_verifier.rb +368 -0
- data/lib/mongo/socket/ssl.rb +46 -25
- data/lib/mongo/socket/tcp.rb +1 -1
- data/lib/mongo/srv/monitor.rb +7 -13
- data/lib/mongo/srv/resolver.rb +14 -10
- data/lib/mongo/timeout.rb +2 -0
- data/lib/mongo/topology_version.rb +9 -0
- data/lib/mongo/uri.rb +21 -390
- data/lib/mongo/uri/options_mapper.rb +582 -0
- data/lib/mongo/uri/srv_protocol.rb +3 -2
- data/lib/mongo/utils.rb +73 -0
- data/lib/mongo/version.rb +1 -1
- data/spec/NOTES.aws-auth.md +12 -7
- data/spec/README.aws-auth.md +2 -2
- data/spec/README.md +63 -1
- data/spec/integration/awaited_ismaster_spec.rb +28 -0
- data/spec/integration/bson_symbol_spec.rb +4 -2
- data/spec/integration/bulk_write_spec.rb +67 -0
- data/spec/integration/change_stream_examples_spec.rb +6 -2
- data/spec/integration/change_stream_spec.rb +1 -1
- data/spec/integration/check_clean_slate_spec.rb +16 -0
- data/spec/integration/client_authentication_options_spec.rb +92 -28
- data/spec/integration/client_construction_spec.rb +1 -0
- data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +9 -5
- data/spec/integration/connect_single_rs_name_spec.rb +5 -2
- data/spec/integration/connection_pool_populator_spec.rb +4 -2
- data/spec/integration/connection_spec.rb +7 -4
- data/spec/integration/crud_spec.rb +4 -4
- data/spec/integration/cursor_reaping_spec.rb +54 -18
- data/spec/integration/docs_examples_spec.rb +6 -0
- data/spec/integration/fork_reconnect_spec.rb +56 -1
- data/spec/integration/grid_fs_bucket_spec.rb +48 -0
- data/spec/integration/heartbeat_events_spec.rb +4 -23
- data/spec/integration/ocsp_connectivity_spec.rb +26 -0
- data/spec/integration/ocsp_verifier_cache_spec.rb +188 -0
- data/spec/integration/ocsp_verifier_spec.rb +334 -0
- data/spec/integration/query_cache_spec.rb +1045 -0
- data/spec/integration/query_cache_transactions_spec.rb +190 -0
- data/spec/integration/read_concern_spec.rb +1 -1
- data/spec/integration/retryable_errors_spec.rb +1 -1
- data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +1 -0
- data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +4 -2
- data/spec/integration/retryable_writes/shared/performs_modern_retries.rb +3 -3
- data/spec/integration/retryable_writes/shared/performs_no_retries.rb +2 -2
- data/spec/integration/sdam_error_handling_spec.rb +122 -15
- data/spec/integration/sdam_events_spec.rb +80 -6
- data/spec/integration/sdam_prose_spec.rb +64 -0
- data/spec/integration/server_monitor_spec.rb +25 -1
- data/spec/integration/server_selection_spec.rb +36 -0
- data/spec/integration/size_limit_spec.rb +23 -5
- data/spec/integration/srv_monitoring_spec.rb +38 -3
- data/spec/integration/srv_spec.rb +56 -0
- data/spec/integration/ssl_uri_options_spec.rb +2 -2
- data/spec/integration/transactions_examples_spec.rb +17 -7
- data/spec/integration/zlib_compression_spec.rb +25 -0
- data/spec/lite_spec_helper.rb +20 -9
- data/spec/mongo/address_spec.rb +1 -1
- data/spec/mongo/auth/aws/request_region_spec.rb +42 -0
- data/spec/mongo/auth/aws/request_spec.rb +76 -0
- data/spec/mongo/auth/scram_spec.rb +1 -1
- data/spec/mongo/auth/user_spec.rb +1 -1
- data/spec/mongo/bulk_write_spec.rb +2 -2
- data/spec/mongo/caching_cursor_spec.rb +70 -0
- data/spec/mongo/client_construction_spec.rb +386 -3
- data/spec/mongo/client_encryption_spec.rb +16 -10
- data/spec/mongo/client_spec.rb +85 -3
- data/spec/mongo/cluster/topology/replica_set_spec.rb +53 -10
- data/spec/mongo/cluster/topology/sharded_spec.rb +1 -1
- data/spec/mongo/cluster/topology/single_spec.rb +19 -8
- data/spec/mongo/cluster/topology/unknown_spec.rb +1 -1
- data/spec/mongo/cluster/topology_spec.rb +1 -1
- data/spec/mongo/cluster_spec.rb +37 -35
- data/spec/mongo/collection/view/change_stream_resume_spec.rb +7 -7
- data/spec/mongo/collection/view/explainable_spec.rb +87 -4
- data/spec/mongo/collection/view/map_reduce_spec.rb +2 -0
- data/spec/mongo/collection/view/readable_spec.rb +36 -0
- data/spec/mongo/collection_spec.rb +572 -0
- data/spec/mongo/crypt/auto_decryption_context_spec.rb +1 -1
- data/spec/mongo/crypt/auto_encryption_context_spec.rb +1 -1
- 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/explicit_decryption_context_spec.rb +1 -1
- data/spec/mongo/crypt/explicit_encryption_context_spec.rb +1 -1
- data/spec/mongo/crypt/status_spec.rb +1 -6
- data/spec/mongo/database_spec.rb +353 -8
- data/spec/mongo/distinguishing_semaphore_spec.rb +63 -0
- data/spec/mongo/error/no_server_available_spec.rb +1 -1
- data/spec/mongo/error/operation_failure_spec.rb +40 -0
- data/spec/mongo/index/view_spec.rb +148 -2
- data/spec/mongo/logger_spec.rb +13 -11
- data/spec/mongo/monitoring/event/server_closed_spec.rb +1 -1
- data/spec/mongo/monitoring/event/server_description_changed_spec.rb +1 -4
- 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/protocol/msg_spec.rb +10 -0
- data/spec/mongo/query_cache_spec.rb +280 -0
- data/spec/mongo/semaphore_spec.rb +51 -0
- data/spec/mongo/server/app_metadata_shared.rb +82 -2
- data/spec/mongo/server/connection_auth_spec.rb +2 -2
- data/spec/mongo/server/connection_pool_spec.rb +7 -3
- data/spec/mongo/server/connection_spec.rb +15 -8
- data/spec/mongo/server/description_spec.rb +18 -0
- data/spec/mongo/server_selector/nearest_spec.rb +23 -23
- data/spec/mongo/server_selector/primary_preferred_spec.rb +26 -26
- data/spec/mongo/server_selector/primary_spec.rb +9 -9
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +22 -22
- data/spec/mongo/server_selector/secondary_spec.rb +18 -18
- data/spec/mongo/server_selector_spec.rb +6 -6
- data/spec/mongo/session_spec.rb +35 -0
- data/spec/mongo/socket/ssl_spec.rb +4 -4
- data/spec/mongo/socket_spec.rb +1 -1
- data/spec/mongo/uri/srv_protocol_spec.rb +64 -33
- data/spec/mongo/uri_option_parsing_spec.rb +11 -11
- data/spec/mongo/uri_spec.rb +68 -41
- data/spec/mongo/utils_spec.rb +39 -0
- data/spec/runners/auth.rb +3 -0
- data/spec/runners/change_streams/test.rb +3 -3
- data/spec/runners/cmap.rb +1 -1
- data/spec/runners/command_monitoring.rb +3 -34
- data/spec/runners/connection_string.rb +35 -124
- data/spec/runners/crud/context.rb +9 -5
- data/spec/runners/crud/operation.rb +59 -27
- data/spec/runners/crud/spec.rb +0 -8
- data/spec/runners/crud/test.rb +1 -1
- data/spec/runners/crud/test_base.rb +0 -19
- data/spec/runners/sdam.rb +2 -2
- data/spec/runners/server_selection.rb +242 -28
- data/spec/runners/transactions.rb +12 -12
- data/spec/runners/transactions/operation.rb +151 -25
- data/spec/runners/transactions/test.rb +62 -18
- 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/spec_tests/cmap_spec.rb +7 -3
- data/spec/spec_tests/command_monitoring_spec.rb +22 -12
- data/spec/spec_tests/crud_spec.rb +1 -1
- data/spec/spec_tests/data/change_streams/change-streams-errors.yml +4 -9
- data/spec/spec_tests/data/change_streams/change-streams-resume-whitelist.yml +66 -0
- data/spec/spec_tests/data/change_streams/change-streams.yml +0 -1
- data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +6 -2
- data/spec/spec_tests/data/cmap/pool-create-min-size.yml +3 -0
- data/spec/spec_tests/data/connection_string/valid-warnings.yml +24 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/MaxStalenessTooSmall.yml +15 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +4 -3
- data/spec/spec_tests/data/max_staleness/Unknown/SmallMaxStaleness.yml +1 -0
- data/spec/spec_tests/data/sdam_integration/cancel-server-check.yml +96 -0
- data/spec/spec_tests/data/sdam_integration/connectTimeoutMS.yml +88 -0
- data/spec/spec_tests/data/sdam_integration/find-network-error.yml +83 -0
- data/spec/spec_tests/data/sdam_integration/find-shutdown-error.yml +116 -0
- data/spec/spec_tests/data/sdam_integration/insert-network-error.yml +86 -0
- data/spec/spec_tests/data/sdam_integration/insert-shutdown-error.yml +115 -0
- data/spec/spec_tests/data/sdam_integration/isMaster-command-error.yml +168 -0
- data/spec/spec_tests/data/sdam_integration/isMaster-network-error.yml +162 -0
- data/spec/spec_tests/data/sdam_integration/isMaster-timeout.yml +229 -0
- data/spec/spec_tests/data/sdam_integration/rediscover-quickly-after-step-down.yml +87 -0
- data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +1 -3
- data/spec/spec_tests/data/sdam_monitoring/standalone.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_suppress_equal_description_changes.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_to_rs_with_me_mismatch.yml +2 -2
- data/spec/spec_tests/data/uri_options/auth-options.yml +25 -0
- data/spec/spec_tests/data/uri_options/compression-options.yml +6 -3
- data/spec/spec_tests/data/uri_options/read-preference-options.yml +24 -0
- data/spec/spec_tests/data/uri_options/ruby-connection-options.yml +1 -0
- data/spec/spec_tests/data/uri_options/tls-options.yml +160 -4
- data/spec/spec_tests/dns_seedlist_discovery_spec.rb +9 -1
- data/spec/spec_tests/max_staleness_spec.rb +4 -142
- data/spec/spec_tests/retryable_reads_spec.rb +2 -2
- data/spec/spec_tests/sdam_integration_spec.rb +13 -0
- data/spec/spec_tests/sdam_monitoring_spec.rb +1 -2
- data/spec/spec_tests/server_selection_spec.rb +4 -116
- data/spec/spec_tests/uri_options_spec.rb +31 -33
- data/spec/stress/cleanup_spec.rb +17 -2
- data/spec/stress/connection_pool_stress_spec.rb +10 -8
- data/spec/stress/fork_reconnect_stress_spec.rb +1 -1
- data/spec/support/certificates/atlas-ocsp-ca.crt +28 -0
- data/spec/support/certificates/atlas-ocsp.crt +41 -0
- data/spec/support/client_registry.rb +1 -0
- data/spec/support/client_registry_macros.rb +11 -2
- data/spec/support/cluster_config.rb +4 -0
- data/spec/support/common_shortcuts.rb +45 -0
- data/spec/support/constraints.rb +6 -253
- data/spec/support/event_subscriber.rb +123 -33
- data/spec/support/keyword_struct.rb +26 -0
- data/spec/support/matchers.rb +16 -0
- data/spec/support/ocsp +1 -0
- data/spec/support/session_registry.rb +52 -0
- data/spec/support/shared/server_selector.rb +13 -1
- data/spec/support/spec_config.rb +60 -13
- data/spec/support/spec_setup.rb +1 -1
- data/spec/support/utils.rb +84 -1
- metadata +1027 -937
- metadata.gz.sig +0 -0
- data/lib/mongo/server_selector/selectable.rb +0 -560
- data/spec/runners/sdam_monitoring.rb +0 -89
- data/spec/support/lite_constraints.rb +0 -141
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'runners/sdam_monitoring'
|
3
2
|
|
4
3
|
describe 'SDAM events' do
|
5
|
-
let(:subscriber) {
|
4
|
+
let(:subscriber) { EventSubscriber.new }
|
6
5
|
|
7
6
|
describe 'server closed event' do
|
8
7
|
it 'is published when client is closed' do
|
@@ -12,11 +11,11 @@ describe 'SDAM events' do
|
|
12
11
|
|
13
12
|
# get the client connected
|
14
13
|
client.database.command(ismaster: 1)
|
15
|
-
expect(subscriber.
|
14
|
+
expect(subscriber.succeeded_events).to be_empty
|
16
15
|
|
17
16
|
client.close
|
18
17
|
|
19
|
-
expect(subscriber.
|
18
|
+
expect(subscriber.succeeded_events).not_to be_empty
|
20
19
|
event = subscriber.first_event('server_closed_event')
|
21
20
|
expect(event).not_to be_nil
|
22
21
|
end
|
@@ -30,15 +29,90 @@ describe 'SDAM events' do
|
|
30
29
|
|
31
30
|
# get the client connected
|
32
31
|
client.database.command(ismaster: 1)
|
33
|
-
expect(subscriber.
|
32
|
+
expect(subscriber.succeeded_events).to be_empty
|
34
33
|
|
35
34
|
client.close
|
36
35
|
|
37
|
-
expect(subscriber.
|
36
|
+
expect(subscriber.succeeded_events).not_to be_empty
|
38
37
|
event = subscriber.first_event('topology_closed_event')
|
39
38
|
expect(event).not_to be_nil
|
40
39
|
|
41
40
|
expect(event.topology).to eql(client.cluster.topology)
|
42
41
|
end
|
43
42
|
end
|
43
|
+
|
44
|
+
describe 'heartbeat event' do
|
45
|
+
require_topology :single
|
46
|
+
|
47
|
+
context 'pre-4.4 servers' do
|
48
|
+
max_server_version '4.2'
|
49
|
+
|
50
|
+
let(:client) do
|
51
|
+
new_local_client(SpecConfig.instance.addresses,
|
52
|
+
# Heartbeat interval is bound by 500 ms
|
53
|
+
SpecConfig.instance.test_options.merge(heartbeat_frequency: 0.5),
|
54
|
+
).tap do |client|
|
55
|
+
client.subscribe(Mongo::Monitoring::SERVER_HEARTBEAT, subscriber)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'is published every heartbeat interval' do
|
60
|
+
client
|
61
|
+
sleep 4
|
62
|
+
client.close
|
63
|
+
|
64
|
+
started_events = subscriber.select_started_events(Mongo::Monitoring::Event::ServerHeartbeatStarted)
|
65
|
+
# Expect about 8 events, maybe 9 or 7
|
66
|
+
started_events.length.should >= 6
|
67
|
+
started_events.length.should <= 10
|
68
|
+
|
69
|
+
succeeded_events = subscriber.select_succeeded_events(Mongo::Monitoring::Event::ServerHeartbeatSucceeded)
|
70
|
+
# Since we gracefully close the client, we expect each heartbeat
|
71
|
+
# to complete.
|
72
|
+
started_events.length.should > 1
|
73
|
+
(succeeded_events.length-1..succeeded_events.length).should include(started_events.length)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context '4.4+ servers' do
|
78
|
+
min_server_fcv '4.4'
|
79
|
+
|
80
|
+
let(:client) do
|
81
|
+
new_local_client(SpecConfig.instance.addresses,
|
82
|
+
# Heartbeat interval is bound by 500 ms
|
83
|
+
SpecConfig.instance.test_options.merge(heartbeat_frequency: 0.5),
|
84
|
+
).tap do |client|
|
85
|
+
client.subscribe(Mongo::Monitoring::SERVER_HEARTBEAT, subscriber)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'is published up to twice every heartbeat interval' do
|
90
|
+
client
|
91
|
+
sleep 3
|
92
|
+
client.close
|
93
|
+
|
94
|
+
events = subscriber.select_started_events(Mongo::Monitoring::Event::ServerHeartbeatStarted)
|
95
|
+
# We could have up to 16 events and should have no fewer than 8 events.
|
96
|
+
# Whenever an awaited ismaster succeeds while the regular monitor is
|
97
|
+
# waiting, the regular monitor's next scan is pushed forward.
|
98
|
+
events.length.should >= 6
|
99
|
+
events.length.should <= 18
|
100
|
+
(started_awaited = events.select(&:awaited?)).should_not be_empty
|
101
|
+
(started_regular = events.reject(&:awaited?)).should_not be_empty
|
102
|
+
|
103
|
+
events = subscriber.select_succeeded_events(Mongo::Monitoring::Event::ServerHeartbeatSucceeded)
|
104
|
+
events.length.should >= 6
|
105
|
+
events.length.should <= 18
|
106
|
+
(succeeded_awaited = events.select(&:awaited?)).should_not be_empty
|
107
|
+
(succeeded_regular = events.reject(&:awaited?)).should_not be_empty
|
108
|
+
|
109
|
+
# There may be in-flight ismasters that don't complete, both
|
110
|
+
# regular and awaited.
|
111
|
+
started_awaited.length.should > 1
|
112
|
+
(succeeded_awaited.length-1..succeeded_awaited.length).should include(started_awaited.length)
|
113
|
+
started_regular.length.should > 1
|
114
|
+
(succeeded_regular.length-1..succeeded_regular.length).should include(started_regular.length)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
44
118
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'SDAM prose tests' do
|
4
|
+
# The "streaming protocol tests" are covered by the tests in
|
5
|
+
# sdam_events_spec.rb.
|
6
|
+
|
7
|
+
describe 'RTT tests' do
|
8
|
+
min_server_fcv '4.4'
|
9
|
+
require_topology :single
|
10
|
+
|
11
|
+
let(:subscriber) { EventSubscriber.new }
|
12
|
+
|
13
|
+
let(:client) do
|
14
|
+
new_local_client(SpecConfig.instance.addresses,
|
15
|
+
# Heartbeat interval is bound by 500 ms
|
16
|
+
SpecConfig.instance.test_options.merge(
|
17
|
+
heartbeat_frequency: 0.5,
|
18
|
+
app_name: 'streamingRttTest',
|
19
|
+
),
|
20
|
+
).tap do |client|
|
21
|
+
client.subscribe(Mongo::Monitoring::SERVER_HEARTBEAT, subscriber)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'updates RTT' do
|
26
|
+
server = client.cluster.next_primary
|
27
|
+
|
28
|
+
sleep 2
|
29
|
+
|
30
|
+
events = subscriber.select_succeeded_events(Mongo::Monitoring::Event::ServerHeartbeatSucceeded)
|
31
|
+
events.each do |event|
|
32
|
+
event.round_trip_time.should be_a(Numeric)
|
33
|
+
event.round_trip_time.should > 0
|
34
|
+
end
|
35
|
+
|
36
|
+
root_authorized_client.use('admin').database.command(
|
37
|
+
configureFailPoint: 'failCommand',
|
38
|
+
mode: {times: 1000},
|
39
|
+
data: {
|
40
|
+
failCommands: ["isMaster"],
|
41
|
+
blockConnection: true,
|
42
|
+
blockTimeMS: 500,
|
43
|
+
appName: "streamingRttTest",
|
44
|
+
},
|
45
|
+
)
|
46
|
+
|
47
|
+
deadline = Time.now + 10
|
48
|
+
loop do
|
49
|
+
if server.average_round_trip_time > 0.25
|
50
|
+
break
|
51
|
+
end
|
52
|
+
if Time.now >= deadline
|
53
|
+
raise "Failed to witness RTT growing to >= 250 ms in 10 seconds"
|
54
|
+
end
|
55
|
+
sleep 0.2
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
after do
|
60
|
+
root_authorized_client.use('admin').database.command(
|
61
|
+
configureFailPoint: 'failCommand', mode: 'off')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -5,7 +5,11 @@ describe 'Server::Monitor' do
|
|
5
5
|
let(:client) do
|
6
6
|
new_local_client([ClusterConfig.instance.primary_address_str],
|
7
7
|
SpecConfig.instance.test_options.merge(SpecConfig.instance.auth_options.merge(
|
8
|
-
|
8
|
+
monitor_options)))
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:monitor_options) do
|
12
|
+
{heartbeat_frequency: 1}
|
9
13
|
end
|
10
14
|
|
11
15
|
it 'refreshes server descriptions in background', retry: 3 do
|
@@ -25,4 +29,24 @@ describe 'Server::Monitor' do
|
|
25
29
|
|
26
30
|
expect(server.description).not_to be_unknown
|
27
31
|
end
|
32
|
+
|
33
|
+
context 'server-pushed ismaster' do
|
34
|
+
min_server_fcv '4.4'
|
35
|
+
require_topology :replica_set
|
36
|
+
|
37
|
+
let(:monitor_options) do
|
38
|
+
{heartbeat_frequency: 20}
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'updates server description' do
|
42
|
+
starting_primary_address = client.cluster.next_primary.address
|
43
|
+
|
44
|
+
ClusterTools.instance.step_down
|
45
|
+
|
46
|
+
sleep 2
|
47
|
+
|
48
|
+
new_primary_address = client.cluster.next_primary.address
|
49
|
+
new_primary_address.should_not == starting_primary_address
|
50
|
+
end
|
51
|
+
end
|
28
52
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Server selection' do
|
4
|
+
context 'replica set' do
|
5
|
+
require_topology :replica_set
|
6
|
+
# 2.6 server does not provide replSetGetConfig and hence we cannot add
|
7
|
+
# the tags to the members.
|
8
|
+
min_server_version '3.0'
|
9
|
+
|
10
|
+
context 'when mixed case tag names are used' do
|
11
|
+
# For simplicity this test assumes our Evergreen configuration:
|
12
|
+
# nodes are started from port 27017 onwards and there are more than
|
13
|
+
# one of them.
|
14
|
+
|
15
|
+
let(:desired_index) do
|
16
|
+
if authorized_client.cluster.next_primary.address.port == 27017
|
17
|
+
1
|
18
|
+
else
|
19
|
+
0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:client) do
|
24
|
+
new_local_client(SpecConfig.instance.addresses,
|
25
|
+
SpecConfig.instance.authorized_test_options.merge(
|
26
|
+
server_selection_timeout: 4,
|
27
|
+
read: {mode: :secondary, tag_sets: [nodeIndex: desired_index.to_s]},
|
28
|
+
))
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'selects the server' do
|
32
|
+
client['nonexistent'].count.should == 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -36,7 +36,7 @@ describe 'BSON & command size limits' do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
authorized_collection.insert_many(documents)
|
39
|
-
authorized_collection.count_documents
|
39
|
+
authorized_collection.count_documents.should == 8
|
40
40
|
end
|
41
41
|
|
42
42
|
# This test ensures that document which are too big definitely fail insertion.
|
@@ -49,7 +49,7 @@ describe 'BSON & command size limits' do
|
|
49
49
|
lambda do
|
50
50
|
authorized_collection.insert_many(documents)
|
51
51
|
end.should raise_error(Mongo::Error::MaxBSONSize, /The document exceeds maximum allowed BSON object size after serialization/)
|
52
|
-
authorized_collection.count_documents
|
52
|
+
authorized_collection.count_documents.should == 0
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'allows user-provided documents to be exactly 16MiB' do
|
@@ -62,13 +62,31 @@ describe 'BSON & command size limits' do
|
|
62
62
|
authorized_collection.insert_one(document)
|
63
63
|
end
|
64
64
|
|
65
|
-
it 'fails on the
|
65
|
+
it 'fails on the driver when a document larger than 16MiB is inserted' do
|
66
66
|
document = { key: 'a' * (max_document_size - 27), _id: 'foo' }
|
67
67
|
expect(document.to_bson.length).to eq(max_document_size+1)
|
68
68
|
|
69
69
|
lambda do
|
70
70
|
authorized_collection.insert_one(document)
|
71
|
-
end.should raise_error(Mongo::Error::
|
71
|
+
end.should raise_error(Mongo::Error::MaxBSONSize, /The document exceeds maximum allowed BSON object size after serialization/)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'fails on the driver when an update larger than 16MiB is performed' do
|
75
|
+
document = { key: 'a' * (max_document_size - 14) }
|
76
|
+
expect(document.to_bson.length).to eq(max_document_size+1)
|
77
|
+
|
78
|
+
lambda do
|
79
|
+
authorized_collection.update_one({ _id: 'foo' }, document)
|
80
|
+
end.should raise_error(Mongo::Error::MaxBSONSize, /The document exceeds maximum allowed BSON object size after serialization/)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'fails on the driver when an delete larger than 16MiB is performed' do
|
84
|
+
document = { key: 'a' * (max_document_size - 14) }
|
85
|
+
expect(document.to_bson.length).to eq(max_document_size+1)
|
86
|
+
|
87
|
+
lambda do
|
88
|
+
authorized_collection.delete_one(document)
|
89
|
+
end.should raise_error(Mongo::Error::MaxBSONSize, /The document exceeds maximum allowed BSON object size after serialization/)
|
72
90
|
end
|
73
91
|
|
74
92
|
it 'fails in the driver when a document larger than 16MiB+16KiB is inserted' do
|
@@ -89,6 +107,6 @@ describe 'BSON & command size limits' do
|
|
89
107
|
end
|
90
108
|
|
91
109
|
authorized_collection.insert_many(documents)
|
92
|
-
authorized_collection.count_documents
|
110
|
+
authorized_collection.count_documents.should == 3
|
93
111
|
end
|
94
112
|
end
|
@@ -76,6 +76,37 @@ describe 'SRV Monitoring' do
|
|
76
76
|
require 'support/dns'
|
77
77
|
end
|
78
78
|
|
79
|
+
around do |example|
|
80
|
+
# Speed up the tests by listening on the fake ports we are using.
|
81
|
+
done = false
|
82
|
+
|
83
|
+
servers = []
|
84
|
+
threads = [27998, 27999].map do |port|
|
85
|
+
Thread.new do
|
86
|
+
server = TCPServer.open(port)
|
87
|
+
servers << server
|
88
|
+
begin
|
89
|
+
loop do
|
90
|
+
break if done
|
91
|
+
server.accept.close rescue nil
|
92
|
+
end
|
93
|
+
ensure
|
94
|
+
server.close
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
begin
|
100
|
+
example.run
|
101
|
+
ensure
|
102
|
+
done = true
|
103
|
+
servers.map(&:close)
|
104
|
+
|
105
|
+
threads.map(&:kill)
|
106
|
+
threads.map(&:join)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
79
110
|
let(:uri) do
|
80
111
|
"mongodb+srv://test-fake.test.build.10gen.cc/?tls=#{SpecConfig.instance.ssl?}&tlsInsecure=true"
|
81
112
|
end
|
@@ -88,11 +119,15 @@ describe 'SRV Monitoring' do
|
|
88
119
|
new_local_client(uri,
|
89
120
|
SpecConfig.instance.ssl_options.merge(
|
90
121
|
server_selection_timeout: 3.16,
|
91
|
-
|
122
|
+
socket_timeout: 8.11,
|
92
123
|
connect_timeout: 8.12,
|
93
124
|
resolv_options: {
|
94
|
-
|
95
|
-
|
125
|
+
# Using localhost instead of 127.0.0.1 here causes Ruby's resolv
|
126
|
+
# client to drop responses.
|
127
|
+
nameserver: '127.0.0.1',
|
128
|
+
# TODO figure out why the address & port here need to be given
|
129
|
+
# twice - if given once, DNS resolution fails.
|
130
|
+
nameserver_port: [['127.0.0.1', 5300], ['127.0.0.1', 5300]],
|
96
131
|
},
|
97
132
|
logger: logger,
|
98
133
|
),
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'SRV lookup' do
|
4
|
+
context 'end to end' do
|
5
|
+
|
6
|
+
# JRuby apparently does not implement non-blocking UDP I/O which is used
|
7
|
+
# by RubyDNS:
|
8
|
+
# NotImplementedError: recvmsg_nonblock is not implemented
|
9
|
+
fails_on_jruby
|
10
|
+
|
11
|
+
before(:all) do
|
12
|
+
require 'support/dns'
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:uri) do
|
16
|
+
"mongodb+srv://test-fake.test.build.10gen.cc/?tls=#{SpecConfig.instance.ssl?}&tlsInsecure=true"
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:client) do
|
20
|
+
new_local_client(uri,
|
21
|
+
SpecConfig.instance.ssl_options.merge(
|
22
|
+
server_selection_timeout: 3.16,
|
23
|
+
timeout: 4.11,
|
24
|
+
connect_timeout: 4.12,
|
25
|
+
resolv_options: {
|
26
|
+
nameserver: 'localhost',
|
27
|
+
nameserver_port: [['localhost', 5300], ['127.0.0.1', 5300]],
|
28
|
+
},
|
29
|
+
),
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'DNS resolver not responding' do
|
34
|
+
it 'fails to create client' do
|
35
|
+
lambda do
|
36
|
+
client
|
37
|
+
end.should raise_error(Mongo::Error::NoSRVRecords, /The DNS query returned no SRV records for 'test-fake.test.build.10gen.cc'/)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'times out in connect_timeout' do
|
41
|
+
start_time = Time.now
|
42
|
+
|
43
|
+
lambda do
|
44
|
+
client
|
45
|
+
end.should raise_error(Mongo::Error::NoSRVRecords)
|
46
|
+
|
47
|
+
elapsed_time = Time.now - start_time
|
48
|
+
elapsed_time.should > 4
|
49
|
+
# The number of queries performed depends on local DNS search suffixes,
|
50
|
+
# therefore we cannot reliably assert how long it would take for this
|
51
|
+
# resolution to time out.
|
52
|
+
#elapsed_time.should < 8
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -20,6 +20,6 @@ describe 'SSL connections with URI options' do
|
|
20
20
|
|
21
21
|
it 'successfully connects and runs an operation' do
|
22
22
|
client = new_local_client(uri)
|
23
|
-
expect { client[:foo].count_documents
|
23
|
+
expect { client[:foo].count_documents }.not_to raise_error
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
@@ -4,28 +4,42 @@ describe 'Transactions examples' do
|
|
4
4
|
require_wired_tiger
|
5
5
|
require_transaction_support
|
6
6
|
|
7
|
+
let(:client) do
|
8
|
+
authorized_client.with(read_concern: {level: :majority}, write: {w: :majority})
|
9
|
+
end
|
10
|
+
|
7
11
|
let(:hr) do
|
8
|
-
|
12
|
+
client.use(:hr).database
|
9
13
|
end
|
10
14
|
|
11
15
|
let(:reporting) do
|
12
|
-
|
16
|
+
client.use(:reporting).database
|
13
17
|
end
|
14
18
|
|
15
19
|
before(:each) do
|
16
20
|
hr[:employees].insert_one(employee: 3, status: 'Active')
|
21
|
+
|
22
|
+
# Sanity check since this test likes to fail
|
23
|
+
employee = hr[:employees].find({ employee: 3 }, limit: 1).first
|
24
|
+
expect(employee).to_not be_nil
|
25
|
+
|
17
26
|
reporting[:events].insert_one(employee: 3, status: { new: 'Active', old: nil})
|
18
27
|
end
|
19
28
|
|
20
29
|
after(:each) do
|
21
30
|
hr.drop
|
22
31
|
reporting.drop
|
32
|
+
|
33
|
+
# Work around https://jira.mongodb.org/browse/SERVER-53015
|
34
|
+
::Utils.mongos_each_direct_client do |client|
|
35
|
+
client.database.command(flushRouterConfig: 1)
|
36
|
+
end
|
23
37
|
end
|
24
38
|
|
25
39
|
context 'individual examples' do
|
26
40
|
|
27
41
|
let(:session) do
|
28
|
-
|
42
|
+
client.start_session
|
29
43
|
end
|
30
44
|
|
31
45
|
# Start Transactions Intro Example 1
|
@@ -142,10 +156,6 @@ describe 'Transactions examples' do
|
|
142
156
|
|
143
157
|
context 'Transactions Retry Example 3 (combined example)' do
|
144
158
|
|
145
|
-
let(:client) do
|
146
|
-
authorized_client
|
147
|
-
end
|
148
|
-
|
149
159
|
let(:run_transaction) do
|
150
160
|
|
151
161
|
# Start Transactions Retry Example 3
|