├── doc ├── __init__.py ├── static │ ├── periodic-executor-refs.png │ └── periodic-executor-refs.dot ├── api │ ├── bson │ │ ├── decimal128.rst │ │ ├── datetime_ms.rst │ │ ├── int64.rst │ │ ├── errors.rst │ │ ├── son.rst │ │ ├── raw_bson.rst │ │ ├── tz_util.rst │ │ ├── codec_options.rst │ │ ├── max_key.rst │ │ ├── min_key.rst │ │ ├── timestamp.rst │ │ ├── regex.rst │ │ ├── code.rst │ │ ├── dbref.rst │ │ ├── json_util.rst │ │ └── index.rst │ ├── pymongo │ │ ├── encryption.rst │ │ ├── auth_oidc.rst │ │ ├── driver_info.rst │ │ ├── client_session.rst │ │ ├── operations.rst │ │ ├── results.rst │ │ ├── change_stream.rst │ │ ├── pool.rst │ │ ├── asynchronous │ │ │ ├── client_session.rst │ │ │ ├── change_stream.rst │ │ │ ├── command_cursor.rst │ │ │ └── index.rst │ │ ├── event_loggers.rst │ │ ├── write_concern.rst │ │ ├── errors.rst │ │ ├── uri_parser.rst │ │ ├── read_concern.rst │ │ ├── command_cursor.rst │ │ ├── client_options.rst │ │ ├── encryption_options.rst │ │ ├── server_description.rst │ │ ├── server_api.rst │ │ └── topology_description.rst │ ├── gridfs │ │ ├── errors.rst │ │ ├── index.rst │ │ ├── asynchronous │ │ │ ├── index.rst │ │ │ └── grid_file.rst │ │ └── grid_file.rst │ └── index.rst └── pydoctheme │ └── theme.conf ├── .evergreen ├── scripts │ ├── __init__.py │ ├── generate-config.sh │ ├── download-and-merge-coverage.sh │ ├── upload-coverage-report.sh │ ├── run-server.sh │ ├── cleanup.sh │ ├── stop-server.sh │ ├── perf-submission-setup.sh │ ├── teardown-tests.sh │ └── run-getdata.sh ├── just.sh ├── combine-coverage.sh ├── setup-spawn-host.sh ├── spec-patch │ └── PYTHON-3712.patch └── run-mongodb-oidc-test.sh ├── pymongo ├── asynchronous │ └── __init__.py ├── synchronous │ └── __init__.py └── py.typed ├── test ├── lambda │ ├── mongodb │ │ ├── __init__.py │ │ └── Makefile │ ├── build_internal.sh │ ├── run.sh │ └── README.md ├── client-side-encryption │ ├── etc │ │ └── data │ │ │ ├── lookup │ │ │ ├── schema-non-csfle.json │ │ │ ├── schema-qe.json │ │ │ ├── schema-qe2.json │ │ │ ├── schema-csfle.json │ │ │ └── schema-csfle2.json │ │ │ ├── keys │ │ │ ├── key2-id.json │ │ │ └── key1-id.json │ │ │ ├── range-encryptedFields-DoubleNoPrecision.json │ │ │ └── range-encryptedFields-DecimalNoPrecision.json │ ├── limits │ │ ├── limits-qe-doc.json │ │ └── limits-encryptedFields.json │ ├── custom │ │ └── schema.json │ └── external │ │ └── external-schema.json ├── server_selection │ ├── rtt │ │ ├── value_test_1.json │ │ ├── first_value.json │ │ ├── first_value_zero.json │ │ ├── value_test_2.json │ │ ├── value_test_3.json │ │ ├── value_test_4.json │ │ └── value_test_5.json │ └── server_selection │ │ ├── Unknown │ │ ├── read │ │ │ ├── SecondaryPreferred.json │ │ │ └── ghost.json │ │ └── write │ │ │ ├── SecondaryPreferred.json │ │ │ └── ghost.json │ │ ├── ReplicaSetNoPrimary │ │ └── read │ │ │ ├── PossiblePrimary.json │ │ │ └── PossiblePrimaryNearest.json │ │ └── LoadBalanced │ │ ├── read │ │ └── Primary.json │ │ └── write │ │ └── Primary.json ├── unified-test-format │ ├── invalid │ │ ├── tests-required.json │ │ ├── tests-type.json │ │ ├── tests-minItems.json │ │ ├── tests-items.json │ │ ├── description-required.json │ │ ├── schemaVersion-required.json │ │ ├── test-description-required.json │ │ ├── test-operations-required.json │ │ ├── schemaVersion-type.json │ │ ├── test-description-type.json │ │ ├── test-operations-type.json │ │ ├── schemaVersion-pattern.json │ │ ├── initialData-type.json │ │ ├── test-outcome-type.json │ │ ├── createEntities-type.json │ │ ├── initialData-minItems.json │ │ ├── test-outcome-minItems.json │ │ ├── test-skipReason-type.json │ │ ├── test-additionalProperties.json │ │ ├── test-operations-items.json │ │ ├── createEntities-minItems.json │ │ ├── runOnRequirements-type.json │ │ ├── test-expectEvents-type.json │ │ ├── initialData-items.json │ │ ├── test-expectEvents-minItems.json │ │ ├── createEntities-items.json │ │ ├── runOnRequirements-minItems.json │ │ ├── entity-minProperties.json │ │ ├── test-expectLogMessages-type.json │ │ ├── test-outcome-items.json │ │ ├── test-runOnRequirements-type.json │ │ ├── runOnRequirements-items.json │ │ ├── test-runOnRequirements-minItems.json │ │ ├── test-expectLogMessages-minItems.json │ │ ├── test-expectEvents-items.json │ │ ├── runOnRequirement-minProperties.json │ │ ├── test-expectLogMessages-items.json │ │ ├── test-runOnRequirements-items.json │ │ ├── entity-additionalProperties.json │ │ ├── entity-client-id-required.json │ │ ├── entity-thread-id-required.json │ │ ├── runOnRequirement-auth-type.json │ │ ├── runOnRequirement-csfle-type.json │ │ ├── runOnRequirement-topologies-type.json │ │ ├── entity-client-id-type.json │ │ ├── runOnRequirement-serverless-enum.json │ │ ├── runOnRequirement-serverless-type.json │ │ ├── entity-thread-id-type.json │ │ ├── runOnRequirement-authMechanism-type.json │ │ ├── runOnRequirement-topologies-minItems.json │ │ ├── runOnRequirement-maxServerVersion-type.json │ │ ├── runOnRequirement-minServerVersion-type.json │ │ ├── entity-stream-id-required.json │ │ ├── runOnRequirement-topologies-items.json │ │ ├── entity-stream-hexBytes-required.json │ │ ├── runOnRequirement-maxServerVersion-pattern.json │ │ ├── runOnRequirement-minServerVersion-pattern.json │ │ ├── runOnRequirement-topologies-enum.json │ │ ├── entity-stream-id-type.json │ │ ├── runOnRequirement-additionalProperties.json │ │ ├── entity-stream-hexBytes-type.json │ │ ├── entity-client-serverApi-type.json │ │ ├── entity-client-uriOptions-type.json │ │ ├── entity-client-additionalProperties.json │ │ ├── entity-stream-hexBytes-pattern.json │ │ ├── entity-client-observeEvents-type.json │ │ ├── entity-thread-additionalProperties.json │ │ ├── entity-client-observeEvents-minItems.json │ │ ├── entity-client-observeLogMessages-type.json │ │ ├── entity-client-serverApi-version-required.json │ │ ├── entity-client-useMultipleMongoses-type.json │ │ ├── runOnRequirement-csfle-minLibmongocryptVersion-type.json │ │ ├── entity-clientEncryption-clientEncryptionOpts-required.json │ │ ├── entity-stream-additionalProperties.json │ │ ├── operation-name-required.json │ │ ├── operation-object-required.json │ │ ├── entity-client-observeEvents-enum.json │ │ ├── entity-client-observeEvents-items.json │ │ ├── entity-client-observeLogMessages-minProperties.json │ │ ├── entity-client-observeSensitiveCommands-type.json │ │ ├── runOnRequirement-csfle-minLibmongocryptVersion-pattern.json │ │ ├── entity-client-serverApi-version-type.json │ │ ├── operation-name-type.json │ │ ├── operation-object-type.json │ │ ├── entity-client-ignoreCommandMonitoringEvents-type.json │ │ ├── entity-session-id-required.json │ │ ├── entity-client-ignoreCommandMonitoringEvents-minItems.json │ │ ├── entity-session-client-required.json │ │ ├── entity-clientEncryption-clientEncryptionOpts-type.json │ │ ├── entity-session-id-type.json │ │ ├── entity-session-client-type.json │ │ ├── entity-client-serverApi-strict-type.json │ │ ├── entity-client-ignoreCommandMonitoringEvents-items.json │ │ ├── entity-client-observeLogMessages-property-type.json │ │ ├── expectedEventsForClient-client-required.json │ │ ├── entity-database-id-required.json │ │ ├── entity-maxProperties.json │ │ ├── entity-client-observeLogMessages-property-value.json │ │ ├── expectedEventsForClient-events-required.json │ │ ├── operation-arguments-type.json │ │ ├── entity-database-client-required.json │ │ ├── operation-additionalProperties.json │ │ ├── operation-expectError-type.json │ │ ├── entity-client-serverApi-deprecationErrors-type.json │ │ ├── entity-database-id-type.json │ │ ├── expectedError-minProperties.json │ │ ├── expectedEventsForClient-client-type.json │ │ ├── expectedLogMessagesForClient-client-required.json │ │ ├── operation-expectEvents-type.json │ │ ├── entity-database-databaseName-required.json │ │ ├── entity-database-client-type.json │ │ ├── expectedEventsForClient-events-type.json │ │ ├── expectedLogMessagesForClient-messages-required.json │ │ ├── expectedLogMessagesForClient-client-type.json │ │ ├── operation-ignoreResultAndError-conflicts_with_expectResult.json │ │ ├── operation-saveResultAsEntity-type.json │ │ ├── entity-session-additionalProperties.json │ │ ├── entity-database-databaseName-type.json │ │ ├── entity-session-sessionOptions-type.json │ │ ├── expectedLogMessagesForClient-messages-type.json │ │ ├── expectedError-isError-type.json │ │ ├── expectedCommandEvent-minProperties.json │ │ ├── expectedEventsForClient-events-items.json │ │ ├── expectedError-errorCode-type.json │ │ ├── expectedError-isError-const.json │ │ ├── expectedLogMessage-additionalProperties.json │ │ ├── operation-ignoreResultAndError-conflicts_with_saveResultAsEntity.json │ │ ├── expectedError-additionalProperties.json │ │ ├── expectedEventsForClient-additionalProperties.json │ │ ├── entity-database-additionalProperties.json │ │ ├── expectedError-errorCodeName-type.json │ │ ├── expectedError-errorContains-type.json │ │ ├── expectedError-errorResponse-type.json │ │ ├── expectedError-isClientError-type.json │ │ ├── expectedError-errorLabelsOmit-type.json │ │ ├── expectedError-isTimeoutError-type.json │ │ ├── expectedEventsForClient-eventType-type.json │ │ ├── operation-ignoreResultAndError-conflicts_with_expectError.json │ │ ├── entity-database-databaseOptions-type.json │ │ ├── expectedEventsForClient-eventType-enum.json │ │ ├── expectedEventsForClient-ignoreExtraEvents-type.json │ │ ├── expectedLogMessagesForClient-additionalProperties.json │ │ ├── expectedLogMessagesForClient-messages-items.json │ │ ├── expectedError-errorLabelsContain-type.json │ │ ├── expectedError-errorLabelsOmit-minItems.json │ │ ├── expectedLogMessagesForClient-ignoreMessages-type.json │ │ ├── expectedError-errorLabelsContain-minItems.json │ │ ├── clientEncryptionOpts-keyVaultClient-required.json │ │ ├── expectedLogMessagesForClient-ignoreExtraMessages-type.json │ │ ├── expectedCmapEvent-poolReadyEvent-additionalProperties.json │ │ ├── expectedCommandEvent-additionalProperties.json │ │ ├── entity-bucket-id-required.json │ │ ├── expectedCmapEvent-connectionClosedEvent-reason-type.json │ │ ├── expectedCmapEvent-poolClosedEvent-additionalProperties.json │ │ ├── expectedCmapEvent-poolCreatedEvent-additionalProperties.json │ │ ├── expectedError-errorLabelsOmit-items.json │ │ ├── entity-bucket-database-required.json │ │ ├── expectedCmapEvent-poolClearedEvent-hasServiceId-type.json │ │ ├── expectedError-errorLabelsContain-items.json │ │ ├── expectedLogMessagesForClient-ignoreMessages-items.json │ │ ├── entity-bucket-id-type.json │ │ ├── expectedCmapEvent-connectionReadyEvent-additionalProperties.json │ │ ├── operation-expectError-conflicts_with_expectResult.json │ │ ├── collectionOrDatabaseOptions-timeoutMS-type.json │ │ ├── expectedCmapEvent-connectionCreatedEvent-additionalProperties.json │ │ ├── collectionOrDatabaseOptions-additionalProperties.json │ │ ├── collectionOrDatabaseOptions-readConcern-type.json │ │ ├── entity-bucket-database-type.json │ │ ├── expectedCmapEvent-connectionCheckOutFailedEvent-reason-type.json │ │ ├── expectedCmapEvent-connectionCheckedInEvent-additionalProperties.json │ │ ├── collectionOrDatabaseOptions-writeConcern-type.json │ │ ├── expectedCmapEvent-connectionCheckedOutEvent-additionalProperties.json │ │ ├── expectedLogMessage-component-required.json │ │ ├── expectedLogMessage-level-required.json │ │ ├── clientEncryptionOpts-kmsProviders-required.json │ │ ├── collectionOrDatabaseOptions-readPreference-type.json │ │ ├── expectedLogMessage-data-required.json │ │ ├── operation-expectError-conflicts_with_saveResultAsEntity.json │ │ ├── expectedSdamEvent-serverDescriptionChangedEvent-additionalProperties.json │ │ ├── expectedCmapEvent-connectionCheckOutStartedEvent-additionalProperties.json │ │ ├── expectedCmapEvent-poolClearedEvent-interruptInUseConnections-type.json │ │ ├── expectedCommandEvent-maxProperties.json │ │ ├── entity-collection-id-required.json │ │ ├── expectedSdamEvent-topologyDescriptionChangedEvent-additionalProperties.json │ │ ├── expectedLogMessage-data-type.json │ │ ├── expectedLogMessage-level-type.json │ │ ├── entity-clientEncryption-id-required.json │ │ ├── entity-collection-database-required.json │ │ ├── expectedLogMessage-component-type.json │ │ ├── expectedLogMessage-level-enum.json │ │ ├── clientEncryptionOpts-kmsProviders-type.json │ │ ├── entity-collection-id-type.json │ │ ├── expectedLogMessage-component-enum.json │ │ ├── clientEncryptionOpts-keyVaultNamespace-required.json │ │ ├── entity-bucket-additionalProperties.json │ │ ├── entity-collection-collectionName-required.json │ │ ├── entity-clientEncryption-id-type.json │ │ ├── entity-bucket-bucketOptions-type.json │ │ ├── entity-collection-database-type.json │ │ └── expectedEventsForClient-events_conflicts_with_default_eventType.json │ ├── valid-fail │ │ ├── schemaVersion-unsupported.json │ │ ├── entity-bucket-database-undefined.json │ │ ├── entity-session-client-undefined.json │ │ ├── entity-database-client-undefined.json │ │ ├── entity-collection-database-undefined.json │ │ ├── operation-unsupported.json │ │ └── entity-client-apiVersion-unsupported.json │ └── valid-pass │ │ ├── operation-empty_array.json │ │ └── assertNumberConnectionsCheckedOut.json ├── uri_options │ ├── ca.pem │ ├── cert.pem │ └── client.pem ├── srv_seedlist │ ├── replica-set │ │ ├── two-txt-records.json │ │ ├── no-results.json │ │ ├── not-enough-parts.json │ │ ├── txt-record-with-unallowed-option.json │ │ ├── uri-with-port.json │ │ ├── returned-parent-wrong.json │ │ ├── parent-part-mismatch4.json │ │ ├── misformatted-option.json │ │ ├── returned-parent-too-short.json │ │ ├── txt-record-not-allowed-option.json │ │ ├── direct-connection-true.json │ │ ├── parent-part-mismatch1.json │ │ ├── parent-part-mismatch2.json │ │ ├── parent-part-mismatch3.json │ │ ├── parent-part-mismatch5.json │ │ ├── uri-with-two-hosts.json │ │ ├── srvMaxHosts-conflicts_with_replicaSet-txt.json │ │ ├── srvMaxHosts-conflicts_with_replicaSet.json │ │ ├── srvMaxHosts-less_than_srv_records.json │ │ ├── loadBalanced-false-txt.json │ │ ├── one-txt-record-multiple-strings.json │ │ ├── one-result-default-port.json │ │ ├── uri-with-uppercase-hostname.json │ │ ├── direct-connection-false.json │ │ ├── one-txt-record.json │ │ ├── txt-record-with-overridden-ssl-option.json │ │ ├── two-results-default-port.json │ │ ├── txt-record-with-overridden-uri-option.json │ │ ├── srvMaxHosts-greater_than_srv_records.json │ │ ├── srvMaxHosts-zero-txt.json │ │ ├── two-results-nonstandard-port.json │ │ ├── srv-service-name.json │ │ ├── srvMaxHosts-equal_to_srv_records.json │ │ ├── srvMaxHosts-zero.json │ │ ├── dbname-with-commas.json │ │ ├── longer-parent-in-return.json │ │ ├── dbname-with-commas-escaped.json │ │ ├── uri-with-admin-database.json │ │ ├── uri-with-auth.json │ │ └── encoded-userinfo-and-db.json │ ├── load-balanced │ │ ├── loadBalanced-no-results.json │ │ ├── loadBalanced-replicaSet-errors.json │ │ ├── loadBalanced-true-multiple-hosts.json │ │ ├── srvMaxHosts-conflicts_with_loadBalanced-true-txt.json │ │ ├── srvMaxHosts-conflicts_with_loadBalanced-true.json │ │ ├── loadBalanced-true-txt.json │ │ ├── srvMaxHosts-zero-txt.json │ │ ├── srvMaxHosts-zero.json │ │ └── loadBalanced-directConnection.json │ └── sharded │ │ ├── srvMaxHosts-less_than_srv_records.json │ │ ├── srvMaxHosts-zero.json │ │ ├── srvMaxHosts-greater_than_srv_records.json │ │ └── srvMaxHosts-equal_to_srv_records.json ├── mypy_fails │ ├── insert_many_dict.py │ ├── insert_one_list.py │ ├── raw_bson_document.py │ └── typedict_client.py ├── bson_corpus │ ├── null.json │ ├── maxkey.json │ ├── minkey.json │ └── undefined.json ├── connection_monitoring │ ├── pool-create.json │ ├── pool-close.json │ └── pool-clear-paused.json ├── max_staleness │ ├── Unknown │ │ └── SmallMaxStaleness.json │ └── ReplicaSetNoPrimary │ │ ├── MaxStalenessTooSmall.json │ │ └── NoKnownServers.json ├── pytest_conf.py └── discovery_and_monitoring │ ├── sharded │ └── normalize_uri_case.json │ └── single │ ├── discover_unavailable_seed.json │ └── direct_connection_unavailable_seed.json ├── requirements ├── snappy.txt ├── aws.txt ├── zstd.txt ├── gssapi.txt ├── test.txt ├── encryption.txt ├── docs.txt └── ocsp.txt ├── .github ├── CODEOWNERS ├── reviewers.txt ├── zizmor.yml ├── dependabot.yml └── workflows │ └── zizmor.yml ├── requirements.txt ├── strict_pyrightconfig.json ├── tools ├── README.rst └── synchro.sh ├── .git-blame-ignore-revs ├── bson └── py.typed ├── gridfs └── py.typed ├── integration_tests ├── run.sh └── test_uv_loop.py ├── setup.py ├── mypy_test.ini └── .readthedocs.yaml /doc/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.evergreen/scripts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pymongo/asynchronous/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pymongo/synchronous/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/lambda/mongodb/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements/snappy.txt: -------------------------------------------------------------------------------- 1 | python-snappy 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @mongodb/dbx-python 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | dnspython>=2.6.1,<3.0.0 2 | -------------------------------------------------------------------------------- /requirements/aws.txt: -------------------------------------------------------------------------------- 1 | pymongo-auth-aws>=1.1.0,<2.0.0 2 | -------------------------------------------------------------------------------- /strict_pyrightconfig.json: -------------------------------------------------------------------------------- 1 | {"strict": ["tests/test_typing_strict.py"]} -------------------------------------------------------------------------------- /requirements/zstd.txt: -------------------------------------------------------------------------------- 1 | backports.zstd>=1.0.0;python_version<'3.14' 2 | -------------------------------------------------------------------------------- /requirements/gssapi.txt: -------------------------------------------------------------------------------- 1 | pykerberos;os.name!='nt' 2 | winkerberos>=0.5.0;os.name=='nt' 3 | -------------------------------------------------------------------------------- /.evergreen/just.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eu 3 | 4 | . .evergreen/scripts/setup-dev-env.sh 5 | just "$@" 6 | -------------------------------------------------------------------------------- /test/client-side-encryption/etc/data/lookup/schema-non-csfle.json: -------------------------------------------------------------------------------- 1 | { 2 | "bsonType": "object" 3 | } 4 | -------------------------------------------------------------------------------- /tools/README.rst: -------------------------------------------------------------------------------- 1 | Tools 2 | ===== 3 | This directory contains tools for use with the ``pymongo`` module. 4 | -------------------------------------------------------------------------------- /requirements/test.txt: -------------------------------------------------------------------------------- 1 | pytest>=8.2 2 | pytest-asyncio>=0.24.0 3 | importlib_metadata>=7.0;python_version < "3.13" 4 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/server_selection/rtt/first_value.json: -------------------------------------------------------------------------------- 1 | { 2 | "avg_rtt_ms": "NULL", 3 | "new_rtt_ms": 10, 4 | "new_avg_rtt": 10 5 | } 6 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/tests-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tests-required", 3 | "schemaVersion": "1.0" 4 | } 5 | -------------------------------------------------------------------------------- /.github/reviewers.txt: -------------------------------------------------------------------------------- 1 | # List of reviewers for auto-assignment of reviews. 2 | caseyclements 3 | blink1073 4 | Jibola 5 | NoahStapp 6 | -------------------------------------------------------------------------------- /doc/static/periodic-executor-refs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mongodb/mongo-python-driver/HEAD/doc/static/periodic-executor-refs.png -------------------------------------------------------------------------------- /test/unified-test-format/invalid/tests-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tests-type", 3 | "schemaVersion": "1.0", 4 | "tests": 0 5 | } 6 | -------------------------------------------------------------------------------- /test/lambda/build_internal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | 3 | cd /src 4 | PYTHON=/opt/python/cp310-cp310/bin/python 5 | $PYTHON -m pip install -v -e . 6 | -------------------------------------------------------------------------------- /test/lambda/mongodb/Makefile: -------------------------------------------------------------------------------- 1 | 2 | build-MongoDBFunction: 3 | cp -r . $(ARTIFACTS_DIR) 4 | python -m pip install -t $(ARTIFACTS_DIR) dnspython 5 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/tests-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tests-minItems", 3 | "schemaVersion": "1.0", 4 | "tests": [] 5 | } 6 | -------------------------------------------------------------------------------- /requirements/encryption.txt: -------------------------------------------------------------------------------- 1 | pymongo-auth-aws>=1.1.0,<2.0.0 2 | pymongocrypt>=1.13.0,<2.0.0 3 | certifi>=2023.7.22;os.name=='nt' or sys_platform=='darwin' 4 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/tests-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tests-items", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | 0 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /test/client-side-encryption/etc/data/keys/key2-id.json: -------------------------------------------------------------------------------- 1 | { 2 | "$binary": { 3 | "base64": "q83vqxI0mHYSNBI0VniQEg==", 4 | "subType": "04" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Initial pre-commit reformat 2 | 5578999a90e439fbca06fc0ffc98f4d04e96f7b4 3 | # pyupgrade and ruff 4 | 0092b0af79378abf35b6db73a082ecb91af1d973 5 | -------------------------------------------------------------------------------- /test/client-side-encryption/etc/data/keys/key1-id.json: -------------------------------------------------------------------------------- 1 | { 2 | "$binary": { 3 | "base64": "EjRWeBI0mHYSNBI0VniQEg==", 4 | "subType": "04" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /.evergreen/scripts/generate-config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Entry point for the generate-config pre-commit hook. 3 | 4 | set -eu 5 | 6 | python .evergreen/scripts/generate_config.py 7 | -------------------------------------------------------------------------------- /test/client-side-encryption/limits/limits-qe-doc.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 3 | } -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /doc/api/bson/decimal128.rst: -------------------------------------------------------------------------------- 1 | :mod:`decimal128` -- Support for BSON Decimal128 2 | ================================================ 3 | .. automodule:: bson.decimal128 4 | :members: 5 | -------------------------------------------------------------------------------- /requirements/docs.txt: -------------------------------------------------------------------------------- 1 | sphinx>=5.3,<9 2 | sphinx_rtd_theme>=2,<4 3 | readthedocs-sphinx-search~=0.3 4 | sphinxcontrib-shellcheck>=1,<2 5 | sphinx-autobuild>=2020.9.1 6 | furo==2025.9.25 7 | -------------------------------------------------------------------------------- /bson/py.typed: -------------------------------------------------------------------------------- 1 | # PEP-561 Support File. 2 | # "Package maintainers who wish to support type checking of their code MUST add a marker file named py.typed to their package supporting typing". 3 | -------------------------------------------------------------------------------- /gridfs/py.typed: -------------------------------------------------------------------------------- 1 | # PEP-561 Support File. 2 | # "Package maintainers who wish to support type checking of their code MUST add a marker file named py.typed to their package supporting typing". 3 | -------------------------------------------------------------------------------- /.evergreen/scripts/download-and-merge-coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Download all the task coverage files. 3 | set -eu 4 | aws s3 cp --recursive s3://"$1"/coverage/"$2"/"$3"/coverage/ coverage/ 5 | -------------------------------------------------------------------------------- /pymongo/py.typed: -------------------------------------------------------------------------------- 1 | # PEP-561 Support File. 2 | # "Package maintainers who wish to support type checking of their code MUST add a marker file named py.typed to their package supporting typing". 3 | -------------------------------------------------------------------------------- /doc/api/pymongo/encryption.rst: -------------------------------------------------------------------------------- 1 | :mod:`encryption` -- Client-Side Field Level Encryption 2 | ======================================================= 3 | 4 | .. automodule:: pymongo.encryption 5 | :members: 6 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/description-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": "1.0", 3 | "tests": [ 4 | { 5 | "description": "foo", 6 | "operations": [] 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /.evergreen/scripts/upload-coverage-report.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Upload a coverate report to s3. 3 | set -eu 4 | aws s3 cp htmlcov/ s3://"$1"/coverage/"$2"/"$3"/htmlcov/ --recursive --acl public-read --region us-east-1 5 | -------------------------------------------------------------------------------- /doc/api/pymongo/auth_oidc.rst: -------------------------------------------------------------------------------- 1 | :mod:`auth_oidc` -- MONGODB-OIDC Authentication 2 | =========================================================================== 3 | 4 | .. automodule:: pymongo.auth_oidc 5 | :members: 6 | -------------------------------------------------------------------------------- /doc/api/pymongo/driver_info.rst: -------------------------------------------------------------------------------- 1 | :mod:`driver_info` 2 | ================== 3 | 4 | .. automodule:: pymongo.driver_info 5 | 6 | .. autoclass:: pymongo.driver_info.DriverInfo(name=None, version=None, platform=None) 7 | -------------------------------------------------------------------------------- /.github/zizmor.yml: -------------------------------------------------------------------------------- 1 | rules: 2 | unpinned-uses: 3 | config: 4 | policies: 5 | actions/*: ref-pin 6 | mongodb-labs/drivers-github-tools/*: ref-pin 7 | mongodb-labs/drivers-evergreen-tools: ref-pin 8 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/schemaVersion-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "schemaVersion-required", 3 | "tests": [ 4 | { 5 | "description": "foo", 6 | "operations": [] 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-description-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-description-required", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "operation": [] 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /doc/api/pymongo/client_session.rst: -------------------------------------------------------------------------------- 1 | :mod:`client_session` -- Logical sessions for sequential operations 2 | =================================================================== 3 | 4 | .. automodule:: pymongo.client_session 5 | :members: 6 | -------------------------------------------------------------------------------- /doc/api/pymongo/operations.rst: -------------------------------------------------------------------------------- 1 | :mod:`operations` -- Operation class definitions 2 | ================================================ 3 | 4 | .. automodule:: pymongo.operations 5 | :synopsis: Operation class definitions 6 | :members: 7 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-operations-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-operations-required", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo" 7 | } 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /test/lambda/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -o errexit # Exit the script with error if any of the commands fail 3 | 4 | sam build 5 | sam local invoke --docker-network host --parameter-overrides "MongoDbUri=mongodb://host.docker.internal:27017" 6 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /doc/api/bson/datetime_ms.rst: -------------------------------------------------------------------------------- 1 | :mod:`datetime_ms` -- Support for BSON UTC Datetime 2 | =================================================== 3 | 4 | .. automodule:: bson.datetime_ms 5 | :synopsis: Support for BSON UTC datetimes. 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/api/pymongo/results.rst: -------------------------------------------------------------------------------- 1 | :mod:`results` -- Result class definitions 2 | ========================================== 3 | 4 | .. automodule:: pymongo.results 5 | :synopsis: Result class definitions 6 | :members: 7 | :inherited-members: 8 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/schemaVersion-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "schemaVersion-type", 3 | "schemaVersion": 0, 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [] 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /doc/api/pymongo/change_stream.rst: -------------------------------------------------------------------------------- 1 | :mod:`change_stream` -- Watch changes on a collection, database, or cluster 2 | =========================================================================== 3 | 4 | .. automodule:: pymongo.change_stream 5 | :members: 6 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-description-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-description-type", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": 0, 7 | "operation": [] 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /doc/api/bson/int64.rst: -------------------------------------------------------------------------------- 1 | :mod:`int64` -- Tools for representing BSON int64 2 | ================================================= 3 | .. versionadded:: 3.0 4 | 5 | .. automodule:: bson.int64 6 | :synopsis: Tools for representing BSON int64 7 | :members: 8 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-operations-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-operations-type", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": 0 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /doc/api/bson/errors.rst: -------------------------------------------------------------------------------- 1 | :mod:`errors` -- Exceptions raised by the :mod:`bson` package 2 | ============================================================= 3 | 4 | .. automodule:: bson.errors 5 | :synopsis: Exceptions raised by the bson package 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/api/bson/son.rst: -------------------------------------------------------------------------------- 1 | :mod:`son` -- Tools for working with SON, an ordered mapping 2 | ============================================================ 3 | 4 | .. automodule:: bson.son 5 | :synopsis: Tools for working with SON, an ordered mapping 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/api/pymongo/pool.rst: -------------------------------------------------------------------------------- 1 | :mod:`pool` -- Pool module for use with a MongoDB client. 2 | ============================================================== 3 | 4 | .. automodule:: pymongo.pool 5 | 6 | .. autoclass:: pymongo.pool.PoolOptions() 7 | :members: 8 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/schemaVersion-pattern.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "schemaVersion-pattern", 3 | "schemaVersion": "1.2.3.4", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [] 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /doc/api/bson/raw_bson.rst: -------------------------------------------------------------------------------- 1 | :mod:`raw_bson` -- Tools for representing raw BSON documents. 2 | ============================================================= 3 | .. automodule:: bson.raw_bson 4 | :synopsis: Tools for representing raw BSON documents. 5 | :members: 6 | -------------------------------------------------------------------------------- /test/unified-test-format/valid-fail/schemaVersion-unsupported.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "schemaVersion-unsupported", 3 | "schemaVersion": "0.1", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [] 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /doc/api/gridfs/errors.rst: -------------------------------------------------------------------------------- 1 | :mod:`errors` -- Exceptions raised by the :mod:`gridfs` package 2 | ================================================================= 3 | 4 | .. automodule:: gridfs.errors 5 | :synopsis: Exceptions raised by the gridfs package 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/api/pymongo/asynchronous/client_session.rst: -------------------------------------------------------------------------------- 1 | :mod:`client_session` -- Logical sessions for sequential operations 2 | =================================================================== 3 | 4 | 5 | .. automodule:: pymongo.asynchronous.client_session 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/api/pymongo/event_loggers.rst: -------------------------------------------------------------------------------- 1 | :mod:`event_loggers` -- Example loggers 2 | =========================================== 3 | 4 | 5 | .. automodule:: pymongo.event_loggers 6 | :synopsis: A collection of simple listeners for monitoring driver events. 7 | :members: 8 | -------------------------------------------------------------------------------- /doc/api/pymongo/write_concern.rst: -------------------------------------------------------------------------------- 1 | :mod:`write_concern` -- Tools for specifying write concern 2 | ========================================================== 3 | 4 | .. automodule:: pymongo.write_concern 5 | :synopsis: Tools for specifying write concern. 6 | :members: 7 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/initialData-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "initialData-type", 3 | "schemaVersion": "1.0", 4 | "initialData": 0, 5 | "tests": [ 6 | { 7 | "description": "foo", 8 | "operations": [] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /doc/api/bson/tz_util.rst: -------------------------------------------------------------------------------- 1 | :mod:`tz_util` -- Utilities for dealing with timezones in Python 2 | ================================================================ 3 | 4 | .. automodule:: bson.tz_util 5 | :synopsis: Utilities for dealing with timezones in Python 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/api/pymongo/errors.rst: -------------------------------------------------------------------------------- 1 | :mod:`errors` -- Exceptions raised by the :mod:`pymongo` package 2 | ================================================================ 3 | 4 | .. automodule:: pymongo.errors 5 | :synopsis: Exceptions raised by the pymongo package 6 | :members: 7 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-outcome-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-outcome-type", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "outcome": 0 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /doc/api/bson/codec_options.rst: -------------------------------------------------------------------------------- 1 | :mod:`codec_options` -- Tools for specifying BSON codec options 2 | =============================================================== 3 | 4 | .. automodule:: bson.codec_options 5 | :synopsis: Tools for specifying BSON codec options. 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/api/pymongo/asynchronous/change_stream.rst: -------------------------------------------------------------------------------- 1 | :mod:`change_stream` -- Watch changes on a collection, database, or cluster 2 | =========================================================================== 3 | 4 | 5 | .. automodule:: pymongo.asynchronous.change_stream 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/api/pymongo/uri_parser.rst: -------------------------------------------------------------------------------- 1 | :mod:`uri_parser` -- Tools to parse and validate a MongoDB URI 2 | ============================================================== 3 | 4 | .. automodule:: pymongo.uri_parser 5 | :synopsis: Tools to parse and validate a MongoDB URI. 6 | :members: 7 | -------------------------------------------------------------------------------- /test/srv_seedlist/load-balanced/loadBalanced-no-results.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test4.test.build.10gen.cc/?loadBalanced=true", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because no SRV records are present for this URI." 7 | } 8 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/createEntities-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "createEntities-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": 0, 5 | "tests": [ 6 | { 7 | "description": "foo", 8 | "operations": [] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/initialData-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "initialData-minItems", 3 | "schemaVersion": "1.0", 4 | "initialData": [], 5 | "tests": [ 6 | { 7 | "description": "foo", 8 | "operations": [] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-outcome-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-outcome-minItems", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "outcome": [] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-skipReason-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-skipReason-type", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "skipReason": 0 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unified-test-format/valid-pass/operation-empty_array.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-empty_array", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "Empty operations array", 7 | "operations": [] 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /doc/api/bson/max_key.rst: -------------------------------------------------------------------------------- 1 | :mod:`max_key` -- Representation for the MongoDB internal MaxKey type 2 | ===================================================================== 3 | .. automodule:: bson.max_key 4 | :synopsis: Representation for the MongoDB internal MaxKey type 5 | :members: 6 | -------------------------------------------------------------------------------- /doc/api/bson/min_key.rst: -------------------------------------------------------------------------------- 1 | :mod:`min_key` -- Representation for the MongoDB internal MinKey type 2 | ===================================================================== 3 | .. automodule:: bson.min_key 4 | :synopsis: Representation for the MongoDB internal MinKey type 5 | :members: 6 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/srv_seedlist/sharded/srvMaxHosts-less_than_srv_records.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=1", 3 | "numSeeds": 1, 4 | "numHosts": 1, 5 | "options": { 6 | "srvMaxHosts": 1, 7 | "ssl": true 8 | }, 9 | "ping": true 10 | } 11 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "foo": 0 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-operations-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-operations-items", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [ 8 | 0 9 | ] 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /doc/api/bson/timestamp.rst: -------------------------------------------------------------------------------- 1 | :mod:`timestamp` -- Tools for representing MongoDB internal Timestamps 2 | ====================================================================== 3 | .. automodule:: bson.timestamp 4 | :synopsis: Tools for representing MongoDB internal Timestamps 5 | :members: 6 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/createEntities-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "createEntities-minItems", 3 | "schemaVersion": "1.0", 4 | "createEntities": [], 5 | "tests": [ 6 | { 7 | "description": "foo", 8 | "operations": [] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirements-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirements-type", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": 0, 5 | "tests": [ 6 | { 7 | "description": "foo", 8 | "operations": [] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-expectEvents-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-expectEvents-type", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": 0 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /.evergreen/scripts/run-server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | HERE=$(dirname ${BASH_SOURCE:-$0}) 6 | 7 | # Try to source the env file. 8 | if [ -f $HERE/env.sh ]; then 9 | echo "Sourcing env file" 10 | source $HERE/env.sh 11 | fi 12 | 13 | uv run $HERE/run_server.py "$@" 14 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/direct-connection-true.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test3.test.build.10gen.cc/?directConnection=true", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because directConnection=true is incompatible with SRV URIs." 7 | } 8 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/initialData-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "initialData-items", 3 | "schemaVersion": "1.0", 4 | "initialData": [ 5 | 0 6 | ], 7 | "tests": [ 8 | { 9 | "description": "foo", 10 | "operations": [] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-expectEvents-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-expectEvents-minItems", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /doc/api/pymongo/read_concern.rst: -------------------------------------------------------------------------------- 1 | :mod:`read_concern` -- Tools for working with read concern. 2 | =========================================================== 3 | 4 | .. automodule:: pymongo.read_concern 5 | :synopsis: Tools for working with read concern. 6 | :members: 7 | :inherited-members: 8 | -------------------------------------------------------------------------------- /test/srv_seedlist/load-balanced/loadBalanced-replicaSet-errors.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test24.test.build.10gen.cc/?replicaSet=replset", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because loadBalanced=true is incompatible with replicaSet" 7 | } 8 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/createEntities-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "createEntities-items", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | 0 6 | ], 7 | "tests": [ 8 | { 9 | "description": "foo", 10 | "operations": [] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirements-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirements-minItems", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [], 5 | "tests": [ 6 | { 7 | "description": "foo", 8 | "operations": [] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /doc/api/bson/regex.rst: -------------------------------------------------------------------------------- 1 | :mod:`regex` -- Tools for representing MongoDB regular expressions 2 | ================================================================== 3 | .. versionadded:: 2.7 4 | 5 | .. automodule:: bson.regex 6 | :synopsis: Tools for representing MongoDB regular expressions 7 | :members: 8 | -------------------------------------------------------------------------------- /test/mypy_fails/insert_many_dict.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from pymongo import MongoClient 4 | 5 | client: MongoClient = MongoClient() 6 | client.test.test.insert_many( 7 | {"a": 1} 8 | ) # error: Dict entry 0 has incompatible type "str": "int"; expected "Mapping[str, Any]": "int" 9 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-minProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-minProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | {} 6 | ], 7 | "tests": [ 8 | { 9 | "description": "foo", 10 | "operations": [] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-expectLogMessages-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-expectLogMessages-type", 3 | "schemaVersion": "1.13", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectLogMessages": 0 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-outcome-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-outcome-items", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "outcome": [ 9 | 0 10 | ] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-runOnRequirements-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-runOnRequirements-type", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "runOnRequirements": 0 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirements-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirements-items", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [ 5 | 0 6 | ], 7 | "tests": [ 8 | { 9 | "description": "foo", 10 | "operations": [] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-runOnRequirements-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-runOnRequirements-minItems", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "runOnRequirements": [] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /doc/api/pymongo/command_cursor.rst: -------------------------------------------------------------------------------- 1 | :mod:`command_cursor` -- Tools for iterating over MongoDB command results 2 | ========================================================================= 3 | 4 | .. automodule:: pymongo.command_cursor 5 | :synopsis: Tools for iterating over MongoDB command results 6 | :members: 7 | -------------------------------------------------------------------------------- /test/srv_seedlist/load-balanced/loadBalanced-true-multiple-hosts.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/?loadBalanced=true", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because loadBalanced is true but the SRV record resolves to multiple hosts" 7 | } 8 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-expectLogMessages-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-expectLogMessages-minItems", 3 | "schemaVersion": "1.11", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectLogMessages": [] 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /doc/api/pymongo/client_options.rst: -------------------------------------------------------------------------------- 1 | :mod:`client_options` -- Read only configuration options for a MongoClient. 2 | =========================================================================== 3 | 4 | .. automodule:: pymongo.client_options 5 | 6 | .. autoclass:: pymongo.client_options.ClientOptions() 7 | :members: 8 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-expectEvents-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-expectEvents-items", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | 0 10 | ] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /tools/synchro.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Keep the synchronous folders in sync with there async counterparts. 3 | set -eu 4 | 5 | python ./tools/synchro.py "$@" 6 | python -m ruff check pymongo/synchronous/ gridfs/synchronous/ test/ --fix --silent 7 | python -m ruff format pymongo/synchronous/ gridfs/synchronous/ test/ --silent 8 | -------------------------------------------------------------------------------- /test/lambda/README.md: -------------------------------------------------------------------------------- 1 | AWS Lambda Testing 2 | ------------------ 3 | 4 | Running locally 5 | =============== 6 | 7 | Prerequisites: 8 | 9 | - AWS SAM CLI 10 | - Docker daemon running 11 | 12 | Usage 13 | ===== 14 | 15 | - Start a local mongodb instance on port 27017 16 | - Run ``build.sh`` 17 | - Run ``test.sh`` 18 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/srvMaxHosts-conflicts_with_replicaSet-txt.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test5.test.build.10gen.cc/?srvMaxHosts=1", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because positive integer for srvMaxHosts conflicts with replicaSet option (TXT)" 7 | } 8 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-minProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-minProperties", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [ 5 | {} 6 | ], 7 | "tests": [ 8 | { 9 | "description": "foo", 10 | "operations": [] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /doc/api/pymongo/encryption_options.rst: -------------------------------------------------------------------------------- 1 | :mod:`encryption_options` -- Automatic Client-Side Field Level Encryption 2 | ========================================================================= 3 | 4 | .. automodule:: pymongo.encryption_options 5 | :synopsis: Support for automatic client-side field level encryption 6 | :members: 7 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/srvMaxHosts-conflicts_with_replicaSet.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0&srvMaxHosts=1", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because positive integer for srvMaxHosts conflicts with replicaSet option" 7 | } 8 | -------------------------------------------------------------------------------- /integration_tests/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run all of the integration test files using `uv run`. 3 | set -eu 4 | 5 | for file in integration_tests/test_*.py ; do 6 | echo "-----------------" 7 | echo "Running $file..." 8 | uv run $file 9 | echo "Running $file...done." 10 | echo "-----------------" 11 | done 12 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | msg = ( 4 | "PyMongo>=4.8 no longer supports building via setup.py, use python -m pip install instead. If " 5 | "this is an editable install (-e) please upgrade to pip>=21.3 first: python -m pip install --upgrade pip" 6 | ) 7 | 8 | raise RuntimeError(msg) 9 | -------------------------------------------------------------------------------- /test/srv_seedlist/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true-txt.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test24.test.build.10gen.cc/?srvMaxHosts=1", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because positive integer for srvMaxHosts conflicts with loadBalanced=true (TXT)" 7 | } 8 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-expectLogMessages-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-expectLogMessages-items", 3 | "schemaVersion": "1.13", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectLogMessages": [ 9 | 0 10 | ] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/test-runOnRequirements-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "test-runOnRequirements-items", 3 | "schemaVersion": "1.0", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "runOnRequirements": [ 9 | 0 10 | ] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /doc/api/bson/code.rst: -------------------------------------------------------------------------------- 1 | :mod:`code` -- Tools for representing JavaScript code 2 | ===================================================== 3 | 4 | .. automodule:: bson.code 5 | :synopsis: Tools for representing JavaScript code 6 | 7 | .. autoclass:: Code(code, scope=None, **kwargs) 8 | :members: 9 | :show-inheritance: 10 | -------------------------------------------------------------------------------- /test/bson_corpus/null.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Null type", 3 | "bson_type": "0x0A", 4 | "test_key": "a", 5 | "valid": [ 6 | { 7 | "description": "Null", 8 | "canonical_bson": "080000000A610000", 9 | "canonical_extjson": "{\"a\" : null}" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/srv_seedlist/load-balanced/srvMaxHosts-conflicts_with_loadBalanced-true.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test3.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=1", 3 | "seeds": [], 4 | "hosts": [], 5 | "error": true, 6 | "comment": "Should fail because positive integer for srvMaxHosts conflicts with loadBalanced=true" 7 | } 8 | -------------------------------------------------------------------------------- /doc/api/pymongo/asynchronous/command_cursor.rst: -------------------------------------------------------------------------------- 1 | :mod:`command_cursor` -- Tools for iterating over MongoDB command results 2 | ========================================================================= 3 | 4 | 5 | .. automodule:: pymongo.asynchronous.command_cursor 6 | :synopsis: Tools for iterating over MongoDB command results 7 | :members: 8 | -------------------------------------------------------------------------------- /test/mypy_fails/insert_one_list.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from pymongo import MongoClient 4 | 5 | client: MongoClient = MongoClient() 6 | client.test.test.insert_one( 7 | [{}] 8 | ) # error: Argument 1 to "insert_one" of "Collection" has incompatible type "List[Dict[, ]]"; expected "Mapping[str, Any]" 9 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "foo": 0 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-id-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-id-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": {} 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /doc/api/bson/dbref.rst: -------------------------------------------------------------------------------- 1 | :mod:`dbref` -- Tools for manipulating DBRefs (references to documents stored in MongoDB) 2 | ========================================================================================= 3 | 4 | .. automodule:: bson.dbref 5 | :synopsis: Tools for manipulating DBRefs (references to documents stored in MongoDB) 6 | :members: 7 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-thread-id-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-thread-id-required", 3 | "schemaVersion": "1.10", 4 | "createEntities": [ 5 | { 6 | "thread": {} 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-auth-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-auth-type", 3 | "schemaVersion": "1.3", 4 | "runOnRequirements": [ 5 | { 6 | "auth": "foo" 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-csfle-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-csfle-type", 3 | "schemaVersion": "1.8", 4 | "runOnRequirements": [ 5 | { 6 | "csfle": "foo" 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/bson_corpus/maxkey.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Maxkey type", 3 | "bson_type": "0x7F", 4 | "test_key": "a", 5 | "valid": [ 6 | { 7 | "description": "Maxkey", 8 | "canonical_bson": "080000007F610000", 9 | "canonical_extjson": "{\"a\" : {\"$maxKey\" : 1}}" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/bson_corpus/minkey.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Minkey type", 3 | "bson_type": "0xFF", 4 | "test_key": "a", 5 | "valid": [ 6 | { 7 | "description": "Minkey", 8 | "canonical_bson": "08000000FF610000", 9 | "canonical_extjson": "{\"a\" : {\"$minKey\" : 1}}" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-topologies-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-topologies-type", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [ 5 | { 6 | "topologies": 0 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-id-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-id-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": 0 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-serverless-enum.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-serverless-enum", 3 | "schemaVersion": "1.4", 4 | "runOnRequirements": [ 5 | { 6 | "serverless": "foo" 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-serverless-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-serverless-type", 3 | "schemaVersion": "1.4", 4 | "runOnRequirements": [ 5 | { 6 | "serverless": 1234 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /doc/api/bson/json_util.rst: -------------------------------------------------------------------------------- 1 | :mod:`json_util` -- Tools for using Python's :mod:`json` module with BSON documents 2 | =================================================================================== 3 | .. automodule:: bson.json_util 4 | :synopsis: Tools for using Python's json module with BSON documents 5 | :members: 6 | :undoc-members: 7 | :member-order: bysource 8 | -------------------------------------------------------------------------------- /test/srv_seedlist/load-balanced/loadBalanced-true-txt.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test24.test.build.10gen.cc/", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:8000" 5 | ], 6 | "hosts": [ 7 | "localhost.test.build.10gen.cc:8000" 8 | ], 9 | "options": { 10 | "loadBalanced": true, 11 | "ssl": true 12 | }, 13 | "ping": true 14 | } 15 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-thread-id-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-thread-id-type", 3 | "schemaVersion": "1.10", 4 | "createEntities": [ 5 | { 6 | "thread": { 7 | "id": 0 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-authMechanism-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-authMechanism-type", 3 | "schemaVersion": "1.19", 4 | "runOnRequirements": [ 5 | { 6 | "authMechanism": 0 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-topologies-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-topologies-minItems", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [ 5 | { 6 | "topologies": [] 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /doc/api/gridfs/index.rst: -------------------------------------------------------------------------------- 1 | :mod:`gridfs` -- Tools for working with GridFS 2 | ============================================== 3 | 4 | .. automodule:: gridfs 5 | :synopsis: Tools for working with GridFS 6 | :members: GridFS, GridFSBucket 7 | 8 | Sub-modules: 9 | 10 | .. toctree:: 11 | :maxdepth: 3 12 | 13 | asynchronous/index 14 | errors 15 | grid_file 16 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/srvMaxHosts-less_than_srv_records.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=1", 3 | "numSeeds": 1, 4 | "hosts": [ 5 | "localhost:27017", 6 | "localhost:27018", 7 | "localhost:27019" 8 | ], 9 | "options": { 10 | "srvMaxHosts": 1, 11 | "ssl": true 12 | }, 13 | "ping": true 14 | } 15 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-maxServerVersion-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-maxServerVersion-type", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [ 5 | { 6 | "maxServerVersion": 0 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-minServerVersion-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-minServerVersion-type", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [ 5 | { 6 | "minServerVersion": 0 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-stream-id-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-stream-id-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "stream": { 7 | "hexBytes": "FF" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /.evergreen/scripts/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Clean up resources at the end of an evergreen run. 3 | set -eu 4 | 5 | HERE=$(dirname ${BASH_SOURCE:-$0}) 6 | 7 | # Try to source the env file. 8 | if [ -f $HERE/env.sh ]; then 9 | echo "Sourcing env file" 10 | source $HERE/env.sh 11 | fi 12 | 13 | rm -rf "${DRIVERS_TOOLS}" || true 14 | rm -f $HERE/../../secrets-export.sh || true 15 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | groups: 9 | actions: 10 | patterns: 11 | - "*" 12 | # Python 13 | - package-ecosystem: "pip" 14 | directory: "/" 15 | schedule: 16 | interval: "weekly" 17 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-topologies-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-topologies-items", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [ 5 | { 6 | "topologies": [ 7 | 0 8 | ] 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /doc/api/pymongo/server_description.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | :mod:`server_description` -- An object representation of a server the driver is connected to. 4 | ============================================================================================= 5 | 6 | .. automodule:: pymongo.server_description 7 | 8 | .. autoclass:: pymongo.server_description.ServerDescription() 9 | :members: 10 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-stream-hexBytes-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-stream-hexBytes-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "stream": { 7 | "id": "stream0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-maxServerVersion-pattern.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-maxServerVersion-pattern", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [ 5 | { 6 | "maxServerVersion": "1.2.3.4" 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-minServerVersion-pattern.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-minServerVersion-pattern", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [ 5 | { 6 | "minServerVersion": "1.2.3.4" 7 | } 8 | ], 9 | "tests": [ 10 | { 11 | "description": "foo", 12 | "operations": [] 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-topologies-enum.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-topologies-enum", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [ 5 | { 6 | "topologies": [ 7 | "foo" 8 | ] 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /doc/api/pymongo/server_api.rst: -------------------------------------------------------------------------------- 1 | :mod:`server_api` -- Support for MongoDB Stable API 2 | ====================================================== 3 | 4 | .. automodule:: pymongo.server_api 5 | :synopsis: Support for MongoDB Stable API 6 | 7 | .. autoclass:: pymongo.server_api.ServerApi 8 | :members: 9 | 10 | .. autoclass:: pymongo.server_api.ServerApiVersion 11 | :members: 12 | -------------------------------------------------------------------------------- /doc/api/pymongo/topology_description.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | :mod:`topology_description` -- An object representation of a deployment of MongoDB servers. 4 | =========================================================================================== 5 | 6 | .. automodule:: pymongo.topology_description 7 | 8 | .. autoclass:: pymongo.topology_description.TopologyDescription() 9 | :members: 10 | -------------------------------------------------------------------------------- /test/client-side-encryption/limits/limits-encryptedFields.json: -------------------------------------------------------------------------------- 1 | { 2 | "fields": [ 3 | { 4 | "keyId": { 5 | "$binary": { 6 | "base64": "LOCALAAAAAAAAAAAAAAAAA==", 7 | "subType": "04" 8 | } 9 | }, 10 | "path": "foo", 11 | "bsonType": "string" 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-stream-id-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-stream-id-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "stream": { 7 | "id": 0, 8 | "hexBytes": "FF" 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /doc/api/gridfs/asynchronous/index.rst: -------------------------------------------------------------------------------- 1 | :mod:`gridfs async` -- Async tools for working with GridFS 2 | ========================================================== 3 | 4 | 5 | .. automodule:: gridfs.asynchronous 6 | :synopsis: Async tools for working with GridFS 7 | :members: AsyncGridFS, AsyncGridFSBucket 8 | 9 | Sub-modules: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | grid_file 15 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "runOnRequirements": [ 5 | { 6 | "minServerVersion": "4.0", 7 | "foo": 0 8 | } 9 | ], 10 | "tests": [ 11 | { 12 | "description": "foo", 13 | "operations": [] 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /test/srv_seedlist/load-balanced/srvMaxHosts-zero-txt.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test24.test.build.10gen.cc/?srvMaxHosts=0", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:8000" 5 | ], 6 | "hosts": [ 7 | "localhost.test.build.10gen.cc:8000" 8 | ], 9 | "options": { 10 | "loadBalanced": true, 11 | "srvMaxHosts": 0, 12 | "ssl": true 13 | }, 14 | "ping": true 15 | } 16 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/loadBalanced-false-txt.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test21.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 | "loadBalanced": false, 13 | "ssl": true 14 | }, 15 | "ping": true 16 | } 17 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-stream-hexBytes-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-stream-hexBytes-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "stream": { 7 | "id": "stream0", 8 | "hexBytes": 0 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | "ping": true 16 | } 17 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-serverApi-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-serverApi-type", 3 | "schemaVersion": "1.1", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "serverApi": 0 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-uriOptions-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-uriOptions-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "uriOptions": 0 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/srv_seedlist/load-balanced/srvMaxHosts-zero.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test23.test.build.10gen.cc/?loadBalanced=true&srvMaxHosts=0", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:8000" 5 | ], 6 | "hosts": [ 7 | "localhost.test.build.10gen.cc:8000" 8 | ], 9 | "options": { 10 | "loadBalanced": true, 11 | "srvMaxHosts": 0, 12 | "ssl": true 13 | }, 14 | "ping": true 15 | } 16 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | "ping": true 16 | } 17 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "foo": 0 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-stream-hexBytes-pattern.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-stream-hexBytes-pattern", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "stream": { 7 | "id": "stream0", 8 | "hexBytes": "FFF" 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/uri-with-uppercase-hostname.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://TEST1.TEST.BUILD.10GEN.CC", 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 | "ssl": true 14 | }, 15 | "ping": true 16 | } 17 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-observeEvents-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-observeEvents-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "observeEvents": 0 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-thread-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-thread-additionalProperties", 3 | "schemaVersion": "1.10", 4 | "createEntities": [ 5 | { 6 | "thread": { 7 | "id": "thread0", 8 | "foo": "bar" 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/valid-fail/entity-bucket-database-undefined.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-bucket-database-undefined", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "bucket": { 7 | "id": "bucket0", 8 | "database": "foo" 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/valid-fail/entity-session-client-undefined.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-session-client-undefined", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "session": { 7 | "id": "session0", 8 | "client": "foo" 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/direct-connection-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test3.test.build.10gen.cc/?directConnection=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 | "ssl": true, 13 | "directConnection": false 14 | }, 15 | "ping": true 16 | } 17 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | "ping": true 17 | } 18 | -------------------------------------------------------------------------------- /test/srv_seedlist/load-balanced/loadBalanced-directConnection.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test24.test.build.10gen.cc/?directConnection=false", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:8000" 5 | ], 6 | "hosts": [ 7 | "localhost.test.build.10gen.cc:8000" 8 | ], 9 | "options": { 10 | "loadBalanced": true, 11 | "ssl": true, 12 | "directConnection": false 13 | }, 14 | "ping": true 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-observeEvents-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-observeEvents-minItems", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "observeEvents": [] 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.evergreen/combine-coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Coverage combine merges (and removes) all the coverage files and 4 | # generates a new .coverage file in the current directory. 5 | 6 | set -eu 7 | 8 | # Set up the virtual env. 9 | . .evergreen/scripts/setup-dev-env.sh 10 | uv sync --group coverage 11 | source .venv/bin/activate 12 | 13 | ls -la coverage/ 14 | 15 | coverage combine coverage/coverage.* 16 | coverage html -d htmlcov 17 | -------------------------------------------------------------------------------- /.evergreen/scripts/stop-server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Stop a server that was started using run-orchestration.sh in DRIVERS_TOOLS. 3 | set -eu 4 | 5 | HERE=$(dirname ${BASH_SOURCE:-$0}) 6 | HERE="$( cd -- "$HERE" > /dev/null 2>&1 && pwd )" 7 | 8 | # Try to source the env file. 9 | if [ -f $HERE/env.sh ]; then 10 | echo "Sourcing env file" 11 | source $HERE/env.sh 12 | fi 13 | 14 | bash ${DRIVERS_TOOLS}/.evergreen/stop-orchestration.sh 15 | -------------------------------------------------------------------------------- /test/server_selection/server_selection/Unknown/read/ghost.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Unknown", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "RSGhost" 9 | } 10 | ] 11 | }, 12 | "operation": "read", 13 | "read_preference": { 14 | "mode": "Nearest" 15 | }, 16 | "suitable_servers": [], 17 | "in_latency_window": [] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-observeLogMessages-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-observeLogMessages-type", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "observeLogMessages": 0 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-serverApi-version-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-serverApi-version-required", 3 | "schemaVersion": "1.1", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "serverApi": {} 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/connection_monitoring/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 | -------------------------------------------------------------------------------- /test/server_selection/server_selection/Unknown/write/ghost.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "Unknown", 4 | "servers": [ 5 | { 6 | "address": "a:27017", 7 | "avg_rtt_ms": 5, 8 | "type": "RSGhost" 9 | } 10 | ] 11 | }, 12 | "operation": "write", 13 | "read_preference": { 14 | "mode": "Nearest" 15 | }, 16 | "suitable_servers": [], 17 | "in_latency_window": [] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-useMultipleMongoses-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-useMultipleMongoses-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "useMultipleMongoses": 0 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-csfle-minLibmongocryptVersion-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-csfle-minLibmongocryptVersion-type", 3 | "schemaVersion": "1.25", 4 | "runOnRequirements": [ 5 | { 6 | "csfle": { 7 | "minLibmongocryptVersion": 0 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-clientEncryption-clientEncryptionOpts-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-clientEncryption-clientEncryptionOpts-required", 3 | "schemaVersion": "1.8", 4 | "createEntities": [ 5 | { 6 | "clientEncryption": { 7 | "id": "clientEncryption0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "", 14 | "operations": [] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-stream-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-stream-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "stream": { 7 | "id": "stream0", 8 | "hexBytes": "FF", 9 | "foo": 0 10 | } 11 | } 12 | ], 13 | "tests": [ 14 | { 15 | "description": "foo", 16 | "operations": [] 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-name-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-name-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "object": "client0" 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-object-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-object-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo" 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /test/client-side-encryption/custom/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "ssn": { 4 | "encrypt": { 5 | "keyId": [{ 6 | "$binary": { 7 | "base64": "YWFhYWFhYWFhYWFhYWFhYQ==", 8 | "subType": "04" 9 | } 10 | }], 11 | "bsonType": "string", 12 | "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" 13 | } 14 | } 15 | }, 16 | "bsonType": "object" 17 | } 18 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | "ping": true 17 | } 18 | -------------------------------------------------------------------------------- /test/srv_seedlist/sharded/srvMaxHosts-zero.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=0", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27017", 5 | "localhost.test.build.10gen.cc:27018" 6 | ], 7 | "hosts": [ 8 | "localhost.test.build.10gen.cc:27017", 9 | "localhost.test.build.10gen.cc:27018" 10 | ], 11 | "options": { 12 | "srvMaxHosts": 0, 13 | "ssl": true 14 | }, 15 | "ping": true 16 | } 17 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-observeEvents-enum.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-observeEvents-enum", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "observeEvents": [ 9 | "foo" 10 | ] 11 | } 12 | } 13 | ], 14 | "tests": [ 15 | { 16 | "description": "foo", 17 | "operations": [] 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-observeEvents-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-observeEvents-items", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "observeEvents": [ 9 | 0 10 | ] 11 | } 12 | } 13 | ], 14 | "tests": [ 15 | { 16 | "description": "foo", 17 | "operations": [] 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-observeLogMessages-minProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-observeLogMessages-minProperties", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "observeLogMessages": {} 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-observeSensitiveCommands-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-observeSensitiveCommands-type", 3 | "schemaVersion": "1.5", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "observeSensitiveCommands": 0 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/runOnRequirement-csfle-minLibmongocryptVersion-pattern.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "runOnRequirement-csfle-minLibmongocryptVersion-pattern", 3 | "schemaVersion": "1.25", 4 | "runOnRequirements": [ 5 | { 6 | "csfle": { 7 | "minLibmongocryptVersion": "1.2.3.4" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/connection_monitoring/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 | -------------------------------------------------------------------------------- /test/unified-test-format/valid-fail/entity-database-client-undefined.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-database-client-undefined", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "database": { 7 | "id": "database0", 8 | "client": "foo", 9 | "databaseName": "foo" 10 | } 11 | } 12 | ], 13 | "tests": [ 14 | { 15 | "description": "foo", 16 | "operations": [] 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | "ping": true 17 | } 18 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/txt-record-with-overridden-uri-option.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://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 | "ping": true 17 | } 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-serverApi-version-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-serverApi-version-type", 3 | "schemaVersion": "1.1", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "serverApi": { 9 | "version": 0 10 | } 11 | } 12 | } 13 | ], 14 | "tests": [ 15 | { 16 | "description": "foo", 17 | "operations": [] 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-name-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-name-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": 0, 17 | "object": "client0" 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-object-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-object-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": 0 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/srvMaxHosts-greater_than_srv_records.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=3", 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 | "srvMaxHosts": 3, 14 | "ssl": true 15 | }, 16 | "ping": true 17 | } 18 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/srvMaxHosts-zero-txt.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test5.test.build.10gen.cc/?srvMaxHosts=0", 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 | "authSource": "thisDB", 13 | "replicaSet": "repl0", 14 | "srvMaxHosts": 0, 15 | "ssl": true 16 | }, 17 | "ping": true 18 | } 19 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | "ping": true 17 | } 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-ignoreCommandMonitoringEvents-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-ignoreCommandMonitoringEvents-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "ignoreCommandMonitoringEvents": 0 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-session-id-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-session-id-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "session": { 12 | "client": "client0" 13 | } 14 | } 15 | ], 16 | "tests": [ 17 | { 18 | "description": "foo", 19 | "operations": [] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/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": 21 10 | } 11 | ] 12 | }, 13 | "read_preference": { 14 | "mode": "Nearest", 15 | "maxStalenessSeconds": 1 16 | }, 17 | "suitable_servers": [], 18 | "in_latency_window": [] 19 | } 20 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/srv-service-name.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test22.test.build.10gen.cc/?srvServiceName=customname", 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 | "ssl": true, 14 | "srvServiceName": "customname" 15 | }, 16 | "ping": true 17 | } 18 | -------------------------------------------------------------------------------- /test/srv_seedlist/sharded/srvMaxHosts-greater_than_srv_records.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=3", 3 | "seeds": [ 4 | "localhost.test.build.10gen.cc:27017", 5 | "localhost.test.build.10gen.cc:27018" 6 | ], 7 | "hosts": [ 8 | "localhost.test.build.10gen.cc:27017", 9 | "localhost.test.build.10gen.cc:27018" 10 | ], 11 | "options": { 12 | "srvMaxHosts": 3, 13 | "ssl": true 14 | }, 15 | "ping": true 16 | } 17 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-ignoreCommandMonitoringEvents-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-ignoreCommandMonitoringEvents-minItems", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "ignoreCommandMonitoringEvents": [] 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "foo", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-session-client-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-session-client-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "session": { 12 | "id": "session0" 13 | } 14 | } 15 | ], 16 | "tests": [ 17 | { 18 | "description": "foo", 19 | "operations": [] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/unified-test-format/valid-fail/entity-collection-database-undefined.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-collection-database-undefined", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "collection": { 7 | "id": "collection0", 8 | "database": "foo", 9 | "collectionName": "foo" 10 | } 11 | } 12 | ], 13 | "tests": [ 14 | { 15 | "description": "foo", 16 | "operations": [] 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /test/max_staleness/ReplicaSetNoPrimary/MaxStalenessTooSmall.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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-clientEncryption-clientEncryptionOpts-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-clientEncryption-clientEncryptionOpts-type", 3 | "schemaVersion": "1.8", 4 | "createEntities": [ 5 | { 6 | "clientEncryption": { 7 | "id": "clientEncryption0", 8 | "clientEncryptionOpts": 0 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "", 15 | "operations": [] 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-session-id-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-session-id-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "session": { 12 | "id": 0, 13 | "client": "client0" 14 | } 15 | } 16 | ], 17 | "tests": [ 18 | { 19 | "description": "foo", 20 | "operations": [] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /doc/static/periodic-executor-refs.dot: -------------------------------------------------------------------------------- 1 | digraph "Monitor and PeriodicExecutor" { 2 | // Strong references. 3 | topology -> server 4 | server -> monitor 5 | monitor -> executor 6 | executor -> "target()" 7 | "target()" -> self_ref 8 | thread -> "target()" 9 | 10 | // Weak references 11 | edge [style="dashed"]; 12 | 13 | self_ref -> monitor [curved=true] 14 | monitor -> topology 15 | executor -> thread 16 | _EXECUTORS -> executor 17 | } 18 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/srvMaxHosts-equal_to_srv_records.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2", 3 | "numSeeds": 2, 4 | "seeds": [ 5 | "localhost.test.build.10gen.cc:27017", 6 | "localhost.test.build.10gen.cc:27018" 7 | ], 8 | "hosts": [ 9 | "localhost:27017", 10 | "localhost:27018", 11 | "localhost:27019" 12 | ], 13 | "options": { 14 | "srvMaxHosts": 2, 15 | "ssl": true 16 | }, 17 | "ping": true 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-session-client-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-session-client-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "session": { 12 | "id": "session0", 13 | "client": 0 14 | } 15 | } 16 | ], 17 | "tests": [ 18 | { 19 | "description": "foo", 20 | "operations": [] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/srv_seedlist/sharded/srvMaxHosts-equal_to_srv_records.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/?srvMaxHosts=2", 3 | "numSeeds": 2, 4 | "seeds": [ 5 | "localhost.test.build.10gen.cc:27017", 6 | "localhost.test.build.10gen.cc:27018" 7 | ], 8 | "hosts": [ 9 | "localhost.test.build.10gen.cc:27017", 10 | "localhost.test.build.10gen.cc:27018" 11 | ], 12 | "options": { 13 | "srvMaxHosts": 2, 14 | "ssl": true 15 | }, 16 | "ping": true 17 | } 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-serverApi-strict-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-serverApi-version-type", 3 | "schemaVersion": "1.1", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "serverApi": { 9 | "version": "1", 10 | "strict": 0 11 | } 12 | } 13 | } 14 | ], 15 | "tests": [ 16 | { 17 | "description": "foo", 18 | "operations": [] 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/srvMaxHosts-zero.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/?replicaSet=repl0&srvMaxHosts=0", 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 | "srvMaxHosts": 0, 15 | "ssl": true 16 | }, 17 | "ping": true 18 | } 19 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-ignoreCommandMonitoringEvents-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-ignoreCommandMonitoringEvents-items", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "ignoreCommandMonitoringEvents": [ 9 | 0 10 | ] 11 | } 12 | } 13 | ], 14 | "tests": [ 15 | { 16 | "description": "foo", 17 | "operations": [] 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-observeLogMessages-property-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-observeLogMessages-property-type", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "observeLogMessages": { 9 | "command": {} 10 | } 11 | } 12 | } 13 | ], 14 | "tests": [ 15 | { 16 | "description": "foo", 17 | "operations": [] 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedEventsForClient-client-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedEventsForClient-client-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "events": [] 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-database-id-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-database-id-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "client": "client0", 13 | "databaseName": "foo" 14 | } 15 | } 16 | ], 17 | "tests": [ 18 | { 19 | "description": "foo", 20 | "operations": [] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-maxProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-maxProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | }, 9 | "database": { 10 | "id": "database0", 11 | "client": "client0", 12 | "databaseName": "foo" 13 | } 14 | } 15 | ], 16 | "tests": [ 17 | { 18 | "description": "foo", 19 | "operations": [] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/bson_corpus/undefined.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Undefined type (deprecated)", 3 | "bson_type": "0x06", 4 | "deprecated": true, 5 | "test_key": "a", 6 | "valid": [ 7 | { 8 | "description": "Undefined", 9 | "canonical_bson": "0800000006610000", 10 | "canonical_extjson": "{\"a\" : {\"$undefined\" : true}}", 11 | "converted_bson": "080000000A610000", 12 | "converted_extjson": "{\"a\" : null}" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-observeLogMessages-property-value.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-observeLogMessages-property-type", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "observeLogMessages": { 9 | "command": "notALogLevel" 10 | } 11 | } 12 | } 13 | ], 14 | "tests": [ 15 | { 16 | "description": "foo", 17 | "operations": [] 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedEventsForClient-events-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedEventsForClient-events-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": "client0" 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-arguments-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-arguments-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "arguments": 0 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/valid-fail/operation-unsupported.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-unsupported", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "Unsupported operation", 14 | "operations": [ 15 | { 16 | "name": "unsupportedOperation", 17 | "object": "client0" 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/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": 90 18 | }, 19 | "suitable_servers": [], 20 | "in_latency_window": [] 21 | } 22 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-database-client-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-database-client-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "databaseName": "foo" 14 | } 15 | } 16 | ], 17 | "tests": [ 18 | { 19 | "description": "foo", 20 | "operations": [] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "foo": 0 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-expectError-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-expectError-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": 0 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/valid-fail/entity-client-apiVersion-unsupported.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-apiVersion-unsupported", 3 | "schemaVersion": "1.1", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "serverApi": { 9 | "version": "server_will_never_support_this_api_version" 10 | } 11 | } 12 | } 13 | ], 14 | "tests": [ 15 | { 16 | "description": "foo", 17 | "operations": [] 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /.evergreen/setup-spawn-host.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Set up a remote evergreen spawn host. 3 | set -eu 4 | 5 | if [ -z "$1" ] 6 | then 7 | echo "Must supply a spawn host URL!" 8 | fi 9 | 10 | target=$1 11 | user=${target%@*} 12 | remote_dir=/home/$user/mongo-python-driver 13 | 14 | echo "Copying files to $target..." 15 | rsync -az -e ssh --exclude '.git' --filter=':- .gitignore' -r . $target:$remote_dir 16 | echo "Copying files to $target... done" 17 | 18 | ssh $target "$remote_dir/.evergreen/scripts/setup-system.sh" 19 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/dbname-with-commas.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/some,db?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 | "defaultDatabase": "some,db" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | "ping": true, 16 | "comment": "Is correct, as returned host name shared the URI root \"test.build.10gen.cc\"." 17 | } 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-client-serverApi-deprecationErrors-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-client-serverApi-version-type", 3 | "schemaVersion": "1.1", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "serverApi": { 9 | "version": "1", 10 | "deprecationErrors": 0 11 | } 12 | } 13 | } 14 | ], 15 | "tests": [ 16 | { 17 | "description": "foo", 18 | "operations": [] 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-database-id-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-database-id-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": 0, 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | } 17 | ], 18 | "tests": [ 19 | { 20 | "description": "foo", 21 | "operations": [] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-minProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-minProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": {} 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedEventsForClient-client-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedEventsForClient-client-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": 0, 18 | "events": [] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessagesForClient-client-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessagesForClient-client-required", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "messages": [] 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-expectEvents-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-expectEvents-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectEvents": 0 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-database-databaseName-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-database-databaseName-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0" 14 | } 15 | } 16 | ], 17 | "tests": [ 18 | { 19 | "description": "foo", 20 | "operations": [] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/dbname-with-commas-escaped.json: -------------------------------------------------------------------------------- 1 | { 2 | "uri": "mongodb+srv://test1.test.build.10gen.cc/some%2Cdb?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 | "defaultDatabase": "some,db" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-database-client-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-database-client-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": 0, 14 | "databaseName": "foo" 15 | } 16 | } 17 | ], 18 | "tests": [ 19 | { 20 | "description": "foo", 21 | "operations": [] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedEventsForClient-events-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedEventsForClient-events-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": "client0", 18 | "events": 0 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessagesForClient-messages-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessagesForClient-messages-required", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0" 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessagesForClient-client-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedEventsForClient-client-type", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": 0, 18 | "messages": [] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-ignoreResultAndError-conflicts_with_expectResult.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-ignoreResultAndError-conflicts_with_expectResult", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "ignoreResultAndError used with expectResult", 7 | "operations": [ 8 | { 9 | "name": "foo", 10 | "object": "bar", 11 | "ignoreResultAndError": true, 12 | "expectResult": 1 13 | } 14 | ] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-saveResultAsEntity-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-saveResultAsEntity-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "saveResultAsEntity": 0 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/mypy_fails/raw_bson_document.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from bson.raw_bson import RawBSONDocument 4 | from pymongo import MongoClient 5 | 6 | client = MongoClient(document_class=RawBSONDocument) 7 | coll = client.test.test 8 | doc = {"my": "doc"} 9 | coll.insert_one(doc) 10 | retrieved = coll.find_one({"_id": doc["_id"]}) 11 | assert retrieved is not None 12 | assert len(retrieved.raw) > 0 13 | retrieved[ 14 | "foo" 15 | ] = "bar" # error: Unsupported target for indexed assignment ("RawBSONDocument") [index] 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-session-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-session-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "session": { 12 | "id": "session0", 13 | "client": "client0", 14 | "foo": 0 15 | } 16 | } 17 | ], 18 | "tests": [ 19 | { 20 | "description": "foo", 21 | "operations": [] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | "ping": true 20 | } 21 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-database-databaseName-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-database-databaseName-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": 0 15 | } 16 | } 17 | ], 18 | "tests": [ 19 | { 20 | "description": "foo", 21 | "operations": [] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /mypy_test.ini: -------------------------------------------------------------------------------- 1 | [mypy] 2 | strict = true 3 | show_error_codes = true 4 | disable_error_code = attr-defined, union-attr, var-annotated, assignment, no-redef, type-arg, import, no-untyped-call, no-untyped-def, index, no-any-return, misc 5 | exclude = (?x)( 6 | ^test/mypy_fails/*.*$ 7 | | ^test/conftest.py$ 8 | ) 9 | 10 | [mypy-pymongo.synchronous.*,gridfs.synchronous.*,test.*] 11 | warn_unused_ignores = false 12 | disable_error_code = unused-coroutine 13 | 14 | [mypy-pymongo.asynchronous.*,test.asynchronous.*] 15 | warn_unused_ignores = false 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-session-sessionOptions-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-session-sessionOptions-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "session": { 12 | "id": "session0", 13 | "client": "client0", 14 | "sessionOptions": 0 15 | } 16 | } 17 | ], 18 | "tests": [ 19 | { 20 | "description": "foo", 21 | "operations": [] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessagesForClient-messages-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessagesForClient-messages-type", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": 0 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /doc/api/gridfs/grid_file.rst: -------------------------------------------------------------------------------- 1 | :mod:`grid_file` -- Tools for representing files stored in GridFS 2 | ================================================================= 3 | 4 | .. automodule:: gridfs.grid_file 5 | :synopsis: Tools for representing files stored in GridFS 6 | 7 | .. autoclass:: GridIn 8 | :members: 9 | 10 | .. autoattribute:: _id 11 | 12 | .. autoclass:: GridOut 13 | :members: 14 | 15 | .. autoattribute:: _id 16 | .. automethod:: __iter__ 17 | 18 | .. autoclass:: GridOutCursor 19 | :members: 20 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-isError-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-isError-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "isError": 0 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCommandEvent-minProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCommandEvent-minProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": "client0", 18 | "events": [ 19 | {} 20 | ] 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedEventsForClient-events-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedEventsForClient-events-items", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": "client0", 18 | "events": [ 19 | 0 20 | ] 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/pytest_conf.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | 4 | def pytest_collection_modifyitems(items, config): 5 | # Markers that should overlap with the default markers. 6 | overlap_markers = ["async"] 7 | 8 | for item in items: 9 | if "asynchronous" in item.fspath.dirname: 10 | default_marker = "default_async" 11 | else: 12 | default_marker = "default" 13 | markers = [m for m in item.iter_markers() if m not in overlap_markers] 14 | if not markers: 15 | item.add_marker(default_marker) 16 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-errorCode-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-errorCode-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "errorCode": "foo" 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-isError-const.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-isError-const", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "isError": false 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessage-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessage-additionalProperties", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [], 19 | "foo": 0 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-ignoreResultAndError-conflicts_with_saveResultAsEntity.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-ignoreResultAndError-conflicts_with_saveResultAsEntity", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "ignoreResultAndError used with saveResultAsEntity", 7 | "operations": [ 8 | { 9 | "name": "foo", 10 | "object": "bar", 11 | "ignoreResultAndError": true, 12 | "saveResultAsEntity": "entity0" 13 | } 14 | ] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "foo": 0 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedEventsForClient-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedEventsForClient-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": "client0", 18 | "events": [], 19 | "foo": 0 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-database-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-database-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo", 15 | "foo": 0 16 | } 17 | } 18 | ], 19 | "tests": [ 20 | { 21 | "description": "foo", 22 | "operations": [] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-errorCodeName-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-errorCodeName-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "errorCodeName": 0 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-errorContains-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-errorContains-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "errorContains": 0 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-errorResponse-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-errorResponse-type", 3 | "schemaVersion": "1.12", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "errorResponse": 0 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-isClientError-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-isClientError-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "isClientError": 0 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /.evergreen/spec-patch/PYTHON-3712.patch: -------------------------------------------------------------------------------- 1 | diff --git a/test/discovery_and_monitoring/unified/serverMonitoringMode.json b/test/discovery_and_monitoring/unified/serverMonitoringMode.json 2 | index e44fad1b..4b492f7d 100644 3 | --- a/test/discovery_and_monitoring/unified/serverMonitoringMode.json 4 | +++ b/test/discovery_and_monitoring/unified/serverMonitoringMode.json 5 | @@ -5,7 +5,8 @@ 6 | { 7 | "topologies": [ 8 | "single", 9 | - "sharded" 10 | + "sharded", 11 | + "sharded-replicaset" 12 | ], 13 | "serverless": "forbid" 14 | } 15 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-errorLabelsOmit-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-errorLabelsOmit-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "errorLabelsOmit": 0 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-isTimeoutError-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-isTimeoutError-type", 3 | "schemaVersion": "1.9", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "isTimeoutError": 0 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedEventsForClient-eventType-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedEventsForClient-eventType-type", 3 | "schemaVersion": "1.3", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "invalid eventType type", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": "client0", 18 | "eventType": 10, 19 | "events": [] 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-ignoreResultAndError-conflicts_with_expectError.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-ignoreResultAndError-conflicts_with_expectError", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "ignoreResultAndError used with expectError", 7 | "operations": [ 8 | { 9 | "name": "foo", 10 | "object": "bar", 11 | "ignoreResultAndError": true, 12 | "expectError": { 13 | "isError": true 14 | } 15 | } 16 | ] 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /doc/api/pymongo/asynchronous/index.rst: -------------------------------------------------------------------------------- 1 | :mod:`pymongo async` -- Async Python driver for MongoDB 2 | ======================================================= 3 | 4 | 5 | .. automodule:: pymongo.asynchronous 6 | :synopsis: Asynchronous Python driver for MongoDB 7 | 8 | .. data:: AsyncMongoClient 9 | 10 | Alias for :class:`pymongo.asynchronous.mongo_client.MongoClient`. 11 | 12 | Sub-modules: 13 | 14 | .. toctree:: 15 | :maxdepth: 2 16 | 17 | change_stream 18 | client_session 19 | collection 20 | command_cursor 21 | cursor 22 | database 23 | mongo_client 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-database-databaseOptions-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-database-databaseOptions-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo", 15 | "databaseOptions": 0 16 | } 17 | } 18 | ], 19 | "tests": [ 20 | { 21 | "description": "foo", 22 | "operations": [] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedEventsForClient-eventType-enum.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedEventsForClient-eventType-enum", 3 | "schemaVersion": "1.3", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "invalid eventType value", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": "client0", 18 | "eventType": "foo", 19 | "events": [] 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedEventsForClient-ignoreExtraEvents-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedEventsForClient-ignoreExtraEvents-type", 3 | "schemaVersion": "1.7", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": "client0", 18 | "events": [], 19 | "ignoreExtraEvents": 0 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessagesForClient-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessagesForClient-additionalProperties", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [], 19 | "foo": 0 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessagesForClient-messages-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessagesForClient-messages-items", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [ 19 | 0 20 | ] 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /.evergreen/run-mongodb-oidc-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Script run on a remote host to test MONGODB-OIDC. 3 | set -eu 4 | 5 | echo "Running MONGODB-OIDC authentication tests on ${OIDC_ENV}..." 6 | 7 | if [ ${OIDC_ENV} == "k8s" ]; then 8 | SUB_TEST_NAME=$K8S_VARIANT-remote 9 | else 10 | SUB_TEST_NAME=$OIDC_ENV-remote 11 | sudo apt-get install -y python3-dev build-essential 12 | fi 13 | 14 | bash ./.evergreen/just.sh setup-tests auth_oidc $SUB_TEST_NAME 15 | bash ./.evergreen/just.sh run-tests "${@:1}" 16 | 17 | echo "Running MONGODB-OIDC authentication tests on ${OIDC_ENV}... done." 18 | -------------------------------------------------------------------------------- /doc/api/index.rst: -------------------------------------------------------------------------------- 1 | API Documentation 2 | ================= 3 | 4 | The PyMongo distribution contains three top-level packages for 5 | interacting with MongoDB. :mod:`bson` is an implementation of the 6 | `BSON format `_, :mod:`pymongo` is a 7 | full-featured driver for MongoDB, and :mod:`gridfs` is a set of tools 8 | for working with the `GridFS 9 | `_ storage 10 | specification. 11 | 12 | .. toctree:: 13 | :maxdepth: 2 14 | 15 | bson/index 16 | pymongo/index 17 | gridfs/index 18 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-errorLabelsContain-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-errorLabelsContain-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "errorLabelsContain": 0 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-errorLabelsOmit-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-errorLabelsOmit-minItems", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "errorLabelsOmit": [] 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/mypy_fails/typedict_client.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from typing import TypedDict 4 | 5 | from pymongo import MongoClient 6 | 7 | 8 | class Movie(TypedDict): 9 | name: str 10 | year: int 11 | 12 | 13 | client: MongoClient[Movie] = MongoClient() 14 | coll = client.test.test 15 | retrieved = coll.find_one({"_id": "foo"}) 16 | assert retrieved is not None 17 | assert retrieved["year"] == 1 18 | assert ( 19 | retrieved["name"] == 2 20 | ) # error: Non-overlapping equality check (left operand type: "str", right operand type: "Literal[2]") [comparison-overlap] 21 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessagesForClient-ignoreMessages-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessagesForClient-ignoreMessages-type", 3 | "schemaVersion": "1.16", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [], 19 | "ignoreMessages": 0 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/zizmor.yml: -------------------------------------------------------------------------------- 1 | name: GitHub Actions Security Analysis with zizmor 🌈 2 | 3 | on: 4 | push: 5 | branches: ["master"] 6 | pull_request: 7 | branches: ["**"] 8 | 9 | jobs: 10 | zizmor: 11 | name: zizmor latest via Cargo 12 | runs-on: ubuntu-latest 13 | permissions: 14 | security-events: write 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v6 18 | with: 19 | persist-credentials: false 20 | - name: Run zizmor 🌈 21 | uses: zizmorcore/zizmor-action@cb3d8e846e148d1111d90b03375b9c03deceda37 22 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-errorLabelsContain-minItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-errorLabelsContain-minItems", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "errorLabelsContain": [] 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /doc/api/gridfs/asynchronous/grid_file.rst: -------------------------------------------------------------------------------- 1 | :mod:`grid_file` -- Async tools for representing files stored in GridFS 2 | ======================================================================= 3 | 4 | .. automodule:: gridfs.asynchronous.grid_file 5 | :synopsis: Async tools for representing files stored in GridFS 6 | 7 | .. autoclass:: AsyncGridIn 8 | :members: 9 | 10 | .. autoattribute:: _id 11 | 12 | .. autoclass:: AsyncGridOut 13 | :members: 14 | 15 | .. autoattribute:: _id 16 | .. automethod:: __aiter__ 17 | 18 | .. autoclass:: AsyncGridOutCursor 19 | :members: 20 | -------------------------------------------------------------------------------- /test/client-side-encryption/etc/data/lookup/schema-qe.json: -------------------------------------------------------------------------------- 1 | { 2 | "escCollection": "enxcol_.qe.esc", 3 | "ecocCollection": "enxcol_.qe.ecoc", 4 | "fields": [ 5 | { 6 | "keyId": { 7 | "$binary": { 8 | "base64": "EjRWeBI0mHYSNBI0VniQEg==", 9 | "subType": "04" 10 | } 11 | }, 12 | "path": "qe", 13 | "bsonType": "string", 14 | "queries": { 15 | "queryType": "equality", 16 | "contention": 0 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | "options": { 13 | "replicaSet": "repl0", 14 | "ssl": true 15 | }, 16 | "parsed_options": { 17 | "user": "auser", 18 | "password": "apass" 19 | }, 20 | "ping": false, 21 | "comment": "Should preserve auth credentials" 22 | } 23 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/clientEncryptionOpts-keyVaultClient-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "clientEncryptionOpts-keyVaultClient-required", 3 | "schemaVersion": "1.8", 4 | "createEntities": [ 5 | { 6 | "clientEncryption": { 7 | "id": "clientEncryption0", 8 | "clientEncryptionOpts": { 9 | "keyVaultNamespace": "keyvault.datakeys", 10 | "kmsProviders": { 11 | "aws": {} 12 | } 13 | } 14 | } 15 | } 16 | ], 17 | "tests": [ 18 | { 19 | "description": "", 20 | "operations": [] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/client-side-encryption/etc/data/lookup/schema-qe2.json: -------------------------------------------------------------------------------- 1 | { 2 | "escCollection": "enxcol_.qe2.esc", 3 | "ecocCollection": "enxcol_.qe2.ecoc", 4 | "fields": [ 5 | { 6 | "keyId": { 7 | "$binary": { 8 | "base64": "EjRWeBI0mHYSNBI0VniQEg==", 9 | "subType": "04" 10 | } 11 | }, 12 | "path": "qe2", 13 | "bsonType": "string", 14 | "queries": { 15 | "queryType": "equality", 16 | "contention": 0 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessagesForClient-ignoreExtraMessages-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessagesForClient-ignoreExtraMessages-type", 3 | "schemaVersion": "1.16", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "ignoreExtraMessages": "true", 19 | "messages": [] 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /.evergreen/scripts/perf-submission-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # We use the requester expansion to determine whether the data is from a mainline evergreen run or not 3 | 4 | set -eu 5 | 6 | # shellcheck disable=SC2154 7 | if [ "${requester}" == "commit" ]; then 8 | echo "is_mainline: true" >> expansion.yml 9 | else 10 | echo "is_mainline: false" >> expansion.yml 11 | fi 12 | 13 | # We parse the username out of the order_id as patches append that in and SPS does not need that information 14 | # shellcheck disable=SC2154 15 | echo "parsed_order_id: $(echo "${revision_order_id}" | awk -F'_' '{print $NF}')" >> expansion.yml 16 | -------------------------------------------------------------------------------- /test/client-side-encryption/external/external-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "encrypted": { 4 | "encrypt": { 5 | "keyId": [ 6 | { 7 | "$binary": { 8 | "base64": "LOCALAAAAAAAAAAAAAAAAA==", 9 | "subType": "04" 10 | } 11 | } 12 | ], 13 | "bsonType": "string", 14 | "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" 15 | } 16 | } 17 | }, 18 | "bsonType": "object" 19 | } 20 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-poolReadyEvent-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-poolReadyEvent-additionalProperties", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "poolReadyEvent": { 15 | "foo": "bar" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCommandEvent-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCommandEvent-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": "client0", 18 | "events": [ 19 | { 20 | "foo": 0 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-bucket-id-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-bucket-id-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | }, 17 | { 18 | "bucket": { 19 | "database": "database0" 20 | } 21 | } 22 | ], 23 | "tests": [ 24 | { 25 | "description": "foo", 26 | "operations": [] 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-connectionClosedEvent-reason-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-connectionClosedEvent-reason-type", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "connectionClosedEvent": { 15 | "reason": 10 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-poolClosedEvent-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-poolClosedEvent-additionalProperties", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "poolClosedEvent": { 15 | "foo": "bar" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-poolCreatedEvent-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-poolCreatedEvent-additionalProperties", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "poolCreatedEvent": { 15 | "foo": "bar" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-errorLabelsOmit-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-errorLabelsOmit-items", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "errorLabelsOmit": [ 20 | 0 21 | ] 22 | } 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/client-side-encryption/etc/data/lookup/schema-csfle.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "csfle": { 4 | "encrypt": { 5 | "keyId": [ 6 | { 7 | "$binary": { 8 | "base64": "EjRWeBI0mHYSNBI0VniQEg==", 9 | "subType": "04" 10 | } 11 | } 12 | ], 13 | "bsonType": "string", 14 | "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" 15 | } 16 | } 17 | }, 18 | "bsonType": "object" 19 | } 20 | -------------------------------------------------------------------------------- /test/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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-bucket-database-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-bucket-database-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | }, 17 | { 18 | "bucket": { 19 | "id": "bucket0" 20 | } 21 | } 22 | ], 23 | "tests": [ 24 | { 25 | "description": "foo", 26 | "operations": [] 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-poolClearedEvent-hasServiceId-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-poolClearedEvent-hasServiceId-type", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "poolClearedEvent": { 15 | "hasServiceId": "foo" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedError-errorLabelsContain-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedError-errorLabelsContain-items", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "errorLabelsContain": [ 20 | 0 21 | ] 22 | } 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /requirements/ocsp.txt: -------------------------------------------------------------------------------- 1 | # PyOpenSSL 17.0.0 introduced support for OCSP. 17.1.0 introduced 2 | # a related feature we need. 17.2.0 fixes a bug 3 | # in set_default_verify_paths we should really avoid. 4 | # service_identity 18.1.0 introduced support for IP addr matching. 5 | # Fallback to certifi on Windows if we can't load CA certs from the system 6 | # store and just use certifi on macOS. 7 | # https://www.pyopenssl.org/en/stable/api/ssl.html#OpenSSL.SSL.Context.set_default_verify_paths 8 | certifi>=2023.7.22;os.name=='nt' or sys_platform=='darwin' 9 | pyopenssl>=17.2.0 10 | requests<3.0.0 11 | cryptography>=2.5 12 | service_identity>=18.1.0 13 | -------------------------------------------------------------------------------- /test/client-side-encryption/etc/data/lookup/schema-csfle2.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "csfle2": { 4 | "encrypt": { 5 | "keyId": [ 6 | { 7 | "$binary": { 8 | "base64": "EjRWeBI0mHYSNBI0VniQEg==", 9 | "subType": "04" 10 | } 11 | } 12 | ], 13 | "bsonType": "string", 14 | "algorithm": "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic" 15 | } 16 | } 17 | }, 18 | "bsonType": "object" 19 | } 20 | -------------------------------------------------------------------------------- /test/discovery_and_monitoring/single/discover_unavailable_seed.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Discover unavailable seed", 3 | "uri": "mongodb://a/?directConnection=false", 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": "Unknown", 20 | "logicalSessionTimeoutMinutes": null, 21 | "setName": null 22 | } 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessagesForClient-ignoreMessages-items.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessagesForClient-ignoreMessages-items", 3 | "schemaVersion": "1.16", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [], 19 | "ignoreMessages": [ 20 | 0 21 | ] 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /test/srv_seedlist/replica-set/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 | "ping": false, 21 | "comment": "Encoded user, pass, and DB parse correctly" 22 | } 23 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-bucket-id-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-bucket-id-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | }, 17 | { 18 | "bucket": { 19 | "id": 0, 20 | "database": "database0" 21 | } 22 | } 23 | ], 24 | "tests": [ 25 | { 26 | "description": "foo", 27 | "operations": [] 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-connectionReadyEvent-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-connectionReadyEvent-additionalProperties", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "connectionReadyEvent": { 15 | "foo": "bar" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-expectError-conflicts_with_expectResult.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-expectError-conflicts_with_expectResult", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "isError": true 20 | }, 21 | "expectResult": {} 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yaml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Build documentation in the doc/ directory with Sphinx 9 | sphinx: 10 | configuration: doc/conf.py 11 | fail_on_warning: true 12 | 13 | # Set the version of Python and requirements required to build the docs. 14 | python: 15 | install: 16 | # Install pymongo itself. 17 | - method: pip 18 | path: . 19 | - requirements: requirements/docs.txt 20 | 21 | build: 22 | os: ubuntu-22.04 23 | tools: 24 | python: "3.11" 25 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/collectionOrDatabaseOptions-timeoutMS-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "collectionOrDatabaseOptions-timeoutMS-type", 3 | "schemaVersion": "1.9", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo", 15 | "databaseOptions": { 16 | "timeoutMS": 4.5 17 | } 18 | } 19 | } 20 | ], 21 | "tests": [ 22 | { 23 | "description": "foo", 24 | "operations": [] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-connectionCreatedEvent-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-connectionCreatedEvent-additionalProperties", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "connectionCreatedEvent": { 15 | "foo": "bar" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/connection_monitoring/pool-clear-paused.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "style": "unit", 4 | "description": "clearing a paused pool emits no events", 5 | "operations": [ 6 | { 7 | "name": "clear" 8 | }, 9 | { 10 | "name": "ready" 11 | }, 12 | { 13 | "name": "clear" 14 | }, 15 | { 16 | "name": "clear" 17 | } 18 | ], 19 | "events": [ 20 | { 21 | "type": "ConnectionPoolReady", 22 | "address": 42 23 | }, 24 | { 25 | "type": "ConnectionPoolCleared", 26 | "address": 42 27 | } 28 | ], 29 | "ignore": [ 30 | "ConnectionPoolCreated" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/collectionOrDatabaseOptions-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "collectionOrDatabaseOptions-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo", 15 | "databaseOptions": { 16 | "foo": 0 17 | } 18 | } 19 | } 20 | ], 21 | "tests": [ 22 | { 23 | "description": "foo", 24 | "operations": [] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/collectionOrDatabaseOptions-readConcern-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "collectionOrDatabaseOptions-readConcern-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo", 15 | "databaseOptions": { 16 | "readConcern": 0 17 | } 18 | } 19 | } 20 | ], 21 | "tests": [ 22 | { 23 | "description": "foo", 24 | "operations": [] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-bucket-database-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-bucket-database-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | }, 17 | { 18 | "bucket": { 19 | "id": "bucket0", 20 | "database": 0 21 | } 22 | } 23 | ], 24 | "tests": [ 25 | { 26 | "description": "foo", 27 | "operations": [] 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-connectionCheckOutFailedEvent-reason-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-connectionCheckOutFailedEvent-reason-type", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "connectionCheckOutFailedEvent": { 15 | "reason": 10 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-connectionCheckedInEvent-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-connectionCheckedInEvent-additionalProperties", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "connectionCheckedInEvent": { 15 | "foo": "bar" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /.evergreen/scripts/teardown-tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Tear down any services that were used by tests. 3 | set -eu 4 | 5 | SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0}) 6 | 7 | # Try to source the env file. 8 | if [ -f $SCRIPT_DIR/env.sh ]; then 9 | echo "Sourcing env inputs" 10 | . $SCRIPT_DIR/env.sh 11 | else 12 | echo "Not sourcing env inputs" 13 | fi 14 | 15 | # Handle test inputs. 16 | if [ -f $SCRIPT_DIR/test-env.sh ]; then 17 | echo "Sourcing test inputs" 18 | . $SCRIPT_DIR/test-env.sh 19 | else 20 | echo "Missing test inputs, please run 'just setup-tests'" 21 | fi 22 | 23 | # Teardown the test runner. 24 | uv run $SCRIPT_DIR/teardown_tests.py 25 | -------------------------------------------------------------------------------- /test/discovery_and_monitoring/single/direct_connection_unavailable_seed.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Direct connection to unavailable seed", 3 | "uri": "mongodb://a/?directConnection=true", 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 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/collectionOrDatabaseOptions-writeConcern-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "collectionOrDatabaseOptions-writeConcern-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo", 15 | "databaseOptions": { 16 | "writeConcern": 0 17 | } 18 | } 19 | } 20 | ], 21 | "tests": [ 22 | { 23 | "description": "foo", 24 | "operations": [] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-connectionCheckedOutEvent-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-connectionCheckedOutEvent-additionalProperties", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "connectionCheckedOutEvent": { 15 | "foo": "bar" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessage-component-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessage-component-type", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [ 19 | { 20 | "level": "debug", 21 | "data": {} 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessage-level-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessage-level-required", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [ 19 | { 20 | "component": "command", 21 | "data": {} 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /test/client-side-encryption/etc/data/range-encryptedFields-DoubleNoPrecision.json: -------------------------------------------------------------------------------- 1 | { 2 | "fields": [ 3 | { 4 | "keyId": { 5 | "$binary": { 6 | "base64": "EjRWeBI0mHYSNBI0VniQEg==", 7 | "subType": "04" 8 | } 9 | }, 10 | "path": "encryptedDoubleNoPrecision", 11 | "bsonType": "double", 12 | "queries": { 13 | "queryType": "range", 14 | "contention": { 15 | "$numberLong": "0" 16 | }, 17 | "trimFactor": { 18 | "$numberInt": "1" 19 | }, 20 | "sparsity": { 21 | "$numberLong": "1" 22 | } 23 | } 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "clientEncryptionOpts-kmsProviders-required", 3 | "schemaVersion": "1.8", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "clientEncryption": { 12 | "id": "clientEncryption0", 13 | "clientEncryptionOpts": { 14 | "keyVaultClient": "client0", 15 | "keyVaultNamespace": "keyvault.datakeys" 16 | } 17 | } 18 | } 19 | ], 20 | "tests": [ 21 | { 22 | "description": "", 23 | "operations": [] 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/collectionOrDatabaseOptions-readPreference-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "collectionOrDatabaseOptions-readPreference-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo", 15 | "databaseOptions": { 16 | "readPreference": 0 17 | } 18 | } 19 | } 20 | ], 21 | "tests": [ 22 | { 23 | "description": "foo", 24 | "operations": [] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessage-data-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessage-data-required", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [ 19 | { 20 | "level": "debug", 21 | "component": "command" 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/operation-expectError-conflicts_with_saveResultAsEntity.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "operation-expectError-conflicts_with_saveResultAsEntity", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [ 15 | { 16 | "name": "foo", 17 | "object": "client0", 18 | "expectError": { 19 | "isError": true 20 | }, 21 | "saveResultAsEntity": "foo" 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /test/client-side-encryption/etc/data/range-encryptedFields-DecimalNoPrecision.json: -------------------------------------------------------------------------------- 1 | { 2 | "fields": [ 3 | { 4 | "keyId": { 5 | "$binary": { 6 | "base64": "EjRWeBI0mHYSNBI0VniQEg==", 7 | "subType": "04" 8 | } 9 | }, 10 | "path": "encryptedDecimalNoPrecision", 11 | "bsonType": "decimal", 12 | "queries": { 13 | "queryType": "range", 14 | "contention": { 15 | "$numberLong": "0" 16 | }, 17 | "trimFactor": { 18 | "$numberInt": "1" 19 | }, 20 | "sparsity": { 21 | "$numberLong": "1" 22 | } 23 | } 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedSdamEvent-serverDescriptionChangedEvent-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedSdamEvent-serverDescriptionChangedEvent-additionalProperties", 3 | "schemaVersion": "1.10", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "sdam", 12 | "events": [ 13 | { 14 | "serverDescriptionChangedEvent": { 15 | "foo": "bar" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /doc/pydoctheme/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = default 3 | stylesheet = pydoctheme.css 4 | pygments_style = sphinx 5 | 6 | [options] 7 | bodyfont = 'Lucida Grande', Arial, sans-serif 8 | headfont = 'Lucida Grande', Arial, sans-serif 9 | footerbgcolor = white 10 | footertextcolor = #555555 11 | relbarbgcolor = white 12 | relbartextcolor = #666666 13 | relbarlinkcolor = #444444 14 | sidebarbgcolor = white 15 | sidebartextcolor = #444444 16 | sidebarlinkcolor = #444444 17 | bgcolor = white 18 | textcolor = #222222 19 | linkcolor = #0090c0 20 | visitedlinkcolor = #00608f 21 | headtextcolor = #1a1a1a 22 | headbgcolor = white 23 | headlinkcolor = #aaaaaa 24 | googletag = False 25 | -------------------------------------------------------------------------------- /integration_tests/test_uv_loop.py: -------------------------------------------------------------------------------- 1 | # /// script 2 | # dependencies = [ 3 | # "uvloop>=0.18" 4 | # ] 5 | # requires-python = ">=3.10" 6 | # /// 7 | from __future__ import annotations 8 | 9 | import sys 10 | from pathlib import Path 11 | 12 | import uvloop 13 | 14 | # Use pymongo from parent directory. 15 | root = Path(__file__).parent.parent 16 | sys.path.insert(0, str(root)) 17 | 18 | from test.asynchronous import async_simple_test_client # noqa: E402 19 | 20 | 21 | async def main(): 22 | async with async_simple_test_client() as client: 23 | result = await client.admin.command("ping") 24 | assert result["ok"] 25 | 26 | 27 | uvloop.run(main()) 28 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-connectionCheckOutStartedEvent-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-connectionCheckOutStartedEvent-additionalProperties", 3 | "schemaVersion": "1.3", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "connectionCheckOutStartedEvent": { 15 | "foo": "bar" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCmapEvent-poolClearedEvent-interruptInUseConnections-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCmapEvent-poolClearedEvent-interruptInUseConnections-type", 3 | "schemaVersion": "1.11", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "cmap", 12 | "events": [ 13 | { 14 | "poolClearedEvent": { 15 | "interruptInUseConnections": "foo" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedCommandEvent-maxProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedCommandEvent-maxProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": "client0", 18 | "events": [ 19 | { 20 | "commandStartedEvent": {}, 21 | "commandSucceededEvent": {} 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /doc/api/bson/index.rst: -------------------------------------------------------------------------------- 1 | :mod:`bson` -- BSON (Binary JSON) Encoding and Decoding 2 | ======================================================= 3 | 4 | .. automodule:: bson 5 | :synopsis: BSON (Binary JSON) Encoding and Decoding 6 | :members: BSON, decode, decode_all, decode_file_iter, decode_iter, encode, gen_list_name, has_c, is_valid 7 | 8 | Sub-modules: 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | binary 14 | code 15 | codec_options 16 | datetime_ms 17 | dbref 18 | decimal128 19 | errors 20 | int64 21 | json_util 22 | max_key 23 | min_key 24 | objectid 25 | raw_bson 26 | regex 27 | son 28 | timestamp 29 | tz_util 30 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-collection-id-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-collection-id-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | }, 17 | { 18 | "collection": { 19 | "database": "database0", 20 | "collectionName": "foo" 21 | } 22 | } 23 | ], 24 | "tests": [ 25 | { 26 | "description": "foo", 27 | "operations": [] 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedSdamEvent-topologyDescriptionChangedEvent-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedSdamEvent-topologyDescriptionChangedEvent-additionalProperties", 3 | "schemaVersion": "1.14", 4 | "tests": [ 5 | { 6 | "description": "foo", 7 | "operations": [], 8 | "expectEvents": [ 9 | { 10 | "client": "client0", 11 | "eventType": "sdam", 12 | "events": [ 13 | { 14 | "topologyDescriptionChangedEvent": { 15 | "foo": "bar" 16 | } 17 | } 18 | ] 19 | } 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /.evergreen/scripts/run-getdata.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Get the debug data for an evergreen task. 3 | set -eu 4 | 5 | . ${DRIVERS_TOOLS}/.evergreen/get-distro.sh || true 6 | get_distro || true 7 | echo $DISTRO 8 | echo $MARCH 9 | echo $OS 10 | 11 | set -x 12 | uname -a || true 13 | ls /etc/*release* || true 14 | cc --version || true 15 | gcc --version || true 16 | clang --version || true 17 | gcov --version || true 18 | lcov --version || true 19 | llvm-cov --version || true 20 | echo $PATH 21 | ls -la /usr/local/Cellar/llvm/*/bin/ || true 22 | ls -la /usr/local/Cellar/ || true 23 | scan-build --version || true 24 | genhtml --version || true 25 | valgrind --version || true 26 | set +x 27 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessage-data-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessage-data-type", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [ 19 | { 20 | "level": "debug", 21 | "component": "command", 22 | "data": 0 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessage-level-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessage-level-type", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [ 19 | { 20 | "level": 0, 21 | "component": "command", 22 | "data": {} 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-clientEncryption-id-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-clientEncryption-id-required", 3 | "schemaVersion": "1.8", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "clientEncryption": { 12 | "clientEncryptionOpts": { 13 | "keyVaultClient": "client0", 14 | "keyVaultNamespace": "keyvault.datakeys", 15 | "kmsProviders": { 16 | "aws": {} 17 | } 18 | } 19 | } 20 | } 21 | ], 22 | "tests": [ 23 | { 24 | "description": "", 25 | "operations": [] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-collection-database-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-collection-database-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | }, 17 | { 18 | "collection": { 19 | "id": "collection0", 20 | "collectionName": "foo" 21 | } 22 | } 23 | ], 24 | "tests": [ 25 | { 26 | "description": "foo", 27 | "operations": [] 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessage-component-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessage-component-type", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [ 19 | { 20 | "level": "debug", 21 | "component": 0, 22 | "data": {} 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessage-level-enum.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessage-level-enum", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [ 19 | { 20 | "level": "foo", 21 | "component": "command", 22 | "data": {} 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/clientEncryptionOpts-kmsProviders-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "clientEncryptionOpts-kmsProviders-type", 3 | "schemaVersion": "1.8", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "clientEncryption": { 12 | "id": "clientEncryption0", 13 | "clientEncryptionOpts": { 14 | "keyVaultClient": "client0", 15 | "keyVaultNamespace": "keyvault.datakeys", 16 | "kmsProviders": 0 17 | } 18 | } 19 | } 20 | ], 21 | "tests": [ 22 | { 23 | "description": "", 24 | "operations": [] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-collection-id-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-collection-id-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | }, 17 | { 18 | "collection": { 19 | "id": 0, 20 | "database": "database0", 21 | "collectionName": "foo" 22 | } 23 | } 24 | ], 25 | "tests": [ 26 | { 27 | "description": "foo", 28 | "operations": [] 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedLogMessage-component-enum.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedLogMessage-component-enum", 3 | "schemaVersion": "1.13", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "foo", 14 | "operations": [], 15 | "expectLogMessages": [ 16 | { 17 | "client": "client0", 18 | "messages": [ 19 | { 20 | "level": "debug", 21 | "component": "foo", 22 | "data": {} 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/clientEncryptionOpts-keyVaultNamespace-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "clientEncryptionOpts-keyVaultNamespace-required", 3 | "schemaVersion": "1.8", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "clientEncryption": { 12 | "id": "clientEncryption0", 13 | "clientEncryptionOpts": { 14 | "keyVaultClient": "client0", 15 | "kmsProviders": { 16 | "aws": {} 17 | } 18 | } 19 | } 20 | } 21 | ], 22 | "tests": [ 23 | { 24 | "description": "", 25 | "operations": [] 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-bucket-additionalProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-bucket-additionalProperties", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | }, 17 | { 18 | "bucket": { 19 | "id": "bucket0", 20 | "database": "database0", 21 | "foo": 0 22 | } 23 | } 24 | ], 25 | "tests": [ 26 | { 27 | "description": "foo", 28 | "operations": [] 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-collection-collectionName-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-collection-collectionName-required", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | }, 17 | { 18 | "collection": { 19 | "id": "collection0", 20 | "database": "database0" 21 | } 22 | } 23 | ], 24 | "tests": [ 25 | { 26 | "description": "foo", 27 | "operations": [] 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /test/server_selection/server_selection/LoadBalanced/read/Primary.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "LoadBalanced", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 0, 8 | "type": "LoadBalancer" 9 | } 10 | ] 11 | }, 12 | "operation": "read", 13 | "read_preference": { 14 | "mode": "Primary" 15 | }, 16 | "suitable_servers": [ 17 | { 18 | "address": "g:27017", 19 | "avg_rtt_ms": 0, 20 | "type": "LoadBalancer" 21 | } 22 | ], 23 | "in_latency_window": [ 24 | { 25 | "address": "g:27017", 26 | "avg_rtt_ms": 0, 27 | "type": "LoadBalancer" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /test/server_selection/server_selection/LoadBalanced/write/Primary.json: -------------------------------------------------------------------------------- 1 | { 2 | "topology_description": { 3 | "type": "LoadBalanced", 4 | "servers": [ 5 | { 6 | "address": "g:27017", 7 | "avg_rtt_ms": 0, 8 | "type": "LoadBalancer" 9 | } 10 | ] 11 | }, 12 | "operation": "write", 13 | "read_preference": { 14 | "mode": "Primary" 15 | }, 16 | "suitable_servers": [ 17 | { 18 | "address": "g:27017", 19 | "avg_rtt_ms": 0, 20 | "type": "LoadBalancer" 21 | } 22 | ], 23 | "in_latency_window": [ 24 | { 25 | "address": "g:27017", 26 | "avg_rtt_ms": 0, 27 | "type": "LoadBalancer" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-clientEncryption-id-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-clientEncryption-id-type", 3 | "schemaVersion": "1.8", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "clientEncryption": { 12 | "id": 0, 13 | "clientEncryptionOpts": { 14 | "keyVaultClient": "client0", 15 | "keyVaultNamespace": "keyvault.datakeys", 16 | "kmsProviders": { 17 | "aws": {} 18 | } 19 | } 20 | } 21 | } 22 | ], 23 | "tests": [ 24 | { 25 | "description": "", 26 | "operations": [] 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-bucket-bucketOptions-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-bucket-bucketOptions-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | }, 17 | { 18 | "bucket": { 19 | "id": "bucket0", 20 | "database": "database0", 21 | "bucketOptions": 0 22 | } 23 | } 24 | ], 25 | "tests": [ 26 | { 27 | "description": "foo", 28 | "operations": [] 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/entity-collection-database-type.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "entity-collection-database-type", 3 | "schemaVersion": "1.0", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | }, 10 | { 11 | "database": { 12 | "id": "database0", 13 | "client": "client0", 14 | "databaseName": "foo" 15 | } 16 | }, 17 | { 18 | "collection": { 19 | "id": "collection0", 20 | "database": 0, 21 | "collectionName": "foo" 22 | } 23 | } 24 | ], 25 | "tests": [ 26 | { 27 | "description": "foo", 28 | "operations": [] 29 | } 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /test/unified-test-format/invalid/expectedEventsForClient-events_conflicts_with_default_eventType.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "expectedEventsForClient-events_conflicts_with_default_eventType", 3 | "schemaVersion": "1.3", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0" 8 | } 9 | } 10 | ], 11 | "tests": [ 12 | { 13 | "description": "invalid event when eventType is unset", 14 | "operations": [], 15 | "expectEvents": [ 16 | { 17 | "client": "client0", 18 | "events": [ 19 | { 20 | "poolCreatedEvent": {} 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /test/unified-test-format/valid-pass/assertNumberConnectionsCheckedOut.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "assertNumberConnectionsCheckedOut", 3 | "schemaVersion": "1.3", 4 | "createEntities": [ 5 | { 6 | "client": { 7 | "id": "client0", 8 | "useMultipleMongoses": true 9 | } 10 | } 11 | ], 12 | "tests": [ 13 | { 14 | "description": "basic assertion succeeds", 15 | "operations": [ 16 | { 17 | "name": "assertNumberConnectionsCheckedOut", 18 | "object": "testRunner", 19 | "arguments": { 20 | "client": "client0", 21 | "connections": 0 22 | } 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | --------------------------------------------------------------------------------