├── .gitignore ├── .travis.yml ├── Cargo.toml ├── LICENSE ├── README.md ├── etc └── update-spec-tests.sh ├── examples ├── decode.rs ├── encode.rs └── test.bson ├── rustfmt.toml ├── serde-tests ├── Cargo.toml ├── lib.rs ├── rustfmt.toml └── test.rs ├── src ├── bson │ ├── compat │ │ ├── mod.rs │ │ └── u2f.rs │ ├── decimal128.rs │ ├── decoder │ │ ├── error.rs │ │ ├── mod.rs │ │ └── serde.rs │ ├── doc.rs │ ├── encoder │ │ ├── error.rs │ │ ├── mod.rs │ │ └── serde.rs │ ├── macros.rs │ ├── mod.rs │ ├── oid.rs │ └── spec.rs ├── bson_util.rs ├── client │ ├── auth │ │ ├── mod.rs │ │ ├── scram.rs │ │ └── test.rs │ ├── executor.rs │ ├── mod.rs │ └── options │ │ ├── mod.rs │ │ └── test.rs ├── cmap │ ├── background.rs │ ├── conn │ │ ├── command.rs │ │ ├── mod.rs │ │ ├── stream.rs │ │ ├── stream_description.rs │ │ └── wire │ │ │ ├── header.rs │ │ │ ├── message.rs │ │ │ ├── mod.rs │ │ │ ├── test.rs │ │ │ └── util.rs │ ├── establish │ │ ├── handshake.rs │ │ └── mod.rs │ ├── mod.rs │ ├── options.rs │ ├── test │ │ ├── event.rs │ │ ├── file.rs │ │ ├── integration.rs │ │ └── mod.rs │ └── wait_queue.rs ├── coll │ ├── batch.rs │ ├── mod.rs │ └── options.rs ├── collation.rs ├── concern.rs ├── cursor.rs ├── db │ ├── mod.rs │ └── options.rs ├── error.rs ├── event │ ├── cmap.rs │ ├── command.rs │ └── mod.rs ├── is_master.rs ├── lib.rs ├── operation │ ├── aggregate │ │ ├── mod.rs │ │ └── test.rs │ ├── count │ │ ├── mod.rs │ │ └── test.rs │ ├── create │ │ ├── mod.rs │ │ └── test.rs │ ├── delete │ │ ├── mod.rs │ │ └── test.rs │ ├── distinct │ │ ├── mod.rs │ │ └── test.rs │ ├── drop_collection │ │ ├── mod.rs │ │ └── test.rs │ ├── drop_database │ │ ├── mod.rs │ │ └── test.rs │ ├── find │ │ ├── mod.rs │ │ └── test.rs │ ├── find_and_modify │ │ ├── mod.rs │ │ ├── options.rs │ │ └── test.rs │ ├── get_more │ │ ├── mod.rs │ │ └── test.rs │ ├── insert │ │ ├── mod.rs │ │ └── test.rs │ ├── list_collections │ │ ├── mod.rs │ │ └── test.rs │ ├── list_databases │ │ ├── mod.rs │ │ └── test.rs │ ├── mod.rs │ ├── run_command │ │ ├── mod.rs │ │ └── test.rs │ └── update │ │ ├── mod.rs │ │ └── test.rs ├── options.rs ├── results.rs ├── sdam │ ├── description │ │ ├── mod.rs │ │ ├── server.rs │ │ └── topology │ │ │ ├── mod.rs │ │ │ ├── server_selection │ │ │ ├── mod.rs │ │ │ └── test.rs │ │ │ └── test │ │ │ ├── mod.rs │ │ │ ├── rtt.rs │ │ │ └── sdam.rs │ ├── mod.rs │ ├── monitor.rs │ ├── public.rs │ └── state │ │ ├── mod.rs │ │ └── server.rs ├── selection_criteria.rs ├── srv.rs ├── test │ ├── atlas_connectivity.rs │ ├── client.rs │ ├── coll.rs │ ├── db.rs │ ├── mod.rs │ ├── spec │ │ ├── auth.rs │ │ ├── command_monitoring │ │ │ ├── event.rs │ │ │ ├── mod.rs │ │ │ └── operation.rs │ │ ├── connection_stepdown.rs │ │ ├── crud │ │ │ ├── aggregate.rs │ │ │ ├── count.rs │ │ │ ├── delete_many.rs │ │ │ ├── delete_one.rs │ │ │ ├── distinct.rs │ │ │ ├── find.rs │ │ │ ├── find_one_and_delete.rs │ │ │ ├── find_one_and_replace.rs │ │ │ ├── find_one_and_update.rs │ │ │ ├── insert_many.rs │ │ │ ├── insert_one.rs │ │ │ ├── mod.rs │ │ │ ├── replace_one.rs │ │ │ ├── update_many.rs │ │ │ └── update_one.rs │ │ ├── initial_dns_seedlist_discovery.rs │ │ ├── json │ │ │ ├── auth │ │ │ │ ├── README.rst │ │ │ │ ├── connection-string.json │ │ │ │ └── connection-string.yml │ │ │ ├── command-monitoring │ │ │ │ ├── README.rst │ │ │ │ ├── bulkWrite.json │ │ │ │ ├── bulkWrite.yml │ │ │ │ ├── command.json │ │ │ │ ├── command.yml │ │ │ │ ├── deleteMany.json │ │ │ │ ├── deleteMany.yml │ │ │ │ ├── deleteOne.json │ │ │ │ ├── deleteOne.yml │ │ │ │ ├── find.json │ │ │ │ ├── find.yml │ │ │ │ ├── insertMany.json │ │ │ │ ├── insertMany.yml │ │ │ │ ├── insertOne.json │ │ │ │ ├── insertOne.yml │ │ │ │ ├── unacknowledgedBulkWrite.json │ │ │ │ ├── unacknowledgedBulkWrite.yml │ │ │ │ ├── updateMany.json │ │ │ │ ├── updateMany.yml │ │ │ │ ├── updateOne.json │ │ │ │ └── updateOne.yml │ │ │ ├── connection-monitoring-and-pooling │ │ │ │ ├── README.rst │ │ │ │ ├── connection-must-have-id.json │ │ │ │ ├── connection-must-have-id.yml │ │ │ │ ├── connection-must-order-ids.json │ │ │ │ ├── connection-must-order-ids.yml │ │ │ │ ├── pool-checkin-destroy-closed.json │ │ │ │ ├── pool-checkin-destroy-closed.yml │ │ │ │ ├── pool-checkin-destroy-stale.json │ │ │ │ ├── pool-checkin-destroy-stale.yml │ │ │ │ ├── pool-checkin-make-available.json │ │ │ │ ├── pool-checkin-make-available.yml │ │ │ │ ├── pool-checkin.json │ │ │ │ ├── pool-checkin.yml │ │ │ │ ├── pool-checkout-connection.json │ │ │ │ ├── pool-checkout-connection.yml │ │ │ │ ├── pool-checkout-error-closed.json │ │ │ │ ├── pool-checkout-error-closed.yml │ │ │ │ ├── pool-checkout-multiple.json │ │ │ │ ├── pool-checkout-multiple.yml │ │ │ │ ├── pool-checkout-no-idle.json │ │ │ │ ├── pool-checkout-no-idle.yml │ │ │ │ ├── pool-checkout-no-stale.json │ │ │ │ ├── pool-checkout-no-stale.yml │ │ │ │ ├── pool-close-destroy-conns.json │ │ │ │ ├── pool-close-destroy-conns.yml │ │ │ │ ├── pool-close.json │ │ │ │ ├── pool-close.yml │ │ │ │ ├── pool-create-max-size.json │ │ │ │ ├── pool-create-max-size.yml │ │ │ │ ├── pool-create-min-size.json │ │ │ │ ├── pool-create-min-size.yml │ │ │ │ ├── pool-create-with-options.json │ │ │ │ ├── pool-create-with-options.yml │ │ │ │ ├── pool-create.json │ │ │ │ ├── pool-create.yml │ │ │ │ ├── wait-queue-fairness.json │ │ │ │ ├── wait-queue-fairness.yml │ │ │ │ ├── wait-queue-timeout.json │ │ │ │ └── wait-queue-timeout.yml │ │ │ ├── connection-string │ │ │ │ ├── README.rst │ │ │ │ ├── invalid-uris.json │ │ │ │ ├── invalid-uris.yml │ │ │ │ ├── valid-auth.json │ │ │ │ ├── valid-auth.yml │ │ │ │ ├── valid-db-with-dotted-name.json │ │ │ │ ├── valid-db-with-dotted-name.yml │ │ │ │ ├── valid-host_identifiers.json │ │ │ │ ├── valid-host_identifiers.yml │ │ │ │ ├── valid-options.json │ │ │ │ ├── valid-options.yml │ │ │ │ ├── valid-unix_socket-absolute.json │ │ │ │ ├── valid-unix_socket-absolute.yml │ │ │ │ ├── valid-unix_socket-relative.json │ │ │ │ ├── valid-unix_socket-relative.yml │ │ │ │ ├── valid-warnings.json │ │ │ │ └── valid-warnings.yml │ │ │ ├── crud │ │ │ │ ├── README.rst │ │ │ │ ├── v1 │ │ │ │ │ ├── read │ │ │ │ │ │ ├── aggregate-collation.json │ │ │ │ │ │ ├── aggregate-collation.yml │ │ │ │ │ │ ├── aggregate-out.json │ │ │ │ │ │ ├── aggregate-out.yml │ │ │ │ │ │ ├── aggregate.json │ │ │ │ │ │ ├── aggregate.yml │ │ │ │ │ │ ├── count-collation.json │ │ │ │ │ │ ├── count-collation.yml │ │ │ │ │ │ ├── count-empty.json │ │ │ │ │ │ ├── count-empty.yml │ │ │ │ │ │ ├── count.json │ │ │ │ │ │ ├── count.yml │ │ │ │ │ │ ├── distinct-collation.json │ │ │ │ │ │ ├── distinct-collation.yml │ │ │ │ │ │ ├── distinct.json │ │ │ │ │ │ ├── distinct.yml │ │ │ │ │ │ ├── find-collation.json │ │ │ │ │ │ ├── find-collation.yml │ │ │ │ │ │ ├── find.json │ │ │ │ │ │ └── find.yml │ │ │ │ │ └── write │ │ │ │ │ │ ├── bulkWrite-arrayFilters.json │ │ │ │ │ │ ├── bulkWrite-arrayFilters.yml │ │ │ │ │ │ ├── bulkWrite-collation.json │ │ │ │ │ │ ├── bulkWrite-collation.yml │ │ │ │ │ │ ├── bulkWrite.json │ │ │ │ │ │ ├── bulkWrite.yml │ │ │ │ │ │ ├── deleteMany-collation.json │ │ │ │ │ │ ├── deleteMany-collation.yml │ │ │ │ │ │ ├── deleteMany.json │ │ │ │ │ │ ├── deleteMany.yml │ │ │ │ │ │ ├── deleteOne-collation.json │ │ │ │ │ │ ├── deleteOne-collation.yml │ │ │ │ │ │ ├── deleteOne.json │ │ │ │ │ │ ├── deleteOne.yml │ │ │ │ │ │ ├── findOneAndDelete-collation.json │ │ │ │ │ │ ├── findOneAndDelete-collation.yml │ │ │ │ │ │ ├── findOneAndDelete.json │ │ │ │ │ │ ├── findOneAndDelete.yml │ │ │ │ │ │ ├── findOneAndReplace-collation.json │ │ │ │ │ │ ├── findOneAndReplace-collation.yml │ │ │ │ │ │ ├── findOneAndReplace-upsert.json │ │ │ │ │ │ ├── findOneAndReplace-upsert.yml │ │ │ │ │ │ ├── findOneAndReplace.json │ │ │ │ │ │ ├── findOneAndReplace.yml │ │ │ │ │ │ ├── findOneAndUpdate-arrayFilters.json │ │ │ │ │ │ ├── findOneAndUpdate-arrayFilters.yml │ │ │ │ │ │ ├── findOneAndUpdate-collation.json │ │ │ │ │ │ ├── findOneAndUpdate-collation.yml │ │ │ │ │ │ ├── findOneAndUpdate.json │ │ │ │ │ │ ├── findOneAndUpdate.yml │ │ │ │ │ │ ├── insertMany.json │ │ │ │ │ │ ├── insertMany.yml │ │ │ │ │ │ ├── insertOne.json │ │ │ │ │ │ ├── insertOne.yml │ │ │ │ │ │ ├── replaceOne-collation.json │ │ │ │ │ │ ├── replaceOne-collation.yml │ │ │ │ │ │ ├── replaceOne.json │ │ │ │ │ │ ├── replaceOne.yml │ │ │ │ │ │ ├── updateMany-arrayFilters.json │ │ │ │ │ │ ├── updateMany-arrayFilters.yml │ │ │ │ │ │ ├── updateMany-collation.json │ │ │ │ │ │ ├── updateMany-collation.yml │ │ │ │ │ │ ├── updateMany.json │ │ │ │ │ │ ├── updateMany.yml │ │ │ │ │ │ ├── updateOne-arrayFilters.json │ │ │ │ │ │ ├── updateOne-arrayFilters.yml │ │ │ │ │ │ ├── updateOne-collation.json │ │ │ │ │ │ ├── updateOne-collation.yml │ │ │ │ │ │ ├── updateOne.json │ │ │ │ │ │ └── updateOne.yml │ │ │ │ └── v2 │ │ │ │ │ ├── aggregate-merge.json │ │ │ │ │ ├── aggregate-merge.yml │ │ │ │ │ ├── aggregate-out-readConcern.json │ │ │ │ │ ├── aggregate-out-readConcern.yml │ │ │ │ │ ├── bulkWrite-arrayFilters.json │ │ │ │ │ ├── bulkWrite-arrayFilters.yml │ │ │ │ │ ├── bulkWrite-update-hint.json │ │ │ │ │ ├── bulkWrite-update-hint.yml │ │ │ │ │ ├── db-aggregate.json │ │ │ │ │ ├── db-aggregate.yml │ │ │ │ │ ├── replaceOne-hint.json │ │ │ │ │ ├── replaceOne-hint.yml │ │ │ │ │ ├── updateMany-hint.json │ │ │ │ │ ├── updateMany-hint.yml │ │ │ │ │ ├── updateOne-hint.json │ │ │ │ │ ├── updateOne-hint.yml │ │ │ │ │ ├── updateWithPipelines.json │ │ │ │ │ └── updateWithPipelines.yml │ │ │ ├── initial-dns-seedlist-discovery │ │ │ │ ├── README.rst │ │ │ │ ├── encoded-userinfo-and-db.json │ │ │ │ ├── encoded-userinfo-and-db.yml │ │ │ │ ├── longer-parent-in-return.json │ │ │ │ ├── longer-parent-in-return.yml │ │ │ │ ├── misformatted-option.json │ │ │ │ ├── misformatted-option.yml │ │ │ │ ├── no-results.json │ │ │ │ ├── no-results.yml │ │ │ │ ├── not-enough-parts.json │ │ │ │ ├── not-enough-parts.yml │ │ │ │ ├── one-result-default-port.json │ │ │ │ ├── one-result-default-port.yml │ │ │ │ ├── one-txt-record-multiple-strings.json │ │ │ │ ├── one-txt-record-multiple-strings.yml │ │ │ │ ├── one-txt-record.json │ │ │ │ ├── one-txt-record.yml │ │ │ │ ├── parent-part-mismatch1.json │ │ │ │ ├── parent-part-mismatch1.yml │ │ │ │ ├── parent-part-mismatch2.json │ │ │ │ ├── parent-part-mismatch2.yml │ │ │ │ ├── parent-part-mismatch3.json │ │ │ │ ├── parent-part-mismatch3.yml │ │ │ │ ├── parent-part-mismatch4.json │ │ │ │ ├── parent-part-mismatch4.yml │ │ │ │ ├── parent-part-mismatch5.json │ │ │ │ ├── parent-part-mismatch5.yml │ │ │ │ ├── returned-parent-too-short.json │ │ │ │ ├── returned-parent-too-short.yml │ │ │ │ ├── returned-parent-wrong.json │ │ │ │ ├── returned-parent-wrong.yml │ │ │ │ ├── two-results-default-port.json │ │ │ │ ├── two-results-default-port.yml │ │ │ │ ├── two-results-nonstandard-port.json │ │ │ │ ├── two-results-nonstandard-port.yml │ │ │ │ ├── two-txt-records.json │ │ │ │ ├── two-txt-records.yml │ │ │ │ ├── txt-record-not-allowed-option.json │ │ │ │ ├── txt-record-not-allowed-option.yml │ │ │ │ ├── txt-record-with-overridden-ssl-option.json │ │ │ │ ├── txt-record-with-overridden-ssl-option.yml │ │ │ │ ├── txt-record-with-overridden-uri-option.json │ │ │ │ ├── txt-record-with-overridden-uri-option.yml │ │ │ │ ├── txt-record-with-unallowed-option.json │ │ │ │ ├── txt-record-with-unallowed-option.yml │ │ │ │ ├── uri-with-admin-database.json │ │ │ │ ├── uri-with-admin-database.yml │ │ │ │ ├── uri-with-auth.json │ │ │ │ ├── uri-with-auth.yml │ │ │ │ ├── uri-with-port.json │ │ │ │ ├── uri-with-port.yml │ │ │ │ ├── uri-with-two-hosts.json │ │ │ │ └── uri-with-two-hosts.yml │ │ │ ├── max-staleness │ │ │ │ ├── README.rst │ │ │ │ ├── ReplicaSetNoPrimary │ │ │ │ │ ├── DefaultNoMaxStaleness.json │ │ │ │ │ ├── DefaultNoMaxStaleness.yml │ │ │ │ │ ├── Incompatible.json │ │ │ │ │ ├── Incompatible.yml │ │ │ │ │ ├── LastUpdateTime.json │ │ │ │ │ ├── LastUpdateTime.yml │ │ │ │ │ ├── Nearest.json │ │ │ │ │ ├── Nearest.yml │ │ │ │ │ ├── Nearest2.json │ │ │ │ │ ├── Nearest2.yml │ │ │ │ │ ├── NoKnownServers.json │ │ │ │ │ ├── NoKnownServers.yml │ │ │ │ │ ├── PrimaryPreferred.json │ │ │ │ │ ├── PrimaryPreferred.yml │ │ │ │ │ ├── PrimaryPreferred_tags.json │ │ │ │ │ ├── PrimaryPreferred_tags.yml │ │ │ │ │ ├── Secondary.json │ │ │ │ │ ├── Secondary.yml │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ ├── SecondaryPreferred.yml │ │ │ │ │ ├── SecondaryPreferred_tags.json │ │ │ │ │ ├── SecondaryPreferred_tags.yml │ │ │ │ │ ├── ZeroMaxStaleness.json │ │ │ │ │ └── ZeroMaxStaleness.yml │ │ │ │ ├── ReplicaSetWithPrimary │ │ │ │ │ ├── DefaultNoMaxStaleness.json │ │ │ │ │ ├── DefaultNoMaxStaleness.yml │ │ │ │ │ ├── Incompatible.json │ │ │ │ │ ├── Incompatible.yml │ │ │ │ │ ├── LastUpdateTime.json │ │ │ │ │ ├── LastUpdateTime.yml │ │ │ │ │ ├── LongHeartbeat.json │ │ │ │ │ ├── LongHeartbeat.yml │ │ │ │ │ ├── LongHeartbeat2.json │ │ │ │ │ ├── LongHeartbeat2.yml │ │ │ │ │ ├── MaxStalenessTooSmall.json │ │ │ │ │ ├── MaxStalenessTooSmall.yml │ │ │ │ │ ├── MaxStalenessWithModePrimary.json │ │ │ │ │ ├── MaxStalenessWithModePrimary.yml │ │ │ │ │ ├── Nearest.json │ │ │ │ │ ├── Nearest.yml │ │ │ │ │ ├── Nearest2.json │ │ │ │ │ ├── Nearest2.yml │ │ │ │ │ ├── Nearest_tags.json │ │ │ │ │ ├── Nearest_tags.yml │ │ │ │ │ ├── PrimaryPreferred.json │ │ │ │ │ ├── PrimaryPreferred.yml │ │ │ │ │ ├── PrimaryPreferred_incompatible.json │ │ │ │ │ ├── PrimaryPreferred_incompatible.yml │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ ├── SecondaryPreferred.yml │ │ │ │ │ ├── SecondaryPreferred_tags.json │ │ │ │ │ ├── SecondaryPreferred_tags.yml │ │ │ │ │ ├── SecondaryPreferred_tags2.json │ │ │ │ │ ├── SecondaryPreferred_tags2.yml │ │ │ │ │ ├── Secondary_tags.json │ │ │ │ │ ├── Secondary_tags.yml │ │ │ │ │ ├── Secondary_tags2.json │ │ │ │ │ ├── Secondary_tags2.yml │ │ │ │ │ ├── ZeroMaxStaleness.json │ │ │ │ │ └── ZeroMaxStaleness.yml │ │ │ │ ├── Sharded │ │ │ │ │ ├── Incompatible.json │ │ │ │ │ ├── Incompatible.yml │ │ │ │ │ ├── SmallMaxStaleness.json │ │ │ │ │ └── SmallMaxStaleness.yml │ │ │ │ ├── Single │ │ │ │ │ ├── Incompatible.json │ │ │ │ │ ├── Incompatible.yml │ │ │ │ │ ├── SmallMaxStaleness.json │ │ │ │ │ └── SmallMaxStaleness.yml │ │ │ │ └── Unknown │ │ │ │ │ ├── SmallMaxStaleness.json │ │ │ │ │ └── SmallMaxStaleness.yml │ │ │ ├── read-write-concern │ │ │ │ ├── README.rst │ │ │ │ ├── connection-string │ │ │ │ │ ├── read-concern.json │ │ │ │ │ ├── read-concern.yml │ │ │ │ │ ├── write-concern.json │ │ │ │ │ └── write-concern.yml │ │ │ │ └── document │ │ │ │ │ ├── read-concern.json │ │ │ │ │ ├── read-concern.yml │ │ │ │ │ ├── write-concern.json │ │ │ │ │ └── write-concern.yml │ │ │ ├── server-discovery-and-monitoring │ │ │ │ ├── README.rst │ │ │ │ ├── monitoring │ │ │ │ │ ├── README.rst │ │ │ │ │ ├── replica_set_with_no_primary.json │ │ │ │ │ ├── replica_set_with_no_primary.yml │ │ │ │ │ ├── replica_set_with_primary.json │ │ │ │ │ ├── replica_set_with_primary.yml │ │ │ │ │ ├── replica_set_with_removal.json │ │ │ │ │ ├── replica_set_with_removal.yml │ │ │ │ │ ├── required_replica_set.json │ │ │ │ │ ├── required_replica_set.yml │ │ │ │ │ ├── standalone.json │ │ │ │ │ └── standalone.yml │ │ │ │ ├── rs │ │ │ │ │ ├── compatible.json │ │ │ │ │ ├── compatible.yml │ │ │ │ │ ├── compatible_unknown.json │ │ │ │ │ ├── compatible_unknown.yml │ │ │ │ │ ├── discover_arbiters.json │ │ │ │ │ ├── discover_arbiters.yml │ │ │ │ │ ├── discover_passives.json │ │ │ │ │ ├── discover_passives.yml │ │ │ │ │ ├── discover_primary.json │ │ │ │ │ ├── discover_primary.yml │ │ │ │ │ ├── discover_secondary.json │ │ │ │ │ ├── discover_secondary.yml │ │ │ │ │ ├── discovery.json │ │ │ │ │ ├── discovery.yml │ │ │ │ │ ├── equal_electionids.json │ │ │ │ │ ├── equal_electionids.yml │ │ │ │ │ ├── ghost_discovered.json │ │ │ │ │ ├── ghost_discovered.yml │ │ │ │ │ ├── hosts_differ_from_seeds.json │ │ │ │ │ ├── hosts_differ_from_seeds.yml │ │ │ │ │ ├── incompatible_arbiter.json │ │ │ │ │ ├── incompatible_arbiter.yml │ │ │ │ │ ├── incompatible_ghost.json │ │ │ │ │ ├── incompatible_ghost.yml │ │ │ │ │ ├── incompatible_other.json │ │ │ │ │ ├── incompatible_other.yml │ │ │ │ │ ├── ls_timeout.json │ │ │ │ │ ├── ls_timeout.yml │ │ │ │ │ ├── member_reconfig.json │ │ │ │ │ ├── member_reconfig.yml │ │ │ │ │ ├── member_standalone.json │ │ │ │ │ ├── member_standalone.yml │ │ │ │ │ ├── new_primary.json │ │ │ │ │ ├── new_primary.yml │ │ │ │ │ ├── new_primary_new_electionid.json │ │ │ │ │ ├── new_primary_new_electionid.yml │ │ │ │ │ ├── new_primary_new_setversion.json │ │ │ │ │ ├── new_primary_new_setversion.yml │ │ │ │ │ ├── new_primary_wrong_set_name.json │ │ │ │ │ ├── new_primary_wrong_set_name.yml │ │ │ │ │ ├── non_rs_member.json │ │ │ │ │ ├── non_rs_member.yml │ │ │ │ │ ├── normalize_case.json │ │ │ │ │ ├── normalize_case.yml │ │ │ │ │ ├── normalize_case_me.json │ │ │ │ │ ├── normalize_case_me.yml │ │ │ │ │ ├── null_election_id.json │ │ │ │ │ ├── null_election_id.yml │ │ │ │ │ ├── primary_becomes_ghost.json │ │ │ │ │ ├── primary_becomes_ghost.yml │ │ │ │ │ ├── primary_becomes_mongos.json │ │ │ │ │ ├── primary_becomes_mongos.yml │ │ │ │ │ ├── primary_becomes_standalone.json │ │ │ │ │ ├── primary_becomes_standalone.yml │ │ │ │ │ ├── primary_changes_set_name.json │ │ │ │ │ ├── primary_changes_set_name.yml │ │ │ │ │ ├── primary_disconnect.json │ │ │ │ │ ├── primary_disconnect.yml │ │ │ │ │ ├── primary_disconnect_electionid.json │ │ │ │ │ ├── primary_disconnect_electionid.yml │ │ │ │ │ ├── primary_disconnect_setversion.json │ │ │ │ │ ├── primary_disconnect_setversion.yml │ │ │ │ │ ├── primary_hint_from_secondary_with_mismatched_me.json │ │ │ │ │ ├── primary_hint_from_secondary_with_mismatched_me.yml │ │ │ │ │ ├── primary_mismatched_me.json │ │ │ │ │ ├── primary_mismatched_me.yml │ │ │ │ │ ├── primary_reports_new_member.json │ │ │ │ │ ├── primary_reports_new_member.yml │ │ │ │ │ ├── primary_to_no_primary_mismatched_me.json │ │ │ │ │ ├── primary_to_no_primary_mismatched_me.yml │ │ │ │ │ ├── primary_wrong_set_name.json │ │ │ │ │ ├── primary_wrong_set_name.yml │ │ │ │ │ ├── response_from_removed.json │ │ │ │ │ ├── response_from_removed.yml │ │ │ │ │ ├── rsother_discovered.json │ │ │ │ │ ├── rsother_discovered.yml │ │ │ │ │ ├── sec_not_auth.json │ │ │ │ │ ├── sec_not_auth.yml │ │ │ │ │ ├── secondary_ignore_ok_0.json │ │ │ │ │ ├── secondary_ignore_ok_0.yml │ │ │ │ │ ├── secondary_mismatched_me.json │ │ │ │ │ ├── secondary_mismatched_me.yml │ │ │ │ │ ├── secondary_wrong_set_name.json │ │ │ │ │ ├── secondary_wrong_set_name.yml │ │ │ │ │ ├── secondary_wrong_set_name_with_primary.json │ │ │ │ │ ├── secondary_wrong_set_name_with_primary.yml │ │ │ │ │ ├── setversion_without_electionid.json │ │ │ │ │ ├── setversion_without_electionid.yml │ │ │ │ │ ├── stepdown_change_set_name.json │ │ │ │ │ ├── stepdown_change_set_name.yml │ │ │ │ │ ├── too_new.json │ │ │ │ │ ├── too_new.yml │ │ │ │ │ ├── too_old.json │ │ │ │ │ ├── too_old.yml │ │ │ │ │ ├── unexpected_mongos.json │ │ │ │ │ ├── unexpected_mongos.yml │ │ │ │ │ ├── use_setversion_without_electionid.json │ │ │ │ │ ├── use_setversion_without_electionid.yml │ │ │ │ │ ├── wrong_set_name.json │ │ │ │ │ └── wrong_set_name.yml │ │ │ │ ├── sharded │ │ │ │ │ ├── compatible.json │ │ │ │ │ ├── compatible.yml │ │ │ │ │ ├── ls_timeout_mongos.json │ │ │ │ │ ├── ls_timeout_mongos.yml │ │ │ │ │ ├── mongos_disconnect.json │ │ │ │ │ ├── mongos_disconnect.yml │ │ │ │ │ ├── multiple_mongoses.json │ │ │ │ │ ├── multiple_mongoses.yml │ │ │ │ │ ├── non_mongos_removed.json │ │ │ │ │ ├── non_mongos_removed.yml │ │ │ │ │ ├── normalize_uri_case.json │ │ │ │ │ ├── normalize_uri_case.yml │ │ │ │ │ ├── too_new.json │ │ │ │ │ ├── too_new.yml │ │ │ │ │ ├── too_old.json │ │ │ │ │ └── too_old.yml │ │ │ │ └── single │ │ │ │ │ ├── compatible.json │ │ │ │ │ ├── compatible.yml │ │ │ │ │ ├── direct_connection_external_ip.json │ │ │ │ │ ├── direct_connection_external_ip.yml │ │ │ │ │ ├── direct_connection_mongos.json │ │ │ │ │ ├── direct_connection_mongos.yml │ │ │ │ │ ├── direct_connection_rsarbiter.json │ │ │ │ │ ├── direct_connection_rsarbiter.yml │ │ │ │ │ ├── direct_connection_rsprimary.json │ │ │ │ │ ├── direct_connection_rsprimary.yml │ │ │ │ │ ├── direct_connection_rssecondary.json │ │ │ │ │ ├── direct_connection_rssecondary.yml │ │ │ │ │ ├── direct_connection_slave.json │ │ │ │ │ ├── direct_connection_slave.yml │ │ │ │ │ ├── direct_connection_standalone.json │ │ │ │ │ ├── direct_connection_standalone.yml │ │ │ │ │ ├── ls_timeout_standalone.json │ │ │ │ │ ├── ls_timeout_standalone.yml │ │ │ │ │ ├── not_ok_response.json │ │ │ │ │ ├── not_ok_response.yml │ │ │ │ │ ├── standalone_removed.json │ │ │ │ │ ├── standalone_removed.yml │ │ │ │ │ ├── too_new.json │ │ │ │ │ ├── too_new.yml │ │ │ │ │ ├── too_old.json │ │ │ │ │ ├── too_old.yml │ │ │ │ │ ├── too_old_then_upgraded.json │ │ │ │ │ ├── too_old_then_upgraded.yml │ │ │ │ │ ├── unavailable_seed.json │ │ │ │ │ └── unavailable_seed.yml │ │ │ ├── server-selection │ │ │ │ ├── README.rst │ │ │ │ ├── rtt │ │ │ │ │ ├── first_value.json │ │ │ │ │ ├── first_value.yml │ │ │ │ │ ├── first_value_zero.json │ │ │ │ │ ├── first_value_zero.yml │ │ │ │ │ ├── value_test_1.json │ │ │ │ │ ├── value_test_1.yml │ │ │ │ │ ├── value_test_2.json │ │ │ │ │ ├── value_test_2.yml │ │ │ │ │ ├── value_test_3.json │ │ │ │ │ ├── value_test_3.yml │ │ │ │ │ ├── value_test_4.json │ │ │ │ │ ├── value_test_4.yml │ │ │ │ │ ├── value_test_5.json │ │ │ │ │ └── value_test_5.yml │ │ │ │ └── server_selection │ │ │ │ │ ├── ReplicaSetNoPrimary │ │ │ │ │ ├── read │ │ │ │ │ │ ├── Nearest.json │ │ │ │ │ │ ├── Nearest.yml │ │ │ │ │ │ ├── Nearest_multiple.json │ │ │ │ │ │ ├── Nearest_multiple.yml │ │ │ │ │ │ ├── Nearest_non_matching.json │ │ │ │ │ │ ├── Nearest_non_matching.yml │ │ │ │ │ │ ├── PossiblePrimary.json │ │ │ │ │ │ ├── PossiblePrimary.yml │ │ │ │ │ │ ├── PossiblePrimaryNearest.json │ │ │ │ │ │ ├── PossiblePrimaryNearest.yml │ │ │ │ │ │ ├── Primary.json │ │ │ │ │ │ ├── Primary.yml │ │ │ │ │ │ ├── PrimaryPreferred.json │ │ │ │ │ │ ├── PrimaryPreferred.yml │ │ │ │ │ │ ├── PrimaryPreferred_non_matching.json │ │ │ │ │ │ ├── PrimaryPreferred_non_matching.yml │ │ │ │ │ │ ├── Secondary.json │ │ │ │ │ │ ├── Secondary.yml │ │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ │ ├── SecondaryPreferred.yml │ │ │ │ │ │ ├── SecondaryPreferred_non_matching.json │ │ │ │ │ │ ├── SecondaryPreferred_non_matching.yml │ │ │ │ │ │ ├── Secondary_multi_tags.json │ │ │ │ │ │ ├── Secondary_multi_tags.yml │ │ │ │ │ │ ├── Secondary_multi_tags2.json │ │ │ │ │ │ ├── Secondary_multi_tags2.yml │ │ │ │ │ │ ├── Secondary_non_matching.json │ │ │ │ │ │ └── Secondary_non_matching.yml │ │ │ │ │ └── write │ │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ │ └── SecondaryPreferred.yml │ │ │ │ │ ├── ReplicaSetWithPrimary │ │ │ │ │ ├── read │ │ │ │ │ │ ├── Nearest.json │ │ │ │ │ │ ├── Nearest.yml │ │ │ │ │ │ ├── Nearest_multiple.json │ │ │ │ │ │ ├── Nearest_multiple.yml │ │ │ │ │ │ ├── Nearest_non_matching.json │ │ │ │ │ │ ├── Nearest_non_matching.yml │ │ │ │ │ │ ├── Primary.json │ │ │ │ │ │ ├── Primary.yml │ │ │ │ │ │ ├── PrimaryPreferred.json │ │ │ │ │ │ ├── PrimaryPreferred.yml │ │ │ │ │ │ ├── PrimaryPreferred_non_matching.json │ │ │ │ │ │ ├── PrimaryPreferred_non_matching.yml │ │ │ │ │ │ ├── Secondary.json │ │ │ │ │ │ ├── Secondary.yml │ │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ │ ├── SecondaryPreferred.yml │ │ │ │ │ │ ├── SecondaryPreferred_non_matching.json │ │ │ │ │ │ ├── SecondaryPreferred_non_matching.yml │ │ │ │ │ │ ├── SecondaryPreferred_tags.json │ │ │ │ │ │ ├── SecondaryPreferred_tags.yml │ │ │ │ │ │ ├── Secondary_non_matching.json │ │ │ │ │ │ └── Secondary_non_matching.yml │ │ │ │ │ └── write │ │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ │ └── SecondaryPreferred.yml │ │ │ │ │ ├── Sharded │ │ │ │ │ ├── read │ │ │ │ │ │ ├── Nearest.json │ │ │ │ │ │ ├── Nearest.yml │ │ │ │ │ │ ├── Primary.json │ │ │ │ │ │ ├── Primary.yml │ │ │ │ │ │ ├── PrimaryPreferred.json │ │ │ │ │ │ ├── PrimaryPreferred.yml │ │ │ │ │ │ ├── Secondary.json │ │ │ │ │ │ ├── Secondary.yml │ │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ │ └── SecondaryPreferred.yml │ │ │ │ │ └── write │ │ │ │ │ │ ├── Nearest.json │ │ │ │ │ │ ├── Nearest.yml │ │ │ │ │ │ ├── Primary.json │ │ │ │ │ │ ├── Primary.yml │ │ │ │ │ │ ├── PrimaryPreferred.json │ │ │ │ │ │ ├── PrimaryPreferred.yml │ │ │ │ │ │ ├── Secondary.json │ │ │ │ │ │ ├── Secondary.yml │ │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ │ └── SecondaryPreferred.yml │ │ │ │ │ ├── Single │ │ │ │ │ ├── read │ │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ │ └── SecondaryPreferred.yml │ │ │ │ │ └── write │ │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ │ └── SecondaryPreferred.yml │ │ │ │ │ └── Unknown │ │ │ │ │ ├── read │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ └── SecondaryPreferred.yml │ │ │ │ │ └── write │ │ │ │ │ ├── SecondaryPreferred.json │ │ │ │ │ └── SecondaryPreferred.yml │ │ │ └── uri-options │ │ │ │ ├── README.rst │ │ │ │ ├── auth-options.json │ │ │ │ ├── auth-options.yml │ │ │ │ ├── ca.pem │ │ │ │ ├── cert.pem │ │ │ │ ├── client.pem │ │ │ │ ├── compression-options.json │ │ │ │ ├── compression-options.yml │ │ │ │ ├── concern-options.json │ │ │ │ ├── concern-options.yml │ │ │ │ ├── connection-options.json │ │ │ │ ├── connection-options.yml │ │ │ │ ├── connection-pool-options.json │ │ │ │ ├── connection-pool-options.yml │ │ │ │ ├── read-preference-options.json │ │ │ │ ├── read-preference-options.yml │ │ │ │ ├── single-threaded-options.json │ │ │ │ ├── single-threaded-options.yml │ │ │ │ ├── tls-options.json │ │ │ │ └── tls-options.yml │ │ ├── mod.rs │ │ └── read_write_concern │ │ │ ├── connection_string.rs │ │ │ ├── document.rs │ │ │ └── mod.rs │ └── util │ │ ├── event.rs │ │ ├── lock.rs │ │ ├── matchable.rs │ │ └── mod.rs └── util │ ├── hex.rs │ ├── md5.rs │ └── mod.rs └── tests ├── bson ├── bson.rs ├── doc.rs ├── encoder_decoder.rs ├── macros.rs ├── mod.rs ├── oid.rs ├── ser.rs └── serde.rs └── lib.rs /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.tmp 3 | *.o 4 | *~ 5 | /target/ 6 | **/*.rs.bk 7 | Cargo.lock 8 | .idea 9 | *.iml 10 | .vscode 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | 3 | rust: 4 | - stable 5 | - beta 6 | - nightly 7 | 8 | cache: cargo 9 | 10 | env: 11 | - RUST_TEST_THREADS=1 12 | 13 | sudo: false 14 | 15 | script: 16 | - cargo build -v 17 | - cargo test -v --no-fail-fast 18 | - cargo test -v --no-fail-fast --features u2i 19 | - cd serde-tests && cargo test -v --no-fail-fast 20 | -------------------------------------------------------------------------------- /etc/update-spec-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This script is used to fetch the latest JSON tests for the CRUD spec. It puts the tests in the 4 | # direcory $reporoot/data/crud. It should be run from the root of the repository. 5 | 6 | set -o errexit 7 | set -o nounset 8 | 9 | if [ ! -d ".git" ]; then 10 | echo "$0: This script must be run from the root of the repository" >&2 11 | exit 1 12 | fi 13 | 14 | if [ $# -ne 1 ]; then 15 | echo "$0: This script must be passed exactly one argument for which tests to sync" >&2 16 | exit 1 17 | fi 18 | 19 | tmpdir=`perl -MFile::Temp=tempdir -wle 'print tempdir(TMPDIR => 1, CLEANUP => 0)'` 20 | curl -sL https://github.com/mongodb/specifications/archive/master.zip -o "$tmpdir/specs.zip" 21 | unzip -d "$tmpdir" "$tmpdir/specs.zip" > /dev/null 22 | mkdir -p "src/test/spec/json/$1" 23 | rsync -ah "$tmpdir/specifications-master/source/$1/tests/" "src/test/spec/json/$1" 24 | rm -rf "$tmpdir" 25 | -------------------------------------------------------------------------------- /examples/decode.rs: -------------------------------------------------------------------------------- 1 | use mongors::bson; 2 | 3 | use std::fs::File; 4 | 5 | fn main() { 6 | let mut f = File::open("examples/test.bson").unwrap(); 7 | 8 | while let Ok(decoded) = bson::decode_document(&mut f) { 9 | println!("{:?}", decoded); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/encode.rs: -------------------------------------------------------------------------------- 1 | use std::io::Cursor; 2 | 3 | use mongors::bson::{decode_document, encode_document, oid, Array, Bson, Document}; 4 | use chrono; 5 | 6 | fn main() { 7 | let mut doc = Document::new(); 8 | doc.insert("foo".to_string(), Bson::String("bar".to_string())); 9 | 10 | let mut arr = Array::new(); 11 | arr.push(Bson::String("blah".to_string())); 12 | arr.push(Bson::UtcDatetime(chrono::Utc::now())); 13 | arr.push(Bson::ObjectId(oid::ObjectId::with_bytes([ 14 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 15 | ]))); 16 | 17 | doc.insert("array".to_string(), Bson::Array(arr)); 18 | 19 | let mut buf = Vec::new(); 20 | encode_document(&mut buf, &doc).unwrap(); 21 | 22 | println!("Encoded: {:?}", buf); 23 | 24 | let doc = decode_document(&mut Cursor::new(&buf[..])).unwrap(); 25 | println!("Decoded: {:?}", doc); 26 | } 27 | -------------------------------------------------------------------------------- /examples/test.bson: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danclive/mongo-rust-driver/a185b3b88ca1d0a271094cd30c250c8b8b7a5046/examples/test.bson -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | combine_control_expr = false 2 | comment_width = 100 3 | condense_wildcard_suffixes = true 4 | format_strings = true 5 | normalize_comments = true 6 | use_try_shorthand = true 7 | wrap_comments = true 8 | merge_imports = true 9 | imports_layout = "HorizontalVertical" 10 | -------------------------------------------------------------------------------- /serde-tests/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "serde-tests" 3 | version = "0.1.0" 4 | authors = ["Kevin Yeh "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | bson = { path = ".." } 9 | serde = { version = "1.0", features = ["derive"] } 10 | 11 | [lib] 12 | name = "serde_tests" 13 | path = "lib.rs" 14 | 15 | [[test]] 16 | name = "serde" 17 | path = "test.rs" 18 | -------------------------------------------------------------------------------- /serde-tests/lib.rs: -------------------------------------------------------------------------------- 1 | // intentionally blank 2 | -------------------------------------------------------------------------------- /serde-tests/rustfmt.toml: -------------------------------------------------------------------------------- 1 | combine_control_expr = false 2 | comment_width = 100 3 | condense_wildcard_suffixes = true 4 | format_strings = true 5 | normalize_comments = true 6 | use_try_shorthand = true 7 | wrap_comments = true 8 | merge_imports = true 9 | imports_layout = "HorizontalVertical" 10 | -------------------------------------------------------------------------------- /src/bson/compat/mod.rs: -------------------------------------------------------------------------------- 1 | //! Backward compatibility 2 | 3 | pub mod u2f; 4 | -------------------------------------------------------------------------------- /src/cmap/conn/wire/mod.rs: -------------------------------------------------------------------------------- 1 | mod header; 2 | mod message; 3 | #[cfg(test)] 4 | mod test; 5 | mod util; 6 | 7 | pub(crate) use self::{message::Message, util::next_request_id}; 8 | -------------------------------------------------------------------------------- /src/event/mod.rs: -------------------------------------------------------------------------------- 1 | //! Contains the events and functionality for monitoring internal `Client` behavior. 2 | 3 | pub mod cmap; 4 | pub mod command; 5 | -------------------------------------------------------------------------------- /src/sdam/description/mod.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod server; 2 | pub(crate) mod topology; 3 | -------------------------------------------------------------------------------- /src/sdam/description/topology/test/mod.rs: -------------------------------------------------------------------------------- 1 | mod rtt; 2 | mod sdam; 3 | 4 | use std::time::Duration; 5 | 6 | pub(crate) fn f64_ms_as_duration(f: f64) -> Duration { 7 | Duration::from_micros((f * 1000.0) as u64) 8 | } 9 | -------------------------------------------------------------------------------- /src/sdam/mod.rs: -------------------------------------------------------------------------------- 1 | mod description; 2 | mod monitor; 3 | pub mod public; 4 | mod state; 5 | 6 | pub use self::public::{ServerInfo, ServerType}; 7 | 8 | #[cfg(test)] 9 | pub(crate) use self::description::server::ServerDescription; 10 | pub(crate) use self::{ 11 | description::topology::TopologyDescription, 12 | monitor::MIN_HEARTBEAT_FREQUENCY, 13 | state::{ 14 | handle_post_handshake_error, 15 | handle_pre_handshake_error, 16 | server::Server, 17 | update_topology, 18 | Topology, 19 | TopologyUpdateCondvar, 20 | }, 21 | }; 22 | -------------------------------------------------------------------------------- /src/test/atlas_connectivity.rs: -------------------------------------------------------------------------------- 1 | use crate::doc; 2 | 3 | use crate::Client; 4 | 5 | fn run_test(uri_env_var: &str) { 6 | if std::env::var_os("MONGO_ATLAS_TESTS").is_none() { 7 | return; 8 | } 9 | 10 | let uri = if let Some(uri) = std::env::var_os(uri_env_var) { 11 | uri 12 | } else { 13 | panic!("could not find variable {}", uri_env_var); 14 | }; 15 | 16 | let client = Client::with_uri_str(uri.to_string_lossy().as_ref()).unwrap(); 17 | 18 | let db = client.database("test"); 19 | db.run_command(doc! { "isMaster": 1 }, None) 20 | .expect("isMaster should succeed"); 21 | 22 | let coll = db.collection("test"); 23 | coll.find_one(None, None).expect("findOne should succeed"); 24 | } 25 | 26 | #[test] 27 | fn atlas_repl_set() { 28 | run_test("MONGO_ATLAS_FREE_TIER_REPL_URI"); 29 | } 30 | 31 | #[test] 32 | fn atlas_repl_set_srv() { 33 | run_test("MONGO_ATLAS_FREE_TIER_REPL_URI_SRV"); 34 | } 35 | -------------------------------------------------------------------------------- /src/test/mod.rs: -------------------------------------------------------------------------------- 1 | mod atlas_connectivity; 2 | mod client; 3 | mod coll; 4 | mod db; 5 | mod spec; 6 | mod util; 7 | 8 | pub(crate) use self::{ 9 | spec::run_spec_test, 10 | util::{assert_matches, parse_version, CommandEvent, EventClient, Matchable}, 11 | }; 12 | 13 | use lazy_static::lazy_static; 14 | 15 | use self::util::{TestClient, TestLock}; 16 | use crate::options::ClientOptions; 17 | 18 | lazy_static! { 19 | pub(crate) static ref CLIENT: TestClient = TestClient::new(); 20 | pub(crate) static ref CLIENT_OPTIONS: ClientOptions = CLIENT.options.clone(); 21 | pub(crate) static ref LOCK: TestLock = TestLock::new(); 22 | } 23 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/connection-must-have-id.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "style": "unit", 4 | "description": "must have an ID number associated with it", 5 | "operations": [ 6 | { 7 | "name": "checkOut" 8 | }, 9 | { 10 | "name": "checkOut" 11 | } 12 | ], 13 | "events": [ 14 | { 15 | "type": "ConnectionCheckOutStarted" 16 | }, 17 | { 18 | "type": "ConnectionCreated", 19 | "connectionId": 42 20 | }, 21 | { 22 | "type": "ConnectionCheckedOut", 23 | "connectionId": 42 24 | }, 25 | { 26 | "type": "ConnectionCheckOutStarted" 27 | }, 28 | { 29 | "type": "ConnectionCreated", 30 | "connectionId": 42 31 | }, 32 | { 33 | "type": "ConnectionCheckedOut", 34 | "connectionId": 42 35 | } 36 | ], 37 | "ignore": [ 38 | "ConnectionPoolCreated", 39 | "ConnectionPoolClosed", 40 | "ConnectionReady" 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/connection-must-have-id.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must have an ID number associated with it 4 | operations: 5 | - name: checkOut 6 | - name: checkOut 7 | events: 8 | - type: ConnectionCheckOutStarted 9 | - type: ConnectionCreated 10 | connectionId: 42 11 | - type: ConnectionCheckedOut 12 | connectionId: 42 13 | - type: ConnectionCheckOutStarted 14 | - type: ConnectionCreated 15 | connectionId: 42 16 | - type: ConnectionCheckedOut 17 | connectionId: 42 18 | ignore: 19 | - ConnectionPoolCreated 20 | - ConnectionPoolClosed 21 | - ConnectionReady 22 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/connection-must-order-ids.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "style": "unit", 4 | "description": "must have IDs assigned in order of creation", 5 | "operations": [ 6 | { 7 | "name": "checkOut" 8 | }, 9 | { 10 | "name": "checkOut" 11 | } 12 | ], 13 | "events": [ 14 | { 15 | "type": "ConnectionCheckOutStarted" 16 | }, 17 | { 18 | "type": "ConnectionCreated", 19 | "connectionId": 1 20 | }, 21 | { 22 | "type": "ConnectionCheckedOut", 23 | "connectionId": 1 24 | }, 25 | { 26 | "type": "ConnectionCheckOutStarted" 27 | }, 28 | { 29 | "type": "ConnectionCreated", 30 | "connectionId": 2 31 | }, 32 | { 33 | "type": "ConnectionCheckedOut", 34 | "connectionId": 2 35 | } 36 | ], 37 | "ignore": [ 38 | "ConnectionPoolCreated", 39 | "ConnectionPoolClosed", 40 | "ConnectionReady" 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/connection-must-order-ids.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must have IDs assigned in order of creation 4 | operations: 5 | - name: checkOut 6 | - name: checkOut 7 | events: 8 | - type: ConnectionCheckOutStarted 9 | - type: ConnectionCreated 10 | connectionId: 1 11 | - type: ConnectionCheckedOut 12 | connectionId: 1 13 | - type: ConnectionCheckOutStarted 14 | - type: ConnectionCreated 15 | connectionId: 2 16 | - type: ConnectionCheckedOut 17 | connectionId: 2 18 | ignore: 19 | - ConnectionPoolCreated 20 | - ConnectionPoolClosed 21 | - ConnectionReady 22 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkin-destroy-closed.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "style": "unit", 4 | "description": "must destroy checked in connection if pool has been closed", 5 | "operations": [ 6 | { 7 | "name": "checkOut", 8 | "label": "conn" 9 | }, 10 | { 11 | "name": "close" 12 | }, 13 | { 14 | "name": "checkIn", 15 | "connection": "conn" 16 | } 17 | ], 18 | "events": [ 19 | { 20 | "type": "ConnectionCheckedOut", 21 | "connectionId": 1 22 | }, 23 | { 24 | "type": "ConnectionPoolClosed", 25 | "address": 42 26 | }, 27 | { 28 | "type": "ConnectionCheckedIn", 29 | "connectionId": 1 30 | }, 31 | { 32 | "type": "ConnectionClosed", 33 | "connectionId": 1, 34 | "reason": "poolClosed" 35 | } 36 | ], 37 | "ignore": [ 38 | "ConnectionPoolCreated", 39 | "ConnectionCreated", 40 | "ConnectionReady", 41 | "ConnectionCheckOutStarted" 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkin-destroy-closed.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must destroy checked in connection if pool has been closed 4 | operations: 5 | - name: checkOut 6 | label: conn 7 | - name: close 8 | - name: checkIn 9 | connection: conn 10 | events: 11 | - type: ConnectionCheckedOut 12 | connectionId: 1 13 | - type: ConnectionPoolClosed 14 | address: 42 15 | - type: ConnectionCheckedIn 16 | connectionId: 1 17 | - type: ConnectionClosed 18 | connectionId: 1 19 | reason: poolClosed 20 | ignore: 21 | - ConnectionPoolCreated 22 | - ConnectionCreated 23 | - ConnectionReady 24 | - ConnectionCheckOutStarted 25 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkin-destroy-stale.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "style": "unit", 4 | "description": "must destroy checked in connection if it is stale", 5 | "operations": [ 6 | { 7 | "name": "checkOut", 8 | "label": "conn" 9 | }, 10 | { 11 | "name": "clear" 12 | }, 13 | { 14 | "name": "checkIn", 15 | "connection": "conn" 16 | } 17 | ], 18 | "events": [ 19 | { 20 | "type": "ConnectionCheckedOut", 21 | "connectionId": 1 22 | }, 23 | { 24 | "type": "ConnectionPoolCleared", 25 | "address": 42 26 | }, 27 | { 28 | "type": "ConnectionCheckedIn", 29 | "connectionId": 1 30 | }, 31 | { 32 | "type": "ConnectionClosed", 33 | "connectionId": 1, 34 | "reason": "stale" 35 | } 36 | ], 37 | "ignore": [ 38 | "ConnectionPoolCreated", 39 | "ConnectionCreated", 40 | "ConnectionReady", 41 | "ConnectionCheckOutStarted" 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkin-destroy-stale.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must destroy checked in connection if it is stale 4 | operations: 5 | - name: checkOut 6 | label: conn 7 | - name: clear 8 | - name: checkIn 9 | connection: conn 10 | events: 11 | - type: ConnectionCheckedOut 12 | connectionId: 1 13 | - type: ConnectionPoolCleared 14 | address: 42 15 | - type: ConnectionCheckedIn 16 | connectionId: 1 17 | - type: ConnectionClosed 18 | connectionId: 1 19 | reason: stale 20 | ignore: 21 | - ConnectionPoolCreated 22 | - ConnectionCreated 23 | - ConnectionReady 24 | - ConnectionCheckOutStarted 25 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkin-make-available.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "style": "unit", 4 | "description": "must make valid checked in connection available", 5 | "operations": [ 6 | { 7 | "name": "checkOut", 8 | "label": "conn" 9 | }, 10 | { 11 | "name": "checkIn", 12 | "connection": "conn" 13 | }, 14 | { 15 | "name": "checkOut" 16 | } 17 | ], 18 | "events": [ 19 | { 20 | "type": "ConnectionCheckedOut", 21 | "connectionId": 1 22 | }, 23 | { 24 | "type": "ConnectionCheckedIn", 25 | "connectionId": 1 26 | }, 27 | { 28 | "type": "ConnectionCheckedOut", 29 | "connectionId": 1 30 | } 31 | ], 32 | "ignore": [ 33 | "ConnectionPoolCreated", 34 | "ConnectionCreated", 35 | "ConnectionReady", 36 | "ConnectionCheckOutStarted" 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkin-make-available.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must make valid checked in connection available 4 | operations: 5 | - name: checkOut 6 | label: conn 7 | - name: checkIn 8 | connection: conn 9 | - name: checkOut 10 | events: 11 | - type: ConnectionCheckedOut 12 | connectionId: 1 13 | - type: ConnectionCheckedIn 14 | connectionId: 1 15 | - type: ConnectionCheckedOut 16 | connectionId: 1 17 | ignore: 18 | - ConnectionPoolCreated 19 | - ConnectionCreated 20 | - ConnectionReady 21 | - ConnectionCheckOutStarted -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkin.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "style": "unit", 4 | "description": "must have a method of allowing the driver to check in a connection", 5 | "operations": [ 6 | { 7 | "name": "checkOut", 8 | "label": "conn" 9 | }, 10 | { 11 | "name": "checkIn", 12 | "connection": "conn" 13 | } 14 | ], 15 | "events": [ 16 | { 17 | "type": "ConnectionCheckedIn", 18 | "connectionId": 42 19 | } 20 | ], 21 | "ignore": [ 22 | "ConnectionPoolCreated", 23 | "ConnectionCreated", 24 | "ConnectionReady", 25 | "ConnectionClosed", 26 | "ConnectionCheckOutStarted", 27 | "ConnectionCheckedOut" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkin.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must have a method of allowing the driver to check in a connection 4 | operations: 5 | - name: checkOut 6 | label: conn 7 | - name: checkIn 8 | connection: conn 9 | events: 10 | - type: ConnectionCheckedIn 11 | connectionId: 42 12 | ignore: 13 | - ConnectionPoolCreated 14 | - ConnectionCreated 15 | - ConnectionReady 16 | - ConnectionClosed 17 | - ConnectionCheckOutStarted 18 | - ConnectionCheckedOut 19 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkout-connection.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "style": "unit", 4 | "description": "must be able to check out a connection", 5 | "operations": [ 6 | { 7 | "name": "checkOut" 8 | } 9 | ], 10 | "events": [ 11 | { 12 | "type": "ConnectionCheckOutStarted" 13 | }, 14 | { 15 | "type": "ConnectionCheckedOut", 16 | "connectionId": 1 17 | } 18 | ], 19 | "ignore": [ 20 | "ConnectionPoolCreated", 21 | "ConnectionCreated", 22 | "ConnectionReady" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkout-connection.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must be able to check out a connection 4 | operations: 5 | - name: checkOut 6 | events: 7 | - type: ConnectionCheckOutStarted 8 | - type: ConnectionCheckedOut 9 | connectionId: 1 10 | ignore: 11 | - ConnectionPoolCreated 12 | - ConnectionCreated 13 | - ConnectionReady -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkout-error-closed.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must throw error if checkOut is called on a closed pool 4 | operations: 5 | - name: checkOut 6 | label: conn1 7 | - name: checkIn 8 | connection: conn1 9 | - name: close 10 | - name: checkOut 11 | error: 12 | type: PoolClosedError 13 | message: Attempted to check out a connection from closed connection pool 14 | events: 15 | - type: ConnectionPoolCreated 16 | address: 42 17 | options: 42 18 | - type: ConnectionCheckOutStarted 19 | address: 42 20 | - type: ConnectionCheckedOut 21 | address: 42 22 | connectionId: 42 23 | - type: ConnectionCheckedIn 24 | address: 42 25 | connectionId: 42 26 | - type: ConnectionPoolClosed 27 | address: 42 28 | - type: ConnectionCheckOutStarted 29 | address: 42 30 | - type: ConnectionCheckOutFailed 31 | address: 42 32 | reason: poolClosed 33 | ignore: 34 | - ConnectionCreated 35 | - ConnectionReady 36 | - ConnectionClosed 37 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkout-multiple.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must be able to check out multiple connections at the same time 4 | operations: 5 | - name: start 6 | target: thread1 7 | - name: start 8 | target: thread2 9 | - name: start 10 | target: thread3 11 | - name: checkOut 12 | thread: thread1 13 | - name: checkOut 14 | thread: thread2 15 | - name: checkOut 16 | thread: thread3 17 | - name: waitForThread 18 | target: thread1 19 | - name: waitForThread 20 | target: thread2 21 | - name: waitForThread 22 | target: thread3 23 | events: 24 | - type: ConnectionCheckedOut 25 | connectionId: 42 26 | - type: ConnectionCheckedOut 27 | connectionId: 42 28 | - type: ConnectionCheckedOut 29 | connectionId: 42 30 | ignore: 31 | - ConnectionCreated 32 | - ConnectionReady 33 | - ConnectionPoolCreated 34 | - ConnectionCheckOutStarted 35 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkout-no-idle.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must destroy and must not check out an idle connection if found while iterating available connections 4 | poolOptions: 5 | maxIdleTimeMS: 10 6 | operations: 7 | - name: checkOut 8 | label: conn 9 | - name: checkIn 10 | connection: conn 11 | - name: wait 12 | ms: 50 13 | - name: checkOut 14 | events: 15 | - type: ConnectionPoolCreated 16 | address: 42 17 | options: 42 18 | - type: ConnectionCheckedOut 19 | connectionId: 1 20 | - type: ConnectionCheckedIn 21 | connectionId: 1 22 | # In between these, wait so connection becomes idle 23 | - type: ConnectionClosed 24 | connectionId: 1 25 | reason: idle 26 | - type: ConnectionCheckedOut 27 | connectionId: 2 28 | ignore: 29 | - ConnectionReady 30 | - ConnectionCreated 31 | - ConnectionCheckOutStarted 32 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-checkout-no-stale.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must destroy and must not check out a stale connection if found while iterating available connections 4 | operations: 5 | - name: checkOut 6 | label: conn 7 | - name: checkIn 8 | connection: conn 9 | - name: clear 10 | - name: checkOut 11 | events: 12 | - type: ConnectionPoolCreated 13 | address: 42 14 | options: 42 15 | - type: ConnectionCheckedOut 16 | connectionId: 1 17 | - type: ConnectionCheckedIn 18 | connectionId: 1 19 | - type: ConnectionPoolCleared 20 | address: 42 21 | - type: ConnectionClosed 22 | connectionId: 1 23 | reason: stale 24 | - type: ConnectionCheckedOut 25 | connectionId: 2 26 | ignore: 27 | - ConnectionReady 28 | - ConnectionCreated 29 | - ConnectionCheckOutStarted 30 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-close-destroy-conns.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: When a pool is closed, it MUST first destroy all available connections in that pool 4 | operations: 5 | - name: checkOut 6 | - name: checkOut 7 | label: conn 8 | - name: checkOut 9 | - name: checkIn 10 | connection: conn 11 | - name: close 12 | events: 13 | - type: ConnectionCheckedIn 14 | connectionId: 2 15 | - type: ConnectionClosed 16 | connectionId: 2 17 | reason: poolClosed 18 | - type: ConnectionPoolClosed 19 | address: 42 20 | ignore: 21 | - ConnectionCreated 22 | - ConnectionReady 23 | - ConnectionPoolCreated 24 | - ConnectionCheckOutStarted 25 | - ConnectionCheckedOut 26 | 27 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-close.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "style": "unit", 4 | "description": "must be able to manually close a pool", 5 | "operations": [ 6 | { 7 | "name": "close" 8 | } 9 | ], 10 | "events": [ 11 | { 12 | "type": "ConnectionPoolCreated", 13 | "address": 42, 14 | "options": 42 15 | }, 16 | { 17 | "type": "ConnectionPoolClosed", 18 | "address": 42 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-close.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must be able to manually close a pool 4 | operations: 5 | - name: close 6 | events: 7 | - type: ConnectionPoolCreated 8 | address: 42 9 | options: 42 10 | - type: ConnectionPoolClosed 11 | address: 42 12 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-create-min-size.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must be able to start a pool with minPoolSize connections 4 | poolOptions: 5 | minPoolSize: 3 6 | operations: 7 | - name: waitForEvent 8 | event: ConnectionCreated 9 | count: 3 10 | - name: checkOut 11 | events: 12 | - type: ConnectionPoolCreated 13 | address: 42 14 | options: 42 15 | - type: ConnectionCreated 16 | connectionId: 42 17 | - type: ConnectionCreated 18 | connectionId: 42 19 | - type: ConnectionCreated 20 | connectionId: 42 21 | # Ensures that by the time pool is closed, there are at least 3 connections 22 | - type: ConnectionCheckedOut 23 | connectionId: 42 24 | ignore: 25 | - ConnectionReady 26 | - ConnectionClosed 27 | - ConnectionCheckOutStarted 28 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-create-with-options.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "style": "unit", 4 | "description": "must be able to start a pool with various options set", 5 | "poolOptions": { 6 | "maxPoolSize": 50, 7 | "minPoolSize": 5, 8 | "maxIdleTimeMS": 100 9 | }, 10 | "operations": [ 11 | { 12 | "name": "waitForEvent", 13 | "event": "ConnectionPoolCreated", 14 | "count": 1 15 | } 16 | ], 17 | "events": [ 18 | { 19 | "type": "ConnectionPoolCreated", 20 | "address": 42, 21 | "options": { 22 | "maxPoolSize": 50, 23 | "minPoolSize": 5, 24 | "maxIdleTimeMS": 100 25 | } 26 | } 27 | ], 28 | "ignore": [ 29 | "ConnectionCreated", 30 | "ConnectionReady" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-create-with-options.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must be able to start a pool with various options set 4 | poolOptions: 5 | maxPoolSize: 50 6 | minPoolSize: 5 7 | maxIdleTimeMS: 100 8 | operations: 9 | - name: waitForEvent 10 | event: ConnectionPoolCreated 11 | count: 1 12 | events: 13 | - type: ConnectionPoolCreated 14 | address: 42 15 | options: 16 | maxPoolSize: 50 17 | minPoolSize: 5 18 | maxIdleTimeMS: 100 19 | ignore: 20 | - ConnectionCreated 21 | - ConnectionReady 22 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-create.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "style": "unit", 4 | "description": "must be able to create a pool", 5 | "operations": [ 6 | { 7 | "name": "waitForEvent", 8 | "event": "ConnectionPoolCreated", 9 | "count": 1 10 | } 11 | ], 12 | "events": [ 13 | { 14 | "type": "ConnectionPoolCreated", 15 | "address": 42, 16 | "options": 42 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-monitoring-and-pooling/pool-create.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | style: unit 3 | description: must be able to create a pool 4 | operations: 5 | - name: waitForEvent 6 | event: ConnectionPoolCreated 7 | count: 1 8 | events: 9 | - type: ConnectionPoolCreated 10 | address: 42 11 | options: 42 12 | 13 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-string/valid-options.json: -------------------------------------------------------------------------------- 1 | { 2 | "tests": [ 3 | { 4 | "description": "Option names are normalized to lowercase", 5 | "uri": "mongodb://alice:secret@example.com/admin?AUTHMechanism=MONGODB-CR", 6 | "valid": true, 7 | "warning": false, 8 | "hosts": [ 9 | { 10 | "type": "hostname", 11 | "host": "example.com", 12 | "port": null 13 | } 14 | ], 15 | "auth": { 16 | "username": "alice", 17 | "password": "secret", 18 | "db": "admin" 19 | }, 20 | "options": { 21 | "authmechanism": "MONGODB-CR" 22 | } 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /src/test/spec/json/connection-string/valid-options.yml: -------------------------------------------------------------------------------- 1 | tests: 2 | - 3 | description: "Option names are normalized to lowercase" 4 | uri: "mongodb://alice:secret@example.com/admin?AUTHMechanism=MONGODB-CR" 5 | valid: true 6 | warning: false 7 | hosts: 8 | - 9 | type: "hostname" 10 | host: "example.com" 11 | port: ~ 12 | auth: 13 | username: "alice" 14 | password: "secret" 15 | db: "admin" 16 | options: 17 | authmechanism: "MONGODB-CR" 18 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/read/aggregate-collation.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "_id": 1, 5 | "x": "ping" 6 | } 7 | ], 8 | "minServerVersion": "3.4", 9 | "tests": [ 10 | { 11 | "description": "Aggregate with collation", 12 | "operation": { 13 | "name": "aggregate", 14 | "arguments": { 15 | "pipeline": [ 16 | { 17 | "$match": { 18 | "x": "PING" 19 | } 20 | } 21 | ], 22 | "collation": { 23 | "locale": "en_US", 24 | "strength": 2 25 | } 26 | } 27 | }, 28 | "outcome": { 29 | "result": [ 30 | { 31 | "_id": 1, 32 | "x": "ping" 33 | } 34 | ] 35 | } 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/read/aggregate-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 'ping'} 3 | minServerVersion: '3.4' 4 | 5 | tests: 6 | - 7 | description: "Aggregate with collation" 8 | operation: 9 | name: aggregate 10 | arguments: 11 | pipeline: 12 | - $match: 13 | x: 'PING' 14 | collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document 15 | outcome: 16 | result: 17 | - {_id: 1, x: 'ping'} 18 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/read/aggregate.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | - {_id: 2, x: 22} 4 | - {_id: 3, x: 33} 5 | 6 | tests: 7 | - 8 | description: "Aggregate with multiple stages" 9 | operation: 10 | name: aggregate 11 | arguments: 12 | pipeline: 13 | - $sort: {x: 1} 14 | - $match: 15 | _id: {$gt: 1} 16 | batchSize: 2 17 | 18 | outcome: 19 | result: 20 | - {_id: 2, x: 22} 21 | - {_id: 3, x: 33} 22 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/read/count-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 'PING'} 3 | minServerVersion: '3.4' 4 | 5 | tests: 6 | - 7 | description: "Count documents with collation" 8 | operation: 9 | name: countDocuments 10 | arguments: 11 | filter: { x: 'ping' } 12 | collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document 13 | 14 | outcome: 15 | result: 1 16 | - 17 | description: "Deprecated count with collation" 18 | operation: 19 | name: count 20 | arguments: 21 | filter: { x: 'ping' } 22 | collation: { locale: 'en_US', strength: 2 } 23 | 24 | outcome: 25 | result: 1 26 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/read/count-empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [], 3 | "tests": [ 4 | { 5 | "description": "Estimated document count with empty collection", 6 | "operation": { 7 | "name": "estimatedDocumentCount", 8 | "arguments": {} 9 | }, 10 | "outcome": { 11 | "result": 0 12 | } 13 | }, 14 | { 15 | "description": "Count documents with empty collection", 16 | "operation": { 17 | "name": "countDocuments", 18 | "arguments": { 19 | "filter": {} 20 | } 21 | }, 22 | "outcome": { 23 | "result": 0 24 | } 25 | }, 26 | { 27 | "description": "Deprecated count with empty collection", 28 | "operation": { 29 | "name": "count", 30 | "arguments": { 31 | "filter": {} 32 | } 33 | }, 34 | "outcome": { 35 | "result": 0 36 | } 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/read/count-empty.yml: -------------------------------------------------------------------------------- 1 | data: [] 2 | 3 | tests: 4 | - 5 | description: "Estimated document count with empty collection" 6 | operation: 7 | name: estimatedDocumentCount 8 | arguments: { } 9 | 10 | outcome: 11 | result: 0 12 | - 13 | description: "Count documents with empty collection" 14 | operation: 15 | name: countDocuments 16 | arguments: 17 | filter: { } 18 | 19 | outcome: 20 | result: 0 21 | - 22 | description: "Deprecated count with empty collection" 23 | operation: 24 | name: count 25 | arguments: 26 | filter: { } 27 | 28 | outcome: 29 | result: 0 30 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/read/distinct-collation.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "_id": 1, 5 | "string": "PING" 6 | }, 7 | { 8 | "_id": 2, 9 | "string": "ping" 10 | } 11 | ], 12 | "minServerVersion": "3.4", 13 | "tests": [ 14 | { 15 | "description": "Distinct with a collation", 16 | "operation": { 17 | "name": "distinct", 18 | "arguments": { 19 | "fieldName": "string", 20 | "collation": { 21 | "locale": "en_US", 22 | "strength": 2 23 | } 24 | } 25 | }, 26 | "outcome": { 27 | "result": [ 28 | "PING" 29 | ] 30 | } 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/read/distinct-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, string: 'PING'} 3 | - {_id: 2, string: 'ping'} 4 | minServerVersion: '3.4' 5 | 6 | tests: 7 | - 8 | description: "Distinct with a collation" 9 | operation: 10 | name: distinct 11 | arguments: 12 | fieldName: "string" 13 | collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document 14 | 15 | outcome: 16 | result: 17 | - 'PING' 18 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/read/distinct.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | - {_id: 2, x: 22} 4 | - {_id: 3, x: 33} 5 | 6 | tests: 7 | - 8 | description: "Distinct without a filter" 9 | operation: 10 | name: distinct 11 | arguments: 12 | fieldName: "x" 13 | filter: {} 14 | 15 | outcome: 16 | result: 17 | - 11 18 | - 22 19 | - 33 20 | - 21 | description: "Distinct with a filter" 22 | operation: 23 | name: distinct 24 | arguments: 25 | fieldName: "x" 26 | filter: 27 | _id: {$gt: 1} 28 | 29 | outcome: 30 | result: 31 | - 22 32 | - 33 -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/read/find-collation.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "_id": 1, 5 | "x": "ping" 6 | } 7 | ], 8 | "minServerVersion": "3.4", 9 | "tests": [ 10 | { 11 | "description": "Find with a collation", 12 | "operation": { 13 | "name": "find", 14 | "arguments": { 15 | "filter": { 16 | "x": "PING" 17 | }, 18 | "collation": { 19 | "locale": "en_US", 20 | "strength": 2 21 | } 22 | } 23 | }, 24 | "outcome": { 25 | "result": [ 26 | { 27 | "_id": 1, 28 | "x": "ping" 29 | } 30 | ] 31 | } 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/read/find-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 'ping'} 3 | minServerVersion: '3.4' 4 | 5 | tests: 6 | - 7 | description: "Find with a collation" 8 | operation: 9 | name: "find" 10 | arguments: 11 | filter: {x: 'PING'} 12 | collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document 13 | outcome: 14 | result: 15 | - {_id: 1, x: 'ping'} 16 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/deleteMany-collation.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "_id": 1, 5 | "x": 11 6 | }, 7 | { 8 | "_id": 2, 9 | "x": "ping" 10 | }, 11 | { 12 | "_id": 3, 13 | "x": "pINg" 14 | } 15 | ], 16 | "minServerVersion": "3.4", 17 | "tests": [ 18 | { 19 | "description": "DeleteMany when many documents match with collation", 20 | "operation": { 21 | "name": "deleteMany", 22 | "arguments": { 23 | "filter": { 24 | "x": "PING" 25 | }, 26 | "collation": { 27 | "locale": "en_US", 28 | "strength": 2 29 | } 30 | } 31 | }, 32 | "outcome": { 33 | "result": { 34 | "deletedCount": 2 35 | }, 36 | "collection": { 37 | "data": [ 38 | { 39 | "_id": 1, 40 | "x": 11 41 | } 42 | ] 43 | } 44 | } 45 | } 46 | ] 47 | } 48 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/deleteMany-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | - {_id: 2, x: 'ping'} 4 | - {_id: 3, x: 'pINg'} 5 | minServerVersion: '3.4' 6 | 7 | tests: 8 | - 9 | description: "DeleteMany when many documents match with collation" 10 | operation: 11 | name: "deleteMany" 12 | arguments: 13 | filter: 14 | x: 'PING' 15 | collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document 16 | 17 | outcome: 18 | result: 19 | deletedCount: 2 20 | collection: 21 | data: 22 | - {_id: 1, x: 11} 23 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/deleteMany.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | - {_id: 2, x: 22} 4 | - {_id: 3, x: 33} 5 | 6 | tests: 7 | - 8 | description: "DeleteMany when many documents match" 9 | operation: 10 | name: "deleteMany" 11 | arguments: 12 | filter: 13 | _id: {$gt: 1} 14 | 15 | outcome: 16 | result: 17 | deletedCount: 2 18 | collection: 19 | data: 20 | - {_id: 1, x: 11} 21 | - 22 | description: "DeleteMany when no document matches" 23 | operation: 24 | name: "deleteMany" 25 | arguments: 26 | filter: {_id: 4} 27 | 28 | outcome: 29 | result: 30 | deletedCount: 0 31 | collection: 32 | data: 33 | - {_id: 1, x: 11} 34 | - {_id: 2, x: 22} 35 | - {_id: 3, x: 33} 36 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/deleteOne-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | - {_id: 2, x: 'ping'} 4 | - {_id: 3, x: 'pINg'} 5 | minServerVersion: '3.4' 6 | 7 | tests: 8 | - 9 | description: "DeleteOne when many documents matches with collation" 10 | operation: 11 | name: "deleteOne" 12 | arguments: 13 | filter: {x: 'PING'} 14 | collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document 15 | 16 | outcome: 17 | result: 18 | deletedCount: 1 19 | collection: 20 | data: 21 | - {_id: 1, x: 11} 22 | - {_id: 3, x: 'pINg'} 23 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/findOneAndDelete-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | - {_id: 2, x: 'ping'} 4 | - {_id: 3, x: 'pINg'} 5 | minServerVersion: '3.4' 6 | 7 | tests: 8 | - 9 | description: "FindOneAndDelete when one document matches with collation" 10 | operation: 11 | name: findOneAndDelete 12 | arguments: 13 | filter: {_id: 2, x: 'PING'} 14 | projection: {x: 1, _id: 0} 15 | sort: {x: 1} 16 | collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document 17 | 18 | outcome: 19 | result: {x: 'ping'} 20 | collection: 21 | data: 22 | - {_id: 1, x: 11} 23 | - {_id: 3, x: 'pINg'} -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/findOneAndReplace-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | - {_id: 2, x: 'ping'} 4 | minServerVersion: '3.4' 5 | 6 | tests: 7 | - 8 | description: "FindOneAndReplace when one document matches with collation returning the document after modification" 9 | operation: 10 | name: findOneAndReplace 11 | arguments: 12 | filter: {x: 'PING'} 13 | replacement: {x: 'pong'} 14 | projection: {x: 1, _id: 0} 15 | returnDocument: After 16 | sort: {x: 1} 17 | collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document 18 | 19 | outcome: 20 | result: {x: 'pong'} 21 | collection: 22 | data: 23 | - {_id: 1, x: 11} 24 | - {_id: 2, x: 'pong'} 25 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/findOneAndUpdate-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | - {_id: 2, x: 'ping'} 4 | - {_id: 3, x: 'pINg'} 5 | minServerVersion: '3.4' 6 | 7 | tests: 8 | - 9 | description: "FindOneAndUpdate when many documents match with collation returning the document before modification" 10 | operation: 11 | name: findOneAndUpdate 12 | arguments: 13 | filter: 14 | x: 'PING' 15 | update: 16 | $set: {x: 'pong'} 17 | projection: {x: 1, _id: 0} 18 | sort: {_id: 1} 19 | collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document 20 | 21 | outcome: 22 | result: {x: 'ping'} 23 | collection: 24 | data: 25 | - {_id: 1, x: 11} 26 | - {_id: 2, x: 'pong'} 27 | - {_id: 3, x: 'pINg'} -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/insertOne.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | { 4 | "_id": 1, 5 | "x": 11 6 | } 7 | ], 8 | "tests": [ 9 | { 10 | "description": "InsertOne with a non-existing document", 11 | "operation": { 12 | "name": "insertOne", 13 | "arguments": { 14 | "document": { 15 | "_id": 2, 16 | "x": 22 17 | } 18 | } 19 | }, 20 | "outcome": { 21 | "result": { 22 | "insertedId": 2 23 | }, 24 | "collection": { 25 | "data": [ 26 | { 27 | "_id": 1, 28 | "x": 11 29 | }, 30 | { 31 | "_id": 2, 32 | "x": 22 33 | } 34 | ] 35 | } 36 | } 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/insertOne.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | 4 | tests: 5 | - 6 | description: "InsertOne with a non-existing document" 7 | operation: 8 | name: "insertOne" 9 | arguments: 10 | document: {_id: 2, x: 22} 11 | 12 | outcome: 13 | result: 14 | insertedId: 2 15 | collection: 16 | data: 17 | - {_id: 1, x: 11} 18 | - {_id: 2, x: 22} -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/replaceOne-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | - {_id: 2, x: 'ping'} 4 | minServerVersion: '3.4' 5 | 6 | tests: 7 | - 8 | description: "ReplaceOne when one document matches with collation" 9 | operation: 10 | name: "replaceOne" 11 | arguments: 12 | filter: {x: 'PING'} 13 | replacement: {_id: 2, x: 'pong'} 14 | collation: {locale: 'en_US', strength: 2} # https://docs.mongodb.com/master/reference/collation/#collation-document 15 | 16 | outcome: 17 | result: 18 | matchedCount: 1 19 | modifiedCount: 1 20 | upsertedCount: 0 21 | collection: 22 | data: 23 | - {_id: 1, x: 11} 24 | - {_id: 2, x: 'pong'} -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/updateMany-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | - {_id: 2, x: 'ping'} 4 | - {_id: 3, x: 'pINg'} 5 | minServerVersion: '3.4' 6 | 7 | tests: 8 | - 9 | description: "UpdateMany when many documents match with collation" 10 | operation: 11 | name: "updateMany" 12 | arguments: 13 | filter: 14 | x: 'ping' 15 | update: 16 | $set: {x: 'pong'} 17 | collation: { locale: 'en_US', strength: 2 } # https://docs.mongodb.com/master/reference/collation/#collation-document 18 | 19 | outcome: 20 | result: 21 | matchedCount: 2 22 | modifiedCount: 2 23 | upsertedCount: 0 24 | collection: 25 | data: 26 | - {_id: 1, x: 11} 27 | - {_id: 2, x: 'pong'} 28 | - {_id: 3, x: 'pong'} 29 | -------------------------------------------------------------------------------- /src/test/spec/json/crud/v1/write/updateOne-collation.yml: -------------------------------------------------------------------------------- 1 | data: 2 | - {_id: 1, x: 11} 3 | - {_id: 2, x: 'ping'} 4 | minServerVersion: '3.4' 5 | 6 | tests: 7 | - 8 | description: "UpdateOne when one document matches with collation" 9 | operation: 10 | name: "updateOne" 11 | arguments: 12 | filter: {x: 'PING'} 13 | update: 14 | $set: {x: 'pong'} 15 | collation: { locale: 'en_US', strength: 2} # https://docs.mongodb.com/master/reference/collation/#collation-document 16 | 17 | outcome: 18 | result: 19 | matchedCount: 1 20 | modifiedCount: 1 21 | upsertedCount: 0 22 | collection: 23 | data: 24 | - {_id: 1, x: 11} 25 | - {_id: 2, x: 'pong'} 26 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/encoded-userinfo-and-db.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://b*b%40f3tt%3D:%244to%40L8%3DMC@test3.test.build.10gen.cc/mydb%3F?replicaSet=repl0", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27017" 5 | ], 6 | "hosts": [ 7 | "localhost:27017", 8 | "localhost:27018", 9 | "localhost:27019" 10 | ], 11 | "options": { 12 | "replicaSet": "repl0", 13 | "ssl": true 14 | }, 15 | "parsed_options": { 16 | "user": "b*b@f3tt=", 17 | "password": "$4to@L8=MC", 18 | "db": "mydb?" 19 | }, 20 | "comment": "Encoded user, pass, and DB parse correctly" 21 | } 22 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/encoded-userinfo-and-db.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://b*b%40f3tt%3D:%244to%40L8%3DMC@test3.test.build.10gen.cc/mydb%3F?replicaSet=repl0" 2 | seeds: 3 | - localhost.test.build.10gen.cc:27017 4 | hosts: 5 | - localhost:27017 6 | - localhost:27018 7 | - localhost:27019 8 | options: 9 | replicaSet: repl0 10 | ssl: true 11 | parsed_options: 12 | user: "b*b@f3tt=" 13 | password: "$4to@L8=MC" 14 | db: "mydb?" 15 | comment: Encoded user, pass, and DB parse correctly 16 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/longer-parent-in-return.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test18.test.build.10gen.cc/?replicaSet=repl0", 3 | "seeds": [ 4 | "localhost.sub.test.build.10gen.cc:27017" 5 | ], 6 | "hosts": [ 7 | "localhost:27017", 8 | "localhost:27018", 9 | "localhost:27019" 10 | ], 11 | "options": { 12 | "replicaSet": "repl0", 13 | "ssl": true 14 | }, 15 | "comment": "Is correct, as returned host name shared the URI root \"test.build.10gen.cc\"." 16 | } 17 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/longer-parent-in-return.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test18.test.build.10gen.cc/?replicaSet=repl0" 2 | seeds: 3 | - localhost.sub.test.build.10gen.cc:27017 4 | hosts: 5 | - localhost:27017 6 | - localhost:27018 7 | - localhost:27019 8 | options: 9 | replicaSet: repl0 10 | ssl: true 11 | comment: Is correct, as returned host name shared the URI root "test.build.10gen.cc". 12 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/misformatted-option.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test8.test.build.10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because the options in the TXT record are incorrectly formatted (misses value)." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/misformatted-option.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test8.test.build.10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because the options in the TXT record are incorrectly formatted (misses value). 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/no-results.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test4.test.build.10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because no SRV records are present for this URI." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/no-results.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test4.test.build.10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because no SRV records are present for this URI. 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/not-enough-parts.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because host in URI does not have {hostname}, {domainname} and {tld}." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/not-enough-parts.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because host in URI does not have {hostname}, {domainname} and {tld}. 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/one-result-default-port.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test3.test.build.10gen.cc/?replicaSet=repl0", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27017" 5 | ], 6 | "hosts": [ 7 | "localhost:27017", 8 | "localhost:27018", 9 | "localhost:27019" 10 | ], 11 | "options": { 12 | "replicaSet": "repl0", 13 | "ssl": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/one-result-default-port.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test3.test.build.10gen.cc/?replicaSet=repl0" 2 | seeds: 3 | - localhost.test.build.10gen.cc:27017 4 | hosts: 5 | - localhost:27017 6 | - localhost:27018 7 | - localhost:27019 8 | options: 9 | replicaSet: repl0 10 | ssl: true 11 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/one-txt-record-multiple-strings.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test11.test.build.10gen.cc/", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27017" 5 | ], 6 | "hosts": [ 7 | "localhost:27017", 8 | "localhost:27018", 9 | "localhost:27019" 10 | ], 11 | "options": { 12 | "replicaSet": "repl0", 13 | "ssl": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/one-txt-record-multiple-strings.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test11.test.build.10gen.cc/" 2 | seeds: 3 | - localhost.test.build.10gen.cc:27017 4 | hosts: 5 | - localhost:27017 6 | - localhost:27018 7 | - localhost:27019 8 | options: 9 | replicaSet: repl0 10 | ssl: true 11 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/one-txt-record.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test5.test.build.10gen.cc/", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27017" 5 | ], 6 | "hosts": [ 7 | "localhost:27017", 8 | "localhost:27018", 9 | "localhost:27019" 10 | ], 11 | "options": { 12 | "replicaSet": "repl0", 13 | "authSource": "thisDB", 14 | "ssl": true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/one-txt-record.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test5.test.build.10gen.cc/" 2 | seeds: 3 | - localhost.test.build.10gen.cc:27017 4 | hosts: 5 | - localhost:27017 6 | - localhost:27018 7 | - localhost:27019 8 | options: 9 | replicaSet: repl0 10 | authSource: thisDB 11 | ssl: true 12 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/parent-part-mismatch1.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test14.test.build.10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because returned host name's part \"not-test\" mismatches URI parent part \"test\"." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/parent-part-mismatch1.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test14.test.build.10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because returned host name's part "not-test" mismatches URI parent part "test". 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/parent-part-mismatch2.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test15.test.build.10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because returned host name's part \"not-build\" mismatches URI parent part \"build\"." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/parent-part-mismatch2.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test15.test.build.10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because returned host name's part "not-build" mismatches URI parent part "build". 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/parent-part-mismatch3.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test16.test.build.10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because returned host name's part \"not-10gen\" mismatches URI parent part \"10gen\"." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/parent-part-mismatch3.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test16.test.build.10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because returned host name's part "not-10gen" mismatches URI parent part "10gen". 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/parent-part-mismatch4.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test17.test.build.10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because returned host name's TLD \"not-cc\" mismatches URI TLD \"cc\"." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/parent-part-mismatch4.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test17.test.build.10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because returned host name's TLD "not-cc" mismatches URI TLD "cc". 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/parent-part-mismatch5.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test19.test.build.10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because one of the returned host names' domain name parts \"evil\" mismatches \"test\"." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/parent-part-mismatch5.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test19.test.build.10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because one of the returned host names' domain name parts "evil" mismatches "test". 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/returned-parent-too-short.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test13.test.build.10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because returned host name's parent (build.10gen.cc) misses \"test.\"" 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/returned-parent-too-short.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test13.test.build.10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because returned host name's parent (build.10gen.cc) misses "test." 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/returned-parent-wrong.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test12.test.build.10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because returned host name is too short and mismatches a parent." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/returned-parent-wrong.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test12.test.build.10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because returned host name is too short and mismatches a parent. 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/two-results-default-port.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27017", 5 | "localhost.test.build.10gen.cc:27018" 6 | ], 7 | "hosts": [ 8 | "localhost:27017", 9 | "localhost:27018", 10 | "localhost:27019" 11 | ], 12 | "options": { 13 | "replicaSet": "repl0", 14 | "ssl": true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/two-results-default-port.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0" 2 | seeds: 3 | - localhost.test.build.10gen.cc:27017 4 | - localhost.test.build.10gen.cc:27018 5 | hosts: 6 | - localhost:27017 7 | - localhost:27018 8 | - localhost:27019 9 | options: 10 | replicaSet: repl0 11 | ssl: true 12 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/two-results-nonstandard-port.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test2.test.build.10gen.cc/?replicaSet=repl0", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27018", 5 | "localhost.test.build.10gen.cc:27019" 6 | ], 7 | "hosts": [ 8 | "localhost:27017", 9 | "localhost:27018", 10 | "localhost:27019" 11 | ], 12 | "options": { 13 | "replicaSet": "repl0", 14 | "ssl": true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/two-results-nonstandard-port.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test2.test.build.10gen.cc/?replicaSet=repl0" 2 | seeds: 3 | - localhost.test.build.10gen.cc:27018 4 | - localhost.test.build.10gen.cc:27019 5 | hosts: 6 | - localhost:27017 7 | - localhost:27018 8 | - localhost:27019 9 | options: 10 | replicaSet: repl0 11 | ssl: true 12 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/two-txt-records.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test6.test.build.10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because there are two TXT records." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/two-txt-records.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test6.test.build.10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because there are two TXT records. 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/txt-record-not-allowed-option.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test10.test.build.10gen.cc/?replicaSet=repl0", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because socketTimeoutMS is not an allowed option." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/txt-record-not-allowed-option.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test10.test.build.10gen.cc/?replicaSet=repl0" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because socketTimeoutMS is not an allowed option. 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/txt-record-with-overridden-ssl-option.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test5.test.build.10gen.cc/?ssl=false", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27017" 5 | ], 6 | "hosts": [ 7 | "localhost:27017", 8 | "localhost:27018", 9 | "localhost:27019" 10 | ], 11 | "options": { 12 | "replicaSet": "repl0", 13 | "authSource": "thisDB", 14 | "ssl": false 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/txt-record-with-overridden-ssl-option.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test5.test.build.10gen.cc/?ssl=false" 2 | seeds: 3 | - localhost.test.build.10gen.cc:27017 4 | hosts: 5 | - localhost:27017 6 | - localhost:27018 7 | - localhost:27019 8 | options: 9 | replicaSet: repl0 10 | authSource: thisDB 11 | ssl: false 12 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/txt-record-with-overridden-uri-option.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://auser:apass@test5.test.build.10gen.cc/?authSource=otherDB", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27017" 5 | ], 6 | "hosts": [ 7 | "localhost:27017", 8 | "localhost:27018", 9 | "localhost:27019" 10 | ], 11 | "options": { 12 | "replicaSet": "repl0", 13 | "authSource": "otherDB", 14 | "ssl": true 15 | }, 16 | "parsed_options": { 17 | "user": "auser", 18 | "password": "apass" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/txt-record-with-overridden-uri-option.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://auser:apass@test5.test.build.10gen.cc/?authSource=otherDB" 2 | seeds: 3 | - localhost.test.build.10gen.cc:27017 4 | hosts: 5 | - localhost:27017 6 | - localhost:27018 7 | - localhost:27019 8 | options: 9 | replicaSet: repl0 10 | authSource: otherDB 11 | ssl: true 12 | parsed_options: 13 | user: auser 14 | password: apass 15 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/txt-record-with-unallowed-option.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test7.test.build.10gen.cc/", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because \"ssl\" is not an allowed option." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/txt-record-with-unallowed-option.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test7.test.build.10gen.cc/" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because "ssl" is not an allowed option. 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/uri-with-admin-database.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/adminDB?replicaSet=repl0", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27017", 5 | "localhost.test.build.10gen.cc:27018" 6 | ], 7 | "hosts": [ 8 | "localhost:27017", 9 | "localhost:27018", 10 | "localhost:27019" 11 | ], 12 | "options": { 13 | "replicaSet": "repl0", 14 | "ssl": true 15 | }, 16 | "parsed_options": { 17 | "auth_database": "adminDB" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/uri-with-admin-database.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test1.test.build.10gen.cc/adminDB?replicaSet=repl0" 2 | seeds: 3 | - localhost.test.build.10gen.cc:27017 4 | - localhost.test.build.10gen.cc:27018 5 | hosts: 6 | - localhost:27017 7 | - localhost:27018 8 | - localhost:27019 9 | options: 10 | replicaSet: repl0 11 | ssl: true 12 | parsed_options: 13 | auth_database: adminDB 14 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/uri-with-auth.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://auser:apass@test1.test.build.10gen.cc/?replicaSet=repl0", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27017", 5 | "localhost.test.build.10gen.cc:27018" 6 | ], 7 | "hosts": [ 8 | "localhost:27017", 9 | "localhost:27018", 10 | "localhost:27019" 11 | ], 12 | "parsed_options": { 13 | "user": "auser", 14 | "password": "apass" 15 | }, 16 | "comment": "Should preserve auth credentials" 17 | } 18 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/uri-with-auth.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://auser:apass@test1.test.build.10gen.cc/?replicaSet=repl0" 2 | seeds: 3 | - localhost.test.build.10gen.cc:27017 4 | - localhost.test.build.10gen.cc:27018 5 | hosts: 6 | - localhost:27017 7 | - localhost:27018 8 | - localhost:27019 9 | parsed_options: 10 | user: auser 11 | password: apass 12 | comment: Should preserve auth credentials 13 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/uri-with-port.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test5.test.build.10gen.cc:8123/?replicaSet=repl0", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because the mongodb+srv URI includes a port." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/uri-with-port.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test5.test.build.10gen.cc:8123/?replicaSet=repl0" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because the mongodb+srv URI includes a port. 6 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/uri-with-two-hosts.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test5.test.build.10gen.cc,test6.test.build.10gen.cc/?replicaSet=repl0", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because the mongodb+srv URI includes two host names." 7 | } 8 | -------------------------------------------------------------------------------- /src/test/spec/json/initial-dns-seedlist-discovery/uri-with-two-hosts.yml: -------------------------------------------------------------------------------- 1 | uri: "mongodb+srv://test5.test.build.10gen.cc,test6.test.build.10gen.cc/?replicaSet=repl0" 2 | seeds: [] 3 | hosts: [] 4 | error: true 5 | comment: Should fail because the mongodb+srv URI includes two host names. 6 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml: -------------------------------------------------------------------------------- 1 | # By default, a read preference sets no maximum on staleness. 2 | --- 3 | topology_description: 4 | type: ReplicaSetNoPrimary 5 | servers: 6 | - &1 7 | address: a:27017 8 | type: RSSecondary 9 | avg_rtt_ms: 50 # Too far. 10 | lastUpdateTime: 0 11 | maxWireVersion: 5 12 | lastWrite: {lastWriteDate: {$numberLong: "1000001"}} 13 | - &2 14 | address: b:27017 15 | type: RSSecondary 16 | avg_rtt_ms: 5 17 | lastUpdateTime: 0 18 | maxWireVersion: 5 19 | lastWrite: {lastWriteDate: {$numberLong: "1"}} # Very stale. 20 | read_preference: 21 | mode: Nearest 22 | suitable_servers: # Very stale server is fine. 23 | - *1 24 | - *2 25 | in_latency_window: 26 | - *2 27 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/Incompatible.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetNoPrimary", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "type": "RSSecondary", 8 | "avg_rtt_ms": 5, 9 | "lastUpdateTime": 0, 10 | "maxWireVersion": 5, 11 | "lastWrite": { 12 | "lastWriteDate": { 13 | "$numberLong": "2" 14 | } 15 | } 16 | }, 17 | { 18 | "address": "b:27017", 19 | "type": "RSSecondary", 20 | "avg_rtt_ms": 5, 21 | "lastUpdateTime": 0, 22 | "maxWireVersion": 4, 23 | "lastWrite": { 24 | "lastWriteDate": { 25 | "$numberLong": "1" 26 | } 27 | } 28 | } 29 | ] 30 | }, 31 | "read_preference": { 32 | "mode": "Nearest", 33 | "maxStalenessSeconds": 120 34 | }, 35 | "error": true 36 | } 37 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/Incompatible.yml: -------------------------------------------------------------------------------- 1 | # During server selection, clients (drivers or mongos) MUST raise an error if 2 | # maxStalenessSeconds is defined and not -1 and any server's ``maxWireVersion`` 3 | # is less than 5 (`SERVER-23893`_). 4 | --- 5 | topology_description: 6 | type: ReplicaSetNoPrimary 7 | servers: 8 | - &1 9 | address: a:27017 10 | type: RSSecondary 11 | avg_rtt_ms: 5 12 | lastUpdateTime: 0 13 | maxWireVersion: 5 14 | lastWrite: {lastWriteDate: {$numberLong: "2"}} 15 | - &2 16 | address: b:27017 17 | type: RSSecondary 18 | avg_rtt_ms: 5 19 | lastUpdateTime: 0 20 | maxWireVersion: 4 # Incompatible. 21 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 22 | read_preference: 23 | mode: Nearest 24 | maxStalenessSeconds: 120 25 | error: true 26 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/LastUpdateTime.yml: -------------------------------------------------------------------------------- 1 | heartbeatFrequencyMS: 25000 # 25 seconds. 2 | topology_description: 3 | type: ReplicaSetNoPrimary 4 | servers: 5 | - &1 6 | address: a:27017 7 | type: RSSecondary 8 | avg_rtt_ms: 5 9 | lastUpdateTime: 1 10 | lastWrite: {lastWriteDate: {$numberLong: "125002"}} 11 | maxWireVersion: 5 12 | - &2 13 | address: b:27017 14 | type: RSSecondary 15 | avg_rtt_ms: 50 # Too far. 16 | lastUpdateTime: 25002 # Not used when there's no primary. 17 | lastWrite: {lastWriteDate: {$numberLong: "2"}} # 125 sec stale + 25 sec heartbeat <= 150 sec maxStaleness. 18 | maxWireVersion: 5 19 | - &3 20 | address: c:27017 21 | type: RSSecondary 22 | avg_rtt_ms: 5 23 | lastUpdateTime: 25001 24 | lastWrite: {lastWriteDate: {$numberLong: "1"}} # Too stale. 25 | maxWireVersion: 5 26 | read_preference: 27 | mode: Nearest 28 | maxStalenessSeconds: 150 29 | suitable_servers: 30 | - *1 31 | - *2 32 | in_latency_window: 33 | - *1 34 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/Nearest.yml: -------------------------------------------------------------------------------- 1 | heartbeatFrequencyMS: 25000 # 25 seconds. 2 | topology_description: 3 | type: ReplicaSetNoPrimary 4 | servers: 5 | - &1 6 | address: a:27017 7 | type: RSSecondary 8 | avg_rtt_ms: 5 9 | lastUpdateTime: 0 10 | lastWrite: {lastWriteDate: {$numberLong: "125002"}} 11 | maxWireVersion: 5 12 | - &2 13 | address: b:27017 14 | type: RSSecondary 15 | avg_rtt_ms: 50 # Too far. 16 | lastUpdateTime: 0 17 | lastWrite: {lastWriteDate: {$numberLong: "2"}} # 125 sec stale + 25 sec heartbeat <= 150 sec maxStaleness. 18 | maxWireVersion: 5 19 | - &3 20 | address: c:27017 21 | avg_rtt_ms: 5 22 | lastUpdateTime: 0 23 | type: RSSecondary 24 | lastWrite: {lastWriteDate: {$numberLong: "1"}} # Too stale. 25 | maxWireVersion: 5 26 | read_preference: 27 | mode: Nearest 28 | maxStalenessSeconds: 150 29 | suitable_servers: 30 | - *1 31 | - *2 32 | in_latency_window: 33 | - *1 34 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/Nearest2.yml: -------------------------------------------------------------------------------- 1 | heartbeatFrequencyMS: 25000 # 25 seconds. 2 | topology_description: 3 | type: ReplicaSetNoPrimary 4 | servers: 5 | - &1 6 | address: a:27017 7 | type: RSSecondary 8 | avg_rtt_ms: 50 # Too far. 9 | lastUpdateTime: 0 10 | lastWrite: {lastWriteDate: {$numberLong: "125002"}} 11 | maxWireVersion: 5 12 | - &2 13 | address: b:27017 14 | type: RSSecondary 15 | avg_rtt_ms: 5 16 | lastUpdateTime: 0 17 | lastWrite: {lastWriteDate: {$numberLong: "2"}} # 125 sec stale + 25 sec heartbeat <= 150 sec maxStaleness. 18 | maxWireVersion: 5 19 | - &3 20 | address: c:27017 21 | avg_rtt_ms: 5 22 | lastUpdateTime: 0 23 | type: RSSecondary 24 | lastWrite: {lastWriteDate: {$numberLong: "1"}} # Too stale. 25 | maxWireVersion: 5 26 | read_preference: 27 | mode: Nearest 28 | maxStalenessSeconds: 150 29 | suitable_servers: 30 | - *1 31 | - *2 32 | in_latency_window: 33 | - *2 34 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/NoKnownServers.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetNoPrimary", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "type": "Unknown" 8 | }, 9 | { 10 | "address": "b:27017", 11 | "type": "Unknown" 12 | } 13 | ] 14 | }, 15 | "read_preference": { 16 | "mode": "Nearest", 17 | "maxStalenessSeconds": 1 18 | }, 19 | "error": true 20 | } 21 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/NoKnownServers.yml: -------------------------------------------------------------------------------- 1 | # maxStalenessSeconds must be at least 90 seconds, even with no known servers. 2 | --- 3 | topology_description: 4 | type: ReplicaSetNoPrimary 5 | servers: 6 | - &1 7 | address: a:27017 8 | type: Unknown 9 | - &2 10 | address: b:27017 11 | type: Unknown 12 | read_preference: 13 | mode: Nearest 14 | maxStalenessSeconds: 1 # Too small. 15 | error: true 16 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml: -------------------------------------------------------------------------------- 1 | # Fallback to secondary if no primary. 2 | --- 3 | heartbeatFrequencyMS: 25000 # 25 seconds. 4 | topology_description: 5 | type: ReplicaSetNoPrimary 6 | servers: 7 | - &1 8 | address: a:27017 9 | type: RSSecondary 10 | avg_rtt_ms: 5 11 | lastUpdateTime: 0 12 | maxWireVersion: 5 13 | lastWrite: {lastWriteDate: {$numberLong: "1000001"}} 14 | - &2 15 | address: b:27017 16 | type: RSSecondary 17 | avg_rtt_ms: 5 18 | lastUpdateTime: 0 19 | maxWireVersion: 5 20 | lastWrite: {lastWriteDate: {$numberLong: "1"}} # Very stale. 21 | read_preference: 22 | mode: PrimaryPreferred 23 | maxStalenessSeconds: 90 24 | suitable_servers: 25 | - *1 26 | in_latency_window: 27 | - *1 28 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | # Filter out the stale secondary. 2 | --- 3 | topology_description: 4 | type: ReplicaSetNoPrimary 5 | servers: 6 | - &1 7 | address: a:27017 8 | type: RSSecondary 9 | avg_rtt_ms: 5 10 | lastUpdateTime: 0 11 | maxWireVersion: 5 12 | lastWrite: {lastWriteDate: {$numberLong: "1000001"}} 13 | - &2 14 | address: b:27017 15 | type: RSSecondary 16 | avg_rtt_ms: 5 17 | lastUpdateTime: 0 18 | maxWireVersion: 5 19 | lastWrite: {lastWriteDate: {$numberLong: "1"}} # Very stale. 20 | read_preference: 21 | mode: SecondaryPreferred 22 | maxStalenessSeconds: 120 23 | suitable_servers: 24 | - *1 25 | in_latency_window: 26 | - *1 27 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetNoPrimary", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "type": "RSSecondary", 8 | "avg_rtt_ms": 5, 9 | "lastUpdateTime": 0, 10 | "maxWireVersion": 5, 11 | "lastWrite": { 12 | "lastWriteDate": { 13 | "$numberLong": "2" 14 | } 15 | } 16 | }, 17 | { 18 | "address": "b:27017", 19 | "type": "RSSecondary", 20 | "avg_rtt_ms": 5, 21 | "lastUpdateTime": 0, 22 | "maxWireVersion": 4, 23 | "lastWrite": { 24 | "lastWriteDate": { 25 | "$numberLong": "1" 26 | } 27 | } 28 | } 29 | ] 30 | }, 31 | "read_preference": { 32 | "mode": "Nearest", 33 | "maxStalenessSeconds": 0 34 | }, 35 | "error": true 36 | } 37 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml: -------------------------------------------------------------------------------- 1 | # maxStalenessSeconds=0 is prohibited. 2 | --- 3 | topology_description: 4 | type: ReplicaSetNoPrimary 5 | servers: 6 | - &1 7 | address: a:27017 8 | type: RSSecondary 9 | avg_rtt_ms: 5 10 | lastUpdateTime: 0 11 | maxWireVersion: 5 12 | lastWrite: {lastWriteDate: {$numberLong: "2"}} 13 | - &2 14 | address: b:27017 15 | type: RSSecondary 16 | avg_rtt_ms: 5 17 | lastUpdateTime: 0 18 | maxWireVersion: 4 # Incompatible. 19 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 20 | read_preference: 21 | mode: Nearest 22 | maxStalenessSeconds: 0 23 | error: true 24 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml: -------------------------------------------------------------------------------- 1 | # By default, a read preference sets no maximum on staleness. 2 | --- 3 | topology_description: 4 | type: ReplicaSetWithPrimary 5 | servers: 6 | - &1 7 | address: a:27017 8 | type: RSPrimary 9 | avg_rtt_ms: 50 # Too far. 10 | lastUpdateTime: 0 11 | maxWireVersion: 5 12 | lastWrite: {lastWriteDate: {$numberLong: "1000001"}} 13 | - &2 14 | address: b:27017 15 | type: RSSecondary 16 | avg_rtt_ms: 5 17 | lastUpdateTime: 0 18 | maxWireVersion: 5 19 | lastWrite: {lastWriteDate: {$numberLong: "1"}} # Very stale. 20 | read_preference: 21 | mode: Nearest 22 | suitable_servers: # Very stale server is fine. 23 | - *1 24 | - *2 25 | in_latency_window: 26 | - *2 27 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/Incompatible.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetWithPrimary", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "type": "RSPrimary", 8 | "avg_rtt_ms": 5, 9 | "lastUpdateTime": 0, 10 | "maxWireVersion": 5, 11 | "lastWrite": { 12 | "lastWriteDate": { 13 | "$numberLong": "1" 14 | } 15 | } 16 | }, 17 | { 18 | "address": "b:27017", 19 | "type": "RSSecondary", 20 | "avg_rtt_ms": 5, 21 | "lastUpdateTime": 0, 22 | "maxWireVersion": 4, 23 | "lastWrite": { 24 | "lastWriteDate": { 25 | "$numberLong": "1" 26 | } 27 | } 28 | } 29 | ] 30 | }, 31 | "read_preference": { 32 | "mode": "Nearest", 33 | "maxStalenessSeconds": 120 34 | }, 35 | "error": true 36 | } 37 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/Incompatible.yml: -------------------------------------------------------------------------------- 1 | # During server selection, clients (drivers or mongos) MUST raise an error if 2 | # maxStalenessSeconds is defined and not -1 and any server's ``maxWireVersion`` 3 | # is less than 5 (`SERVER-23893`_). 4 | --- 5 | topology_description: 6 | type: ReplicaSetWithPrimary 7 | servers: 8 | - &1 9 | address: a:27017 10 | type: RSPrimary 11 | avg_rtt_ms: 5 12 | lastUpdateTime: 0 13 | maxWireVersion: 5 14 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 15 | - &2 16 | address: b:27017 17 | type: RSSecondary 18 | avg_rtt_ms: 5 19 | lastUpdateTime: 0 20 | maxWireVersion: 4 # Incompatible. 21 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 22 | read_preference: 23 | mode: Nearest 24 | maxStalenessSeconds: 120 25 | error: true 26 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/LongHeartbeat.yml: -------------------------------------------------------------------------------- 1 | # If users configure a longer ``heartbeatFrequencyMS`` than the default, 2 | # ``maxStalenessSeconds`` might have a larger minimum. 3 | --- 4 | heartbeatFrequencyMS: 120000 # 120 seconds. 5 | topology_description: 6 | type: ReplicaSetWithPrimary 7 | servers: 8 | - &1 9 | address: a:27017 10 | type: RSPrimary 11 | avg_rtt_ms: 5 12 | lastUpdateTime: 0 13 | maxWireVersion: 5 14 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 15 | - &2 16 | address: b:27017 17 | type: RSSecondary 18 | avg_rtt_ms: 50 # Too far. 19 | lastUpdateTime: 0 20 | maxWireVersion: 5 21 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 22 | read_preference: 23 | mode: Nearest 24 | maxStalenessSeconds: 130 # OK, must be 120 + 10 = 130 seconds. 25 | suitable_servers: 26 | - *1 27 | - *2 28 | in_latency_window: 29 | - *1 30 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/LongHeartbeat2.json: -------------------------------------------------------------------------------- 1 | { 2 | "heartbeatFrequencyMS": 120000, 3 | "topology_description": { 4 | "type": "ReplicaSetWithPrimary", 5 | "servers": [ 6 | { 7 | "address": "a:27017", 8 | "type": "RSPrimary", 9 | "avg_rtt_ms": 5, 10 | "lastUpdateTime": 0, 11 | "maxWireVersion": 5, 12 | "lastWrite": { 13 | "lastWriteDate": { 14 | "$numberLong": "1" 15 | } 16 | } 17 | }, 18 | { 19 | "address": "b:27017", 20 | "type": "RSSecondary", 21 | "avg_rtt_ms": 5, 22 | "lastUpdateTime": 0, 23 | "maxWireVersion": 5, 24 | "lastWrite": { 25 | "lastWriteDate": { 26 | "$numberLong": "1" 27 | } 28 | } 29 | } 30 | ] 31 | }, 32 | "read_preference": { 33 | "mode": "Nearest", 34 | "maxStalenessSeconds": 129 35 | }, 36 | "error": true 37 | } 38 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/LongHeartbeat2.yml: -------------------------------------------------------------------------------- 1 | # If users configure a longer ``heartbeatFrequencyMS`` than the default, 2 | # ``maxStalenessSeconds`` might have a larger minimum. 3 | --- 4 | heartbeatFrequencyMS: 120000 # 120 seconds. 5 | topology_description: 6 | type: ReplicaSetWithPrimary 7 | servers: 8 | - &1 9 | address: a:27017 10 | type: RSPrimary 11 | avg_rtt_ms: 5 12 | lastUpdateTime: 0 13 | maxWireVersion: 5 14 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 15 | - &2 16 | address: b:27017 17 | type: RSSecondary 18 | avg_rtt_ms: 5 19 | lastUpdateTime: 0 20 | maxWireVersion: 5 21 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 22 | read_preference: 23 | mode: Nearest 24 | maxStalenessSeconds: 129 # Too small, must be 120 + 10 = 130 seconds. 25 | error: true 26 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.json: -------------------------------------------------------------------------------- 1 | { 2 | "heartbeatFrequencyMS": 500, 3 | "topology_description": { 4 | "type": "ReplicaSetWithPrimary", 5 | "servers": [ 6 | { 7 | "address": "a:27017", 8 | "type": "RSPrimary", 9 | "avg_rtt_ms": 5, 10 | "lastUpdateTime": 0, 11 | "maxWireVersion": 5, 12 | "lastWrite": { 13 | "lastWriteDate": { 14 | "$numberLong": "1" 15 | } 16 | } 17 | }, 18 | { 19 | "address": "b:27017", 20 | "type": "RSSecondary", 21 | "avg_rtt_ms": 5, 22 | "lastUpdateTime": 0, 23 | "maxWireVersion": 5, 24 | "lastWrite": { 25 | "lastWriteDate": { 26 | "$numberLong": "1" 27 | } 28 | } 29 | } 30 | ] 31 | }, 32 | "read_preference": { 33 | "mode": "Nearest", 34 | "maxStalenessSeconds": 89 35 | }, 36 | "error": true 37 | } 38 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml: -------------------------------------------------------------------------------- 1 | # A driver MUST raise an error 2 | # if the TopologyType is ReplicaSetWithPrimary or ReplicaSetNoPrimary 3 | # and ``maxStalenessSeconds`` is less than 90. 4 | --- 5 | heartbeatFrequencyMS: 500 6 | topology_description: 7 | type: ReplicaSetWithPrimary 8 | servers: 9 | - &1 10 | address: a:27017 11 | type: RSPrimary 12 | avg_rtt_ms: 5 13 | lastUpdateTime: 0 14 | maxWireVersion: 5 15 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 16 | - &2 17 | address: b:27017 18 | type: RSSecondary 19 | avg_rtt_ms: 5 20 | lastUpdateTime: 0 21 | maxWireVersion: 5 22 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 23 | read_preference: 24 | mode: Nearest 25 | maxStalenessSeconds: 89 # Too small. 26 | error: true 27 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetWithPrimary", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "type": "RSPrimary", 8 | "avg_rtt_ms": 5, 9 | "lastUpdateTime": 0, 10 | "maxWireVersion": 5, 11 | "lastWrite": { 12 | "lastWriteDate": { 13 | "$numberLong": "1" 14 | } 15 | } 16 | }, 17 | { 18 | "address": "b:27017", 19 | "type": "RSSecondary", 20 | "avg_rtt_ms": 5, 21 | "lastUpdateTime": 0, 22 | "maxWireVersion": 5, 23 | "lastWrite": { 24 | "lastWriteDate": { 25 | "$numberLong": "1" 26 | } 27 | } 28 | } 29 | ] 30 | }, 31 | "read_preference": { 32 | "maxStalenessSeconds": 120 33 | }, 34 | "error": true 35 | } 36 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml: -------------------------------------------------------------------------------- 1 | # Drivers MUST raise an error if maxStalenessSeconds is defined and not -1 2 | # and the ``mode`` field is 'primary'. 3 | --- 4 | topology_description: 5 | type: ReplicaSetWithPrimary 6 | servers: 7 | - &1 8 | address: a:27017 9 | type: RSPrimary 10 | avg_rtt_ms: 5 11 | lastUpdateTime: 0 12 | maxWireVersion: 5 13 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 14 | - &2 15 | address: b:27017 16 | type: RSSecondary 17 | avg_rtt_ms: 5 18 | lastUpdateTime: 0 19 | maxWireVersion: 5 20 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 21 | read_preference: 22 | maxStalenessSeconds: 120 23 | error: true 24 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/Nearest.yml: -------------------------------------------------------------------------------- 1 | heartbeatFrequencyMS: 25000 # 25 seconds. 2 | topology_description: 3 | type: ReplicaSetWithPrimary 4 | servers: 5 | - &1 6 | address: a:27017 7 | type: RSPrimary 8 | avg_rtt_ms: 5 9 | lastUpdateTime: 0 10 | lastWrite: {lastWriteDate: {$numberLong: "125002"}} 11 | maxWireVersion: 5 12 | - &2 13 | address: b:27017 14 | type: RSSecondary 15 | avg_rtt_ms: 50 # Too far. 16 | lastUpdateTime: 0 17 | lastWrite: {lastWriteDate: {$numberLong: "2"}} # 125 sec stale + 25 sec heartbeat <= 150 sec maxStaleness. 18 | maxWireVersion: 5 19 | - &3 20 | address: c:27017 21 | avg_rtt_ms: 5 22 | lastUpdateTime: 0 23 | type: RSSecondary 24 | lastWrite: {lastWriteDate: {$numberLong: "1"}} # Too stale. 25 | maxWireVersion: 5 26 | read_preference: 27 | mode: Nearest 28 | maxStalenessSeconds: 150 29 | suitable_servers: 30 | - *1 31 | - *2 32 | in_latency_window: 33 | - *1 34 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/Nearest2.yml: -------------------------------------------------------------------------------- 1 | heartbeatFrequencyMS: 25000 # 25 seconds. 2 | topology_description: 3 | type: ReplicaSetWithPrimary 4 | servers: 5 | - &1 6 | address: a:27017 7 | type: RSPrimary 8 | avg_rtt_ms: 50 # Too far. 9 | lastUpdateTime: 0 10 | lastWrite: {lastWriteDate: {$numberLong: "125002"}} 11 | maxWireVersion: 5 12 | - &2 13 | address: b:27017 14 | type: RSSecondary 15 | avg_rtt_ms: 5 16 | lastUpdateTime: 0 17 | lastWrite: {lastWriteDate: {$numberLong: "2"}} # 125 sec stale + 25 sec heartbeat <= 150 sec maxStaleness. 18 | maxWireVersion: 5 19 | - &3 20 | address: c:27017 21 | avg_rtt_ms: 5 22 | lastUpdateTime: 0 23 | type: RSSecondary 24 | lastWrite: {lastWriteDate: {$numberLong: "1"}} # Too stale. 25 | maxWireVersion: 5 26 | read_preference: 27 | mode: Nearest 28 | maxStalenessSeconds: 150 29 | suitable_servers: 30 | - *1 31 | - *2 32 | in_latency_window: 33 | - *2 34 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml: -------------------------------------------------------------------------------- 1 | # Ignore maxStalenessSeconds if primary is available. 2 | --- 3 | heartbeatFrequencyMS: 25000 # 25 seconds. 4 | topology_description: 5 | type: ReplicaSetWithPrimary 6 | servers: 7 | - &1 8 | address: a:27017 9 | type: RSPrimary 10 | avg_rtt_ms: 5 11 | lastUpdateTime: 0 12 | maxWireVersion: 5 13 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 14 | - &2 15 | address: b:27017 16 | type: RSSecondary 17 | avg_rtt_ms: 5 18 | lastUpdateTime: 0 19 | maxWireVersion: 5 20 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 21 | read_preference: 22 | mode: PrimaryPreferred 23 | maxStalenessSeconds: 150 24 | suitable_servers: 25 | - *1 26 | in_latency_window: 27 | - *1 28 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetWithPrimary", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "type": "RSPrimary", 8 | "avg_rtt_ms": 5, 9 | "lastUpdateTime": 0, 10 | "maxWireVersion": 5, 11 | "lastWrite": { 12 | "lastWriteDate": { 13 | "$numberLong": "1" 14 | } 15 | } 16 | }, 17 | { 18 | "address": "b:27017", 19 | "type": "RSSecondary", 20 | "avg_rtt_ms": 5, 21 | "lastUpdateTime": 0, 22 | "maxWireVersion": 4, 23 | "lastWrite": { 24 | "lastWriteDate": { 25 | "$numberLong": "1" 26 | } 27 | } 28 | } 29 | ] 30 | }, 31 | "read_preference": { 32 | "mode": "PrimaryPreferred", 33 | "maxStalenessSeconds": 150 34 | }, 35 | "error": true 36 | } 37 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.yml: -------------------------------------------------------------------------------- 1 | # Primary has wire version 5, secondary has 4, read preference primaryPreferred 2 | # with maxStalenessSeconds. The client must error, even though it uses primary and 3 | # never applies maxStalenessSeconds. Proves that the compatibility check precedes 4 | # filtration. 5 | --- 6 | topology_description: 7 | type: ReplicaSetWithPrimary 8 | servers: 9 | - &1 10 | address: a:27017 11 | type: RSPrimary 12 | avg_rtt_ms: 5 13 | lastUpdateTime: 0 14 | maxWireVersion: 5 15 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 16 | - &2 17 | address: b:27017 18 | type: RSSecondary 19 | avg_rtt_ms: 5 20 | lastUpdateTime: 0 21 | maxWireVersion: 4 # Too old. 22 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 23 | read_preference: 24 | mode: PrimaryPreferred 25 | maxStalenessSeconds: 150 26 | error: true 27 | 28 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | # Fallback to primary if no secondary is fresh enough. 2 | --- 3 | topology_description: 4 | type: ReplicaSetWithPrimary 5 | servers: 6 | - &1 7 | address: a:27017 8 | type: RSPrimary 9 | avg_rtt_ms: 5 10 | lastUpdateTime: 0 11 | maxWireVersion: 5 12 | lastWrite: {lastWriteDate: {$numberLong: "1000001"}} 13 | - &2 14 | address: b:27017 15 | type: RSSecondary 16 | avg_rtt_ms: 5 17 | lastUpdateTime: 0 18 | maxWireVersion: 5 19 | lastWrite: {lastWriteDate: {$numberLong: "1"}} # Very stale. 20 | read_preference: 21 | mode: SecondaryPreferred 22 | maxStalenessSeconds: 120 23 | suitable_servers: 24 | - *1 25 | in_latency_window: 26 | - *1 27 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetWithPrimary", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "type": "RSPrimary", 8 | "avg_rtt_ms": 5, 9 | "lastUpdateTime": 0, 10 | "maxWireVersion": 5, 11 | "lastWrite": { 12 | "lastWriteDate": { 13 | "$numberLong": "2" 14 | } 15 | } 16 | }, 17 | { 18 | "address": "b:27017", 19 | "type": "RSSecondary", 20 | "avg_rtt_ms": 5, 21 | "lastUpdateTime": 0, 22 | "maxWireVersion": 4, 23 | "lastWrite": { 24 | "lastWriteDate": { 25 | "$numberLong": "1" 26 | } 27 | } 28 | } 29 | ] 30 | }, 31 | "read_preference": { 32 | "mode": "Nearest", 33 | "maxStalenessSeconds": 0 34 | }, 35 | "error": true 36 | } 37 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml: -------------------------------------------------------------------------------- 1 | # maxStalenessSeconds=0 is prohibited. 2 | --- 3 | topology_description: 4 | type: ReplicaSetWithPrimary 5 | servers: 6 | - &1 7 | address: a:27017 8 | type: RSPrimary 9 | avg_rtt_ms: 5 10 | lastUpdateTime: 0 11 | maxWireVersion: 5 12 | lastWrite: {lastWriteDate: {$numberLong: "2"}} 13 | - &2 14 | address: b:27017 15 | type: RSSecondary 16 | avg_rtt_ms: 5 17 | lastUpdateTime: 0 18 | maxWireVersion: 4 # Incompatible. 19 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 20 | read_preference: 21 | mode: Nearest 22 | maxStalenessSeconds: 0 23 | error: true 24 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/Sharded/Incompatible.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Sharded", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "type": "Mongos", 8 | "avg_rtt_ms": 5, 9 | "lastUpdateTime": 0, 10 | "maxWireVersion": 5, 11 | "lastWrite": { 12 | "lastWriteDate": { 13 | "$numberLong": "1" 14 | } 15 | } 16 | }, 17 | { 18 | "address": "b:27017", 19 | "type": "Mongos", 20 | "avg_rtt_ms": 5, 21 | "lastUpdateTime": 0, 22 | "maxWireVersion": 4, 23 | "lastWrite": { 24 | "lastWriteDate": { 25 | "$numberLong": "1" 26 | } 27 | } 28 | } 29 | ] 30 | }, 31 | "read_preference": { 32 | "mode": "Nearest", 33 | "maxStalenessSeconds": 120 34 | }, 35 | "error": true 36 | } 37 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/Sharded/Incompatible.yml: -------------------------------------------------------------------------------- 1 | # During server selection, clients (drivers or mongos) MUST raise an error if 2 | # maxStalenessSeconds is defined and not -1 and any server's ``maxWireVersion`` 3 | # is less than 5 (`SERVER-23893`_). 4 | --- 5 | topology_description: 6 | type: Sharded 7 | servers: 8 | - &1 9 | address: a:27017 10 | type: Mongos 11 | avg_rtt_ms: 5 12 | lastUpdateTime: 0 13 | maxWireVersion: 5 14 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 15 | - &2 16 | address: b:27017 17 | type: Mongos 18 | avg_rtt_ms: 5 19 | lastUpdateTime: 0 20 | maxWireVersion: 4 # Incompatible. 21 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 22 | read_preference: 23 | mode: Nearest 24 | maxStalenessSeconds: 120 25 | error: true 26 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/Sharded/SmallMaxStaleness.yml: -------------------------------------------------------------------------------- 1 | # Driver doesn't validate maxStalenessSeconds for mongos 2 | --- 3 | heartbeatFrequencyMS: 10000 4 | topology_description: 5 | type: Sharded 6 | servers: 7 | - &1 8 | address: a:27017 9 | type: Mongos 10 | avg_rtt_ms: 5 11 | lastUpdateTime: 0 12 | maxWireVersion: 5 13 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 14 | - &2 15 | address: b:27017 16 | type: Mongos 17 | avg_rtt_ms: 50 # Too far. 18 | lastUpdateTime: 0 19 | maxWireVersion: 5 20 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 21 | read_preference: 22 | mode: Nearest 23 | maxStalenessSeconds: 1 # OK for sharding. 24 | suitable_servers: 25 | - *1 26 | - *2 27 | in_latency_window: 28 | - *1 29 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/Single/Incompatible.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Single", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "type": "Standalone", 8 | "avg_rtt_ms": 5, 9 | "lastUpdateTime": 0, 10 | "maxWireVersion": 4, 11 | "lastWrite": { 12 | "lastWriteDate": { 13 | "$numberLong": "1" 14 | } 15 | } 16 | } 17 | ] 18 | }, 19 | "read_preference": { 20 | "mode": "Nearest", 21 | "maxStalenessSeconds": 120 22 | }, 23 | "error": true 24 | } 25 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/Single/Incompatible.yml: -------------------------------------------------------------------------------- 1 | # During server selection, clients (drivers or mongos) MUST raise an error if 2 | # maxStalenessSeconds is defined and not -1 and any server's ``maxWireVersion`` 3 | # is less than 5 (`SERVER-23893`_). 4 | --- 5 | topology_description: 6 | type: Single 7 | servers: 8 | - &1 9 | address: a:27017 10 | type: Standalone 11 | avg_rtt_ms: 5 12 | lastUpdateTime: 0 13 | maxWireVersion: 4 # Incompatible. 14 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 15 | read_preference: 16 | mode: Nearest 17 | maxStalenessSeconds: 120 18 | error: true 19 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/Single/SmallMaxStaleness.yml: -------------------------------------------------------------------------------- 1 | # Driver doesn't validate maxStalenessSeconds for direct connection. 2 | --- 3 | heartbeatFrequencyMS: 10000 4 | topology_description: 5 | type: Single 6 | servers: 7 | - &1 8 | address: a:27017 9 | type: Standalone 10 | avg_rtt_ms: 5 11 | lastUpdateTime: 0 12 | maxWireVersion: 5 13 | lastWrite: {lastWriteDate: {$numberLong: "1"}} 14 | read_preference: 15 | mode: Nearest 16 | maxStalenessSeconds: 1 17 | suitable_servers: 18 | - *1 19 | in_latency_window: 20 | - *1 21 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/Unknown/SmallMaxStaleness.json: -------------------------------------------------------------------------------- 1 | { 2 | "heartbeatFrequencyMS": 10000, 3 | "topology_description": { 4 | "type": "Unknown", 5 | "servers": [ 6 | { 7 | "address": "a:27017", 8 | "type": "Unknown", 9 | "maxWireVersion": 5 10 | } 11 | ] 12 | }, 13 | "read_preference": { 14 | "mode": "Nearest", 15 | "maxStalenessSeconds": 1 16 | }, 17 | "suitable_servers": [], 18 | "in_latency_window": [] 19 | } 20 | -------------------------------------------------------------------------------- /src/test/spec/json/max-staleness/Unknown/SmallMaxStaleness.yml: -------------------------------------------------------------------------------- 1 | # Driver doesn't validate maxStalenessSeconds while TopologyType is Unknown. 2 | --- 3 | heartbeatFrequencyMS: 10000 4 | topology_description: 5 | type: Unknown 6 | servers: 7 | - &1 8 | address: a:27017 9 | type: Unknown 10 | maxWireVersion: 5 11 | read_preference: 12 | mode: Nearest 13 | maxStalenessSeconds: 1 14 | suitable_servers: [] 15 | in_latency_window: [] 16 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/monitoring/README.rst: -------------------------------------------------------------------------------- 1 | ===================== 2 | SDAM Monitoring Tests 3 | ===================== 4 | 5 | The YAML and JSON files in this directory tree are platform-independent tests 6 | that drivers can use to prove their conformance to the SDAM Monitoring spec. 7 | 8 | Format 9 | ------ 10 | 11 | The format of the tests follows the standard SDAM test and should be able to leverage 12 | the existing test runner in each language for the SDAM tests. 13 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/compatible_unknown.yml: -------------------------------------------------------------------------------- 1 | description: "Replica set member and an unknown server" 2 | uri: "mongodb://a,b/?replicaSet=rs" 3 | phases: [ 4 | { 5 | responses: [ 6 | ["a:27017", { 7 | ok: 1, 8 | ismaster: true, 9 | setName: "rs", 10 | hosts: ["a:27017", "b:27017"], 11 | minWireVersion: 0, 12 | maxWireVersion: 6 13 | }], 14 | ], 15 | outcome: { 16 | servers: { 17 | "a:27017": { 18 | type: "RSPrimary", 19 | setName: "rs" 20 | }, 21 | "b:27017": { 22 | type: "Unknown", 23 | } 24 | }, 25 | topologyType: "ReplicaSetWithPrimary", 26 | setName: "rs", 27 | logicalSessionTimeoutMinutes: null, 28 | compatible: true 29 | } 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/ghost_discovered.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Ghost discovered", 3 | "uri": "mongodb://a,b/?replicaSet=rs", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "b:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": false, 12 | "isreplicaset": true, 13 | "minWireVersion": 0, 14 | "maxWireVersion": 6 15 | } 16 | ] 17 | ], 18 | "outcome": { 19 | "servers": { 20 | "a:27017": { 21 | "type": "Unknown", 22 | "setName": null 23 | }, 24 | "b:27017": { 25 | "type": "RSGhost", 26 | "setName": null 27 | } 28 | }, 29 | "topologyType": "ReplicaSetNoPrimary", 30 | "logicalSessionTimeoutMinutes": null, 31 | "setName": "rs" 32 | } 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/ghost_discovered.yml: -------------------------------------------------------------------------------- 1 | description: "Ghost discovered" 2 | 3 | uri: "mongodb://a,b/?replicaSet=rs" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["b:27017", { 11 | 12 | ok: 1, 13 | ismaster: false, 14 | isreplicaset: true, 15 | minWireVersion: 0, 16 | maxWireVersion: 6 17 | }] 18 | ], 19 | 20 | outcome: { 21 | 22 | servers: { 23 | 24 | "a:27017": { 25 | 26 | type: "Unknown", 27 | setName: 28 | }, 29 | 30 | "b:27017": { 31 | 32 | type: "RSGhost", 33 | setName: 34 | } 35 | }, 36 | topologyType: "ReplicaSetNoPrimary", 37 | logicalSessionTimeoutMinutes: null, 38 | setName: "rs" 39 | } 40 | } 41 | ] 42 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/hosts_differ_from_seeds.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Host list differs from seeds", 3 | "uri": "mongodb://a/?replicaSet=rs", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "setName": "rs", 13 | "hosts": [ 14 | "b:27017" 15 | ], 16 | "minWireVersion": 0, 17 | "maxWireVersion": 6 18 | } 19 | ] 20 | ], 21 | "outcome": { 22 | "servers": { 23 | "b:27017": { 24 | "type": "Unknown", 25 | "setName": null 26 | } 27 | }, 28 | "topologyType": "ReplicaSetNoPrimary", 29 | "logicalSessionTimeoutMinutes": null, 30 | "setName": "rs" 31 | } 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/hosts_differ_from_seeds.yml: -------------------------------------------------------------------------------- 1 | description: "Host list differs from seeds" 2 | 3 | uri: "mongodb://a/?replicaSet=rs" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: true, 14 | setName: "rs", 15 | hosts: ["b:27017"], 16 | minWireVersion: 0, 17 | maxWireVersion: 6 18 | }] 19 | ], 20 | 21 | outcome: { 22 | 23 | servers: { 24 | 25 | "b:27017": { 26 | 27 | type: "Unknown", 28 | setName: 29 | } 30 | }, 31 | topologyType: "ReplicaSetNoPrimary", 32 | logicalSessionTimeoutMinutes: null, 33 | setName: "rs" 34 | } 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/incompatible_arbiter.yml: -------------------------------------------------------------------------------- 1 | description: "Incompatible arbiter" 2 | uri: "mongodb://a,b/?replicaSet=rs" 3 | phases: 4 | - responses: 5 | - 6 | - "a:27017" 7 | - ok: 1 8 | ismaster: true 9 | setName: "rs" 10 | hosts: ["a:27017", "b:27017"] 11 | minWireVersion: 0 12 | maxWireVersion: 6 13 | - 14 | - "b:27017" 15 | - ok: 1 16 | arbiterOnly: true 17 | setName: "rs" 18 | hosts: ["a:27017", "b:27017"] 19 | minWireVersion: 0 20 | maxWireVersion: 1 21 | outcome: 22 | servers: 23 | "a:27017": 24 | type: "RSPrimary" 25 | setName: "rs" 26 | "b:27017": 27 | type: "RSArbiter" 28 | setName: "rs" 29 | topologyType: "ReplicaSetWithPrimary" 30 | setName: "rs" 31 | logicalSessionTimeoutMinutes: ~ 32 | compatible: false 33 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/incompatible_ghost.yml: -------------------------------------------------------------------------------- 1 | description: "Incompatible ghost" 2 | uri: "mongodb://a,b/?replicaSet=rs" 3 | phases: 4 | - responses: 5 | - 6 | - "a:27017" 7 | - ok: 1 8 | ismaster: true 9 | setName: "rs" 10 | hosts: ["a:27017", "b:27017"] 11 | minWireVersion: 0 12 | maxWireVersion: 6 13 | - 14 | - "b:27017" 15 | - ok: 1 16 | isreplicaset: true 17 | minWireVersion: 0 18 | maxWireVersion: 1 19 | outcome: 20 | servers: 21 | "a:27017": 22 | type: "RSPrimary" 23 | setName: "rs" 24 | "b:27017": 25 | type: "RSGhost" 26 | setName: 27 | topologyType: "ReplicaSetWithPrimary" 28 | setName: "rs" 29 | logicalSessionTimeoutMinutes: ~ 30 | compatible: false 31 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/incompatible_other.yml: -------------------------------------------------------------------------------- 1 | description: "Incompatible other" 2 | uri: "mongodb://a,b/?replicaSet=rs" 3 | phases: 4 | - responses: 5 | - 6 | - "a:27017" 7 | - ok: 1 8 | ismaster: true 9 | setName: "rs" 10 | hosts: ["a:27017", "b:27017"] 11 | minWireVersion: 0 12 | maxWireVersion: 6 13 | - 14 | - "b:27017" 15 | - ok: 1 16 | hidden: true 17 | setName: "rs" 18 | hosts: ["a:27017", "b:27017"] 19 | minWireVersion: 0 20 | maxWireVersion: 1 21 | outcome: 22 | servers: 23 | "a:27017": 24 | type: "RSPrimary" 25 | setName: "rs" 26 | "b:27017": 27 | type: "RSOther" 28 | setName: "rs" 29 | topologyType: "ReplicaSetWithPrimary" 30 | setName: "rs" 31 | logicalSessionTimeoutMinutes: ~ 32 | compatible: false 33 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/non_rs_member.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Non replicaSet member responds", 3 | "uri": "mongodb://a,b/?replicaSet=rs", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "b:27017", 9 | { 10 | "ok": 1, 11 | "minWireVersion": 0, 12 | "maxWireVersion": 6 13 | } 14 | ] 15 | ], 16 | "outcome": { 17 | "servers": { 18 | "a:27017": { 19 | "type": "Unknown", 20 | "setName": null 21 | } 22 | }, 23 | "topologyType": "ReplicaSetNoPrimary", 24 | "logicalSessionTimeoutMinutes": null, 25 | "setName": "rs" 26 | } 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/non_rs_member.yml: -------------------------------------------------------------------------------- 1 | description: "Non replicaSet member responds" 2 | 3 | uri: "mongodb://a,b/?replicaSet=rs" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["b:27017", { 11 | ok: 1, 12 | minWireVersion: 0, 13 | maxWireVersion: 6 14 | }] 15 | ], 16 | 17 | outcome: { 18 | 19 | servers: { 20 | 21 | "a:27017": { 22 | 23 | type: "Unknown", 24 | setName: 25 | } 26 | }, 27 | topologyType: "ReplicaSetNoPrimary", 28 | logicalSessionTimeoutMinutes: null, 29 | setName: "rs" 30 | } 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/primary_mismatched_me.yml: -------------------------------------------------------------------------------- 1 | description: Primary mismatched me 2 | phases: 3 | - outcome: 4 | servers: 5 | 'a:27017': 6 | setName: null 7 | type: Unknown 8 | 'b:27017': 9 | setName: null 10 | type: Unknown 11 | setName: rs 12 | topologyType: ReplicaSetNoPrimary 13 | logicalSessionTimeoutMinutes: null 14 | responses: 15 | - - 'localhost:27017' 16 | - me: 'a:27017' 17 | hosts: 18 | - 'a:27017' 19 | - 'b:27017' 20 | ismaster: true 21 | ok: 1 22 | setName: rs 23 | minWireVersion: 0 24 | maxWireVersion: 6 25 | uri: 'mongodb://localhost:27017/?replicaSet=rs' 26 | 27 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/primary_wrong_set_name.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Primary wrong setName", 3 | "uri": "mongodb://a/?replicaSet=rs", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "hosts": [ 13 | "a:27017" 14 | ], 15 | "setName": "wrong", 16 | "minWireVersion": 0, 17 | "maxWireVersion": 6 18 | } 19 | ] 20 | ], 21 | "outcome": { 22 | "servers": {}, 23 | "topologyType": "ReplicaSetNoPrimary", 24 | "logicalSessionTimeoutMinutes": null, 25 | "setName": "rs" 26 | } 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/primary_wrong_set_name.yml: -------------------------------------------------------------------------------- 1 | description: "Primary wrong setName" 2 | 3 | uri: "mongodb://a/?replicaSet=rs" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: true, 14 | hosts: ["a:27017"], 15 | setName: "wrong", 16 | minWireVersion: 0, 17 | maxWireVersion: 6 18 | }] 19 | ], 20 | 21 | outcome: { 22 | 23 | servers: {}, 24 | topologyType: "ReplicaSetNoPrimary", 25 | logicalSessionTimeoutMinutes: null, 26 | setName: "rs" 27 | } 28 | } 29 | ] 30 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/secondary_mismatched_me.yml: -------------------------------------------------------------------------------- 1 | description: Secondary mismatched me 2 | phases: 3 | - outcome: 4 | servers: 5 | 'a:27017': 6 | setName: null 7 | type: Unknown 8 | 'b:27017': 9 | setName: null 10 | type: Unknown 11 | setName: rs 12 | topologyType: ReplicaSetNoPrimary 13 | logicalSessionTimeoutMinutes: null 14 | responses: 15 | - - 'localhost:27017' 16 | - me: 'a:27017' 17 | hosts: 18 | - 'a:27017' 19 | - 'b:27017' 20 | ismaster: false 21 | ok: 1 22 | setName: rs 23 | minWireVersion: 0 24 | maxWireVersion: 6 25 | uri: 'mongodb://localhost:27017/?replicaSet=rs' 26 | 27 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/secondary_wrong_set_name.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Secondary wrong setName", 3 | "uri": "mongodb://a/?replicaSet=rs", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": false, 12 | "secondary": true, 13 | "hosts": [ 14 | "a:27017" 15 | ], 16 | "setName": "wrong", 17 | "minWireVersion": 0, 18 | "maxWireVersion": 6 19 | } 20 | ] 21 | ], 22 | "outcome": { 23 | "servers": {}, 24 | "topologyType": "ReplicaSetNoPrimary", 25 | "logicalSessionTimeoutMinutes": null, 26 | "setName": "rs" 27 | } 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/secondary_wrong_set_name.yml: -------------------------------------------------------------------------------- 1 | description: "Secondary wrong setName" 2 | 3 | uri: "mongodb://a/?replicaSet=rs" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: false, 14 | secondary: true, 15 | hosts: ["a:27017"], 16 | setName: "wrong", 17 | minWireVersion: 0, 18 | maxWireVersion: 6 19 | }] 20 | ], 21 | 22 | outcome: { 23 | 24 | servers: {}, 25 | topologyType: "ReplicaSetNoPrimary", 26 | logicalSessionTimeoutMinutes: null, 27 | setName: "rs" 28 | } 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/unexpected_mongos.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Unexpected mongos", 3 | "uri": "mongodb://b/?replicaSet=rs", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "b:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "msg": "isdbgrid", 13 | "minWireVersion": 0, 14 | "maxWireVersion": 6 15 | } 16 | ] 17 | ], 18 | "outcome": { 19 | "servers": {}, 20 | "topologyType": "ReplicaSetNoPrimary", 21 | "logicalSessionTimeoutMinutes": null, 22 | "setName": "rs" 23 | } 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/unexpected_mongos.yml: -------------------------------------------------------------------------------- 1 | description: "Unexpected mongos" 2 | 3 | uri: "mongodb://b/?replicaSet=rs" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["b:27017", { 11 | 12 | ok: 1, 13 | ismaster: true, 14 | msg: "isdbgrid", 15 | minWireVersion: 0, 16 | maxWireVersion: 6 17 | }] 18 | ], 19 | 20 | outcome: { 21 | 22 | servers: {}, 23 | topologyType: "ReplicaSetNoPrimary", 24 | logicalSessionTimeoutMinutes: null, 25 | setName: "rs" 26 | } 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/wrong_set_name.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Wrong setName", 3 | "uri": "mongodb://a,b/?replicaSet=rs", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "b:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": false, 12 | "secondary": true, 13 | "hosts": [ 14 | "b:27017", 15 | "c:27017" 16 | ], 17 | "setName": "wrong", 18 | "minWireVersion": 0, 19 | "maxWireVersion": 6 20 | } 21 | ] 22 | ], 23 | "outcome": { 24 | "servers": { 25 | "a:27017": { 26 | "type": "Unknown", 27 | "setName": null 28 | } 29 | }, 30 | "topologyType": "ReplicaSetNoPrimary", 31 | "logicalSessionTimeoutMinutes": null, 32 | "setName": "rs" 33 | } 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/rs/wrong_set_name.yml: -------------------------------------------------------------------------------- 1 | description: "Wrong setName" 2 | 3 | uri: "mongodb://a,b/?replicaSet=rs" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["b:27017", { 11 | 12 | ok: 1, 13 | ismaster: false, 14 | secondary: true, 15 | hosts: ["b:27017", "c:27017"], 16 | setName: "wrong", 17 | minWireVersion: 0, 18 | maxWireVersion: 6 19 | }] 20 | ], 21 | 22 | outcome: { 23 | 24 | servers: { 25 | 26 | "a:27017": { 27 | 28 | type: "Unknown", 29 | setName: 30 | } 31 | }, 32 | topologyType: "ReplicaSetNoPrimary", 33 | logicalSessionTimeoutMinutes: null, 34 | setName: "rs" 35 | } 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/sharded/normalize_uri_case.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Normalize URI case", 3 | "uri": "mongodb://A,B", 4 | "phases": [ 5 | { 6 | "responses": [], 7 | "outcome": { 8 | "servers": { 9 | "a:27017": { 10 | "type": "Unknown", 11 | "setName": null 12 | }, 13 | "b:27017": { 14 | "type": "Unknown", 15 | "setName": null 16 | } 17 | }, 18 | "topologyType": "Unknown", 19 | "logicalSessionTimeoutMinutes": null, 20 | "setName": null 21 | } 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/sharded/normalize_uri_case.yml: -------------------------------------------------------------------------------- 1 | description: "Normalize URI case" 2 | 3 | uri: "mongodb://A,B" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | ], 10 | 11 | outcome: { 12 | 13 | servers: { 14 | 15 | "a:27017": { 16 | 17 | type: "Unknown", 18 | setName: 19 | }, 20 | 21 | "b:27017": { 22 | 23 | type: "Unknown", 24 | setName: 25 | } 26 | }, 27 | topologyType: "Unknown", 28 | logicalSessionTimeoutMinutes: null, 29 | setName: 30 | } 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/compatible.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Standalone with large maxWireVersion", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "minWireVersion": 0, 13 | "maxWireVersion": 6 14 | } 15 | ] 16 | ], 17 | "outcome": { 18 | "servers": { 19 | "a:27017": { 20 | "type": "Standalone", 21 | "setName": null 22 | } 23 | }, 24 | "topologyType": "Single", 25 | "logicalSessionTimeoutMinutes": null, 26 | "setName": null, 27 | "compatible": true 28 | } 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/compatible.yml: -------------------------------------------------------------------------------- 1 | description: "Standalone with large maxWireVersion" 2 | uri: "mongodb://a" 3 | phases: [ 4 | { 5 | responses: [ 6 | ["a:27017", { 7 | ok: 1, 8 | ismaster: true, 9 | minWireVersion: 0, 10 | maxWireVersion: 6 11 | }] 12 | ], 13 | outcome: { 14 | servers: { 15 | "a:27017": { 16 | type: "Standalone", 17 | setName: 18 | } 19 | }, 20 | topologyType: "Single", 21 | logicalSessionTimeoutMinutes: null, 22 | setName: , 23 | compatible: true 24 | } 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_external_ip.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Direct connection to RSPrimary via external IP", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "hosts": [ 13 | "b:27017" 14 | ], 15 | "setName": "rs", 16 | "minWireVersion": 0, 17 | "maxWireVersion": 6 18 | } 19 | ] 20 | ], 21 | "outcome": { 22 | "servers": { 23 | "a:27017": { 24 | "type": "RSPrimary", 25 | "setName": "rs" 26 | } 27 | }, 28 | "topologyType": "Single", 29 | "logicalSessionTimeoutMinutes": null, 30 | "setName": null 31 | } 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_external_ip.yml: -------------------------------------------------------------------------------- 1 | description: "Direct connection to RSPrimary via external IP" 2 | 3 | uri: "mongodb://a" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: true, 14 | hosts: ["b:27017"], # Internal IP. 15 | setName: "rs", 16 | minWireVersion: 0, 17 | maxWireVersion: 6 18 | }] 19 | ], 20 | 21 | outcome: { 22 | 23 | servers: { 24 | 25 | "a:27017": { 26 | 27 | type: "RSPrimary", 28 | setName: "rs" 29 | } 30 | }, 31 | topologyType: "Single", 32 | logicalSessionTimeoutMinutes: null, 33 | setName: 34 | } 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_mongos.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Connect to mongos", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "msg": "isdbgrid", 13 | "minWireVersion": 0, 14 | "maxWireVersion": 6 15 | } 16 | ] 17 | ], 18 | "outcome": { 19 | "servers": { 20 | "a:27017": { 21 | "type": "Mongos", 22 | "setName": null 23 | } 24 | }, 25 | "topologyType": "Single", 26 | "logicalSessionTimeoutMinutes": null, 27 | "setName": null 28 | } 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_mongos.yml: -------------------------------------------------------------------------------- 1 | description: "Connect to mongos" 2 | 3 | uri: "mongodb://a" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: true, 14 | msg: "isdbgrid", 15 | minWireVersion: 0, 16 | maxWireVersion: 6 17 | }] 18 | ], 19 | 20 | outcome: { 21 | 22 | servers: { 23 | 24 | "a:27017": { 25 | 26 | type: "Mongos", 27 | setName: 28 | } 29 | }, 30 | topologyType: "Single", 31 | logicalSessionTimeoutMinutes: null, 32 | setName: 33 | } 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_rsarbiter.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Connect to RSArbiter", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": false, 12 | "arbiterOnly": true, 13 | "hosts": [ 14 | "a:27017", 15 | "b:27017" 16 | ], 17 | "setName": "rs", 18 | "minWireVersion": 0, 19 | "maxWireVersion": 6 20 | } 21 | ] 22 | ], 23 | "outcome": { 24 | "servers": { 25 | "a:27017": { 26 | "type": "RSArbiter", 27 | "setName": "rs" 28 | } 29 | }, 30 | "topologyType": "Single", 31 | "logicalSessionTimeoutMinutes": null, 32 | "setName": null 33 | } 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_rsarbiter.yml: -------------------------------------------------------------------------------- 1 | description: "Connect to RSArbiter" 2 | 3 | uri: "mongodb://a" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: false, 14 | arbiterOnly: true, 15 | hosts: ["a:27017", "b:27017"], 16 | setName: "rs", 17 | minWireVersion: 0, 18 | maxWireVersion: 6 19 | }] 20 | ], 21 | 22 | outcome: { 23 | 24 | servers: { 25 | 26 | "a:27017": { 27 | 28 | type: "RSArbiter", 29 | setName: "rs" 30 | } 31 | }, 32 | topologyType: "Single", 33 | logicalSessionTimeoutMinutes: null, 34 | setName: 35 | } 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_rsprimary.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Connect to RSPrimary", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "hosts": [ 13 | "a:27017", 14 | "b:27017" 15 | ], 16 | "setName": "rs", 17 | "minWireVersion": 0, 18 | "maxWireVersion": 6 19 | } 20 | ] 21 | ], 22 | "outcome": { 23 | "servers": { 24 | "a:27017": { 25 | "type": "RSPrimary", 26 | "setName": "rs" 27 | } 28 | }, 29 | "topologyType": "Single", 30 | "logicalSessionTimeoutMinutes": null, 31 | "setName": null 32 | } 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_rsprimary.yml: -------------------------------------------------------------------------------- 1 | description: "Connect to RSPrimary" 2 | 3 | uri: "mongodb://a" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: true, 14 | hosts: ["a:27017", "b:27017"], 15 | setName: "rs", 16 | minWireVersion: 0, 17 | maxWireVersion: 6 18 | }] 19 | ], 20 | 21 | outcome: { 22 | 23 | servers: { 24 | 25 | "a:27017": { 26 | 27 | type: "RSPrimary", 28 | setName: "rs" 29 | } 30 | }, 31 | topologyType: "Single", 32 | logicalSessionTimeoutMinutes: null, 33 | setName: 34 | } 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_rssecondary.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Connect to RSSecondary", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": false, 12 | "secondary": true, 13 | "hosts": [ 14 | "a:27017", 15 | "b:27017" 16 | ], 17 | "setName": "rs", 18 | "minWireVersion": 0, 19 | "maxWireVersion": 6 20 | } 21 | ] 22 | ], 23 | "outcome": { 24 | "servers": { 25 | "a:27017": { 26 | "type": "RSSecondary", 27 | "setName": "rs" 28 | } 29 | }, 30 | "topologyType": "Single", 31 | "logicalSessionTimeoutMinutes": null, 32 | "setName": null 33 | } 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_rssecondary.yml: -------------------------------------------------------------------------------- 1 | description: "Connect to RSSecondary" 2 | 3 | uri: "mongodb://a" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: false, 14 | secondary: true, 15 | hosts: ["a:27017", "b:27017"], 16 | setName: "rs", 17 | minWireVersion: 0, 18 | maxWireVersion: 6 19 | }] 20 | ], 21 | 22 | outcome: { 23 | 24 | servers: { 25 | 26 | "a:27017": { 27 | 28 | type: "RSSecondary", 29 | setName: "rs" 30 | } 31 | }, 32 | topologyType: "Single", 33 | logicalSessionTimeoutMinutes: null, 34 | setName: 35 | } 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_slave.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Direct connection to slave", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": false, 12 | "minWireVersion": 0, 13 | "maxWireVersion": 6 14 | } 15 | ] 16 | ], 17 | "outcome": { 18 | "servers": { 19 | "a:27017": { 20 | "type": "Standalone", 21 | "setName": null 22 | } 23 | }, 24 | "topologyType": "Single", 25 | "logicalSessionTimeoutMinutes": null, 26 | "setName": null 27 | } 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_slave.yml: -------------------------------------------------------------------------------- 1 | description: "Direct connection to slave" 2 | 3 | uri: "mongodb://a" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: false, 14 | minWireVersion: 0, 15 | maxWireVersion: 6 16 | }] 17 | ], 18 | 19 | outcome: { 20 | 21 | servers: { 22 | 23 | "a:27017": { 24 | 25 | type: "Standalone", 26 | setName: 27 | } 28 | }, 29 | topologyType: "Single", 30 | logicalSessionTimeoutMinutes: null, 31 | setName: 32 | } 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_standalone.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Connect to standalone", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "minWireVersion": 0, 13 | "maxWireVersion": 6 14 | } 15 | ] 16 | ], 17 | "outcome": { 18 | "servers": { 19 | "a:27017": { 20 | "type": "Standalone", 21 | "setName": null 22 | } 23 | }, 24 | "topologyType": "Single", 25 | "logicalSessionTimeoutMinutes": null, 26 | "setName": null 27 | } 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/direct_connection_standalone.yml: -------------------------------------------------------------------------------- 1 | description: "Connect to standalone" 2 | 3 | uri: "mongodb://a" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: true, 14 | minWireVersion: 0, 15 | maxWireVersion: 6 16 | }] 17 | ], 18 | 19 | outcome: { 20 | 21 | servers: { 22 | 23 | "a:27017": { 24 | 25 | type: "Standalone", 26 | setName: 27 | } 28 | }, 29 | topologyType: "Single", 30 | logicalSessionTimeoutMinutes: null, 31 | setName: 32 | } 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/ls_timeout_standalone.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Parse logicalSessionTimeoutMinutes from standalone", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "logicalSessionTimeoutMinutes": 7, 13 | "minWireVersion": 0, 14 | "maxWireVersion": 6 15 | } 16 | ] 17 | ], 18 | "outcome": { 19 | "servers": { 20 | "a:27017": { 21 | "type": "Standalone", 22 | "setName": null 23 | } 24 | }, 25 | "topologyType": "Single", 26 | "logicalSessionTimeoutMinutes": 7, 27 | "setName": null 28 | } 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/ls_timeout_standalone.yml: -------------------------------------------------------------------------------- 1 | description: "Parse logicalSessionTimeoutMinutes from standalone" 2 | 3 | uri: "mongodb://a" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: true, 14 | logicalSessionTimeoutMinutes: 7, 15 | minWireVersion: 0, 16 | maxWireVersion: 6 17 | }] 18 | ], 19 | 20 | outcome: { 21 | 22 | servers: { 23 | 24 | "a:27017": { 25 | 26 | type: "Standalone", 27 | setName: 28 | } 29 | }, 30 | topologyType: "Single", 31 | logicalSessionTimeoutMinutes: 7, 32 | setName: 33 | } 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/not_ok_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Handle a not-ok ismaster response", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "minWireVersion": 0, 13 | "maxWireVersion": 6 14 | } 15 | ], 16 | [ 17 | "a:27017", 18 | { 19 | "ok": 0, 20 | "ismaster": true, 21 | "minWireVersion": 0, 22 | "maxWireVersion": 6 23 | } 24 | ] 25 | ], 26 | "outcome": { 27 | "servers": { 28 | "a:27017": { 29 | "type": "Unknown", 30 | "setName": null 31 | } 32 | }, 33 | "topologyType": "Single", 34 | "logicalSessionTimeoutMinutes": null, 35 | "setName": null 36 | } 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/not_ok_response.yml: -------------------------------------------------------------------------------- 1 | description: "Handle a not-ok ismaster response" 2 | 3 | uri: "mongodb://a" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: true, 14 | minWireVersion: 0, 15 | maxWireVersion: 6 16 | }], 17 | 18 | ["a:27017", { 19 | 20 | ok: 0, 21 | ismaster: true, 22 | minWireVersion: 0, 23 | maxWireVersion: 6 24 | }] 25 | ], 26 | 27 | outcome: { 28 | 29 | servers: { 30 | 31 | "a:27017": { 32 | 33 | type: "Unknown", 34 | setName: 35 | } 36 | }, 37 | topologyType: "Single", 38 | logicalSessionTimeoutMinutes: null, 39 | setName: 40 | } 41 | } 42 | ] 43 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/standalone_removed.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Standalone removed from multi-server topology", 3 | "uri": "mongodb://a,b", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "minWireVersion": 0, 13 | "maxWireVersion": 6 14 | } 15 | ] 16 | ], 17 | "outcome": { 18 | "servers": { 19 | "b:27017": { 20 | "type": "Unknown", 21 | "setName": null 22 | } 23 | }, 24 | "topologyType": "Unknown", 25 | "logicalSessionTimeoutMinutes": null, 26 | "setName": null 27 | } 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/standalone_removed.yml: -------------------------------------------------------------------------------- 1 | description: "Standalone removed from multi-server topology" 2 | 3 | uri: "mongodb://a,b" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", { 11 | 12 | ok: 1, 13 | ismaster: true, 14 | minWireVersion: 0, 15 | maxWireVersion: 6 16 | }] 17 | ], 18 | 19 | outcome: { 20 | 21 | servers: { 22 | 23 | "b:27017": { 24 | 25 | type: "Unknown", 26 | setName: 27 | } 28 | }, 29 | topologyType: "Unknown", 30 | logicalSessionTimeoutMinutes: null, 31 | setName: 32 | } 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/too_new.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Standalone with large minWireVersion", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true, 12 | "minWireVersion": 999, 13 | "maxWireVersion": 1000 14 | } 15 | ] 16 | ], 17 | "outcome": { 18 | "servers": { 19 | "a:27017": { 20 | "type": "Standalone", 21 | "setName": null 22 | } 23 | }, 24 | "topologyType": "Single", 25 | "logicalSessionTimeoutMinutes": null, 26 | "setName": null, 27 | "compatible": false 28 | } 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/too_new.yml: -------------------------------------------------------------------------------- 1 | description: "Standalone with large minWireVersion" 2 | uri: "mongodb://a" 3 | phases: [ 4 | { 5 | responses: [ 6 | ["a:27017", { 7 | ok: 1, 8 | ismaster: true, 9 | minWireVersion: 999, 10 | maxWireVersion: 1000 11 | }] 12 | ], 13 | outcome: { 14 | servers: { 15 | "a:27017": { 16 | type: "Standalone", 17 | setName: 18 | } 19 | }, 20 | topologyType: "Single", 21 | logicalSessionTimeoutMinutes: null, 22 | setName: , 23 | compatible: false 24 | } 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/too_old.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Standalone with default maxWireVersion of 0", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | { 10 | "ok": 1, 11 | "ismaster": true 12 | } 13 | ] 14 | ], 15 | "outcome": { 16 | "servers": { 17 | "a:27017": { 18 | "type": "Standalone", 19 | "setName": null 20 | } 21 | }, 22 | "topologyType": "Single", 23 | "logicalSessionTimeoutMinutes": null, 24 | "setName": null, 25 | "compatible": false 26 | } 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/too_old.yml: -------------------------------------------------------------------------------- 1 | description: "Standalone with default maxWireVersion of 0" 2 | uri: "mongodb://a" 3 | phases: [ 4 | { 5 | responses: [ 6 | ["a:27017", { 7 | ok: 1, 8 | ismaster: true 9 | }] 10 | ], 11 | outcome: { 12 | servers: { 13 | "a:27017": { 14 | type: "Standalone", 15 | setName: 16 | } 17 | }, 18 | topologyType: "Single", 19 | logicalSessionTimeoutMinutes: null, 20 | setName: , 21 | compatible: false 22 | } 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/unavailable_seed.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Unavailable seed", 3 | "uri": "mongodb://a", 4 | "phases": [ 5 | { 6 | "responses": [ 7 | [ 8 | "a:27017", 9 | {} 10 | ] 11 | ], 12 | "outcome": { 13 | "servers": { 14 | "a:27017": { 15 | "type": "Unknown", 16 | "setName": null 17 | } 18 | }, 19 | "topologyType": "Single", 20 | "logicalSessionTimeoutMinutes": null, 21 | "setName": null 22 | } 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /src/test/spec/json/server-discovery-and-monitoring/single/unavailable_seed.yml: -------------------------------------------------------------------------------- 1 | description: "Unavailable seed" 2 | 3 | uri: "mongodb://a" 4 | 5 | phases: [ 6 | 7 | { 8 | responses: [ 9 | 10 | ["a:27017", {}] 11 | ], 12 | 13 | outcome: { 14 | 15 | servers: { 16 | 17 | "a:27017": { 18 | 19 | type: "Unknown", 20 | setName: 21 | } 22 | }, 23 | topologyType: "Single", 24 | logicalSessionTimeoutMinutes: null, 25 | setName: 26 | } 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/first_value.json: -------------------------------------------------------------------------------- 1 | { 2 | "avg_rtt_ms": "NULL", 3 | "new_rtt_ms": 10, 4 | "new_avg_rtt": 10 5 | } 6 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/first_value.yml: -------------------------------------------------------------------------------- 1 | avg_rtt_ms: 'NULL' 2 | new_rtt_ms: 10 3 | new_avg_rtt: 10 4 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/first_value_zero.json: -------------------------------------------------------------------------------- 1 | { 2 | "avg_rtt_ms": "NULL", 3 | "new_rtt_ms": 0, 4 | "new_avg_rtt": 0 5 | } 6 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/first_value_zero.yml: -------------------------------------------------------------------------------- 1 | avg_rtt_ms: 'NULL' 2 | new_rtt_ms: 0 3 | new_avg_rtt: 0 4 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/value_test_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "avg_rtt_ms": 0, 3 | "new_rtt_ms": 5, 4 | "new_avg_rtt": 1 5 | } 6 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/value_test_1.yml: -------------------------------------------------------------------------------- 1 | avg_rtt_ms: 0 2 | new_rtt_ms: 5 3 | new_avg_rtt: 1.0 4 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/value_test_2.json: -------------------------------------------------------------------------------- 1 | { 2 | "avg_rtt_ms": 3.1, 3 | "new_rtt_ms": 36, 4 | "new_avg_rtt": 9.68 5 | } 6 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/value_test_2.yml: -------------------------------------------------------------------------------- 1 | avg_rtt_ms: 3.1 2 | new_rtt_ms: 36 3 | new_avg_rtt: 9.68 4 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/value_test_3.json: -------------------------------------------------------------------------------- 1 | { 2 | "avg_rtt_ms": 9.12, 3 | "new_rtt_ms": 9.12, 4 | "new_avg_rtt": 9.12 5 | } 6 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/value_test_3.yml: -------------------------------------------------------------------------------- 1 | avg_rtt_ms: 9.12 2 | new_rtt_ms: 9.12 3 | new_avg_rtt: 9.12 4 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/value_test_4.json: -------------------------------------------------------------------------------- 1 | { 2 | "avg_rtt_ms": 1, 3 | "new_rtt_ms": 1000, 4 | "new_avg_rtt": 200.8 5 | } 6 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/value_test_4.yml: -------------------------------------------------------------------------------- 1 | avg_rtt_ms: 1 2 | new_rtt_ms: 1000 3 | new_avg_rtt: 200.8 4 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/value_test_5.json: -------------------------------------------------------------------------------- 1 | { 2 | "avg_rtt_ms": 0, 3 | "new_rtt_ms": 0.25, 4 | "new_avg_rtt": 0.05 5 | } 6 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/rtt/value_test_5.yml: -------------------------------------------------------------------------------- 1 | avg_rtt_ms: 0 2 | new_rtt_ms: 0.25 3 | new_avg_rtt: 0.05 4 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/Nearest.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetNoPrimary 3 | servers: 4 | - &1 5 | address: b:27017 6 | avg_rtt_ms: 5 7 | type: RSSecondary 8 | tags: 9 | data_center: nyc 10 | - &2 11 | address: c:27017 12 | avg_rtt_ms: 100 13 | type: RSSecondary 14 | tags: 15 | data_center: nyc 16 | operation: read 17 | read_preference: 18 | mode: Nearest 19 | tag_sets: 20 | - data_center: nyc 21 | suitable_servers: 22 | - *1 23 | - *2 24 | in_latency_window: 25 | - *1 26 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/Nearest_multiple.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetNoPrimary 3 | servers: 4 | - &1 5 | address: b:27017 6 | avg_rtt_ms: 10 7 | type: RSSecondary 8 | tags: 9 | data_center: nyc 10 | - &2 11 | address: c:27017 12 | avg_rtt_ms: 20 13 | type: RSSecondary 14 | tags: 15 | data_center: nyc 16 | operation: read 17 | read_preference: 18 | mode: Nearest 19 | tag_sets: 20 | - data_center: nyc 21 | suitable_servers: 22 | - *1 23 | - *2 24 | in_latency_window: 25 | - *1 26 | - *2 27 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/Nearest_non_matching.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetNoPrimary", 4 | "servers": [ 5 | { 6 | "address": "b:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "RSSecondary", 9 | "tags": { 10 | "data_center": "nyc" 11 | } 12 | }, 13 | { 14 | "address": "c:27017", 15 | "avg_rtt_ms": 100, 16 | "type": "RSSecondary", 17 | "tags": { 18 | "data_center": "nyc" 19 | } 20 | } 21 | ] 22 | }, 23 | "operation": "read", 24 | "read_preference": { 25 | "mode": "Nearest", 26 | "tag_sets": [ 27 | { 28 | "data_center": "sf" 29 | } 30 | ] 31 | }, 32 | "suitable_servers": [], 33 | "in_latency_window": [] 34 | } 35 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/Nearest_non_matching.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetNoPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | operation: read 15 | read_preference: 16 | mode: Nearest 17 | tag_sets: 18 | - data_center: sf 19 | suitable_servers: [] 20 | in_latency_window: [] 21 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/PossiblePrimary.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetNoPrimary", 4 | "servers": [ 5 | { 6 | "address": "b:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "PossiblePrimary" 9 | } 10 | ] 11 | }, 12 | "operation": "read", 13 | "read_preference": { 14 | "mode": "Primary", 15 | "tag_sets": [ 16 | {} 17 | ] 18 | }, 19 | "suitable_servers": [], 20 | "in_latency_window": [] 21 | } 22 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/PossiblePrimary.yml: -------------------------------------------------------------------------------- 1 | # Test that PossiblePrimary isn't candidate for any read preference mode. 2 | --- 3 | topology_description: 4 | type: ReplicaSetNoPrimary 5 | servers: 6 | - address: b:27017 7 | avg_rtt_ms: 5 8 | type: PossiblePrimary 9 | operation: read 10 | read_preference: 11 | mode: Primary 12 | tag_sets: 13 | - {} 14 | suitable_servers: [] 15 | in_latency_window: [] 16 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/PossiblePrimaryNearest.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetNoPrimary", 4 | "servers": [ 5 | { 6 | "address": "b:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "PossiblePrimary" 9 | } 10 | ] 11 | }, 12 | "operation": "read", 13 | "read_preference": { 14 | "mode": "Nearest", 15 | "tag_sets": [ 16 | {} 17 | ] 18 | }, 19 | "suitable_servers": [], 20 | "in_latency_window": [] 21 | } 22 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/PossiblePrimaryNearest.yml: -------------------------------------------------------------------------------- 1 | # Test that PossiblePrimary isn't candidate for any read preference mode. 2 | --- 3 | topology_description: 4 | type: ReplicaSetNoPrimary 5 | servers: 6 | - address: b:27017 7 | avg_rtt_ms: 5 8 | type: PossiblePrimary 9 | operation: read 10 | read_preference: 11 | mode: Nearest 12 | tag_sets: 13 | - {} 14 | suitable_servers: [] 15 | in_latency_window: [] 16 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/Primary.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetNoPrimary", 4 | "servers": [ 5 | { 6 | "address": "b:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "RSSecondary", 9 | "tags": { 10 | "data_center": "nyc" 11 | } 12 | }, 13 | { 14 | "address": "c:27017", 15 | "avg_rtt_ms": 100, 16 | "type": "RSSecondary", 17 | "tags": { 18 | "data_center": "nyc" 19 | } 20 | } 21 | ] 22 | }, 23 | "operation": "read", 24 | "read_preference": { 25 | "mode": "Primary" 26 | }, 27 | "suitable_servers": [], 28 | "in_latency_window": [] 29 | } 30 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/Primary.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetNoPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | operation: read 15 | read_preference: 16 | mode: Primary 17 | suitable_servers: [] 18 | in_latency_window: [] 19 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/PrimaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetNoPrimary 3 | servers: 4 | - &1 5 | address: b:27017 6 | avg_rtt_ms: 5 7 | type: RSSecondary 8 | tags: 9 | data_center: nyc 10 | - &2 11 | address: c:27017 12 | avg_rtt_ms: 100 13 | type: RSSecondary 14 | tags: 15 | data_center: nyc 16 | operation: read 17 | read_preference: 18 | mode: PrimaryPreferred 19 | tag_sets: 20 | - {} 21 | suitable_servers: 22 | - *1 23 | - *2 24 | in_latency_window: 25 | - *1 26 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/PrimaryPreferred_non_matching.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetNoPrimary", 4 | "servers": [ 5 | { 6 | "address": "b:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "RSSecondary", 9 | "tags": { 10 | "data_center": "nyc" 11 | } 12 | }, 13 | { 14 | "address": "c:27017", 15 | "avg_rtt_ms": 100, 16 | "type": "RSSecondary", 17 | "tags": { 18 | "data_center": "nyc" 19 | } 20 | } 21 | ] 22 | }, 23 | "operation": "read", 24 | "read_preference": { 25 | "mode": "PrimaryPreferred", 26 | "tag_sets": [ 27 | { 28 | "data_center": "sf" 29 | } 30 | ] 31 | }, 32 | "suitable_servers": [], 33 | "in_latency_window": [] 34 | } 35 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/PrimaryPreferred_non_matching.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetNoPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | operation: read 15 | read_preference: 16 | mode: PrimaryPreferred 17 | tag_sets: 18 | - data_center: sf 19 | suitable_servers: [] 20 | in_latency_window: [] 21 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/Secondary.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetNoPrimary 3 | servers: 4 | - &1 5 | address: b:27017 6 | avg_rtt_ms: 5 7 | type: RSSecondary 8 | tags: 9 | data_center: nyc 10 | - &2 11 | address: c:27017 12 | avg_rtt_ms: 100 13 | type: RSSecondary 14 | tags: 15 | data_center: nyc 16 | operation: read 17 | read_preference: 18 | mode: Secondary 19 | tag_sets: 20 | - data_center: nyc 21 | suitable_servers: 22 | - *1 23 | - *2 24 | in_latency_window: 25 | - *1 26 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetNoPrimary 3 | servers: 4 | - &1 5 | address: b:27017 6 | avg_rtt_ms: 5 7 | type: RSSecondary 8 | tags: 9 | data_center: nyc 10 | - &2 11 | address: c:27017 12 | avg_rtt_ms: 100 13 | type: RSSecondary 14 | tags: 15 | data_center: nyc 16 | operation: read 17 | read_preference: 18 | mode: SecondaryPreferred 19 | tag_sets: 20 | - data_center: nyc 21 | suitable_servers: 22 | - *1 23 | - *2 24 | in_latency_window: 25 | - *1 26 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/SecondaryPreferred_non_matching.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetNoPrimary", 4 | "servers": [ 5 | { 6 | "address": "b:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "RSSecondary", 9 | "tags": { 10 | "data_center": "nyc" 11 | } 12 | }, 13 | { 14 | "address": "c:27017", 15 | "avg_rtt_ms": 100, 16 | "type": "RSSecondary", 17 | "tags": { 18 | "data_center": "nyc" 19 | } 20 | } 21 | ] 22 | }, 23 | "operation": "read", 24 | "read_preference": { 25 | "mode": "SecondaryPreferred", 26 | "tag_sets": [ 27 | { 28 | "data_center": "sf" 29 | } 30 | ] 31 | }, 32 | "suitable_servers": [], 33 | "in_latency_window": [] 34 | } 35 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/SecondaryPreferred_non_matching.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetNoPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | operation: read 15 | read_preference: 16 | mode: SecondaryPreferred 17 | tag_sets: 18 | - data_center: sf 19 | suitable_servers: [] 20 | in_latency_window: [] 21 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/Secondary_multi_tags.yml: -------------------------------------------------------------------------------- 1 | # Catch bugs like CDRIVER-1447, ensure clients select a server that matches all 2 | # tags, even when the other server mismatches multiple tags. 3 | --- 4 | topology_description: 5 | type: ReplicaSetNoPrimary 6 | servers: 7 | - &1 8 | address: b:27017 9 | avg_rtt_ms: 5 10 | type: RSSecondary 11 | tags: 12 | rack: one 13 | data_center: nyc 14 | - &2 15 | address: c:27017 16 | avg_rtt_ms: 5 17 | type: RSSecondary 18 | tags: 19 | rack: two 20 | data_center: sf 21 | operation: read 22 | read_preference: 23 | mode: Secondary 24 | tag_sets: 25 | - data_center: nyc 26 | rack: one 27 | - other_tag: doesntexist 28 | suitable_servers: 29 | - *1 30 | in_latency_window: 31 | - *1 32 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/Secondary_multi_tags2.yml: -------------------------------------------------------------------------------- 1 | # Ensure clients select a server that matches all tags, even when the other 2 | # server matches one tag and doesn't match the other. 3 | --- 4 | topology_description: 5 | type: ReplicaSetNoPrimary 6 | servers: 7 | - &1 8 | address: b:27017 9 | avg_rtt_ms: 5 10 | type: RSSecondary 11 | tags: 12 | rack: one 13 | data_center: nyc 14 | - &2 15 | address: c:27017 16 | avg_rtt_ms: 5 17 | type: RSSecondary 18 | tags: 19 | rack: two # mismatch 20 | data_center: nyc # match 21 | operation: read 22 | read_preference: 23 | mode: Secondary 24 | tag_sets: 25 | - data_center: nyc 26 | rack: one 27 | - other_tag: doesntexist 28 | suitable_servers: 29 | - *1 30 | in_latency_window: 31 | - *1 32 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/Secondary_non_matching.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetNoPrimary", 4 | "servers": [ 5 | { 6 | "address": "b:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "RSSecondary", 9 | "tags": { 10 | "data_center": "nyc" 11 | } 12 | }, 13 | { 14 | "address": "c:27017", 15 | "avg_rtt_ms": 100, 16 | "type": "RSSecondary", 17 | "tags": { 18 | "data_center": "nyc" 19 | } 20 | } 21 | ] 22 | }, 23 | "operation": "read", 24 | "read_preference": { 25 | "mode": "Secondary", 26 | "tag_sets": [ 27 | { 28 | "data_center": "sf" 29 | } 30 | ] 31 | }, 32 | "suitable_servers": [], 33 | "in_latency_window": [] 34 | } 35 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/read/Secondary_non_matching.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetNoPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | operation: read 15 | read_preference: 16 | mode: Secondary 17 | tag_sets: 18 | - data_center: sf 19 | suitable_servers: [] 20 | in_latency_window: [] 21 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/write/SecondaryPreferred.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetNoPrimary", 4 | "servers": [ 5 | { 6 | "address": "b:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "RSSecondary", 9 | "tags": { 10 | "data_center": "nyc" 11 | } 12 | }, 13 | { 14 | "address": "c:27017", 15 | "avg_rtt_ms": 100, 16 | "type": "RSSecondary", 17 | "tags": { 18 | "data_center": "nyc" 19 | } 20 | } 21 | ] 22 | }, 23 | "operation": "write", 24 | "read_preference": { 25 | "mode": "SecondaryPreferred", 26 | "tag_sets": [ 27 | { 28 | "data_center": "nyc" 29 | } 30 | ] 31 | }, 32 | "suitable_servers": [], 33 | "in_latency_window": [] 34 | } 35 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetNoPrimary/write/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetNoPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | operation: write 15 | read_preference: 16 | mode: SecondaryPreferred 17 | tag_sets: 18 | - data_center: nyc 19 | suitable_servers: [] 20 | in_latency_window: [] 21 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/Nearest.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetWithPrimary 3 | servers: 4 | - &1 5 | address: b:27017 6 | avg_rtt_ms: 5 7 | type: RSSecondary 8 | tags: 9 | data_center: nyc 10 | - &3 11 | address: c:27017 12 | avg_rtt_ms: 100 13 | type: RSSecondary 14 | tags: 15 | data_center: nyc 16 | - &2 17 | address: a:27017 18 | avg_rtt_ms: 26 19 | type: RSPrimary 20 | tags: 21 | data_center: nyc 22 | operation: read 23 | read_preference: 24 | mode: Nearest 25 | tag_sets: 26 | - data_center: nyc 27 | suitable_servers: 28 | - *1 29 | - *2 30 | - *3 31 | in_latency_window: 32 | - *1 33 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/Nearest_multiple.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetWithPrimary 3 | servers: 4 | - &1 5 | address: b:27017 6 | avg_rtt_ms: 10 7 | type: RSSecondary 8 | tags: 9 | data_center: nyc 10 | - &3 11 | address: c:27017 12 | avg_rtt_ms: 100 13 | type: RSSecondary 14 | tags: 15 | data_center: nyc 16 | - &2 17 | address: a:27017 18 | avg_rtt_ms: 20 19 | type: RSPrimary 20 | tags: 21 | data_center: nyc 22 | operation: read 23 | read_preference: 24 | mode: Nearest 25 | tag_sets: 26 | - data_center: nyc 27 | suitable_servers: 28 | - *1 29 | - *2 30 | - *3 31 | in_latency_window: 32 | - *1 33 | - *2 34 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/Nearest_non_matching.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "ReplicaSetWithPrimary", 4 | "servers": [ 5 | { 6 | "address": "b:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "RSSecondary", 9 | "tags": { 10 | "data_center": "nyc" 11 | } 12 | }, 13 | { 14 | "address": "c:27017", 15 | "avg_rtt_ms": 100, 16 | "type": "RSSecondary", 17 | "tags": { 18 | "data_center": "nyc" 19 | } 20 | }, 21 | { 22 | "address": "a:27017", 23 | "avg_rtt_ms": 26, 24 | "type": "RSPrimary", 25 | "tags": { 26 | "data_center": "nyc" 27 | } 28 | } 29 | ] 30 | }, 31 | "operation": "read", 32 | "read_preference": { 33 | "mode": "Nearest", 34 | "tag_sets": [ 35 | { 36 | "data_center": "sf" 37 | } 38 | ] 39 | }, 40 | "suitable_servers": [], 41 | "in_latency_window": [] 42 | } 43 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/Nearest_non_matching.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetWithPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | - address: a:27017 15 | avg_rtt_ms: 26 16 | type: RSPrimary 17 | tags: 18 | data_center: nyc 19 | operation: read 20 | read_preference: 21 | mode: Nearest 22 | tag_sets: 23 | - data_center: sf 24 | suitable_servers: [] 25 | in_latency_window: [] 26 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/Primary.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetWithPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | - &1 15 | address: a:27017 16 | avg_rtt_ms: 26 17 | type: RSPrimary 18 | tags: 19 | data_center: nyc 20 | operation: read 21 | read_preference: 22 | mode: Primary 23 | suitable_servers: 24 | - *1 25 | in_latency_window: 26 | - *1 27 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/PrimaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetWithPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | - &1 15 | address: a:27017 16 | avg_rtt_ms: 26 17 | type: RSPrimary 18 | tags: 19 | data_center: nyc 20 | operation: read 21 | read_preference: 22 | mode: PrimaryPreferred 23 | tag_sets: 24 | - {} 25 | suitable_servers: 26 | - *1 27 | in_latency_window: 28 | - *1 29 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/PrimaryPreferred_non_matching.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetWithPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | - &1 15 | address: a:27017 16 | avg_rtt_ms: 26 17 | type: RSPrimary 18 | tags: 19 | data_center: nyc 20 | operation: read 21 | read_preference: 22 | mode: PrimaryPreferred 23 | tag_sets: 24 | - data_center: sf 25 | suitable_servers: 26 | - *1 27 | in_latency_window: 28 | - *1 29 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/Secondary.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetWithPrimary 3 | servers: 4 | - &1 5 | address: b:27017 6 | avg_rtt_ms: 5 7 | type: RSSecondary 8 | tags: 9 | data_center: nyc 10 | - &2 11 | address: c:27017 12 | avg_rtt_ms: 100 13 | type: RSSecondary 14 | tags: 15 | data_center: nyc 16 | - address: a:27017 17 | avg_rtt_ms: 26 18 | type: RSPrimary 19 | tags: 20 | data_center: nyc 21 | operation: read 22 | read_preference: 23 | mode: Secondary 24 | tag_sets: 25 | - data_center: nyc 26 | suitable_servers: 27 | - *1 28 | - *2 29 | in_latency_window: 30 | - *1 31 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetWithPrimary 3 | servers: 4 | - &1 5 | address: b:27017 6 | avg_rtt_ms: 5 7 | type: RSSecondary 8 | tags: 9 | data_center: nyc 10 | - &2 11 | address: c:27017 12 | avg_rtt_ms: 100 13 | type: RSSecondary 14 | tags: 15 | data_center: nyc 16 | - address: a:27017 17 | avg_rtt_ms: 26 18 | type: RSPrimary 19 | tags: 20 | data_center: nyc 21 | operation: read 22 | read_preference: 23 | mode: SecondaryPreferred 24 | tag_sets: 25 | - data_center: nyc 26 | suitable_servers: 27 | - *1 28 | - *2 29 | in_latency_window: 30 | - *1 31 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred_non_matching.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetWithPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | - &1 15 | address: a:27017 16 | avg_rtt_ms: 26 17 | type: RSPrimary 18 | tags: 19 | data_center: nyc 20 | operation: read 21 | read_preference: 22 | mode: SecondaryPreferred 23 | tag_sets: 24 | - data_center: sf 25 | suitable_servers: 26 | - *1 27 | in_latency_window: 28 | - *1 29 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred_tags.yml: -------------------------------------------------------------------------------- 1 | # Attempt to select the secondary, except its tag doesn't match. 2 | # Fall back to primary. 3 | --- 4 | topology_description: 5 | type: ReplicaSetWithPrimary 6 | servers: 7 | - &1 8 | address: a:27017 9 | avg_rtt_ms: 5 10 | type: RSPrimary 11 | tags: 12 | data_center: nyc 13 | - &2 14 | address: b:27017 15 | avg_rtt_ms: 5 16 | type: RSSecondary 17 | tags: 18 | data_center: sf # No match. 19 | operation: read 20 | read_preference: 21 | mode: SecondaryPreferred 22 | tag_sets: 23 | - data_center: nyc 24 | suitable_servers: 25 | - *1 26 | in_latency_window: 27 | - *1 28 | 29 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/read/Secondary_non_matching.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetWithPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | - address: a:27017 15 | avg_rtt_ms: 26 16 | type: RSPrimary 17 | tags: 18 | data_center: nyc 19 | operation: read 20 | read_preference: 21 | mode: Secondary 22 | tag_sets: 23 | - data_center: sf 24 | suitable_servers: [] 25 | in_latency_window: [] 26 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/ReplicaSetWithPrimary/write/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: ReplicaSetWithPrimary 3 | servers: 4 | - address: b:27017 5 | avg_rtt_ms: 5 6 | type: RSSecondary 7 | tags: 8 | data_center: nyc 9 | - address: c:27017 10 | avg_rtt_ms: 100 11 | type: RSSecondary 12 | tags: 13 | data_center: nyc 14 | - &1 15 | address: a:27017 16 | avg_rtt_ms: 26 17 | type: RSPrimary 18 | tags: 19 | data_center: nyc 20 | operation: write 21 | read_preference: 22 | mode: SecondaryPreferred 23 | tag_sets: 24 | - data_center: nyc 25 | suitable_servers: 26 | - *1 27 | in_latency_window: 28 | - *1 29 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/read/Nearest.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Sharded", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Mongos" 9 | }, 10 | { 11 | "address": "h:27017", 12 | "avg_rtt_ms": 35, 13 | "type": "Mongos" 14 | } 15 | ] 16 | }, 17 | "operation": "read", 18 | "read_preference": { 19 | "mode": "Nearest", 20 | "tag_sets": [ 21 | { 22 | "data_center": "nyc" 23 | } 24 | ] 25 | }, 26 | "suitable_servers": [ 27 | { 28 | "address": "g:27017", 29 | "avg_rtt_ms": 5, 30 | "type": "Mongos" 31 | }, 32 | { 33 | "address": "h:27017", 34 | "avg_rtt_ms": 35, 35 | "type": "Mongos" 36 | } 37 | ], 38 | "in_latency_window": [ 39 | { 40 | "address": "g:27017", 41 | "avg_rtt_ms": 5, 42 | "type": "Mongos" 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/read/Nearest.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Sharded 3 | servers: 4 | - &1 5 | address: g:27017 6 | avg_rtt_ms: 5 7 | type: Mongos 8 | - &2 9 | address: h:27017 10 | avg_rtt_ms: 35 11 | type: Mongos 12 | operation: read 13 | read_preference: 14 | mode: Nearest 15 | tag_sets: 16 | - data_center: nyc 17 | suitable_servers: 18 | - *1 19 | - *2 20 | in_latency_window: 21 | - *1 22 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/read/Primary.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Sharded", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Mongos" 9 | }, 10 | { 11 | "address": "h:27017", 12 | "avg_rtt_ms": 35, 13 | "type": "Mongos" 14 | } 15 | ] 16 | }, 17 | "operation": "read", 18 | "read_preference": { 19 | "mode": "Primary" 20 | }, 21 | "suitable_servers": [ 22 | { 23 | "address": "g:27017", 24 | "avg_rtt_ms": 5, 25 | "type": "Mongos" 26 | }, 27 | { 28 | "address": "h:27017", 29 | "avg_rtt_ms": 35, 30 | "type": "Mongos" 31 | } 32 | ], 33 | "in_latency_window": [ 34 | { 35 | "address": "g:27017", 36 | "avg_rtt_ms": 5, 37 | "type": "Mongos" 38 | } 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/read/Primary.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Sharded 3 | servers: 4 | - &1 5 | address: g:27017 6 | avg_rtt_ms: 5 7 | type: Mongos 8 | - &2 9 | address: h:27017 10 | avg_rtt_ms: 35 11 | type: Mongos 12 | operation: read 13 | read_preference: 14 | mode: Primary 15 | suitable_servers: 16 | - *1 17 | - *2 18 | in_latency_window: 19 | - *1 20 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/read/PrimaryPreferred.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Sharded", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Mongos" 9 | }, 10 | { 11 | "address": "h:27017", 12 | "avg_rtt_ms": 35, 13 | "type": "Mongos" 14 | } 15 | ] 16 | }, 17 | "operation": "read", 18 | "read_preference": { 19 | "mode": "PrimaryPreferred", 20 | "tag_sets": [ 21 | { 22 | "data_center": "nyc" 23 | } 24 | ] 25 | }, 26 | "suitable_servers": [ 27 | { 28 | "address": "g:27017", 29 | "avg_rtt_ms": 5, 30 | "type": "Mongos" 31 | }, 32 | { 33 | "address": "h:27017", 34 | "avg_rtt_ms": 35, 35 | "type": "Mongos" 36 | } 37 | ], 38 | "in_latency_window": [ 39 | { 40 | "address": "g:27017", 41 | "avg_rtt_ms": 5, 42 | "type": "Mongos" 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/read/PrimaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Sharded 3 | servers: 4 | - &1 5 | address: g:27017 6 | avg_rtt_ms: 5 7 | type: Mongos 8 | - &2 9 | address: h:27017 10 | avg_rtt_ms: 35 11 | type: Mongos 12 | operation: read 13 | read_preference: 14 | mode: PrimaryPreferred 15 | tag_sets: 16 | - data_center: nyc 17 | suitable_servers: 18 | - *1 19 | - *2 20 | in_latency_window: 21 | - *1 22 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/read/Secondary.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Sharded", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Mongos" 9 | }, 10 | { 11 | "address": "h:27017", 12 | "avg_rtt_ms": 35, 13 | "type": "Mongos" 14 | } 15 | ] 16 | }, 17 | "operation": "read", 18 | "read_preference": { 19 | "mode": "Secondary", 20 | "tag_sets": [ 21 | { 22 | "data_center": "nyc" 23 | } 24 | ] 25 | }, 26 | "suitable_servers": [ 27 | { 28 | "address": "g:27017", 29 | "avg_rtt_ms": 5, 30 | "type": "Mongos" 31 | }, 32 | { 33 | "address": "h:27017", 34 | "avg_rtt_ms": 35, 35 | "type": "Mongos" 36 | } 37 | ], 38 | "in_latency_window": [ 39 | { 40 | "address": "g:27017", 41 | "avg_rtt_ms": 5, 42 | "type": "Mongos" 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/read/Secondary.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Sharded 3 | servers: 4 | - &1 5 | address: g:27017 6 | avg_rtt_ms: 5 7 | type: Mongos 8 | - &2 9 | address: h:27017 10 | avg_rtt_ms: 35 11 | type: Mongos 12 | operation: read 13 | read_preference: 14 | mode: Secondary 15 | tag_sets: 16 | - data_center: nyc 17 | suitable_servers: 18 | - *1 19 | - *2 20 | in_latency_window: 21 | - *1 22 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/read/SecondaryPreferred.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Sharded", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Mongos" 9 | }, 10 | { 11 | "address": "h:27017", 12 | "avg_rtt_ms": 35, 13 | "type": "Mongos" 14 | } 15 | ] 16 | }, 17 | "operation": "read", 18 | "read_preference": { 19 | "mode": "SecondaryPreferred", 20 | "tag_sets": [ 21 | { 22 | "data_center": "nyc" 23 | } 24 | ] 25 | }, 26 | "suitable_servers": [ 27 | { 28 | "address": "g:27017", 29 | "avg_rtt_ms": 5, 30 | "type": "Mongos" 31 | }, 32 | { 33 | "address": "h:27017", 34 | "avg_rtt_ms": 35, 35 | "type": "Mongos" 36 | } 37 | ], 38 | "in_latency_window": [ 39 | { 40 | "address": "g:27017", 41 | "avg_rtt_ms": 5, 42 | "type": "Mongos" 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/read/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Sharded 3 | servers: 4 | - &1 5 | address: g:27017 6 | avg_rtt_ms: 5 7 | type: Mongos 8 | - &2 9 | address: h:27017 10 | avg_rtt_ms: 35 11 | type: Mongos 12 | operation: read 13 | read_preference: 14 | mode: SecondaryPreferred 15 | tag_sets: 16 | - data_center: nyc 17 | suitable_servers: 18 | - *1 19 | - *2 20 | in_latency_window: 21 | - *1 22 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/write/Nearest.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Sharded", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Mongos" 9 | }, 10 | { 11 | "address": "h:27017", 12 | "avg_rtt_ms": 35, 13 | "type": "Mongos" 14 | } 15 | ] 16 | }, 17 | "operation": "write", 18 | "read_preference": { 19 | "mode": "Nearest", 20 | "tag_sets": [ 21 | { 22 | "data_center": "nyc" 23 | } 24 | ] 25 | }, 26 | "suitable_servers": [ 27 | { 28 | "address": "g:27017", 29 | "avg_rtt_ms": 5, 30 | "type": "Mongos" 31 | }, 32 | { 33 | "address": "h:27017", 34 | "avg_rtt_ms": 35, 35 | "type": "Mongos" 36 | } 37 | ], 38 | "in_latency_window": [ 39 | { 40 | "address": "g:27017", 41 | "avg_rtt_ms": 5, 42 | "type": "Mongos" 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/write/Nearest.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Sharded 3 | servers: 4 | - &1 5 | address: g:27017 6 | avg_rtt_ms: 5 7 | type: Mongos 8 | - &2 9 | address: h:27017 10 | avg_rtt_ms: 35 11 | type: Mongos 12 | operation: write 13 | read_preference: 14 | mode: Nearest 15 | tag_sets: 16 | - data_center: nyc 17 | suitable_servers: 18 | - *1 19 | - *2 20 | in_latency_window: 21 | - *1 22 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/write/Primary.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Sharded", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Mongos" 9 | }, 10 | { 11 | "address": "h:27017", 12 | "avg_rtt_ms": 35, 13 | "type": "Mongos" 14 | } 15 | ] 16 | }, 17 | "operation": "write", 18 | "read_preference": { 19 | "mode": "Primary" 20 | }, 21 | "suitable_servers": [ 22 | { 23 | "address": "g:27017", 24 | "avg_rtt_ms": 5, 25 | "type": "Mongos" 26 | }, 27 | { 28 | "address": "h:27017", 29 | "avg_rtt_ms": 35, 30 | "type": "Mongos" 31 | } 32 | ], 33 | "in_latency_window": [ 34 | { 35 | "address": "g:27017", 36 | "avg_rtt_ms": 5, 37 | "type": "Mongos" 38 | } 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/write/Primary.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Sharded 3 | servers: 4 | - &1 5 | address: g:27017 6 | avg_rtt_ms: 5 7 | type: Mongos 8 | - &2 9 | address: h:27017 10 | avg_rtt_ms: 35 11 | type: Mongos 12 | operation: write 13 | read_preference: 14 | mode: Primary 15 | suitable_servers: 16 | - *1 17 | - *2 18 | in_latency_window: 19 | - *1 20 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/write/PrimaryPreferred.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Sharded", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Mongos" 9 | }, 10 | { 11 | "address": "h:27017", 12 | "avg_rtt_ms": 35, 13 | "type": "Mongos" 14 | } 15 | ] 16 | }, 17 | "operation": "write", 18 | "read_preference": { 19 | "mode": "PrimaryPreferred", 20 | "tag_sets": [ 21 | { 22 | "data_center": "nyc" 23 | } 24 | ] 25 | }, 26 | "suitable_servers": [ 27 | { 28 | "address": "g:27017", 29 | "avg_rtt_ms": 5, 30 | "type": "Mongos" 31 | }, 32 | { 33 | "address": "h:27017", 34 | "avg_rtt_ms": 35, 35 | "type": "Mongos" 36 | } 37 | ], 38 | "in_latency_window": [ 39 | { 40 | "address": "g:27017", 41 | "avg_rtt_ms": 5, 42 | "type": "Mongos" 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/write/PrimaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Sharded 3 | servers: 4 | - &1 5 | address: g:27017 6 | avg_rtt_ms: 5 7 | type: Mongos 8 | - &2 9 | address: h:27017 10 | avg_rtt_ms: 35 11 | type: Mongos 12 | operation: write 13 | read_preference: 14 | mode: PrimaryPreferred 15 | tag_sets: 16 | - data_center: nyc 17 | suitable_servers: 18 | - *1 19 | - *2 20 | in_latency_window: 21 | - *1 22 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/write/Secondary.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Sharded", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Mongos" 9 | }, 10 | { 11 | "address": "h:27017", 12 | "avg_rtt_ms": 35, 13 | "type": "Mongos" 14 | } 15 | ] 16 | }, 17 | "operation": "write", 18 | "read_preference": { 19 | "mode": "Secondary", 20 | "tag_sets": [ 21 | { 22 | "data_center": "nyc" 23 | } 24 | ] 25 | }, 26 | "suitable_servers": [ 27 | { 28 | "address": "g:27017", 29 | "avg_rtt_ms": 5, 30 | "type": "Mongos" 31 | }, 32 | { 33 | "address": "h:27017", 34 | "avg_rtt_ms": 35, 35 | "type": "Mongos" 36 | } 37 | ], 38 | "in_latency_window": [ 39 | { 40 | "address": "g:27017", 41 | "avg_rtt_ms": 5, 42 | "type": "Mongos" 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/write/Secondary.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Sharded 3 | servers: 4 | - &1 5 | address: g:27017 6 | avg_rtt_ms: 5 7 | type: Mongos 8 | - &2 9 | address: h:27017 10 | avg_rtt_ms: 35 11 | type: Mongos 12 | operation: write 13 | read_preference: 14 | mode: Secondary 15 | tag_sets: 16 | - data_center: nyc 17 | suitable_servers: 18 | - *1 19 | - *2 20 | in_latency_window: 21 | - *1 22 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/write/SecondaryPreferred.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Sharded", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Mongos" 9 | }, 10 | { 11 | "address": "h:27017", 12 | "avg_rtt_ms": 35, 13 | "type": "Mongos" 14 | } 15 | ] 16 | }, 17 | "operation": "write", 18 | "read_preference": { 19 | "mode": "SecondaryPreferred", 20 | "tag_sets": [ 21 | { 22 | "data_center": "nyc" 23 | } 24 | ] 25 | }, 26 | "suitable_servers": [ 27 | { 28 | "address": "g:27017", 29 | "avg_rtt_ms": 5, 30 | "type": "Mongos" 31 | }, 32 | { 33 | "address": "h:27017", 34 | "avg_rtt_ms": 35, 35 | "type": "Mongos" 36 | } 37 | ], 38 | "in_latency_window": [ 39 | { 40 | "address": "g:27017", 41 | "avg_rtt_ms": 5, 42 | "type": "Mongos" 43 | } 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Sharded/write/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Sharded 3 | servers: 4 | - &1 5 | address: g:27017 6 | avg_rtt_ms: 5 7 | type: Mongos 8 | - &2 9 | address: h:27017 10 | avg_rtt_ms: 35 11 | type: Mongos 12 | operation: write 13 | read_preference: 14 | mode: SecondaryPreferred 15 | tag_sets: 16 | - data_center: nyc 17 | suitable_servers: 18 | - *1 19 | - *2 20 | in_latency_window: 21 | - *1 22 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Single/read/SecondaryPreferred.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Single", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Standalone", 9 | "tags": { 10 | "data_center": "dc" 11 | } 12 | } 13 | ] 14 | }, 15 | "operation": "read", 16 | "read_preference": { 17 | "mode": "SecondaryPreferred", 18 | "tag_sets": [ 19 | { 20 | "data_center": "nyc" 21 | } 22 | ] 23 | }, 24 | "suitable_servers": [ 25 | { 26 | "address": "a:27017", 27 | "avg_rtt_ms": 5, 28 | "type": "Standalone", 29 | "tags": { 30 | "data_center": "dc" 31 | } 32 | } 33 | ], 34 | "in_latency_window": [ 35 | { 36 | "address": "a:27017", 37 | "avg_rtt_ms": 5, 38 | "type": "Standalone", 39 | "tags": { 40 | "data_center": "dc" 41 | } 42 | } 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Single/read/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Single 3 | servers: 4 | - &1 5 | address: a:27017 6 | avg_rtt_ms: 5 7 | type: Standalone 8 | tags: 9 | data_center: dc 10 | operation: read 11 | read_preference: 12 | mode: SecondaryPreferred 13 | tag_sets: 14 | - data_center: nyc 15 | suitable_servers: 16 | - *1 17 | in_latency_window: 18 | - *1 19 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Single/write/SecondaryPreferred.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Single", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "Standalone", 9 | "tags": { 10 | "data_center": "dc" 11 | } 12 | } 13 | ] 14 | }, 15 | "operation": "write", 16 | "read_preference": { 17 | "mode": "SecondaryPreferred", 18 | "tag_sets": [ 19 | { 20 | "data_center": "nyc" 21 | } 22 | ] 23 | }, 24 | "suitable_servers": [ 25 | { 26 | "address": "a:27017", 27 | "avg_rtt_ms": 5, 28 | "type": "Standalone", 29 | "tags": { 30 | "data_center": "dc" 31 | } 32 | } 33 | ], 34 | "in_latency_window": [ 35 | { 36 | "address": "a:27017", 37 | "avg_rtt_ms": 5, 38 | "type": "Standalone", 39 | "tags": { 40 | "data_center": "dc" 41 | } 42 | } 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Single/write/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Single 3 | servers: 4 | - &1 5 | address: a:27017 6 | avg_rtt_ms: 5 7 | type: Standalone 8 | tags: 9 | data_center: dc 10 | operation: write 11 | read_preference: 12 | mode: SecondaryPreferred 13 | tag_sets: 14 | - data_center: nyc 15 | suitable_servers: 16 | - *1 17 | in_latency_window: 18 | - *1 19 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Unknown/read/SecondaryPreferred.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Unknown", 4 | "servers": [] 5 | }, 6 | "operation": "read", 7 | "read_preference": { 8 | "mode": "SecondaryPreferred", 9 | "tag_sets": [ 10 | { 11 | "data_center": "nyc" 12 | } 13 | ] 14 | }, 15 | "suitable_servers": [], 16 | "in_latency_window": [] 17 | } 18 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Unknown/read/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Unknown 3 | servers: [] 4 | operation: read 5 | read_preference: 6 | mode: SecondaryPreferred 7 | tag_sets: 8 | - data_center: nyc 9 | suitable_servers: [] 10 | in_latency_window: [] 11 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Unknown/write/SecondaryPreferred.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Unknown", 4 | "servers": [] 5 | }, 6 | "operation": "write", 7 | "read_preference": { 8 | "mode": "SecondaryPreferred", 9 | "tag_sets": [ 10 | { 11 | "data_center": "nyc" 12 | } 13 | ] 14 | }, 15 | "suitable_servers": [], 16 | "in_latency_window": [] 17 | } 18 | -------------------------------------------------------------------------------- /src/test/spec/json/server-selection/server_selection/Unknown/write/SecondaryPreferred.yml: -------------------------------------------------------------------------------- 1 | topology_description: 2 | type: Unknown 3 | servers: [] 4 | operation: write 5 | read_preference: 6 | mode: SecondaryPreferred 7 | tag_sets: 8 | - data_center: nyc 9 | suitable_servers: [] 10 | in_latency_window: [] 11 | -------------------------------------------------------------------------------- /src/test/spec/json/uri-options/auth-options.json: -------------------------------------------------------------------------------- 1 | { 2 | "tests": [ 3 | { 4 | "description": "Valid auth options are parsed correctly", 5 | "uri": "mongodb://foo:bar@example.com/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true&authSource=$external", 6 | "valid": true, 7 | "warning": false, 8 | "hosts": null, 9 | "auth": null, 10 | "options": { 11 | "authMechanism": "GSSAPI", 12 | "authMechanismProperties": { 13 | "SERVICE_NAME": "other", 14 | "CANONICALIZE_HOST_NAME": true 15 | }, 16 | "authSource": "$external" 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /src/test/spec/json/uri-options/auth-options.yml: -------------------------------------------------------------------------------- 1 | tests: 2 | - 3 | description: "Valid auth options are parsed correctly" 4 | uri: "mongodb://foo:bar@example.com/?authMechanism=GSSAPI&authMechanismProperties=SERVICE_NAME:other,CANONICALIZE_HOST_NAME:true&authSource=$external" 5 | valid: true 6 | warning: false 7 | hosts: ~ 8 | auth: ~ 9 | options: 10 | authMechanism: "GSSAPI" 11 | authMechanismProperties: 12 | SERVICE_NAME: "other" 13 | CANONICALIZE_HOST_NAME: true 14 | authSource: "$external" 15 | -------------------------------------------------------------------------------- /src/test/spec/json/uri-options/ca.pem: -------------------------------------------------------------------------------- 1 | # This file exists solely for the purpose of facilitating drivers which check for the existence of files specified in the URI options at parse time. 2 | -------------------------------------------------------------------------------- /src/test/spec/json/uri-options/cert.pem: -------------------------------------------------------------------------------- 1 | # This file exists solely for the purpose of facilitating drivers which check for the existence of files specified in the URI options at parse time. 2 | -------------------------------------------------------------------------------- /src/test/spec/json/uri-options/client.pem: -------------------------------------------------------------------------------- 1 | # This file exists solely for the purpose of facilitating drivers which check for the existence of files specified in the URI options at parse time. 2 | -------------------------------------------------------------------------------- /src/test/spec/json/uri-options/connection-pool-options.json: -------------------------------------------------------------------------------- 1 | { 2 | "tests": [ 3 | { 4 | "description": "Valid connection pool options are parsed correctly", 5 | "uri": "mongodb://example.com/?maxIdleTimeMS=50000", 6 | "valid": true, 7 | "warning": false, 8 | "hosts": null, 9 | "auth": null, 10 | "options": { 11 | "maxIdleTimeMS": 50000 12 | } 13 | }, 14 | { 15 | "description": "Non-numeric maxIdleTimeMS causes a warning", 16 | "uri": "mongodb://example.com/?maxIdleTimeMS=invalid", 17 | "valid": true, 18 | "warning": true, 19 | "hosts": null, 20 | "auth": null, 21 | "options": {} 22 | }, 23 | { 24 | "description": "Too low maxIdleTimeMS causes a warning", 25 | "uri": "mongodb://example.com/?maxIdleTimeMS=-2", 26 | "valid": true, 27 | "warning": true, 28 | "hosts": null, 29 | "auth": null, 30 | "options": {} 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /src/test/spec/json/uri-options/connection-pool-options.yml: -------------------------------------------------------------------------------- 1 | tests: 2 | - 3 | description: "Valid connection pool options are parsed correctly" 4 | uri: "mongodb://example.com/?maxIdleTimeMS=50000" 5 | valid: true 6 | warning: false 7 | hosts: ~ 8 | auth: ~ 9 | options: 10 | maxIdleTimeMS: 50000 11 | - 12 | description: "Non-numeric maxIdleTimeMS causes a warning" 13 | uri: "mongodb://example.com/?maxIdleTimeMS=invalid" 14 | valid: true 15 | warning: true 16 | hosts: ~ 17 | auth: ~ 18 | options: {} 19 | - 20 | description: "Too low maxIdleTimeMS causes a warning" 21 | uri: "mongodb://example.com/?maxIdleTimeMS=-2" 22 | valid: true 23 | warning: true 24 | hosts: ~ 25 | auth: ~ 26 | options: {} 27 | -------------------------------------------------------------------------------- /src/test/spec/json/uri-options/single-threaded-options.json: -------------------------------------------------------------------------------- 1 | { 2 | "tests": [ 3 | { 4 | "description": "Valid options specific to single-threaded drivers are parsed correctly", 5 | "uri": "mongodb://example.com/?serverSelectionTryOnce=false", 6 | "valid": true, 7 | "warning": false, 8 | "hosts": null, 9 | "auth": null, 10 | "options": { 11 | "serverSelectionTryOnce": false 12 | } 13 | }, 14 | { 15 | "description": "Invalid serverSelectionTryOnce causes a warning", 16 | "uri": "mongodb://example.com/?serverSelectionTryOnce=invalid", 17 | "valid": true, 18 | "warning": true, 19 | "hosts": null, 20 | "auth": null, 21 | "options": {} 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /src/test/spec/json/uri-options/single-threaded-options.yml: -------------------------------------------------------------------------------- 1 | tests: 2 | - 3 | description: "Valid options specific to single-threaded drivers are parsed correctly" 4 | uri: "mongodb://example.com/?serverSelectionTryOnce=false" 5 | valid: true 6 | warning: false 7 | hosts: ~ 8 | auth: ~ 9 | options: 10 | serverSelectionTryOnce: false 11 | - 12 | description: "Invalid serverSelectionTryOnce causes a warning" 13 | uri: "mongodb://example.com/?serverSelectionTryOnce=invalid" 14 | valid: true 15 | warning: true 16 | hosts: ~ 17 | auth: ~ 18 | options: {} 19 | -------------------------------------------------------------------------------- /src/test/spec/read_write_concern/mod.rs: -------------------------------------------------------------------------------- 1 | mod connection_string; 2 | mod document; 3 | 4 | use crate::bson::{self, Bson, Document}; 5 | use crate::{error::Result, options::WriteConcern}; 6 | 7 | fn write_concern_to_document(write_concern: &WriteConcern) -> Result { 8 | match bson::to_bson(&write_concern)? { 9 | Bson::Document(doc) => Ok(doc), 10 | _ => unreachable!(), 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/util/lock.rs: -------------------------------------------------------------------------------- 1 | use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard}; 2 | 3 | #[derive(Default)] 4 | pub struct TestLock { 5 | inner: RwLock<()>, 6 | } 7 | 8 | impl TestLock { 9 | pub fn new() -> Self { 10 | Default::default() 11 | } 12 | 13 | pub fn run_concurrently(&self) -> RwLockReadGuard<()> { 14 | self.inner.read().unwrap() 15 | } 16 | 17 | pub fn run_exclusively(&self) -> RwLockWriteGuard<()> { 18 | self.inner.write().unwrap() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/util/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hex; 2 | pub mod md5; 3 | -------------------------------------------------------------------------------- /tests/bson/mod.rs: -------------------------------------------------------------------------------- 1 | mod bson; 2 | mod encoder_decoder; 3 | mod macros; 4 | mod oid; 5 | mod doc; 6 | mod ser; 7 | mod serde; 8 | -------------------------------------------------------------------------------- /tests/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::cognitive_complexity)] 2 | 3 | mod bson; 4 | --------------------------------------------------------------------------------