mongo 2.19.1 → 2.21.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
- data/README.md +40 -1
- data/Rakefile +83 -174
- data/lib/mongo/address.rb +22 -3
- data/lib/mongo/auth/aws/credentials_retriever.rb +70 -17
- data/lib/mongo/auth/base.rb +1 -1
- data/lib/mongo/bulk_write.rb +35 -2
- data/lib/mongo/client.rb +38 -6
- data/lib/mongo/client_encryption.rb +6 -3
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +6 -1
- data/lib/mongo/cluster/sdam_flow.rb +20 -7
- data/lib/mongo/cluster/topology/base.rb +16 -0
- data/lib/mongo/cluster.rb +41 -5
- data/lib/mongo/collection/helpers.rb +1 -1
- data/lib/mongo/collection/view/aggregation/behavior.rb +131 -0
- data/lib/mongo/collection/view/aggregation.rb +33 -99
- data/lib/mongo/collection/view/builder/aggregation.rb +1 -7
- data/lib/mongo/collection/view/change_stream.rb +80 -27
- data/lib/mongo/collection/view/iterable.rb +92 -60
- data/lib/mongo/collection/view/map_reduce.rb +25 -8
- data/lib/mongo/collection/view/readable.rb +79 -30
- data/lib/mongo/collection/view/writable.rb +109 -48
- data/lib/mongo/collection/view.rb +44 -3
- data/lib/mongo/collection.rb +185 -26
- data/lib/mongo/config.rb +2 -2
- data/lib/mongo/crypt/auto_encrypter.rb +4 -6
- data/lib/mongo/crypt/binding.rb +4 -4
- data/lib/mongo/crypt/context.rb +20 -14
- data/lib/mongo/crypt/encryption_io.rb +56 -26
- data/lib/mongo/crypt/explicit_encrypter.rb +49 -20
- data/lib/mongo/crypt/explicit_encryption_context.rb +17 -11
- data/lib/mongo/crypt/kms/azure/credentials_retriever.rb +22 -6
- data/lib/mongo/crypt/kms/gcp/credentials_retriever.rb +29 -4
- data/lib/mongo/csot_timeout_holder.rb +119 -0
- data/lib/mongo/cursor/kill_spec.rb +5 -2
- data/lib/mongo/cursor/nontailable.rb +27 -0
- data/lib/mongo/cursor.rb +86 -24
- data/lib/mongo/cursor_host.rb +82 -0
- data/lib/mongo/database/view.rb +81 -14
- data/lib/mongo/database.rb +88 -18
- data/lib/mongo/error/operation_failure.rb +209 -204
- data/lib/mongo/error/server_timeout_error.rb +12 -0
- data/lib/mongo/error/socket_timeout_error.rb +3 -1
- data/lib/mongo/error/timeout_error.rb +23 -0
- data/lib/mongo/error/transactions_not_supported.rb +34 -0
- data/lib/mongo/error.rb +3 -0
- data/lib/mongo/grid/fs_bucket.rb +48 -9
- data/lib/mongo/grid/stream/read.rb +15 -1
- data/lib/mongo/grid/stream/write.rb +21 -4
- data/lib/mongo/index/view.rb +77 -16
- data/lib/mongo/monitoring/event/secure.rb +1 -1
- data/lib/mongo/operation/context.rb +40 -2
- data/lib/mongo/operation/create_search_indexes/op_msg.rb +31 -0
- data/lib/mongo/operation/create_search_indexes.rb +15 -0
- data/lib/mongo/operation/delete/op_msg.rb +2 -1
- data/lib/mongo/operation/drop_search_index/op_msg.rb +33 -0
- data/lib/mongo/operation/drop_search_index.rb +15 -0
- data/lib/mongo/operation/find/op_msg.rb +45 -0
- data/lib/mongo/operation/get_more/op_msg.rb +33 -0
- data/lib/mongo/operation/insert/op_msg.rb +3 -2
- data/lib/mongo/operation/insert/result.rb +4 -2
- data/lib/mongo/operation/list_collections/result.rb +1 -1
- data/lib/mongo/operation/map_reduce/result.rb +1 -1
- data/lib/mongo/operation/op_msg_base.rb +3 -1
- data/lib/mongo/operation/result.rb +26 -5
- data/lib/mongo/operation/shared/executable.rb +55 -28
- data/lib/mongo/operation/shared/op_msg_executable.rb +4 -1
- data/lib/mongo/operation/shared/response_handling.rb +25 -27
- data/lib/mongo/operation/shared/sessions_supported.rb +1 -1
- data/lib/mongo/operation/shared/specifiable.rb +7 -0
- data/lib/mongo/operation/shared/timed.rb +52 -0
- data/lib/mongo/operation/shared/write.rb +4 -1
- data/lib/mongo/operation/update/op_msg.rb +2 -1
- data/lib/mongo/operation/update_search_index/op_msg.rb +34 -0
- data/lib/mongo/operation/update_search_index.rb +15 -0
- data/lib/mongo/operation.rb +4 -0
- data/lib/mongo/protocol/message.rb +1 -4
- data/lib/mongo/protocol/msg.rb +2 -2
- data/lib/mongo/retryable/base_worker.rb +28 -3
- data/lib/mongo/retryable/read_worker.rb +78 -36
- data/lib/mongo/retryable/write_worker.rb +59 -25
- data/lib/mongo/retryable.rb +8 -2
- data/lib/mongo/search_index/view.rb +232 -0
- data/lib/mongo/server/app_metadata/environment.rb +64 -9
- data/lib/mongo/server/app_metadata.rb +5 -4
- data/lib/mongo/server/connection.rb +11 -5
- data/lib/mongo/server/connection_base.rb +22 -2
- data/lib/mongo/server/connection_pool.rb +32 -14
- data/lib/mongo/server/description/features.rb +2 -1
- data/lib/mongo/server/description.rb +18 -5
- data/lib/mongo/server/monitor.rb +7 -4
- data/lib/mongo/server/pending_connection.rb +25 -8
- data/lib/mongo/server/{round_trip_time_averager.rb → round_trip_time_calculator.rb} +25 -7
- data/lib/mongo/server.rb +11 -6
- data/lib/mongo/server_selector/base.rb +54 -12
- data/lib/mongo/session/server_session/dirtyable.rb +52 -0
- data/lib/mongo/session/server_session.rb +3 -0
- data/lib/mongo/session/session_pool.rb +12 -18
- data/lib/mongo/session.rb +110 -9
- data/lib/mongo/socket/ssl.rb +131 -18
- data/lib/mongo/socket/tcp.rb +40 -6
- data/lib/mongo/socket.rb +154 -25
- data/lib/mongo/uri/options_mapper.rb +1 -0
- data/lib/mongo/uri.rb +0 -4
- data/lib/mongo/version.rb +1 -5
- data/lib/mongo.rb +2 -0
- data/mongo.gemspec +9 -18
- data/spec/atlas/atlas_connectivity_spec.rb +9 -9
- data/spec/atlas/operations_spec.rb +5 -5
- data/spec/faas/ruby-sam-app/Gemfile +9 -0
- data/spec/faas/ruby-sam-app/mongodb/Gemfile +4 -0
- data/spec/faas/ruby-sam-app/mongodb/app.rb +149 -0
- data/spec/faas/ruby-sam-app/template.yaml +48 -0
- data/spec/integration/client_side_encryption/auto_encryption_mongocryptd_spawn_spec.rb +2 -1
- data/spec/integration/client_side_encryption/auto_encryption_spec.rb +494 -487
- data/spec/integration/client_side_encryption/corpus_spec.rb +10 -2
- data/spec/integration/client_side_encryption/on_demand_aws_credentials_spec.rb +1 -1
- data/spec/integration/client_side_encryption/range_explicit_encryption_prose_spec.rb +67 -20
- data/spec/integration/client_side_operations_timeout/encryption_prose_spec.rb +131 -0
- data/spec/integration/connection_pool_populator_spec.rb +2 -0
- data/spec/integration/cursor_pinning_spec.rb +15 -60
- data/spec/integration/cursor_reaping_spec.rb +1 -1
- data/spec/integration/docs_examples_spec.rb +1 -1
- data/spec/integration/find_options_spec.rb +227 -0
- data/spec/integration/operation_failure_code_spec.rb +1 -1
- data/spec/integration/operation_failure_message_spec.rb +3 -3
- data/spec/integration/retryable_errors_spec.rb +2 -2
- data/spec/integration/retryable_reads_errors_spec.rb +196 -31
- data/spec/integration/retryable_writes_errors_spec.rb +156 -0
- data/spec/integration/sdam_error_handling_spec.rb +4 -1
- data/spec/integration/search_indexes_prose_spec.rb +172 -0
- data/spec/integration/server_spec.rb +4 -3
- data/spec/integration/transactions_api_examples_spec.rb +2 -0
- data/spec/kerberos/kerberos_spec.rb +4 -0
- data/spec/lite_spec_helper.rb +34 -20
- data/spec/mongo/auth/user/view_spec.rb +1 -1
- data/spec/mongo/caching_cursor_spec.rb +1 -1
- data/spec/mongo/client_encryption_spec.rb +1 -0
- data/spec/mongo/client_spec.rb +158 -4
- data/spec/mongo/cluster_spec.rb +36 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +20 -40
- data/spec/mongo/collection/view/change_stream_spec.rb +3 -3
- data/spec/mongo/collection/view/explainable_spec.rb +2 -0
- data/spec/mongo/collection_crud_spec.rb +2 -1
- data/spec/mongo/collection_spec.rb +5 -6
- data/spec/mongo/crypt/auto_encrypter_spec.rb +14 -12
- data/spec/mongo/crypt/data_key_context_spec.rb +3 -1
- data/spec/mongo/crypt/explicit_encryption_context_spec.rb +2 -2
- data/spec/mongo/crypt/handle_spec.rb +1 -1
- data/spec/mongo/cursor_spec.rb +26 -9
- data/spec/mongo/error/operation_failure_heavy_spec.rb +2 -2
- data/spec/mongo/operation/context_spec.rb +79 -0
- data/spec/mongo/operation/create/op_msg_spec.rb +106 -110
- data/spec/mongo/operation/delete/op_msg_spec.rb +6 -5
- data/spec/mongo/operation/find/op_msg_spec.rb +66 -0
- data/spec/mongo/operation/get_more/op_msg_spec.rb +65 -0
- data/spec/mongo/operation/insert/op_msg_spec.rb +128 -131
- data/spec/mongo/operation/insert_spec.rb +1 -1
- data/spec/mongo/operation/shared/csot/examples.rb +113 -0
- data/spec/mongo/query_cache_spec.rb +243 -225
- data/spec/mongo/retryable/write_worker_spec.rb +39 -0
- data/spec/mongo/retryable_spec.rb +1 -0
- data/spec/mongo/server/app_metadata/environment_spec.rb +135 -0
- data/spec/mongo/server/app_metadata_spec.rb +12 -2
- data/spec/mongo/server/connection_spec.rb +26 -0
- data/spec/mongo/server/round_trip_time_calculator_spec.rb +120 -0
- data/spec/mongo/session/session_pool_spec.rb +1 -16
- data/spec/mongo/session_transaction_spec.rb +15 -0
- data/spec/mongo/socket/ssl_spec.rb +0 -10
- data/spec/mongo/uri_spec.rb +0 -9
- data/spec/runners/change_streams/test.rb +2 -2
- data/spec/runners/crud/operation.rb +1 -1
- data/spec/runners/crud/test.rb +0 -8
- data/spec/runners/crud/verifier.rb +3 -1
- data/spec/runners/crud.rb +1 -1
- data/spec/runners/transactions/operation.rb +4 -6
- data/spec/runners/transactions/test.rb +12 -3
- data/spec/runners/unified/ambiguous_operations.rb +13 -0
- data/spec/runners/unified/assertions.rb +20 -3
- data/spec/runners/unified/change_stream_operations.rb +14 -24
- data/spec/runners/unified/crud_operations.rb +82 -47
- data/spec/runners/unified/ddl_operations.rb +38 -7
- data/spec/runners/unified/grid_fs_operations.rb +37 -2
- data/spec/runners/unified/search_index_operations.rb +63 -0
- data/spec/runners/unified/support_operations.rb +46 -9
- data/spec/runners/unified/test.rb +33 -12
- data/spec/runners/unified.rb +1 -1
- data/spec/solo/clean_exit_spec.rb +2 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/spec_tests/client_side_operations_timeout_spec.rb +15 -0
- data/spec/spec_tests/data/change_streams_unified/change-streams-clusterTime.yml +3 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-disambiguatedPaths.yml +3 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-errors.yml +3 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-pre_and_post_images.yml +1 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-resume-allowlist.yml +1 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-resume-errorLabels.yml +1 -1
- data/spec/spec_tests/data/change_streams_unified/change-streams-showExpandedEvents.yml +1 -1
- data/spec/spec_tests/data/client_side_encryption/badQueries.yml +2 -1
- data/spec/spec_tests/data/client_side_encryption/explain.yml +2 -2
- data/spec/spec_tests/data/client_side_encryption/fle2v2-BypassQueryAnalysis.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Compact.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-CreateCollection.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-DecryptExistingData.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Delete.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-EncryptedFields-vs-EncryptedFieldsMap.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-EncryptedFields-vs-jsonSchema.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-EncryptedFieldsMap-defaults.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-FindOneAndUpdate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-InsertFind-Indexed.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-InsertFind-Unindexed.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-MissingKey.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-NoEncryption.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Update.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-validatorAndPartialFieldExpression.yml +2 -1
- data/spec/spec_tests/data/client_side_encryption/timeoutMS.yml +67 -0
- data/spec/spec_tests/data/client_side_operations_timeout/bulkWrite.yml +87 -0
- data/spec/spec_tests/data/client_side_operations_timeout/change-streams.yml +358 -0
- data/spec/spec_tests/data/client_side_operations_timeout/close-cursors.yml +129 -0
- data/spec/spec_tests/data/client_side_operations_timeout/command-execution.yml +250 -0
- data/spec/spec_tests/data/client_side_operations_timeout/convenient-transactions.yml +113 -0
- data/spec/spec_tests/data/client_side_operations_timeout/cursors.yml +70 -0
- data/spec/spec_tests/data/client_side_operations_timeout/deprecated-options.yml +3982 -0
- data/spec/spec_tests/data/client_side_operations_timeout/error-transformations.yml +96 -0
- data/spec/spec_tests/data/client_side_operations_timeout/global-timeoutMS.yml +3236 -0
- data/spec/spec_tests/data/client_side_operations_timeout/gridfs-advanced.yml +207 -0
- data/spec/spec_tests/data/client_side_operations_timeout/gridfs-delete.yml +152 -0
- data/spec/spec_tests/data/client_side_operations_timeout/gridfs-download.yml +182 -0
- data/spec/spec_tests/data/client_side_operations_timeout/gridfs-find.yml +100 -0
- data/spec/spec_tests/data/client_side_operations_timeout/gridfs-upload.yml +249 -0
- data/spec/spec_tests/data/client_side_operations_timeout/legacy-timeouts.yml +204 -0
- data/spec/spec_tests/data/client_side_operations_timeout/non-tailable-cursors.yml +307 -0
- data/spec/spec_tests/data/client_side_operations_timeout/override-collection-timeoutMS.yml +1877 -0
- data/spec/spec_tests/data/client_side_operations_timeout/override-operation-timeoutMS.yml +1918 -0
- data/spec/spec_tests/data/client_side_operations_timeout/retryability-legacy-timeouts.yml +1676 -0
- data/spec/spec_tests/data/client_side_operations_timeout/retryability-timeoutMS.yml +2824 -0
- data/spec/spec_tests/data/client_side_operations_timeout/sessions-inherit-timeoutMS.yml +168 -0
- data/spec/spec_tests/data/client_side_operations_timeout/sessions-override-operation-timeoutMS.yml +171 -0
- data/spec/spec_tests/data/client_side_operations_timeout/sessions-override-timeoutMS.yml +168 -0
- data/spec/spec_tests/data/client_side_operations_timeout/tailable-awaitData.yml +247 -0
- data/spec/spec_tests/data/client_side_operations_timeout/tailable-non-awaitData.yml +181 -0
- data/spec/spec_tests/data/connection_string/invalid-uris.yml +0 -10
- data/spec/spec_tests/data/connection_string/valid-options.yml +13 -0
- data/spec/spec_tests/data/crud_unified/aggregate-write-readPreference.yml +6 -0
- data/spec/spec_tests/data/crud_unified/db-aggregate-write-readPreference.yml +6 -0
- data/spec/spec_tests/data/crud_unified/find-test-all-options.yml +377 -0
- data/spec/spec_tests/data/index_management/createSearchIndex.yml +64 -0
- data/spec/spec_tests/data/index_management/createSearchIndexes.yml +86 -0
- data/spec/spec_tests/data/index_management/dropSearchIndex.yml +43 -0
- data/spec/spec_tests/data/index_management/listSearchIndexes.yml +91 -0
- data/spec/spec_tests/data/index_management/updateSearchIndex.yml +46 -0
- data/spec/spec_tests/data/retryable_writes/unified/bulkWrite-serverErrors.yml +3 -6
- data/spec/spec_tests/data/retryable_writes/unified/insertOne-serverErrors.yml +3 -6
- data/spec/spec_tests/data/run_command_unified/runCommand.yml +319 -0
- data/spec/spec_tests/data/sessions_unified/driver-sessions-dirty-session-errors.yml +351 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-crud.yml +1 -1
- data/spec/spec_tests/data/unified/valid-pass/poc-retryable-writes.yml +7 -7
- data/spec/spec_tests/data/unified/valid-pass/poc-sessions.yml +3 -4
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-convenient-api.yml +1 -1
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-mongos-pin-auto.yml +1 -1
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions.yml +3 -3
- data/spec/spec_tests/index_management_unified_spec.rb +13 -0
- data/spec/spec_tests/run_command_unified_spec.rb +13 -0
- data/spec/spec_tests/sdam_unified_spec.rb +2 -0
- data/spec/spec_tests/server_selection_rtt_spec.rb +6 -6
- data/spec/spec_tests/transactions_unified_spec.rb +2 -1
- data/spec/support/certificates/atlas-ocsp-ca.crt +89 -79
- data/spec/support/certificates/atlas-ocsp.crt +117 -122
- data/spec/support/certificates/retrieve-atlas-cert +1 -1
- data/spec/support/cluster_tools.rb +3 -3
- data/spec/support/common_shortcuts.rb +2 -2
- data/spec/support/constraints.rb +6 -0
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-Date.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-DecimalNoPrecision.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-DecimalPrecision.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-DoubleNoPrecision.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-DoublePrecision.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-Int.json +1 -1
- data/spec/support/crypt/encrypted_fields/range-encryptedFields-Long.json +1 -1
- data/spec/support/ocsp +1 -1
- data/spec/support/recording_logger.rb +27 -0
- data/spec/support/shared/session.rb +2 -2
- data/spec/support/spec_config.rb +5 -0
- data/spec/support/spec_setup.rb +2 -2
- data/spec/support/utils.rb +3 -1
- metadata +1329 -1368
- checksums.yaml.gz.sig +0 -0
- data/spec/mongo/server/round_trip_time_averager_spec.rb +0 -48
- data/spec/shared/LICENSE +0 -20
- data/spec/shared/bin/get-mongodb-download-url +0 -17
- data/spec/shared/bin/s3-copy +0 -45
- data/spec/shared/bin/s3-upload +0 -69
- data/spec/shared/lib/mrss/child_process_helper.rb +0 -80
- data/spec/shared/lib/mrss/cluster_config.rb +0 -231
- data/spec/shared/lib/mrss/constraints.rb +0 -378
- data/spec/shared/lib/mrss/docker_runner.rb +0 -295
- data/spec/shared/lib/mrss/eg_config_utils.rb +0 -51
- data/spec/shared/lib/mrss/event_subscriber.rb +0 -210
- data/spec/shared/lib/mrss/lite_constraints.rb +0 -238
- data/spec/shared/lib/mrss/server_version_registry.rb +0 -113
- data/spec/shared/lib/mrss/session_registry.rb +0 -69
- data/spec/shared/lib/mrss/session_registry_legacy.rb +0 -60
- data/spec/shared/lib/mrss/spec_organizer.rb +0 -179
- data/spec/shared/lib/mrss/utils.rb +0 -37
- data/spec/shared/share/Dockerfile.erb +0 -330
- data/spec/shared/share/haproxy-1.conf +0 -16
- data/spec/shared/share/haproxy-2.conf +0 -17
- data/spec/shared/shlib/config.sh +0 -27
- data/spec/shared/shlib/distro.sh +0 -74
- data/spec/shared/shlib/server.sh +0 -416
- data/spec/shared/shlib/set_env.sh +0 -169
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Aggregate.yml +0 -241
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Correctness.yml +0 -422
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Delete.yml +0 -182
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-FindOneAndUpdate.yml +0 -239
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-InsertFind.yml +0 -235
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Update.yml +0 -252
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Aggregate.yml +0 -1687
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Correctness.yml +0 -293
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Delete.yml +0 -905
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-FindOneAndUpdate.yml +0 -1684
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-InsertFind.yml +0 -1680
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Update.yml +0 -1697
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Aggregate.yml +0 -329
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Correctness.yml +0 -424
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Delete.yml +0 -226
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-FindOneAndUpdate.yml +0 -327
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-InsertFind.yml +0 -319
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Update.yml +0 -336
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Aggregate.yml +0 -913
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Correctness.yml +0 -292
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Delete.yml +0 -518
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-FindOneAndUpdate.yml +0 -911
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-InsertFind.yml +0 -907
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Update.yml +0 -924
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Aggregate.yml +0 -325
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Correctness.yml +0 -424
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Delete.yml +0 -224
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-FindOneAndUpdate.yml +0 -323
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-InsertFind.yml +0 -319
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Update.yml +0 -338
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Aggregate.yml +0 -241
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Correctness.yml +0 -423
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Delete.yml +0 -182
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-FindOneAndUpdate.yml +0 -239
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-InsertFind.yml +0 -235
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Update.yml +0 -254
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Aggregate.yml +0 -241
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Correctness.yml +0 -422
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Delete.yml +0 -182
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-FindOneAndUpdate.yml +0 -239
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-InsertFind.yml +0 -235
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Update.yml +0 -254
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-WrongType.yml +0 -43
- data/spec/spec_tests/data/cmap/pool-clear-interrupt-immediately.yml +0 -49
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -2
|
@@ -8,6 +8,8 @@ describe 'SDAM error handling' do
|
|
|
8
8
|
|
|
9
9
|
clean_slate
|
|
10
10
|
|
|
11
|
+
retry_test
|
|
12
|
+
|
|
11
13
|
after do
|
|
12
14
|
# Close all clients after every test to avoid leaking expectations into
|
|
13
15
|
# subsequent tests because we set global assertions on sockets.
|
|
@@ -418,7 +420,8 @@ describe 'SDAM error handling' do
|
|
|
418
420
|
expect_server_state_change
|
|
419
421
|
end
|
|
420
422
|
|
|
421
|
-
|
|
423
|
+
# https://jira.mongodb.org/browse/RUBY-2523
|
|
424
|
+
# it_behaves_like 'marks server unknown and clears connection pool'
|
|
422
425
|
|
|
423
426
|
after do
|
|
424
427
|
admin_client.command(configureFailPoint: 'failCommand', mode: 'off')
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
class SearchIndexHelper
|
|
6
|
+
attr_reader :client, :collection_name
|
|
7
|
+
|
|
8
|
+
def initialize(client)
|
|
9
|
+
@client = client
|
|
10
|
+
|
|
11
|
+
# https://github.com/mongodb/specifications/blob/master/source/index-management/tests/README.rst#id4
|
|
12
|
+
# "...each test uses a randomly generated collection name. Drivers may
|
|
13
|
+
# generate this collection name however they like, but a suggested
|
|
14
|
+
# implementation is a hex representation of an ObjectId..."
|
|
15
|
+
@collection_name = BSON::ObjectId.new.to_s
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# `soft_create` means to create the collection object without forcing it to
|
|
19
|
+
# be created in the database.
|
|
20
|
+
def collection(soft_create: false)
|
|
21
|
+
@collection ||= client.database[collection_name].tap do |collection|
|
|
22
|
+
collection.create unless soft_create
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Wait for all of the indexes with the given names to be ready; then return
|
|
27
|
+
# the list of index definitions corresponding to those names.
|
|
28
|
+
def wait_for(*names, &condition)
|
|
29
|
+
timeboxed_wait do
|
|
30
|
+
result = collection.search_indexes
|
|
31
|
+
return filter_results(result, names) if names.all? { |name| ready?(result, name, &condition) }
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Wait until all of the indexes with the given names are absent from the
|
|
36
|
+
# search index list.
|
|
37
|
+
def wait_for_absense_of(*names)
|
|
38
|
+
names.each do |name|
|
|
39
|
+
timeboxed_wait do
|
|
40
|
+
break if collection.search_indexes(name: name).empty?
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def timeboxed_wait(step: 5, max: 300)
|
|
48
|
+
start = Mongo::Utils.monotonic_time
|
|
49
|
+
|
|
50
|
+
loop do
|
|
51
|
+
yield
|
|
52
|
+
|
|
53
|
+
sleep step
|
|
54
|
+
raise Timeout::Error, 'wait took too long' if Mongo::Utils.monotonic_time - start > max
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Returns true if the list of search indexes includes one with the given name,
|
|
59
|
+
# which is ready to be queried.
|
|
60
|
+
def ready?(list, name, &condition)
|
|
61
|
+
condition ||= ->(index) { index['queryable'] }
|
|
62
|
+
list.any? { |index| index['name'] == name && condition[index] }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def filter_results(result, names)
|
|
66
|
+
result.select { |index| names.include?(index['name']) }
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe 'Mongo::Collection#search_indexes prose tests' do
|
|
71
|
+
# https://github.com/mongodb/specifications/blob/master/source/index-management/tests/README.rst#id5
|
|
72
|
+
# "These tests must run against an Atlas cluster with a 7.0+ server."
|
|
73
|
+
require_atlas
|
|
74
|
+
|
|
75
|
+
let(:client) do
|
|
76
|
+
Mongo::Client.new(
|
|
77
|
+
ENV['ATLAS_URI'],
|
|
78
|
+
database: SpecConfig.instance.test_db,
|
|
79
|
+
ssl: true,
|
|
80
|
+
ssl_verify: true
|
|
81
|
+
)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
let(:helper) { SearchIndexHelper.new(client) }
|
|
85
|
+
|
|
86
|
+
let(:name) { 'test-search-index' }
|
|
87
|
+
let(:definition) { { 'mappings' => { 'dynamic' => false } } }
|
|
88
|
+
let(:create_index) { helper.collection.search_indexes.create_one(definition, name: name) }
|
|
89
|
+
|
|
90
|
+
after do
|
|
91
|
+
client.close
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Case 1: Driver can successfully create and list search indexes
|
|
95
|
+
context 'when creating and listing search indexes' do
|
|
96
|
+
let(:index) { helper.wait_for(name).first }
|
|
97
|
+
|
|
98
|
+
it 'succeeds' do
|
|
99
|
+
expect(create_index).to be == name
|
|
100
|
+
expect(index['latestDefinition']).to be == definition
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Case 2: Driver can successfully create multiple indexes in batch
|
|
105
|
+
context 'when creating multiple indexes in batch' do
|
|
106
|
+
let(:specs) do
|
|
107
|
+
[
|
|
108
|
+
{ 'name' => 'test-search-index-1', 'definition' => definition },
|
|
109
|
+
{ 'name' => 'test-search-index-2', 'definition' => definition }
|
|
110
|
+
]
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
let(:names) { specs.map { |spec| spec['name'] } }
|
|
114
|
+
let(:create_indexes) { helper.collection.search_indexes.create_many(specs) }
|
|
115
|
+
|
|
116
|
+
let(:indexes) { helper.wait_for(*names) }
|
|
117
|
+
|
|
118
|
+
let(:index1) { indexes[0] }
|
|
119
|
+
let(:index2) { indexes[1] }
|
|
120
|
+
|
|
121
|
+
it 'succeeds' do
|
|
122
|
+
expect(create_indexes).to be == names
|
|
123
|
+
expect(index1['latestDefinition']).to be == specs[0]['definition']
|
|
124
|
+
expect(index2['latestDefinition']).to be == specs[1]['definition']
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Case 3: Driver can successfully drop search indexes
|
|
129
|
+
context 'when dropping search indexes' do
|
|
130
|
+
it 'succeeds' do
|
|
131
|
+
expect(create_index).to be == name
|
|
132
|
+
helper.wait_for(name)
|
|
133
|
+
|
|
134
|
+
helper.collection.search_indexes.drop_one(name: name)
|
|
135
|
+
|
|
136
|
+
expect { helper.wait_for_absense_of(name) }.not_to raise_error
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Case 4: Driver can update a search index
|
|
141
|
+
context 'when updating search indexes' do
|
|
142
|
+
let(:new_definition) { { 'mappings' => { 'dynamic' => true } } }
|
|
143
|
+
|
|
144
|
+
let(:index) do
|
|
145
|
+
helper
|
|
146
|
+
.wait_for(name) { |idx| idx['queryable'] && idx['status'] == 'READY' }
|
|
147
|
+
.first
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# rubocop:disable RSpec/ExampleLength
|
|
151
|
+
it 'succeeds' do
|
|
152
|
+
expect(create_index).to be == name
|
|
153
|
+
helper.wait_for(name)
|
|
154
|
+
|
|
155
|
+
expect do
|
|
156
|
+
helper.collection.search_indexes.update_one(new_definition, name: name)
|
|
157
|
+
end.not_to raise_error
|
|
158
|
+
|
|
159
|
+
expect(index['latestDefinition']).to be == new_definition
|
|
160
|
+
end
|
|
161
|
+
# rubocop:enable RSpec/ExampleLength
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Case 5: dropSearchIndex suppresses namespace not found errors
|
|
165
|
+
context 'when dropping a non-existent search index' do
|
|
166
|
+
it 'ignores `namespace not found` errors' do
|
|
167
|
+
collection = helper.collection(soft_create: true)
|
|
168
|
+
expect { collection.search_indexes.drop_one(name: name) }
|
|
169
|
+
.not_to raise_error
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
end
|
|
@@ -6,6 +6,7 @@ require 'spec_helper'
|
|
|
6
6
|
describe 'Server' do
|
|
7
7
|
let(:client) { authorized_client }
|
|
8
8
|
|
|
9
|
+
let(:context) { Mongo::Operation::Context.new(client: client) }
|
|
9
10
|
let(:server) { client.cluster.next_primary }
|
|
10
11
|
|
|
11
12
|
let(:collection) { client['collection'] }
|
|
@@ -15,7 +16,7 @@ describe 'Server' do
|
|
|
15
16
|
context 'it performs read operations and receives the correct result type' do
|
|
16
17
|
context 'normal server' do
|
|
17
18
|
it 'can be used for reads' do
|
|
18
|
-
result = view.send(:send_initial_query, server)
|
|
19
|
+
result = view.send(:send_initial_query, server, context)
|
|
19
20
|
expect(result).to be_a(Mongo::Operation::Find::Result)
|
|
20
21
|
end
|
|
21
22
|
end
|
|
@@ -35,7 +36,7 @@ describe 'Server' do
|
|
|
35
36
|
|
|
36
37
|
it 'can be used for reads' do
|
|
37
38
|
# See also RUBY-3102.
|
|
38
|
-
result = view.send(:send_initial_query, server)
|
|
39
|
+
result = view.send(:send_initial_query, server, context)
|
|
39
40
|
expect(result).to be_a(Mongo::Operation::Find::Result)
|
|
40
41
|
end
|
|
41
42
|
end
|
|
@@ -57,7 +58,7 @@ describe 'Server' do
|
|
|
57
58
|
it 'is unusable' do
|
|
58
59
|
# See also RUBY-3102.
|
|
59
60
|
lambda do
|
|
60
|
-
view.send(:send_initial_query, server)
|
|
61
|
+
view.send(:send_initial_query, server, context)
|
|
61
62
|
end.should raise_error(Mongo::Error::ServerNotUsable)
|
|
62
63
|
end
|
|
63
64
|
end
|
data/spec/lite_spec_helper.rb
CHANGED
|
@@ -22,7 +22,9 @@ CMAP_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/cmap/*.yml").sort.select
|
|
|
22
22
|
!defined?(JRUBY_VERSION) || !f.include?('pool-checkout-minPoolSize-connection-maxConnecting.yml')
|
|
23
23
|
end
|
|
24
24
|
AUTH_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/auth/*.yml").sort
|
|
25
|
-
CLIENT_SIDE_ENCRYPTION_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/client_side_encryption/*.yml").sort
|
|
25
|
+
CLIENT_SIDE_ENCRYPTION_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/client_side_encryption/*.yml").sort.delete_if do |spec|
|
|
26
|
+
![ 1, '1', 'yes', 'true' ].include?(ENV['CSOT_SPEC_TESTS']) && spec =~ /.*timeoutMS.yml$/
|
|
27
|
+
end
|
|
26
28
|
|
|
27
29
|
# Disable output buffering: https://www.rubyguides.com/2019/02/ruby-io/
|
|
28
30
|
STDOUT.sync = true
|
|
@@ -106,6 +108,31 @@ Mrss.patch_mongo_for_session_registry
|
|
|
106
108
|
|
|
107
109
|
class ExampleTimeout < StandardError; end
|
|
108
110
|
|
|
111
|
+
STANDARD_TIMEOUTS = {
|
|
112
|
+
stress: 210,
|
|
113
|
+
jruby: 90,
|
|
114
|
+
default: 45,
|
|
115
|
+
}.freeze
|
|
116
|
+
|
|
117
|
+
def timeout_type
|
|
118
|
+
if ENV['EXAMPLE_TIMEOUT'].to_i > 0
|
|
119
|
+
:custom
|
|
120
|
+
elsif %w(1 true yes).include?(ENV['STRESS']&.downcase)
|
|
121
|
+
:stress
|
|
122
|
+
elsif BSON::Environment.jruby?
|
|
123
|
+
:jruby
|
|
124
|
+
else
|
|
125
|
+
:default
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def example_timeout_seconds
|
|
130
|
+
STANDARD_TIMEOUTS.fetch(
|
|
131
|
+
timeout_type,
|
|
132
|
+
(ENV['EXAMPLE_TIMEOUT'] || STANDARD_TIMEOUTS[:default]).to_i
|
|
133
|
+
)
|
|
134
|
+
end
|
|
135
|
+
|
|
109
136
|
RSpec.configure do |config|
|
|
110
137
|
config.extend(CommonShortcuts::ClassMethods)
|
|
111
138
|
config.include(CommonShortcuts::InstanceMethods)
|
|
@@ -123,6 +150,12 @@ RSpec.configure do |config|
|
|
|
123
150
|
end
|
|
124
151
|
end
|
|
125
152
|
|
|
153
|
+
def require_atlas
|
|
154
|
+
before do
|
|
155
|
+
skip 'Set ATLAS_URI in environment to run atlas tests' if ENV['ATLAS_URI'].nil?
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
126
159
|
if SpecConfig.instance.ci?
|
|
127
160
|
SdamFormatterIntegration.subscribe
|
|
128
161
|
config.add_formatter(JsonExtFormatter, File.join(File.dirname(__FILE__), '../tmp/rspec.json'))
|
|
@@ -137,25 +170,6 @@ RSpec.configure do |config|
|
|
|
137
170
|
end
|
|
138
171
|
end
|
|
139
172
|
|
|
140
|
-
if SpecConfig.instance.ci? && !%w(1 true yes).include?(ENV['INTERACTIVE']&.downcase)
|
|
141
|
-
# Tests should take under 10 seconds ideally but it seems
|
|
142
|
-
# we have some that run for more than 10 seconds in CI.
|
|
143
|
-
config.around(:each) do |example|
|
|
144
|
-
timeout = if %w(1 true yes).include?(ENV['STRESS']&.downcase)
|
|
145
|
-
210
|
|
146
|
-
else
|
|
147
|
-
if BSON::Environment.jruby?
|
|
148
|
-
90
|
|
149
|
-
else
|
|
150
|
-
45
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
TimeoutInterrupt.timeout(timeout, ExampleTimeout) do
|
|
154
|
-
example.run
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
173
|
if SpecConfig.instance.ci?
|
|
160
174
|
if defined?(Rfc::Rif)
|
|
161
175
|
unless BSON::Environment.jruby?
|
|
@@ -526,7 +526,7 @@ describe Mongo::Auth::User::View do
|
|
|
526
526
|
it "raises and reports the write concern error correctly" do
|
|
527
527
|
begin
|
|
528
528
|
view.send(method, input)
|
|
529
|
-
rescue Mongo::Error::OperationFailure => e
|
|
529
|
+
rescue Mongo::Error::OperationFailure::Family => e
|
|
530
530
|
expect(e.write_concern_error?).to be true
|
|
531
531
|
expect(e.write_concern_error_document).to eq(
|
|
532
532
|
"code" => 64,
|
data/spec/mongo/client_spec.rb
CHANGED
|
@@ -561,6 +561,75 @@ describe Mongo::Client do
|
|
|
561
561
|
expect(command['comment']).to eq('comment')
|
|
562
562
|
end
|
|
563
563
|
end
|
|
564
|
+
|
|
565
|
+
context 'with timeout_ms' do
|
|
566
|
+
# To make it easier with failCommand
|
|
567
|
+
require_topology :single
|
|
568
|
+
min_server_version '4.4'
|
|
569
|
+
|
|
570
|
+
before do
|
|
571
|
+
root_authorized_client.use('admin').command({
|
|
572
|
+
configureFailPoint: "failCommand",
|
|
573
|
+
mode: "alwaysOn",
|
|
574
|
+
data: {
|
|
575
|
+
failCommands: ["listDatabases"],
|
|
576
|
+
blockConnection: true,
|
|
577
|
+
blockTimeMS: 100
|
|
578
|
+
}
|
|
579
|
+
})
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
after do
|
|
583
|
+
root_authorized_client.use('admin').command({
|
|
584
|
+
configureFailPoint: "failCommand",
|
|
585
|
+
mode: "off"
|
|
586
|
+
})
|
|
587
|
+
end
|
|
588
|
+
|
|
589
|
+
context 'when timeout_ms is set on command level' do
|
|
590
|
+
context 'when there is not enough time' do
|
|
591
|
+
it 'raises' do
|
|
592
|
+
expect do
|
|
593
|
+
monitored_client.database_names({}, timeout_ms: 50)
|
|
594
|
+
end.to raise_error(Mongo::Error::TimeoutError)
|
|
595
|
+
end
|
|
596
|
+
end
|
|
597
|
+
|
|
598
|
+
context 'when there is enough time' do
|
|
599
|
+
it 'does not raise' do
|
|
600
|
+
expect do
|
|
601
|
+
monitored_client.database_names({}, timeout_ms: 200)
|
|
602
|
+
end.not_to raise_error
|
|
603
|
+
end
|
|
604
|
+
end
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
context 'when timeout_ms is set on client level' do
|
|
608
|
+
context 'when there is not enough time' do
|
|
609
|
+
let(:client) do
|
|
610
|
+
root_authorized_client.with(timeout_ms: 50)
|
|
611
|
+
end
|
|
612
|
+
|
|
613
|
+
it 'raises' do
|
|
614
|
+
expect do
|
|
615
|
+
client.database_names({})
|
|
616
|
+
end.to raise_error(Mongo::Error::TimeoutError)
|
|
617
|
+
end
|
|
618
|
+
end
|
|
619
|
+
|
|
620
|
+
context 'when there is enough time' do
|
|
621
|
+
let(:client) do
|
|
622
|
+
root_authorized_client.with(timeout_ms: 200)
|
|
623
|
+
end
|
|
624
|
+
|
|
625
|
+
it 'does not raise' do
|
|
626
|
+
expect do
|
|
627
|
+
monitored_client.database_names({})
|
|
628
|
+
end.not_to raise_error
|
|
629
|
+
end
|
|
630
|
+
end
|
|
631
|
+
end
|
|
632
|
+
end
|
|
564
633
|
end
|
|
565
634
|
|
|
566
635
|
describe '#list_databases' do
|
|
@@ -572,8 +641,6 @@ describe Mongo::Client do
|
|
|
572
641
|
end
|
|
573
642
|
|
|
574
643
|
context 'when filter criteria is present' do
|
|
575
|
-
min_server_fcv '3.6'
|
|
576
|
-
|
|
577
644
|
include_context 'ensure test db exists'
|
|
578
645
|
|
|
579
646
|
let(:result) do
|
|
@@ -591,8 +658,6 @@ describe Mongo::Client do
|
|
|
591
658
|
end
|
|
592
659
|
|
|
593
660
|
context 'when name_only is true' do
|
|
594
|
-
min_server_fcv '3.6'
|
|
595
|
-
|
|
596
661
|
let(:command) do
|
|
597
662
|
Utils.get_command_event(root_authorized_client, 'listDatabases') do |client|
|
|
598
663
|
client.list_databases({}, true)
|
|
@@ -667,6 +732,75 @@ describe Mongo::Client do
|
|
|
667
732
|
expect(command['comment']).to eq('comment')
|
|
668
733
|
end
|
|
669
734
|
end
|
|
735
|
+
|
|
736
|
+
context 'with timeout_ms' do
|
|
737
|
+
# To make it easier with failCommand
|
|
738
|
+
require_topology :single
|
|
739
|
+
min_server_version '4.4'
|
|
740
|
+
|
|
741
|
+
before do
|
|
742
|
+
root_authorized_client.use('admin').command({
|
|
743
|
+
configureFailPoint: "failCommand",
|
|
744
|
+
mode: "alwaysOn",
|
|
745
|
+
data: {
|
|
746
|
+
failCommands: ["listDatabases"],
|
|
747
|
+
blockConnection: true,
|
|
748
|
+
blockTimeMS: 100
|
|
749
|
+
}
|
|
750
|
+
})
|
|
751
|
+
end
|
|
752
|
+
|
|
753
|
+
after do
|
|
754
|
+
root_authorized_client.use('admin').command({
|
|
755
|
+
configureFailPoint: "failCommand",
|
|
756
|
+
mode: "off"
|
|
757
|
+
})
|
|
758
|
+
end
|
|
759
|
+
|
|
760
|
+
context 'when timeout_ms is set on command level' do
|
|
761
|
+
context 'when there is not enough time' do
|
|
762
|
+
it 'raises' do
|
|
763
|
+
expect do
|
|
764
|
+
monitored_client.list_databases({}, false, timeout_ms: 50)
|
|
765
|
+
end.to raise_error(Mongo::Error::TimeoutError)
|
|
766
|
+
end
|
|
767
|
+
end
|
|
768
|
+
|
|
769
|
+
context 'when there is enough time' do
|
|
770
|
+
it 'does not raise' do
|
|
771
|
+
expect do
|
|
772
|
+
monitored_client.list_databases({}, false, timeout_ms: 200)
|
|
773
|
+
end.not_to raise_error
|
|
774
|
+
end
|
|
775
|
+
end
|
|
776
|
+
end
|
|
777
|
+
|
|
778
|
+
context 'when timeout_ms is set on client level' do
|
|
779
|
+
context 'when there is not enough time' do
|
|
780
|
+
let(:client) do
|
|
781
|
+
root_authorized_client.with(timeout_ms: 50)
|
|
782
|
+
end
|
|
783
|
+
|
|
784
|
+
it 'raises' do
|
|
785
|
+
expect do
|
|
786
|
+
client.list_databases({})
|
|
787
|
+
end.to raise_error(Mongo::Error::TimeoutError)
|
|
788
|
+
end
|
|
789
|
+
end
|
|
790
|
+
|
|
791
|
+
context 'when there is enough time' do
|
|
792
|
+
let(:client) do
|
|
793
|
+
root_authorized_client.with(timeout_ms: 200)
|
|
794
|
+
end
|
|
795
|
+
|
|
796
|
+
it 'does not raise' do
|
|
797
|
+
expect do
|
|
798
|
+
monitored_client.list_databases({})
|
|
799
|
+
end.not_to raise_error
|
|
800
|
+
end
|
|
801
|
+
end
|
|
802
|
+
end
|
|
803
|
+
end
|
|
670
804
|
end
|
|
671
805
|
|
|
672
806
|
describe '#list_mongo_databases' do
|
|
@@ -1156,6 +1290,26 @@ describe Mongo::Client do
|
|
|
1156
1290
|
}.to raise_exception(Mongo::Error::InvalidSession)
|
|
1157
1291
|
end
|
|
1158
1292
|
end
|
|
1293
|
+
|
|
1294
|
+
context 'when CSOT is set on the client' do
|
|
1295
|
+
require_topology :replica_set
|
|
1296
|
+
|
|
1297
|
+
let(:timeout_ms) { 10 }
|
|
1298
|
+
|
|
1299
|
+
let(:timeout_sec) { timeout_ms / 1_000.0 }
|
|
1300
|
+
|
|
1301
|
+
let(:client) do
|
|
1302
|
+
authorized_client.with(timeout_ms: timeout_ms)
|
|
1303
|
+
end
|
|
1304
|
+
|
|
1305
|
+
it 'uses CSOT timeout set on the client' do
|
|
1306
|
+
expect_any_instance_of(Mongo::ServerSelector::PrimaryPreferred).to(
|
|
1307
|
+
receive(:select_server).with(anything, {timeout: timeout_sec}).and_call_original
|
|
1308
|
+
)
|
|
1309
|
+
|
|
1310
|
+
client.start_session
|
|
1311
|
+
end
|
|
1312
|
+
end
|
|
1159
1313
|
end
|
|
1160
1314
|
|
|
1161
1315
|
describe '#summary' do
|
data/spec/mongo/cluster_spec.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
|
+
require 'support/recording_logger'
|
|
4
5
|
|
|
5
6
|
# let these existing styles stand, rather than going in for a deep refactoring
|
|
6
7
|
# of these specs.
|
|
@@ -84,6 +85,41 @@ describe Mongo::Cluster do
|
|
|
84
85
|
)
|
|
85
86
|
end
|
|
86
87
|
end
|
|
88
|
+
|
|
89
|
+
context 'when a non-genuine host is detected' do
|
|
90
|
+
before { described_class.new(host_names, monitoring, logger: logger, monitoring_io: false) }
|
|
91
|
+
|
|
92
|
+
let(:logger) { RecordingLogger.new }
|
|
93
|
+
|
|
94
|
+
shared_examples 'an action that logs' do
|
|
95
|
+
it 'writes a warning to the log' do
|
|
96
|
+
expect(logger.lines).to include(a_string_matching(expected_log_output))
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
context 'when CosmosDB is detected' do
|
|
101
|
+
let(:host_names) { %w[ xyz.cosmos.azure.com ] }
|
|
102
|
+
let(:expected_log_output) { %r{https://www.mongodb.com/supportability/cosmosdb} }
|
|
103
|
+
|
|
104
|
+
it_behaves_like 'an action that logs'
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
context 'when DocumentDB is detected' do
|
|
108
|
+
let(:expected_log_output) { %r{https://www.mongodb.com/supportability/documentdb} }
|
|
109
|
+
|
|
110
|
+
context 'with docdb uri' do
|
|
111
|
+
let(:host_names) { [ 'xyz.docdb.amazonaws.com' ] }
|
|
112
|
+
|
|
113
|
+
it_behaves_like 'an action that logs'
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
context 'with docdb-elastic uri' do
|
|
117
|
+
let(:host_names) { [ 'xyz.docdb-elastic.amazonaws.com' ] }
|
|
118
|
+
|
|
119
|
+
it_behaves_like 'an action that logs'
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
87
123
|
end
|
|
88
124
|
|
|
89
125
|
describe '#==' do
|
|
@@ -156,8 +156,6 @@ describe Mongo::Collection::View::Aggregation do
|
|
|
156
156
|
end
|
|
157
157
|
|
|
158
158
|
context 'when the initial response has no results but an active cursor' do
|
|
159
|
-
min_server_fcv '3.2'
|
|
160
|
-
|
|
161
159
|
let(:documents) do
|
|
162
160
|
[
|
|
163
161
|
{ city: 'a'*6000000 },
|
|
@@ -166,7 +164,7 @@ describe Mongo::Collection::View::Aggregation do
|
|
|
166
164
|
end
|
|
167
165
|
|
|
168
166
|
let(:options) do
|
|
169
|
-
{
|
|
167
|
+
{}
|
|
170
168
|
end
|
|
171
169
|
|
|
172
170
|
let(:pipeline) do
|
|
@@ -321,7 +319,12 @@ describe Mongo::Collection::View::Aggregation do
|
|
|
321
319
|
min_server_fcv '4.2'
|
|
322
320
|
|
|
323
321
|
let(:result) do
|
|
324
|
-
aggregation.explain
|
|
322
|
+
if aggregation.explain.key?('queryPlanner')
|
|
323
|
+
aggregation.explain['queryPlanner']['collation']['locale']
|
|
324
|
+
else
|
|
325
|
+
# 7.2+ sharded cluster
|
|
326
|
+
aggregation.explain['shards'].first.last['queryPlanner']['collation']['locale']
|
|
327
|
+
end
|
|
325
328
|
end
|
|
326
329
|
|
|
327
330
|
it_behaves_like 'applies the collation'
|
|
@@ -481,48 +484,25 @@ describe Mongo::Collection::View::Aggregation do
|
|
|
481
484
|
end
|
|
482
485
|
end
|
|
483
486
|
|
|
484
|
-
context 'when
|
|
485
|
-
|
|
486
|
-
context 'when use_cursor is true' do
|
|
487
|
-
|
|
488
|
-
context 'when batch_size is set' do
|
|
489
|
-
|
|
490
|
-
let(:options) do
|
|
491
|
-
{ :use_cursor => true,
|
|
492
|
-
:batch_size => 10
|
|
493
|
-
}
|
|
494
|
-
end
|
|
495
|
-
|
|
496
|
-
it 'sets a batch size document in the spec' do
|
|
497
|
-
expect(aggregation_spec[:selector][:cursor][:batchSize]).to eq(options[:batch_size])
|
|
498
|
-
end
|
|
499
|
-
end
|
|
500
|
-
|
|
501
|
-
context 'when batch_size is not set' do
|
|
502
|
-
|
|
503
|
-
let(:options) do
|
|
504
|
-
{ :use_cursor => true }
|
|
505
|
-
end
|
|
506
|
-
|
|
507
|
-
it 'sets an empty document in the spec' do
|
|
508
|
-
expect(aggregation_spec[:selector][:cursor]).to eq({})
|
|
509
|
-
end
|
|
510
|
-
end
|
|
487
|
+
context 'when batch_size is set' do
|
|
511
488
|
|
|
489
|
+
let(:options) do
|
|
490
|
+
{ :batch_size => 10 }
|
|
512
491
|
end
|
|
513
492
|
|
|
514
|
-
|
|
493
|
+
it 'sets a batch size document in the spec' do
|
|
494
|
+
expect(aggregation_spec[:selector][:cursor][:batchSize]).to eq(options[:batch_size])
|
|
495
|
+
end
|
|
496
|
+
end
|
|
515
497
|
|
|
516
|
-
|
|
517
|
-
{ :use_cursor => false }
|
|
518
|
-
end
|
|
498
|
+
context 'when batch_size is not set' do
|
|
519
499
|
|
|
520
|
-
|
|
500
|
+
let(:options) do
|
|
501
|
+
{}
|
|
502
|
+
end
|
|
521
503
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
end
|
|
525
|
-
end
|
|
504
|
+
it 'sets an empty document in the spec' do
|
|
505
|
+
expect(aggregation_spec[:selector][:cursor]).to eq({})
|
|
526
506
|
end
|
|
527
507
|
end
|
|
528
508
|
end
|