mongo 2.13.0.beta1 → 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 -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
@@ -0,0 +1,175 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
module Mrss
|
5
|
+
module LiteConstraints
|
6
|
+
|
7
|
+
# Constrain tests that use TimeoutInterrupt to MRI (and Unix).
|
8
|
+
def require_mri
|
9
|
+
before(:all) do
|
10
|
+
unless SpecConfig.instance.mri?
|
11
|
+
skip "MRI required, we have #{SpecConfig.instance.platform}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def require_jruby
|
17
|
+
before(:all) do
|
18
|
+
unless BSON::Environment.jruby?
|
19
|
+
skip "JRuby required, we have #{SpecConfig.instance.platform}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# This is for marking tests that fail on JRuby that should
|
25
|
+
# in principle work (as opposed to being fundamentally incompatible
|
26
|
+
# with JRuby).
|
27
|
+
# Often times these failures happen only in Evergreen.
|
28
|
+
def fails_on_jruby(version=nil)
|
29
|
+
before(:all) do
|
30
|
+
if BSON::Environment.jruby?
|
31
|
+
if version
|
32
|
+
min_parts = version.split('.').map(&:to_i)
|
33
|
+
actual_parts = JRUBY_VERSION.split('.').map(&:to_i)[0...min_parts.length]
|
34
|
+
actual = actual_parts.join('.')
|
35
|
+
if actual <= version
|
36
|
+
skip "Fails on jruby through #{version}"
|
37
|
+
end
|
38
|
+
else
|
39
|
+
skip "Fails on jruby"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Indicates that the respective test uses the internet in some capacity,
|
46
|
+
# for example the test resolves SRV DNS records.
|
47
|
+
def require_external_connectivity
|
48
|
+
before(:all) do
|
49
|
+
if ENV['EXTERNAL_DISABLED']
|
50
|
+
skip "Test requires external connectivity"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def require_mongo_kerberos
|
56
|
+
before(:all) do
|
57
|
+
# TODO Use a more generic environment variable name if/when
|
58
|
+
# Mongoid tests get Kerberos configurations.
|
59
|
+
unless %w(1 yes true).include?(ENV['MONGO_RUBY_DRIVER_KERBEROS']&.downcase)
|
60
|
+
skip 'Set MONGO_RUBY_DRIVER_KERBEROS=1 in environment to run Kerberos unit tests'
|
61
|
+
end
|
62
|
+
require 'mongo_kerberos'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def require_linting
|
67
|
+
before(:all) do
|
68
|
+
unless Mongo::Lint.enabled?
|
69
|
+
skip "Linting is not enabled"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Some tests will fail if linting is enabled:
|
75
|
+
# 1. Tests that pass invalid options to client, etc. which the linter
|
76
|
+
# rejects.
|
77
|
+
# 2. Tests that set expectations on topologies, server descriptions, etc.
|
78
|
+
# (since setting expectations requires mutating said objects, and when
|
79
|
+
# linting is on those objects are frozen).
|
80
|
+
def require_no_linting
|
81
|
+
before(:all) do
|
82
|
+
if Mongo::Lint.enabled?
|
83
|
+
skip "Linting is enabled"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def require_libmongocrypt
|
89
|
+
before(:all) do
|
90
|
+
unless ENV['LIBMONGOCRYPT_PATH']
|
91
|
+
skip 'Test requires path to libmongocrypt to be specified in LIBMONGOCRYPT_PATH env variable'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def require_no_libmongocrypt
|
97
|
+
before(:all) do
|
98
|
+
if ENV['LIBMONGOCRYPT_PATH']
|
99
|
+
skip 'Test requires libmongocrypt to not be configured'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def require_aws_auth
|
105
|
+
before(:all) do
|
106
|
+
unless (ENV['AUTH'] || '') =~ /^aws/
|
107
|
+
skip 'This test requires AUTH=aws* and an appropriately configured runtime environment'
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def require_ec2_host
|
113
|
+
before(:all) do
|
114
|
+
if $have_aws.nil?
|
115
|
+
$have_aws = begin
|
116
|
+
require 'open-uri'
|
117
|
+
begin
|
118
|
+
Timeout.timeout(3.81) do
|
119
|
+
URI.parse('http://169.254.169.254/latest/meta-data/profile').open.read
|
120
|
+
end
|
121
|
+
true
|
122
|
+
# When trying to use the EC2 metadata endpoint on ECS:
|
123
|
+
# Errno::EINVAL: Failed to open TCP connection to 169.254.169.254:80 (Invalid argument - connect(2) for "169.254.169.254" port 80)
|
124
|
+
rescue Timeout::Error, Errno::ETIMEDOUT, Errno::EINVAL, OpenURI::HTTPError => $aws_error
|
125
|
+
false
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
unless $have_aws
|
130
|
+
skip "EC2 instance metadata is not available - assuming not running on an EC2 instance: #{$aws_error.class}: #{$aws_error}"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def require_stress
|
136
|
+
before(:all) do
|
137
|
+
if !SpecConfig.instance.stress?
|
138
|
+
skip 'Set STRESS=1 in environment to run stress tests'
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def require_fork
|
144
|
+
before(:all) do
|
145
|
+
if !SpecConfig.instance.fork?
|
146
|
+
skip 'Set FORK=1 in environment to run fork tests'
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def require_ocsp
|
152
|
+
before(:all) do
|
153
|
+
if !SpecConfig.instance.ocsp?
|
154
|
+
skip 'Set OCSP=1 in environment to run OCSP tests'
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def require_ocsp_verifier
|
160
|
+
before(:all) do
|
161
|
+
if !SpecConfig.instance.ocsp_verifier?
|
162
|
+
skip 'Set OCSP_VERIFIER=1 in environment to run OCSP verifier tests'
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def require_ocsp_connectivity
|
168
|
+
before(:all) do
|
169
|
+
if !SpecConfig.instance.ocsp_connectivity?
|
170
|
+
skip 'Set OCSP_CONNECTIVITY=pass or OCSP_CONNECTIVITY=fail in environment to run OCSP connectivity tests'
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
autoload :JSON, 'json'
|
2
|
+
autoload :FileUtils, 'fileutils'
|
3
|
+
autoload :Find, 'find'
|
4
|
+
|
5
|
+
module Mrss
|
6
|
+
|
7
|
+
autoload :ChildProcessHelper, 'mrss/child_process_helper'
|
8
|
+
|
9
|
+
# Organizes and runs all of the tests in the test suite in batches.
|
10
|
+
#
|
11
|
+
# Organizing the tests in batches serves two purposes:
|
12
|
+
#
|
13
|
+
# 1. This allows running unit tests before integration tests, therefore
|
14
|
+
# in theory revealing failures quicker on average.
|
15
|
+
# 2. This allows running some tests that have high intermittent failure rate
|
16
|
+
# in their own test process.
|
17
|
+
#
|
18
|
+
# This class aggregates RSpec results after the test runs.
|
19
|
+
class SpecOrganizer
|
20
|
+
|
21
|
+
class BucketsNotPrioritized < StandardError
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(root: nil, classifiers:, priority_order:,
|
25
|
+
spec_root: nil, rspec_json_path: nil, rspec_all_json_path: nil
|
26
|
+
)
|
27
|
+
@spec_root = spec_root || File.join(root, 'spec')
|
28
|
+
@classifiers = classifiers
|
29
|
+
@priority_order = priority_order
|
30
|
+
@rspec_json_path = rspec_json_path || File.join(root, 'tmp/rspec.json')
|
31
|
+
@rspec_all_json_path = rspec_all_json_path || File.join(root, 'tmp/rspec-all.json')
|
32
|
+
end
|
33
|
+
|
34
|
+
attr_reader :spec_root, :classifiers, :priority_order
|
35
|
+
attr_reader :rspec_json_path, :rspec_all_json_path
|
36
|
+
|
37
|
+
def buckets
|
38
|
+
@buckets ||= {}.tap do |buckets|
|
39
|
+
Find.find(spec_root) do |path|
|
40
|
+
next unless File.file?(path)
|
41
|
+
next unless path =~ /_spec\.rb\z/
|
42
|
+
rel_path = path[(spec_root.length + 1)..path.length]
|
43
|
+
|
44
|
+
found = false
|
45
|
+
classifiers.each do |(regexp, category)|
|
46
|
+
if regexp =~ rel_path
|
47
|
+
buckets[category] ||= []
|
48
|
+
buckets[category] << File.join('spec', rel_path)
|
49
|
+
found = true
|
50
|
+
break
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
unless found
|
55
|
+
buckets[nil] ||= []
|
56
|
+
buckets[nil] << File.join('spec', rel_path)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end.freeze
|
60
|
+
end
|
61
|
+
|
62
|
+
def ordered_buckets
|
63
|
+
@ordered_buckets ||= {}.tap do |ordered_buckets|
|
64
|
+
buckets = self.buckets.dup
|
65
|
+
priority_order.each do |category|
|
66
|
+
files = buckets.delete(category)
|
67
|
+
ordered_buckets[category] = files
|
68
|
+
end
|
69
|
+
|
70
|
+
if files = buckets.delete(nil)
|
71
|
+
ordered_buckets[nil] = files
|
72
|
+
end
|
73
|
+
|
74
|
+
unless buckets.empty?
|
75
|
+
raise BucketsNotPrioritized, "Some buckets were not prioritized: #{buckets.keys.map(&:to_s).join(', ')}"
|
76
|
+
end
|
77
|
+
end.freeze
|
78
|
+
end
|
79
|
+
|
80
|
+
def run
|
81
|
+
FileUtils.rm_f(rspec_all_json_path)
|
82
|
+
|
83
|
+
failed = []
|
84
|
+
buckets = self.buckets.dup
|
85
|
+
|
86
|
+
priority_order.each do |category|
|
87
|
+
if files = buckets.delete(category)
|
88
|
+
unless run_files(category, files)
|
89
|
+
failed << category
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
if files = buckets.delete(nil)
|
94
|
+
unless run_files('remaining', files)
|
95
|
+
failed << 'remaining'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
unless buckets.empty?
|
100
|
+
raise "Some buckets were not executed: #{buckets.keys.map(&:to_s).join(', ')}"
|
101
|
+
end
|
102
|
+
|
103
|
+
if failed.any?
|
104
|
+
raise "The following buckets failed: #{failed.map(&:to_s).join(', ')}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def run_files(category, paths)
|
109
|
+
puts "Running #{category.to_s.gsub('_', ' ')} tests"
|
110
|
+
FileUtils.rm_f(rspec_json_path)
|
111
|
+
cmd = %w(rspec) + paths
|
112
|
+
|
113
|
+
begin
|
114
|
+
ChildProcessHelper.check_call(cmd)
|
115
|
+
ensure
|
116
|
+
if File.exist?(rspec_json_path)
|
117
|
+
if File.exist?(rspec_all_json_path)
|
118
|
+
merge_rspec_results
|
119
|
+
else
|
120
|
+
FileUtils.cp(rspec_json_path, rspec_all_json_path)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
true
|
126
|
+
rescue ChildProcessHelper::SpawnError
|
127
|
+
false
|
128
|
+
end
|
129
|
+
|
130
|
+
def merge_rspec_results
|
131
|
+
all = JSON.parse(File.read(rspec_all_json_path))
|
132
|
+
new = JSON.parse(File.read(rspec_json_path))
|
133
|
+
all['examples'] += new.delete('examples')
|
134
|
+
new.delete('summary').each do |k, v|
|
135
|
+
all['summary'][k] += v
|
136
|
+
end
|
137
|
+
new.delete('version')
|
138
|
+
new.delete('summary_line')
|
139
|
+
unless new.empty?
|
140
|
+
raise "Unhandled rspec results keys: #{new.keys.join(', ')}"
|
141
|
+
end
|
142
|
+
# We do not merge summary lines, delete them from aggregated results
|
143
|
+
all.delete('summary_line')
|
144
|
+
File.open(rspec_all_json_path, 'w') do |f|
|
145
|
+
f << JSON.dump(all)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'lite_spec_helper'
|
2
2
|
|
3
|
+
require 'mrss/constraints'
|
4
|
+
require 'support/constraints'
|
3
5
|
require 'support/authorization'
|
4
6
|
require 'support/primary_socket'
|
5
|
-
require 'support/constraints'
|
6
7
|
require 'support/cluster_config'
|
7
8
|
require 'support/cluster_tools'
|
8
9
|
require 'rspec/retry'
|
@@ -11,6 +12,7 @@ require 'support/local_resource_registry'
|
|
11
12
|
|
12
13
|
RSpec.configure do |config|
|
13
14
|
config.include(Authorization)
|
15
|
+
config.extend(Mrss::Constraints)
|
14
16
|
config.extend(Constraints)
|
15
17
|
|
16
18
|
config.before(:all) do
|
@@ -22,9 +22,13 @@ describe 'Cmap' do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
let(:options) do
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
Mongo::Utils.shallow_symbolize_keys(Mongo::Client.canonicalize_ruby_options(
|
26
|
+
SpecConfig.instance.all_test_options,
|
27
|
+
)).update(monitoring_io: false).tap do |options|
|
28
|
+
# We have a wait queue timeout set in the test suite options, but having
|
29
|
+
# this option set interferes with assertions in the cmap spec tests.
|
30
|
+
options.delete(:wait_queue_timeout)
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
CMAP_TESTS.each do |file|
|
@@ -20,7 +20,7 @@ describe 'Command Monitoring Events' do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
let(:subscriber) do
|
23
|
-
|
23
|
+
EventSubscriber.new
|
24
24
|
end
|
25
25
|
|
26
26
|
let(:monitoring) do
|
@@ -32,25 +32,35 @@ describe 'Command Monitoring Events' do
|
|
32
32
|
authorized_client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
monitoring.subscribers[Mongo::Monitoring::COMMAND].delete(subscriber)
|
37
|
-
authorized_collection.find.delete_many
|
38
|
-
end
|
39
|
-
|
40
|
-
test.expectations.each do |expectation|
|
35
|
+
test.expectations.each_with_index do |expectation, index|
|
41
36
|
|
42
37
|
it "generates a #{expectation.event_name} for #{expectation.command_name}" do
|
43
38
|
begin
|
44
|
-
test.run(authorized_collection)
|
45
|
-
|
46
|
-
expect(event).to send(expectation.matcher, expectation)
|
39
|
+
test.run(authorized_collection, subscriber)
|
40
|
+
check_event(subscriber, index, expectation)
|
47
41
|
rescue Mongo::Error::OperationFailure, Mongo::Error::BulkWriteError
|
48
|
-
|
49
|
-
expect(event).to send(expectation.matcher, expectation)
|
42
|
+
check_event(subscriber, index, expectation)
|
50
43
|
end
|
51
44
|
end
|
52
45
|
end
|
53
46
|
end
|
54
47
|
end
|
55
48
|
end
|
49
|
+
|
50
|
+
def check_event(subscriber, index, expectation)
|
51
|
+
subscriber.all_events.length.should > index
|
52
|
+
# TODO move this filtering into EventSubscriber
|
53
|
+
events = subscriber.all_events.reject do |event|
|
54
|
+
(
|
55
|
+
event.is_a?(Mongo::Monitoring::Event::CommandStarted) ||
|
56
|
+
event.is_a?(Mongo::Monitoring::Event::CommandSucceeded) ||
|
57
|
+
event.is_a?(Mongo::Monitoring::Event::CommandFailed)
|
58
|
+
) &&
|
59
|
+
%w(authenticate getnonce saslStart saslContinue).include?(event.command_name)
|
60
|
+
end
|
61
|
+
actual_event = events[index]
|
62
|
+
expected_event_type = expectation.event_type.sub(/_event$/, '')
|
63
|
+
Utils.underscore(actual_event.class.name.sub(/.*::/, '')).to_s.should == expected_event_type
|
64
|
+
expect(actual_event).to send(expectation.matcher, expectation)
|
65
|
+
end
|
56
66
|
end
|
@@ -11,7 +11,7 @@ end
|
|
11
11
|
describe 'CRUD v2 spec tests' do
|
12
12
|
define_crud_spec_tests(CRUD2_TESTS) do |spec, req, test|
|
13
13
|
let(:client) do
|
14
|
-
authorized_client.tap do |client|
|
14
|
+
authorized_client.use(spec.database_name || 'crud-default').tap do |client|
|
15
15
|
client.subscribe(Mongo::Monitoring::COMMAND, event_subscriber)
|
16
16
|
end
|
17
17
|
end
|
@@ -12,7 +12,6 @@ tests:
|
|
12
12
|
changeStreamPipeline: []
|
13
13
|
changeStreamOptions: {}
|
14
14
|
operations: []
|
15
|
-
# https://jira.mongodb.org/browse/SPEC-1462
|
16
15
|
expectations: ~
|
17
16
|
result:
|
18
17
|
error:
|
@@ -73,25 +72,21 @@ tests:
|
|
73
72
|
result:
|
74
73
|
error:
|
75
74
|
code: 280
|
76
|
-
errorLabels: [ "NonResumableChangeStreamError" ]
|
77
|
-
|
78
75
|
-
|
79
|
-
description: change stream errors on
|
76
|
+
description: change stream errors on ElectionInProgress
|
80
77
|
minServerVersion: "4.2"
|
81
78
|
failPoint:
|
82
79
|
configureFailPoint: failCommand
|
83
80
|
mode: { times: 1 }
|
84
81
|
data:
|
85
82
|
failCommands: ["getMore"]
|
86
|
-
errorCode:
|
83
|
+
errorCode: 216 # An error code that's not on the old blacklist or whitelist
|
87
84
|
closeConnection: false
|
88
85
|
target: collection
|
89
86
|
topology:
|
90
87
|
- replicaset
|
91
88
|
- sharded
|
92
|
-
changeStreamPipeline:
|
93
|
-
-
|
94
|
-
$project: { _id: 0 }
|
89
|
+
changeStreamPipeline: []
|
95
90
|
changeStreamOptions: {}
|
96
91
|
operations:
|
97
92
|
-
|
@@ -103,4 +98,4 @@ tests:
|
|
103
98
|
z: 3
|
104
99
|
result:
|
105
100
|
error:
|
106
|
-
code:
|
101
|
+
code: 216
|