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
|
@@ -1,8 +1,52 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# rubocop:todo all
|
|
2
3
|
|
|
3
4
|
require 'spec_helper'
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
|
|
7
|
+
MOCKED_DOCKERENV_PATH = File.expand_path(File.join(Dir.pwd, '.dockerenv-mocked'))
|
|
8
|
+
|
|
9
|
+
module ContainerChecking
|
|
10
|
+
def mock_dockerenv_path
|
|
11
|
+
before do
|
|
12
|
+
allow_any_instance_of(Mongo::Server::AppMetadata::Environment)
|
|
13
|
+
.to receive(:dockerenv_path)
|
|
14
|
+
.and_return(MOCKED_DOCKERENV_PATH)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def with_docker
|
|
19
|
+
mock_dockerenv_path
|
|
20
|
+
|
|
21
|
+
around do |example|
|
|
22
|
+
File.write(MOCKED_DOCKERENV_PATH, 'placeholder')
|
|
23
|
+
example.run
|
|
24
|
+
ensure
|
|
25
|
+
File.delete(MOCKED_DOCKERENV_PATH)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def without_docker
|
|
30
|
+
mock_dockerenv_path
|
|
31
|
+
|
|
32
|
+
around do |example|
|
|
33
|
+
FileUtils.rm_f(MOCKED_DOCKERENV_PATH)
|
|
34
|
+
example.run
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def with_kubernetes
|
|
39
|
+
local_env 'KUBERNETES_SERVICE_HOST' => 'kubernetes.default.svc.cluster.local'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def without_kubernetes
|
|
43
|
+
local_env 'KUBERNETES_SERVICE_HOST' => nil
|
|
44
|
+
end
|
|
45
|
+
end
|
|
4
46
|
|
|
5
47
|
describe Mongo::Server::AppMetadata::Environment do
|
|
48
|
+
extend ContainerChecking
|
|
49
|
+
|
|
6
50
|
let(:env) { described_class.new }
|
|
7
51
|
|
|
8
52
|
shared_examples_for 'running in a FaaS environment' do
|
|
@@ -17,6 +61,36 @@ describe Mongo::Server::AppMetadata::Environment do
|
|
|
17
61
|
end
|
|
18
62
|
end
|
|
19
63
|
|
|
64
|
+
shared_examples_for 'not running in a Docker container' do
|
|
65
|
+
it 'does not detect Docker' do
|
|
66
|
+
expect(env.container || {}).not_to include :runtime
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
shared_examples_for 'not running under Kubernetes' do
|
|
71
|
+
it 'does not detect Kubernetes' do
|
|
72
|
+
expect(env.container || {}).not_to include :orchestrator
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
shared_examples_for 'running under Kubernetes' do
|
|
77
|
+
it 'detects that Kubernetes is present' do
|
|
78
|
+
expect(env.container[:orchestrator]).to be == 'kubernetes'
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
shared_examples_for 'running in a Docker container' do
|
|
83
|
+
it 'detects that Docker is present' do
|
|
84
|
+
expect(env.container[:runtime]).to be == 'docker'
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
shared_examples_for 'running under Kerbenetes' do
|
|
89
|
+
it 'detects that kubernetes is present' do
|
|
90
|
+
expect(env.container['orchestrator']).to be == 'kubernetes'
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
20
94
|
context 'when run outside of a FaaS environment' do
|
|
21
95
|
it_behaves_like 'running outside a FaaS environment'
|
|
22
96
|
end
|
|
@@ -204,6 +278,67 @@ describe Mongo::Server::AppMetadata::Environment do
|
|
|
204
278
|
timeout_sec: 60, region: 'us-central1',
|
|
205
279
|
}
|
|
206
280
|
end
|
|
281
|
+
|
|
282
|
+
context 'when a container is present' do
|
|
283
|
+
with_kubernetes
|
|
284
|
+
with_docker
|
|
285
|
+
|
|
286
|
+
it 'includes a container key' do
|
|
287
|
+
expect(env.to_h[:container]).to be == {
|
|
288
|
+
runtime: 'docker',
|
|
289
|
+
orchestrator: 'kubernetes'
|
|
290
|
+
}
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
context 'when no container is present' do
|
|
295
|
+
without_kubernetes
|
|
296
|
+
without_docker
|
|
297
|
+
|
|
298
|
+
it 'does not include a container key' do
|
|
299
|
+
expect(env.to_h).not_to include(:container)
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
# have a specific test for this, since the tests that check
|
|
306
|
+
# for Docker use a mocked value for the .dockerenv path.
|
|
307
|
+
it 'should look for dockerenv in root directory' do
|
|
308
|
+
expect(described_class::DOCKERENV_PATH).to be == '/.dockerenv'
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
context 'when no container is present' do
|
|
312
|
+
without_kubernetes
|
|
313
|
+
without_docker
|
|
314
|
+
|
|
315
|
+
it_behaves_like 'not running in a Docker container'
|
|
316
|
+
it_behaves_like 'not running under Kubernetes'
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
context 'when container is present' do
|
|
320
|
+
context 'when kubernetes is present' do
|
|
321
|
+
without_docker
|
|
322
|
+
with_kubernetes
|
|
323
|
+
|
|
324
|
+
it_behaves_like 'not running in a Docker container'
|
|
325
|
+
it_behaves_like 'running under Kubernetes'
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
context 'when docker is present' do
|
|
329
|
+
with_docker
|
|
330
|
+
without_kubernetes
|
|
331
|
+
|
|
332
|
+
it_behaves_like 'running in a Docker container'
|
|
333
|
+
it_behaves_like 'not running under Kubernetes'
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
context 'when both kubernetes and docker are present' do
|
|
337
|
+
with_docker
|
|
338
|
+
with_kubernetes
|
|
339
|
+
|
|
340
|
+
it_behaves_like 'running in a Docker container'
|
|
341
|
+
it_behaves_like 'running under Kubernetes'
|
|
207
342
|
end
|
|
208
343
|
end
|
|
209
344
|
end
|
|
@@ -87,8 +87,18 @@ describe Mongo::Server::AppMetadata do
|
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
context 'when run outside of a FaaS environment' do
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
context 'when a container is present' do
|
|
91
|
+
local_env 'KUBERNETES_SERVICE_HOST' => 'something'
|
|
92
|
+
|
|
93
|
+
it 'includes the :env key in the client document' do
|
|
94
|
+
expect(app_metadata.client_document.key?(:env)).to be true
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
context 'when no container is present' do
|
|
99
|
+
it 'excludes the :env key from the client document' do
|
|
100
|
+
expect(app_metadata.client_document.key?(:env)).to be false
|
|
101
|
+
end
|
|
92
102
|
end
|
|
93
103
|
end
|
|
94
104
|
|
|
@@ -265,6 +265,10 @@ describe Mongo::Server::Connection do
|
|
|
265
265
|
context 'when #authenticate! raises an exception' do
|
|
266
266
|
require_auth
|
|
267
267
|
|
|
268
|
+
# because the mock/stub flow here doesn't cover the flow used by
|
|
269
|
+
# the X.509 authentication mechanism...
|
|
270
|
+
forbid_x509_auth
|
|
271
|
+
|
|
268
272
|
let(:server_options) do
|
|
269
273
|
Mongo::Client.canonicalize_ruby_options(
|
|
270
274
|
SpecConfig.instance.all_test_options,
|
|
@@ -579,6 +583,28 @@ describe Mongo::Server::Connection do
|
|
|
579
583
|
end
|
|
580
584
|
end
|
|
581
585
|
|
|
586
|
+
context 'when the server returns unknown saslSupportedMechs' do
|
|
587
|
+
min_server_version '4.0'
|
|
588
|
+
|
|
589
|
+
let(:connection) do
|
|
590
|
+
described_class.new(server, server.options.merge(connection_pool: pool))
|
|
591
|
+
end
|
|
592
|
+
|
|
593
|
+
before do
|
|
594
|
+
expect_any_instance_of(Mongo::Server::PendingConnection).to receive(:get_handshake_response).and_wrap_original do |original_method, *args|
|
|
595
|
+
original_method.call(*args).tap do |result|
|
|
596
|
+
if result.documents.first.fetch('saslSupportedMechs', nil).is_a?(Array)
|
|
597
|
+
result.documents.first['saslSupportedMechs'].append('unknownMechanism')
|
|
598
|
+
end
|
|
599
|
+
end
|
|
600
|
+
end
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
it 'does not raise an error' do
|
|
604
|
+
expect { connection.connect! }.not_to raise_error
|
|
605
|
+
end
|
|
606
|
+
end
|
|
607
|
+
|
|
582
608
|
end
|
|
583
609
|
|
|
584
610
|
describe '#disconnect!' do
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# rubocop:todo all
|
|
3
|
+
|
|
4
|
+
require 'spec_helper'
|
|
5
|
+
|
|
6
|
+
describe Mongo::Server::RoundTripTimeCalculator do
|
|
7
|
+
let(:calculator) { Mongo::Server::RoundTripTimeCalculator.new }
|
|
8
|
+
|
|
9
|
+
describe '#update_average_round_trip_time' do
|
|
10
|
+
context 'no existing average rtt' do
|
|
11
|
+
it 'updates average rtt' do
|
|
12
|
+
calculator.instance_variable_set('@last_round_trip_time', 5)
|
|
13
|
+
calculator.update_average_round_trip_time
|
|
14
|
+
expect(calculator.average_round_trip_time).to eq(5)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context 'with existing average rtt' do
|
|
19
|
+
it 'averages with existing average rtt' do
|
|
20
|
+
calculator.instance_variable_set('@last_round_trip_time', 5)
|
|
21
|
+
calculator.instance_variable_set('@average_round_trip_time', 10)
|
|
22
|
+
calculator.update_average_round_trip_time
|
|
23
|
+
expect(calculator.average_round_trip_time).to eq(9)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe '#update_minimum_round_trip_time' do
|
|
29
|
+
context 'with no samples' do
|
|
30
|
+
it 'sets minimum_round_trip_time to zero' do
|
|
31
|
+
calculator.update_minimum_round_trip_time
|
|
32
|
+
expect(calculator.minimum_round_trip_time).to eq(0)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context 'with one sample' do
|
|
37
|
+
before do
|
|
38
|
+
calculator.instance_variable_set('@last_round_trip_time', 5)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'sets minimum_round_trip_time to zero' do
|
|
42
|
+
calculator.update_minimum_round_trip_time
|
|
43
|
+
expect(calculator.minimum_round_trip_time).to eq(0)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context 'with two samples' do
|
|
48
|
+
before do
|
|
49
|
+
calculator.instance_variable_set('@last_round_trip_time', 10)
|
|
50
|
+
calculator.instance_variable_set('@rtts', [5])
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'sets minimum_round_trip_time to zero' do
|
|
54
|
+
calculator.update_minimum_round_trip_time
|
|
55
|
+
expect(calculator.minimum_round_trip_time).to eq(0)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context 'with samples less than maximum' do
|
|
60
|
+
before do
|
|
61
|
+
calculator.instance_variable_set('@last_round_trip_time', 10)
|
|
62
|
+
calculator.instance_variable_set('@rtts', [5, 4, 120])
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'properly sets minimum_round_trip_time' do
|
|
66
|
+
calculator.update_minimum_round_trip_time
|
|
67
|
+
expect(calculator.minimum_round_trip_time).to eq(4)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
context 'with more than maximum samples' do
|
|
72
|
+
before do
|
|
73
|
+
calculator.instance_variable_set('@last_round_trip_time', 2)
|
|
74
|
+
calculator.instance_variable_set('@rtts', [1, 20, 15, 4, 5, 6, 7, 39, 8, 4])
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'properly sets minimum_round_trip_time' do
|
|
78
|
+
calculator.update_minimum_round_trip_time
|
|
79
|
+
expect(calculator.minimum_round_trip_time).to eq(2)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe '#measure' do
|
|
86
|
+
context 'block does not raise' do
|
|
87
|
+
it 'updates average rtt' do
|
|
88
|
+
expect(calculator).to receive(:update_average_round_trip_time)
|
|
89
|
+
calculator.measure do
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'updates minimum rtt' do
|
|
94
|
+
expect(calculator).to receive(:update_minimum_round_trip_time)
|
|
95
|
+
calculator.measure do
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
context 'block raises' do
|
|
101
|
+
it 'does not update average rtt' do
|
|
102
|
+
expect(calculator).not_to receive(:update_average_round_trip_time)
|
|
103
|
+
expect do
|
|
104
|
+
calculator.measure do
|
|
105
|
+
raise "Problem"
|
|
106
|
+
end
|
|
107
|
+
end.to raise_error(/Problem/)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'does not update minimum rtt' do
|
|
111
|
+
expect(calculator).not_to receive(:update_minimum_round_trip_time)
|
|
112
|
+
expect do
|
|
113
|
+
calculator.measure do
|
|
114
|
+
raise "Problem"
|
|
115
|
+
end
|
|
116
|
+
end.to raise_error(/Problem/)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
@@ -17,21 +17,6 @@ describe Mongo::Session::SessionPool do
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
describe '.create' do
|
|
21
|
-
|
|
22
|
-
let!(:pool) do
|
|
23
|
-
described_class.create(cluster)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'creates a session pool' do
|
|
27
|
-
expect(pool).to be_a(Mongo::Session::SessionPool)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'adds the pool as an instance variable on the cluster' do
|
|
31
|
-
expect(cluster.session_pool).to eq(pool)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
20
|
describe '#initialize' do
|
|
36
21
|
|
|
37
22
|
let(:pool) do
|
|
@@ -181,7 +166,7 @@ describe Mongo::Session::SessionPool do
|
|
|
181
166
|
describe '#end_sessions' do
|
|
182
167
|
|
|
183
168
|
let(:pool) do
|
|
184
|
-
|
|
169
|
+
client.cluster.session_pool
|
|
185
170
|
end
|
|
186
171
|
|
|
187
172
|
let!(:session_a) do
|
|
@@ -26,6 +26,17 @@ describe Mongo::Session do
|
|
|
26
26
|
collection.delete_many
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
describe 'start_transaction' do
|
|
30
|
+
context 'when topology is sharded and server is < 4.2' do
|
|
31
|
+
max_server_fcv '4.1'
|
|
32
|
+
require_topology :sharded
|
|
33
|
+
|
|
34
|
+
it 'raises an error' do
|
|
35
|
+
expect { session.start_transaction }.to raise_error(Mongo::Error::TransactionsNotSupported, /sharded transactions require server version/)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
29
40
|
describe '#abort_transaction' do
|
|
30
41
|
require_topology :replica_set
|
|
31
42
|
|
|
@@ -75,6 +86,8 @@ describe Mongo::Session do
|
|
|
75
86
|
end
|
|
76
87
|
|
|
77
88
|
describe '#with_transaction' do
|
|
89
|
+
require_topology :replica_set
|
|
90
|
+
|
|
78
91
|
context 'callback successful' do
|
|
79
92
|
it 'commits' do
|
|
80
93
|
session.with_transaction do
|
|
@@ -123,6 +136,7 @@ describe Mongo::Session do
|
|
|
123
136
|
expect(Mongo::Utils).to receive(:monotonic_time).ordered.and_return(start + 1)
|
|
124
137
|
expect(Mongo::Utils).to receive(:monotonic_time).ordered.and_return(start + 2)
|
|
125
138
|
expect(Mongo::Utils).to receive(:monotonic_time).ordered.and_return(start + 200)
|
|
139
|
+
allow(session).to receive('check_transactions_supported!').and_return true
|
|
126
140
|
|
|
127
141
|
expect do
|
|
128
142
|
session.with_transaction do
|
|
@@ -156,6 +170,7 @@ describe Mongo::Session do
|
|
|
156
170
|
expect(Mongo::Utils).to receive(:monotonic_time).ordered.and_return(start + i)
|
|
157
171
|
end
|
|
158
172
|
expect(Mongo::Utils).to receive(:monotonic_time).ordered.and_return(start + 200)
|
|
173
|
+
allow(session).to receive('check_transactions_supported!').and_return true
|
|
159
174
|
|
|
160
175
|
exc = Mongo::Error::OperationFailure.new('timeout test')
|
|
161
176
|
exc.add_label(label)
|
|
@@ -103,16 +103,6 @@ describe Mongo::Socket::SSL do
|
|
|
103
103
|
expect(socket).to be_alive
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
|
-
|
|
107
|
-
context 'when connecting the tcp socket raises an exception' do
|
|
108
|
-
|
|
109
|
-
it 'raises an exception' do
|
|
110
|
-
expect_any_instance_of(::Socket).to receive(:connect).and_raise(Mongo::Error::SocketTimeoutError)
|
|
111
|
-
expect do
|
|
112
|
-
socket
|
|
113
|
-
end.to raise_error(Mongo::Error::SocketTimeoutError)
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
106
|
end
|
|
117
107
|
|
|
118
108
|
context 'when a certificate and key are provided as strings' do
|
data/spec/mongo/uri_spec.rb
CHANGED
|
@@ -266,15 +266,6 @@ describe Mongo::URI do
|
|
|
266
266
|
end
|
|
267
267
|
end
|
|
268
268
|
|
|
269
|
-
context 'no slash after hosts, and options' do
|
|
270
|
-
|
|
271
|
-
let(:string) { 'mongodb://example.com?tls=true' }
|
|
272
|
-
|
|
273
|
-
it 'raises an error' do
|
|
274
|
-
expect { uri }.to raise_error(Mongo::Error::InvalidURI, %r,MongoDB URI must have a slash \(/\) after the hosts if options are given,)
|
|
275
|
-
end
|
|
276
|
-
end
|
|
277
|
-
|
|
278
269
|
context 'mongodb://example.com/?w' do
|
|
279
270
|
|
|
280
271
|
let(:string) { 'mongodb://example.com/?w' }
|
|
@@ -111,7 +111,7 @@ module Mongo
|
|
|
111
111
|
def run
|
|
112
112
|
change_stream = begin
|
|
113
113
|
@target.watch(@pipeline, ::Utils.snakeize_hash(@options))
|
|
114
|
-
rescue Mongo::Error::OperationFailure => e
|
|
114
|
+
rescue Mongo::Error::OperationFailure::Family => e
|
|
115
115
|
return {
|
|
116
116
|
result: {
|
|
117
117
|
error: {
|
|
@@ -146,7 +146,7 @@ module Mongo
|
|
|
146
146
|
begin
|
|
147
147
|
change = enum.next
|
|
148
148
|
changes << change
|
|
149
|
-
rescue Mongo::Error::OperationFailure => e
|
|
149
|
+
rescue Mongo::Error::OperationFailure::Family => e
|
|
150
150
|
return {
|
|
151
151
|
result: {
|
|
152
152
|
error: {
|
|
@@ -355,7 +355,7 @@ module Mongo
|
|
|
355
355
|
if coll.indexes.map { |doc| doc['name'] }.include?(ixn = arguments.fetch('index'))
|
|
356
356
|
raise "Index #{ixn} exists in collection #{cn} in database #{dn}, but must not"
|
|
357
357
|
end
|
|
358
|
-
rescue Mongo::Error::OperationFailure => e
|
|
358
|
+
rescue Mongo::Error::OperationFailure::Family => e
|
|
359
359
|
if e.to_s =~ /ns does not exist/
|
|
360
360
|
# Success.
|
|
361
361
|
else
|
data/spec/runners/crud/test.rb
CHANGED
|
@@ -110,14 +110,6 @@ module Mongo
|
|
|
110
110
|
end
|
|
111
111
|
setup_fail_point(client)
|
|
112
112
|
end
|
|
113
|
-
|
|
114
|
-
def actual_collection_contents(client)
|
|
115
|
-
unless @spec.collection_name
|
|
116
|
-
raise ArgumentError, 'Spec does not specify a global collection'
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
client[@spec.collection_name, read_concern: {level: :majority}].find.to_a
|
|
120
|
-
end
|
|
121
113
|
end
|
|
122
114
|
end
|
|
123
115
|
end
|
|
@@ -134,7 +134,7 @@ EOT
|
|
|
134
134
|
expect(actual).not_to be nil
|
|
135
135
|
when Hash
|
|
136
136
|
if actual.is_a?(Hash) && actual['error'] &&
|
|
137
|
-
!expected.keys.any? { |key| key.start_with?('error') }
|
|
137
|
+
!expected.keys.any? { |key| key.start_with?('error') || key == 'isTimeoutError' }
|
|
138
138
|
then
|
|
139
139
|
raise RSpec::Expectations::ExpectationNotMetError.new,
|
|
140
140
|
"Expected operation not to fail but it failed: #{actual.inspect}"
|
|
@@ -143,6 +143,8 @@ EOT
|
|
|
143
143
|
|
|
144
144
|
expected.each do |k, v|
|
|
145
145
|
case k
|
|
146
|
+
when 'isTimeoutError'
|
|
147
|
+
expect(actual['errorContains']).to eq('Mongo::Error::TimeoutError')
|
|
146
148
|
when 'errorContains'
|
|
147
149
|
expect(actual['errorContains'].downcase).to include(v.downcase)
|
|
148
150
|
when 'errorLabelsContain'
|
data/spec/runners/crud.rb
CHANGED
|
@@ -26,7 +26,7 @@ require 'runners/crud/operation'
|
|
|
26
26
|
require 'runners/crud/verifier'
|
|
27
27
|
|
|
28
28
|
def collection_data(collection)
|
|
29
|
-
collection.find.to_a
|
|
29
|
+
collection.find.sort(_id: 1).to_a
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def crud_execute_operations(spec, test, num_ops, event_subscriber, expect_error,
|
|
@@ -43,12 +43,10 @@ module Mongo
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
result
|
|
46
|
-
rescue Mongo::Error::OperationFailure => e
|
|
47
|
-
result
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
end
|
|
51
|
-
err_doc = result.send(:first_document)
|
|
46
|
+
rescue Mongo::Error::OperationFailure::Family => e
|
|
47
|
+
raise "OperationFailure had nil result: #{e}" if e.result.nil?
|
|
48
|
+
|
|
49
|
+
err_doc = e.result.send(:first_document)
|
|
52
50
|
error_code_name = err_doc['codeName'] || err_doc['writeConcernError'] && err_doc['writeConcernError']['codeName']
|
|
53
51
|
if error_code_name.nil?
|
|
54
52
|
# Sometimes the server does not return the error code name,
|
|
@@ -132,7 +132,6 @@ module Mongo
|
|
|
132
132
|
@test_client ||= begin
|
|
133
133
|
sdam_proc = lambda do |test_client|
|
|
134
134
|
test_client.subscribe(Mongo::Monitoring::COMMAND, command_subscriber)
|
|
135
|
-
|
|
136
135
|
test_client.subscribe(Mongo::Monitoring::TOPOLOGY_OPENING, sdam_subscriber)
|
|
137
136
|
test_client.subscribe(Mongo::Monitoring::SERVER_OPENING, sdam_subscriber)
|
|
138
137
|
test_client.subscribe(Mongo::Monitoring::SERVER_DESCRIPTION_CHANGED, sdam_subscriber)
|
|
@@ -321,6 +320,9 @@ module Mongo
|
|
|
321
320
|
# without auto_encryption_options for querying results.
|
|
322
321
|
result_collection_name = outcome&.collection_name || @spec.collection_name
|
|
323
322
|
@result_collection = support_client.use(@spec.database_name)[result_collection_name]
|
|
323
|
+
|
|
324
|
+
# DRIVERS-2816, adjusted for legacy spec runner
|
|
325
|
+
@cluster_time = support_client.command(ping: 1).cluster_time
|
|
324
326
|
end
|
|
325
327
|
|
|
326
328
|
def teardown_test
|
|
@@ -358,12 +360,19 @@ module Mongo
|
|
|
358
360
|
end
|
|
359
361
|
end
|
|
360
362
|
|
|
363
|
+
def new_session(options)
|
|
364
|
+
test_client.start_session(options || {}).tap do |s|
|
|
365
|
+
# DRIVERS-2816, adjusted for legacy spec runner
|
|
366
|
+
s.advance_cluster_time(@cluster_time)
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
|
|
361
370
|
def session0
|
|
362
|
-
@session0 ||=
|
|
371
|
+
@session0 ||= new_session(@session_options[:session0])
|
|
363
372
|
end
|
|
364
373
|
|
|
365
374
|
def session1
|
|
366
|
-
@session1 ||=
|
|
375
|
+
@session1 ||= new_session(@session_options[:session1])
|
|
367
376
|
end
|
|
368
377
|
end
|
|
369
378
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Unified
|
|
4
|
+
module AmbiguousOperations
|
|
5
|
+
def find(op)
|
|
6
|
+
entities.get(:collection, op['object'])
|
|
7
|
+
crud_find(op)
|
|
8
|
+
rescue Unified::Error::EntityMissing
|
|
9
|
+
entities.get(:bucket, op['object'])
|
|
10
|
+
gridfs_find(op)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -251,11 +251,11 @@ module Unified
|
|
|
251
251
|
end
|
|
252
252
|
when Hash
|
|
253
253
|
if expected.keys == %w($$unsetOrMatches) && expected.values.first.keys == %w(insertedId)
|
|
254
|
-
actual_v = actual
|
|
254
|
+
actual_v = get_actual_value(actual, 'inserted_id')
|
|
255
255
|
expected_v = expected.values.first.values.first
|
|
256
256
|
assert_value_matches(actual_v, expected_v, 'inserted_id')
|
|
257
257
|
elsif expected.keys == %w(insertedId)
|
|
258
|
-
actual_v = actual
|
|
258
|
+
actual_v = get_actual_value(actual, 'inserted_id')
|
|
259
259
|
expected_v = expected.values.first
|
|
260
260
|
assert_value_matches(actual_v, expected_v, 'inserted_id')
|
|
261
261
|
else
|
|
@@ -270,7 +270,7 @@ module Unified
|
|
|
270
270
|
if k.start_with?('$$')
|
|
271
271
|
assert_value_matches(actual, expected, k)
|
|
272
272
|
else
|
|
273
|
-
actual_v = actual
|
|
273
|
+
actual_v = get_actual_value(actual, k)
|
|
274
274
|
if Hash === expected_v && expected_v.length == 1 && expected_v.keys.first.start_with?('$$')
|
|
275
275
|
assert_value_matches(actual_v, expected_v, k)
|
|
276
276
|
else
|
|
@@ -290,6 +290,19 @@ module Unified
|
|
|
290
290
|
end
|
|
291
291
|
end
|
|
292
292
|
|
|
293
|
+
# The actual value may be of different types depending on the operation.
|
|
294
|
+
# In order to avoid having to write a lot of code to handle the different
|
|
295
|
+
# types, we use this method to get the actual value.
|
|
296
|
+
def get_actual_value(actual, key)
|
|
297
|
+
if Hash === actual
|
|
298
|
+
actual[key]
|
|
299
|
+
elsif Mongo::Operation::Result === actual && !actual.respond_to?(key.to_sym)
|
|
300
|
+
actual.documents.first[key]
|
|
301
|
+
else
|
|
302
|
+
actual.send(key)
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
293
306
|
def assert_type(object, type)
|
|
294
307
|
ok = [*type].reduce(false) { |acc, x| acc || type_matches?(object, x) }
|
|
295
308
|
|
|
@@ -366,6 +379,10 @@ module Unified
|
|
|
366
379
|
unless actual == result
|
|
367
380
|
raise Error::ResultMismatch, "Actual value #{actual} does not match entity #{expected_v} with value #{result}"
|
|
368
381
|
end
|
|
382
|
+
when '$$lte'
|
|
383
|
+
if actual.nil? || actual >= expected_v
|
|
384
|
+
raise Error::ResultMismatch, "Actual value #{actual} should be less than #{expected_v}"
|
|
385
|
+
end
|
|
369
386
|
else
|
|
370
387
|
raise NotImplementedError, "Unknown operator #{operator}"
|
|
371
388
|
end
|