diff --git a/source/index.md b/source/index.md index fcf33d1933..29b2a51e86 100644 --- a/source/index.md +++ b/source/index.md @@ -36,6 +36,7 @@ - [MongoDB Handshake](mongodb-handshake/handshake.md) - [OCSP Support](ocsp-support/ocsp-support.md) - [OP_MSG](message/OP_MSG.md) +- [OpenTelemetry](open-telemetry/open-telemetry.md) - [Performance Benchmarking](benchmarking/benchmarking.md) - [Polling SRV Records for mongos Discovery](polling-srv-records-for-mongos-discovery/polling-srv-records-for-mongos-discovery.md) - [Read and Write Concern](read-write-concern/read-write-concern.md) diff --git a/source/open-telemetry/open-telemetry.md b/source/open-telemetry/open-telemetry.md new file mode 100644 index 0000000000..0ab8ad8385 --- /dev/null +++ b/source/open-telemetry/open-telemetry.md @@ -0,0 +1,424 @@ +# OpenTelemetry + +- Title: OpenTelemetry +- Status: Accepted +- Minimum Server Version: N/A + +______________________________________________________________________ + +## Abstract + +This specification defines requirements for drivers' OpenTelemetry integration and behavior. Drivers will trace database +commands and driver operations with a pre-defined set of attributes when OpenTelemetry is enabled and configured in an +application. + +## META + +The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and +"OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt). + +## Specification + +### Terms + +**Host Application** + +An application that uses the MongoDB driver. + +**Span** + +A Span represents a single operation within a trace. Spans can be nested to form a trace tree. Each trace contains a +root span, which typically describes the entire operation and, optionally, one or more sub-spans for its sub-operations. + +Spans encapsulate: + +- The span name +- An immutable SpanContext that uniquely identifies the Span +- A parent span in the form of a Span, SpanContext, or null +- A SpanKind +- A start timestamp +- An end timestamp +- Attributes +- A list of links to other Spans +- A list of timestamped Events +- A Status + +### Implementation Requirements + +#### External Dependencies + +**OpenTelemetry API and SDK** + +OpenTelemetry offers two components for implementing instrumentation – API and SDK. The OpenTelemetry API provides all +the necessary types and method signatures. If there is no OpenTelemetry SDK available at runtime, API methods are +no-ops. OpenTelemetry SDK is an actual implementation of the API. If the SDK is available, API methods do work. + +Drivers MAY add a dependency to the corresponding OpenTelemetry API. This is the recommended way for implementing +OpenTelemetry in libraries. Alternatively, drivers can implement OpenTelemetry support using any suitable tools within +the driver ecosystem. Drivers MUST NOT add a dependency to OpenTelemetry SDK. + +#### Enabling, Disabling, and Configuring OpenTelemetry + +OpenTelemetry SHOULD be disabled by default. + +Drivers SHOULD support configuring OpenTelemetry on multiple levels. + +- **MongoClient Level**: Drivers SHOULD provide a configuration option for `MongoClient`'s Configuration/Settings that + enables or disables tracing for operations and commands executed with this client. This option MUST override + settings on higher levels. This configuration can be implemented with a `MongoClient` option. See + [Client Options](#client-options) section below. +- **Driver Level**: Drivers SHOULD provide a global setting that enables or disables OpenTelemetry for all `MongoClient` + instances (excluding those that explicitly override the setting). This configuration SHOULD be implemented with an + environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_ENABLED`. Drivers MAY provide other means to globally + disable OpenTelemetry that are more suitable for their language ecosystem. This option MUST override settings on the + higher level. +- **Host Application Level**: If the host application enables OpenTelemetry for all available instrumentations (e.g., + Ruby), and a driver can detect this, OpenTelemetry SHOULD be enabled in the driver. + +Drivers MUST NOT try to detect whether the OpenTelemetry SDK library is available, and enable tracing based on this. +Drivers MUST NOT add means that configure OpenTelemetry SDK (e.g., setting a specific exporter). Drivers MUST NOT add +means that configure OpenTelemetry on the host application level (e.g., setting a specific sampler). + + + +##### `MongoClient` Options for configuring OpenTelemetry on the client level + +Drivers SHOULD add new options to `MongoClient` for configuring OpenTelemetry as described above. These options SHOULD +be a dictionary that groups all OpenTelemetry-related options, the name of the dictionary SHOULD be `tracing`. The +dictionary SHOULD contain at least the following options: + +- `enabled`: A boolean that enables or disables OpenTelemetry for this `MongoClient` instance. Default is `false` (i.e., + use the driver-level setting). +- `query_text_max_length`: An integer that sets the maximum length of the `db.query.text` attribute of command spans. + Default is `0` (i.e., do not add the attribute). + +#### Environment Variables for configuring OpenTelemetry + +Drivers SHOULD support configuration of OpenTelemetry on the driver level via at least the following environment +variables: + +- `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_ENABLED`: enables OpenTelemetry when set to `1`, `true`, `yes`. +- `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_QUERY_TEXT_MAX_LENGTH`: An integer that sets the maximum length of the + `db.query.text` attribute of command spans. Default is `0` (i.e., do not add the attribute). + +#### Tracer Attributes + +If a driver creates a Tracer using OpenTelemetry API, drivers MUST use the following attributes: + +- `name`: A string that identifies the driver. It can be the name of a driver's component (e.g., "mongo", "PyMongo") or + a package name (e.g., "com.mongo.Driver"). Drivers SHOULD select a name that is idiomatic for their language and + ecosystem. Drivers SHOULD follow the Instrumentation Scope guidance. +- `version`: A string that represents internal driver version. The version formatting is not defined; drivers SHOULD + apply the same formatting as the use for `client.driver.version` attribute of the + [handshake](https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.md#clientdriverversion). + +#### Instrumenting Driver Operations + +When a user calls the driver's public API, the driver MUST create a span for every driver operation. Drivers MUST start +the span as soon as possible so that the span’s duration reflects all activities made by the driver, such as server +selection and serialization/deserialization. + +The span for the operation MUST be created within the current span of the host application, with the exceptions listed +below. + +##### Transactions + +When a user starts a transaction with `startTransaction`, the driver SHOULD create a span for the pseudo operation +`transaction`. This span MUST have only one attribute `db.system` with the value `mongodb`. All operations executed +within the transaction SHOULD be nested to the `transaction` span. + +When a user commits or aborts a transaction with `commitTransaction` or `abortTransaction`, the driver SHOULD finish the +`transaction` span. + +##### `withTransaction` + +In case of `withTransaction` operation spans for operations that are executed inside the callbacks SHOULD be nested into +the `withTransaction` span. + +##### Operation Span Name + +The span name SHOULD be: + +- `driver_operation_name db.collection_name` if the operation is executed on a collection (e.g., + `collection.findOneAndDelete(filter)` will report `findAndModify warehouse_db.users_coll`). + +**Note**: since the `findOneAndDelete` operation is implemented as a `findAndModify` command, the operation name in the +span is `findAndModify`. This ensures consistency between drivers when naming operations. See the +[covered operations](#covered-operations) table below for mapping of public API methods to operation names. + +- `driver_operation_name db` if there is no specific collection for the operation (e.g., `runCommand warehouse`). + +##### Operation Span Kind + +Span kind MUST be "client". + +##### Operation Span Attributes + +Spans SHOULD have the following attributes: + +| Attribute | Type | Description | Requirement Level | +| :--------------------- | :------- | :------------------------------------------------------------------------- | :-------------------- | +| `db.system` | `string` | MUST be 'mongodb' | Required | +| `db.namespace` | `string` | The database name | Required if available | +| `db.collection.name` | `string` | The collection being accessed within the database stated in `db.namespace` | Required if available | +| `db.operation.name` | `string` | The name of the driver operation being executed | Required | +| `db.operation.summary` | `string` | Equivalent to span name | Required | + +Not all attributes are available at the moment of span creation. Drivers need to add attributes at later stages, which +requires an operation span to be available throughout the complete operation lifecycle. + +###### db.namespace + +This attribute SHOULD be set to current database name except for operations executing against admin db ex: (transaction, +client `bulkWrite`) operations. + +Examples: + +- `find` on `test.users` → `test` +- `runCommand` on `admin` → `admin` +- `commitTransaction` → `admin` +- `abortTransaction` → `admin` +- client `bulkWrite` → `admin` + +The name of this attribute is defined in the +[OpenTelemetry Specifications](https://opentelemetry.io/docs/specs/semconv/registry/attributes/db/#db-namespace). In +order to be compliant with these, we use this name even though the term `namespace` has a different +[meaning](https://www.mongodb.com/docs/manual/reference/glossary/) for MongoDB. + +###### db.collection.name + +This attribute should be set to the user's collection if the operation is executing against a collection, this field is +omitted for commands running against `admin` database or commands that do not target a specific collection. + +Examples: + +- `find` on `test.users` → `users` +- `runCommand` on `admin` → *omitted* +- `commitTransaction` → *omitted* +- `abortTransaction` → *omitted* +- client `bulkWrite` → *omitted* + +##### Exceptions + +If the driver operation fails with an exception, drivers MUST record an exception to the current operation span. This +does not relate to exceptions that happen on the server command level (see below). Those exceptions MUST be recorded to +the corresponding command span. + +When recording an exception, drivers SHOULD add the following attributes to the span, when the content for the attribute +if available: + +- `exception.message` +- `exception.type` +- `exception.stacktrace` + +#### Instrumenting Server Commands + +Drivers MUST create a span for every server command sent to the server as a result of a public API call, except for +sensitive commands as listed in the command logging and monitoring specification. + +Spans for commands MUST be nested to the span for the corresponding driver operation span. If the command is being +retried, the driver MUST create a separate span for each retry; all the retries MUST be nested to the same operation +span. + +##### Command Span Name + +The span name SHOULD be the command name. For example, `find`, `insert`, `update`, etc. + +##### Command Span Kind + +Span kind MUST be "client". + +##### Command Span Attributes + +Spans SHOULD have the following attributes: + +| Attribute | Type | Description | Requirement Level | +| :-------------------------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------- | +| `db.system` | `string` | MUST be 'mongodb' | Required | +| `db.namespace` | `string` | The database name | Required if available | +| `db.collection.name` | `string` | The collection being accessed within the database stated in `db.namespace` | Required if available | +| `db.command.name` | `string` | The name of the server command being executed | Required | +| `db.response.status_code` | `string` | MongoDB error code represented as a string. This attribute should be added only if an error happens. | Required if an error happens | +| `server.port` | `int64` | Server port number | Required | +| `server.address` | `string` | Name of the database host, or IP address if name is not known | Required | +| `network.transport` | `string` | MUST be 'tcp' or 'unix' depending on the protocol | Required | +| `db.query.summary` | `string` | (see explanation below) | Required | +| `db.mongodb.server_connection_id` | `int64` | Server connection id | Required if available | +| `db.mongodb.driver_connection_id` | `int64` | Local connection id | Required if available | +| `db.query.text` | `string` | Database command that was sent to the server. Content should be equivalent to the `document` field of the CommandStartedEvent of the command monitoring. | Conditional | +| `db.mongodb.cursor_id` | `int64` | If a cursor is created or used in the operation | Required if available | +| `db.mongodb.lsid` | `string` | Logical session id | Required if available | +| `db.mongodb.txn_number` | `int64` | Transaction number | Required if available | + +Besides the attributes listed in the table above, drivers MAY add other attributes from the +[Semantic Conventions for Databases](https://opentelemetry.io/docs/specs/semconv/registry/attributes/db/) that are +applicable to MongoDB. + +###### db.namespace + +This attribute SHOULD be set to current database name except for operations executing against admin db ex: (transaction, +client `bulkWrite`) operations. + +Examples: + +- `find` on `test.users` → `test` +- `runCommand` on `admin` → `admin` +- `commitTransaction` → `admin` +- `abortTransaction` → `admin` +- client `bulkWrite` → `admin` + +The name of this attribute is defined in the +[OpenTelemetry Specifications](https://opentelemetry.io/docs/specs/semconv/registry/attributes/db/#db-namespace). In +order to be compliant with these, we use this name even though the term `namespace` has a different +[meaning](https://www.mongodb.com/docs/manual/reference/glossary/) for MongoDB. + +###### db.collection.name + +This attribute should be set to the user's collection if the operation is executing against a collection, this field is +omitted for commands running against `admin` database or commands that do not target a specific collection. + +Examples: + +- `find` on `test.users` → `users` +- `runCommand` on `admin` → *omitted* +- `commitTransaction` → *omitted* +- `abortTransaction` → *omitted* +- client `bulkWrite` → *omitted* + +###### db.query.summary + +This attribute SHOULD contain: + +- `command_name db.collection_name` if the command is executed on a collection. +- `command_name db` if there is no specific collection for the command. +- `command_name admin` in other cases (e.g., commands executed against `admin` database, transaction or client + `bulkWrite`). + +###### db.query.text + +This attribute contains the full database command executed serialized to extended JSON. If not truncated, the content of +this attribute SHOULD be equivalent to the `document` field of the CommandStartedEvent of the command monitoring +excluding the following fields: `lsid`, `$db`, `$clusterTime`, `signature`. + +Drivers MUST NOT add this attribute by default. Drivers MUST provide a toggle to enable this attribute. This +configuration can be implemented with an environment variable +`OTEL_#{LANG}_INSTRUMENTATION_MONGODB_QUERY_TEXT_MAX_LENGTH` set to a positive integer value. The attribute will be +added and truncated to the provided value (similar to the Logging specification). + +On the `MongoClient` level this configuration can be implemented with a `MongoClient` option, for example, +`tracing.query_text_max_length`. + +###### db.mongodb.cursor_id + +If the command returns a cursor, or uses a cursor, the `cursor_id` attribute SHOULD be added. + +##### Exceptions + +If the server command fails with an exception, drivers MUST record an exception to the current command span. When +recording an exception, drivers SHOULD add the following attributes to the span, when the content for the attribute if +available: + +- `exception.message` +- `exception.type` +- `exception.stacktrace` + +## Motivation for Change + +A common complaint from our support team is that they don't know how to easily get debugging information from drivers. +Some drivers provide debug logging, but others do not. For drivers that do provide it, the log messages produced and the +mechanisms for enabling debug logging are inconsistent. + +OpenTelemetry is currently the industry standard for instrumenting, generating, and collecting telemetry data (metrics, +logs, and traces). By instrumenting our drivers natively, we allow our end users to collect traces in a +batteries-included way, with the additional benefits that the tracing is developed and maintained in-house, and conforms +to the open-source standard for tracing. This also ensures that traces generated on the client-side on driver operations +can tie into other traces, thus giving our end users a broader picture of the network hops that a single request might +take. + +## Test Plan + +See [OpenTelemetry Tests](tests/README.md) for the test plan. + +## Covered operations + +The OpenTelemetry specification covers all driver operations including but not limited to the following operations: + +| Operation | Test | +| :----------------------- | :----------------------------------------------------------------------------- | +| `aggregate` | [tests/operation/aggregate.yml](tests/operation/aggregate.yml) | +| `findAndModify` | [tests/operation/find_and_modify.yml](tests/operation/find_and_modify.yml) | +| `bulkWrite` | [tests/operation/bulk_write.yml](tests/operation/bulk_write.yml) | +| `commitTransaction` | [tests/transaction/core_api.yml](tests/transaction/core_api.yml) | +| `abortTransaction` | [tests/transaction/core_api.yml](tests/transaction/core_api.yml) | +| `withTransaction` | [tests/transaction/convenient.yml](tests/transaction/convenient.yml) | +| `createCollection` | [tests/operation/create_collection.yml](tests/operation/create_collection.yml) | +| `createIndexes` | [tests/operation/create_indexes.yml](tests/operation/create_indexes.yml) | +| `distinct` | [tests/operation/distinct.yml](tests/operation/distinct.yml) | +| `dropCollection` | [tests/operation/drop_collection.yml](tests/operation/drop_collection.yml) | +| `dropIndexes` | [tests/operation/drop_indexes.yml](tests/operation/drop_indexes.yml) | +| `find` | [tests/operation/find.yml](tests/operation/find.yml) | +| `listCollections` | [tests/operation/list_collections.yml](tests/operation/list_collections.yml) | +| `listDatabases` | [tests/operation/list_databases.yml](tests/operation/list_databases.yml) | +| `listIndexes` | [tests/operation/list_indexes.yml](tests/operation/list_indexes.yml) | +| `mapReduce` | [tests/operation/map_reduce.yml](tests/operation/map_reduce.yml) | +| `estimatedDocumentCount` | [tests/operation/count.yml](tests/operation/count.yml) | +| `insert` | [tests/operation/insert.yml](tests/operation/insert.yml) | +| `delete` | [tests/operation/delete.yml](tests/operation/delete.yml) | +| `update` | [tests/operation/update.yml](tests/operation/update.yml) | +| `createSearchIndexes` | [tests/operation/atlas_search.yml](tests/operation/atlas_search.yml) | +| `dropSearchIndex` | [tests/operation/atlas_search.yml](tests/operation/atlas_search.yml) | +| `updateSearchIndex` | [tests/operation/delete.yml](tests/operation/delete.yml) | +| `delete` | [tests/operation/atlas_search.yml](tests/operation/atlas_search.yml) | + +## Backwards Compatibility + +Introduction of OpenTelemetry in new driver versions should not significantly affect existing applications that do not +enable OpenTelemetry. However, since the no-op tracing operation may introduce some performance degradation (though it +should be negligible), customers should be informed of this feature and how to disable it completely. + +If a driver is used in an application that has OpenTelemetry enabled, customers will see traces from the driver in their +OpenTelemetry backends. This may be unexpected and MAY cause negative effects in some cases (e.g., the OpenTelemetry +backend MAY not have enough capacity to process new traces). Customers should be informed of this feature and how to +disable it completely. + +## Security Implication + +Drivers MUST take care to avoid exposing sensitive information (e.g. authentication credentials) in traces. Drivers +SHOULD follow the +[Security](https://github.com/mongodb/specifications/blob/master/source/command-logging-and-monitoring/command-logging-and-monitoring.md#security) +guidance of the Command Logging and Monitoring spec. + +## Future Work + +### Query Parametrization + +It might be beneficial to implement query parametrization for the `db.query.text` attribute. + +One might want to replace dynamic values in queries with placeholders. For example, the query + +```json +{ find: "users", filter: { age: { $gt: 30 } } } +``` + +will be transformed to + +```json +{ find: "users", filter: { age: { $gt: "?" } } } +``` + +for purposes of obfuscating queries in traces or query aggregation. + +In the case of CSFLE, the query might already have BSON binary values (with the encrypted subtype) by the time the query +is sent along for tracing, which can also be considered a form of parameterization. In that case, a driver could easily +replace those binary values with placeholders (assuming the encrypted blobs are irrelevant for logging). + +## Design Rationale + +### No URI options + +Enabling tracing may have performance and security implications. Copying and using a connection string that enables +tracing may have unexpected negative outcome. + +Further, we already have two attributes that configure tracing, and we expect there might be more. + +A URI options can be added later if we realise our users need it, while the opposite is not easily accomplished. diff --git a/source/open-telemetry/tests/README.md b/source/open-telemetry/tests/README.md new file mode 100644 index 0000000000..99bcc8d293 --- /dev/null +++ b/source/open-telemetry/tests/README.md @@ -0,0 +1,60 @@ +# OpenTelemetry Tests + +______________________________________________________________________ + +## Testing + +### Automated Tests + +The YAML and JSON files in this directory are platform-independent tests meant to exercise a driver's implementation of +the OpenTelemetry specification. These tests utilize the +[Unified Test Format](../../unified-test-format/unified-test-format.md). + +For each test, create a MongoClient, configure it to enable tracing. + +```yaml +createEntities: + - client: + id: client0 + observeTracingMessages: + enableCommandPayload: true +``` + +These tests require the ability to collect tracing [spans](../open-telemetry.md) data in a structured form as described +in the +[Unified Test Format specification.expectTracingMessages](../../unified-test-format/unified-test-format.md#expectTracingMessages). +For example the Java driver uses [Micrometer](https://jira.mongodb.org/browse/JAVA-5732) to collect tracing spans. + +```yaml +expectTracingMessages: + client: client0 + ignoreExtraSpans: false + spans: + ... +``` + +### Prose Tests + +*Test 1: Tracing Enable/Disable via Environment Variable* + +1. Set the environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_ENABLED` to `false`. +2. Create a `MongoClient` without explicitly enabling tracing. +3. Perform a database operation (e.g., `find()` on a test collection). +4. Assert that no OpenTelemetry tracing spans are emitted for the operation. +5. Set the environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_ENABLED` to `true`. +6. Create a new `MongoClient` without explicitly enabling tracing. +7. Perform the same database operation. +8. Assert that OpenTelemetry tracing spans are emitted for the operation. + +*Test 2: Command Payload Emission via Environment Variable* + +1. Set the environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_ENABLED` to `true`. +2. Set the environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_QUERY_TEXT_MAX_LENGTH` to a positive integer + (e.g., 1024). +3. Create a `MongoClient` without explicitly enabling command payload emission. +4. Perform a database operation (e.g., `find()`). +5. Assert that the emitted tracing span includes the `db.query.text` attribute. +6. Unset the environment variable `OTEL_#{LANG}_INSTRUMENTATION_MONGODB_QUERY_TEXT_MAX_LENGTH`. +7. Create a new `MongoClient`. +8. Perform the same database operation. +9. Assert that the emitted tracing span does not include the `db.query.text` attribute. diff --git a/source/open-telemetry/tests/operation/aggregate.json b/source/open-telemetry/tests/operation/aggregate.json new file mode 100644 index 0000000000..9c30c36f8e --- /dev/null +++ b/source/open-telemetry/tests/operation/aggregate.json @@ -0,0 +1,130 @@ +{ + "description": "operation aggregate", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-aggregate" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "tests": [ + { + "description": "aggregation", + "operations": [ + { + "name": "aggregate", + "object": "collection0", + "arguments": { + "pipeline": [ + { + "$match": { + "_id": 1 + } + } + ] + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "aggregate operation-aggregate.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-aggregate", + "db.collection.name": "test", + "db.operation.name": "aggregate", + "db.operation.summary": "aggregate operation-aggregate.test" + }, + "nested": [ + { + "name": "aggregate", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-aggregate", + "db.collection.name": "test", + "db.command.name": "aggregate", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "aggregate operation-aggregate.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "aggregate": "test", + "pipeline": [ + { + "$match": { + "_id": 1 + } + } + ] + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/aggregate.yml b/source/open-telemetry/tests/operation/aggregate.yml new file mode 100644 index 0000000000..5f78a7ed5f --- /dev/null +++ b/source/open-telemetry/tests/operation/aggregate.yml @@ -0,0 +1,62 @@ +description: operation aggregate +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-aggregate + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collectionName0 test + +tests: + - description: aggregation + operations: + - name: aggregate + object: *collection0 + arguments: + pipeline: &pipeline0 + - $match: { _id: 1 } + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: aggregate operation-aggregate.test + attributes: + db.system: mongodb + db.namespace: operation-aggregate + db.collection.name: test + db.operation.name: aggregate + db.operation.summary: aggregate operation-aggregate.test + nested: + - name: aggregate + attributes: + db.system: mongodb + db.namespace: operation-aggregate + db.collection.name: *collectionName0 + db.command.name: aggregate + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [int, long] } + db.query.summary: aggregate operation-aggregate.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + aggregate: test + pipeline: *pipeline0 + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/atlas_search.json b/source/open-telemetry/tests/operation/atlas_search.json new file mode 100644 index 0000000000..820f2f5074 --- /dev/null +++ b/source/open-telemetry/tests/operation/atlas_search.json @@ -0,0 +1,239 @@ +{ + "description": "operation atlas_search", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-atlas-search" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "runOnRequirements": [ + { + "minServerVersion": "7.0.5", + "maxServerVersion": "7.0.99", + "topologies": [ + "replicaset", + "load-balanced", + "sharded" + ], + "serverless": "forbid" + }, + { + "minServerVersion": "7.2.0", + "topologies": [ + "replicaset", + "load-balanced", + "sharded" + ], + "serverless": "forbid" + } + ], + "tests": [ + { + "description": "atlas search indexes", + "operations": [ + { + "name": "createSearchIndex", + "object": "collection0", + "arguments": { + "model": { + "definition": { + "mappings": { + "dynamic": true + } + }, + "type": "search" + } + }, + "expectError": { + "isError": true, + "errorContains": "Atlas" + } + }, + { + "name": "updateSearchIndex", + "object": "collection0", + "arguments": { + "name": "test index", + "definition": {} + }, + "expectError": { + "isError": true, + "errorContains": "Atlas" + } + }, + { + "name": "dropSearchIndex", + "object": "collection0", + "arguments": { + "name": "test index" + }, + "expectError": { + "isError": true, + "errorContains": "Atlas" + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "createSearchIndexes operation-atlas-search.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-atlas-search", + "db.collection.name": "test", + "db.operation.name": "createSearchIndexes", + "db.operation.summary": "createSearchIndexes operation-atlas-search.test" + }, + "nested": [ + { + "name": "createSearchIndexes", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-atlas-search", + "db.collection.name": "test", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "createSearchIndexes operation-atlas-search.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "createSearchIndexes": "test", + "indexes": [ + { + "type": "search", + "definition": { + "mappings": { + "dynamic": true + } + } + } + ] + } + } + } + } + } + ] + }, + { + "name": "updateSearchIndex operation-atlas-search.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-atlas-search", + "db.collection.name": "test", + "db.operation.name": "updateSearchIndex", + "db.operation.summary": "updateSearchIndex operation-atlas-search.test" + }, + "nested": [ + { + "name": "updateSearchIndex", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-atlas-search", + "db.collection.name": "test", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "updateSearchIndex operation-atlas-search.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "updateSearchIndex": "test", + "name": "test index", + "definition": {} + } + } + } + } + } + ] + }, + { + "name": "dropSearchIndex operation-atlas-search.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-atlas-search", + "db.collection.name": "test", + "db.operation.name": "dropSearchIndex", + "db.operation.summary": "dropSearchIndex operation-atlas-search.test" + }, + "nested": [ + { + "name": "dropSearchIndex", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-atlas-search", + "db.collection.name": "test", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "dropSearchIndex operation-atlas-search.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "dropSearchIndex": "test", + "name": "test index" + } + } + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/atlas_search.yml b/source/open-telemetry/tests/operation/atlas_search.yml new file mode 100644 index 0000000000..9800d9be35 --- /dev/null +++ b/source/open-telemetry/tests/operation/atlas_search.yml @@ -0,0 +1,139 @@ +description: operation atlas_search +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-atlas-search + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: test + +runOnRequirements: + # Skip server versions without fix of SERVER-83107 to avoid error message "BSON field 'createSearchIndexes.indexes.type' is an unknown field." + # SERVER-83107 was not backported to 7.1. + - minServerVersion: "7.0.5" + maxServerVersion: "7.0.99" + topologies: [ replicaset, load-balanced, sharded ] + serverless: forbid + - minServerVersion: "7.2.0" + topologies: [ replicaset, load-balanced, sharded ] + serverless: forbid + + +tests: + - description: atlas search indexes + operations: + - name: createSearchIndex + object: *collection0 + arguments: + model: { definition: { mappings: { dynamic: true } } , type: 'search' } + expectError: + # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting + # that the driver constructs and sends the correct command. + # The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages. + isError: true + errorContains: Atlas + + - name: updateSearchIndex + object: *collection0 + arguments: + name: 'test index' + definition: {} + expectError: + # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting + # that the driver constructs and sends the correct command. + # The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages. + isError: true + errorContains: Atlas + + - name: dropSearchIndex + object: *collection0 + arguments: + name: 'test index' + expectError: + # This test always errors in a non-Atlas environment. The test functions as a unit test by asserting + # that the driver constructs and sends the correct command. + # The expected error message was changed in SERVER-83003. Check for the substring "Atlas" shared by both error messages. + isError: true + errorContains: Atlas + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: createSearchIndexes operation-atlas-search.test + attributes: + db.system: mongodb + db.namespace: operation-atlas-search + db.collection.name: test + db.operation.name: createSearchIndexes + db.operation.summary: createSearchIndexes operation-atlas-search.test + nested: + - name: createSearchIndexes + attributes: + db.system: mongodb + db.namespace: operation-atlas-search + db.collection.name: test + server.address: { $$type: string } + server.port: { $$type: [ long, string ] } + server.type: { $$type: string } + db.query.summary: createSearchIndexes operation-atlas-search.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + createSearchIndexes: test + indexes: [ { "type": "search", "definition": { "mappings": { "dynamic": true } } } ] + + - name: updateSearchIndex operation-atlas-search.test + attributes: + db.system: mongodb + db.namespace: operation-atlas-search + db.collection.name: test + db.operation.name: updateSearchIndex + db.operation.summary: updateSearchIndex operation-atlas-search.test + nested: + - name: updateSearchIndex + attributes: + db.system: mongodb + db.namespace: operation-atlas-search + db.collection.name: test + server.address: { $$type: string } + server.port: { $$type: [ long, string ] } + server.type: { $$type: string } + db.query.summary: updateSearchIndex operation-atlas-search.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + updateSearchIndex: test + name: test index + definition: {} + + - name: dropSearchIndex operation-atlas-search.test + attributes: + db.system: mongodb + db.namespace: operation-atlas-search + db.collection.name: test + db.operation.name: dropSearchIndex + db.operation.summary: dropSearchIndex operation-atlas-search.test + nested: + - name: dropSearchIndex + attributes: + db.system: mongodb + db.namespace: operation-atlas-search + db.collection.name: test + server.address: { $$type: string } + server.port: { $$type: [ long, string ] } + server.type: { $$type: string } + db.query.summary: dropSearchIndex operation-atlas-search.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + dropSearchIndex: test + name: test index diff --git a/source/open-telemetry/tests/operation/bulk_write.json b/source/open-telemetry/tests/operation/bulk_write.json new file mode 100644 index 0000000000..bf9d4d9b65 --- /dev/null +++ b/source/open-telemetry/tests/operation/bulk_write.json @@ -0,0 +1,336 @@ +{ + "description": "operation bulk_write", + "schemaVersion": "1.27", + "runOnRequirements": [ + { + "minServerVersion": "8.0", + "serverless": "forbid" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-bulk-write-0" + } + }, + { + "database": { + "id": "database1", + "client": "client0", + "databaseName": "operation-bulk-write-1" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test0" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test1" + } + } + ], + "initialData": [ + { + "collectionName": "test0", + "databaseName": "operation-bulk-write-0", + "documents": [] + }, + { + "collectionName": "test1", + "databaseName": "operation-bulk-write-1", + "documents": [] + } + ], + "_yamlAnchors": { + "namespace0": "operation-bulk-write-0.test0", + "namespace1": "operation-bulk-write-1.test1" + }, + "tests": [ + { + "description": "bulkWrite", + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "insertOne": { + "namespace": "operation-bulk-write-0.test0", + "document": { + "_id": 8, + "x": 88 + } + } + }, + { + "updateOne": { + "namespace": "operation-bulk-write-0.test0", + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "x": 1 + } + } + } + }, + { + "updateMany": { + "namespace": "operation-bulk-write-1.test1", + "filter": { + "$and": [ + { + "_id": { + "$gt": 1 + } + }, + { + "_id": { + "$lte": 3 + } + } + ] + }, + "update": { + "$inc": { + "x": 2 + } + } + } + }, + { + "replaceOne": { + "namespace": "operation-bulk-write-1.test1", + "filter": { + "_id": 4 + }, + "replacement": { + "x": 44 + }, + "upsert": true + } + }, + { + "deleteOne": { + "namespace": "operation-bulk-write-0.test0", + "filter": { + "_id": 5 + } + } + }, + { + "deleteMany": { + "namespace": "operation-bulk-write-1.test1", + "filter": { + "$and": [ + { + "_id": { + "$gt": 5 + } + }, + { + "_id": { + "$lte": 7 + } + } + ] + } + } + } + ] + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "bulkWrite admin", + "attributes": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": { + "$$exists": false + }, + "db.operation.name": "bulkWrite", + "db.operation.summary": "bulkWrite admin" + }, + "nested": [ + { + "name": "bulkWrite", + "attributes": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": { + "$$exists": false + }, + "db.command.name": "bulkWrite", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "bulkWrite admin", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "bulkWrite": 1, + "errorsOnly": true, + "ordered": true, + "ops": [ + { + "insert": 0, + "document": { + "_id": 8, + "x": 88 + } + }, + { + "update": 0, + "multi": false, + "filter": { + "_id": 1 + }, + "updateMods": { + "$inc": { + "x": 1 + } + } + }, + { + "update": 1, + "multi": true, + "filter": { + "$and": [ + { + "_id": { + "$gt": 1 + } + }, + { + "_id": { + "$lte": 3 + } + } + ] + }, + "updateMods": { + "$inc": { + "x": 2 + } + } + }, + { + "update": 1, + "multi": false, + "filter": { + "_id": 4 + }, + "updateMods": { + "x": 44 + }, + "upsert": true + }, + { + "delete": 0, + "multi": false, + "filter": { + "_id": 5 + } + }, + { + "delete": 1, + "multi": true, + "filter": { + "$and": [ + { + "_id": { + "$gt": 5 + } + }, + { + "_id": { + "$lte": 7 + } + } + ] + } + } + ], + "nsInfo": [ + { + "ns": "operation-bulk-write-0.test0" + }, + { + "ns": "operation-bulk-write-1.test1" + } + ] + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/bulk_write.yml b/source/open-telemetry/tests/operation/bulk_write.yml new file mode 100644 index 0000000000..54f3ba2b79 --- /dev/null +++ b/source/open-telemetry/tests/operation/bulk_write.yml @@ -0,0 +1,199 @@ +description: operation bulk_write +schemaVersion: '1.27' +runOnRequirements: + - minServerVersion: "8.0" + serverless: forbid + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: &databaseName0 operation-bulk-write-0 + - database: + id: &database1 database1 + client: *client0 + databaseName: &databaseName1 operation-bulk-write-1 + - collection: + id: collection0 + database: *database0 + collectionName: &collectionName0 test0 + - collection: + id: collection1 + database: *database1 + collectionName: &collectionName1 test1 + +initialData: + - collectionName: *collectionName0 + databaseName: *databaseName0 + documents: [ ] + - collectionName: *collectionName1 + databaseName: *databaseName1 + documents: [ ] + +_yamlAnchors: + namespace0: &namespace0 "operation-bulk-write-0.test0" + namespace1: &namespace1 "operation-bulk-write-1.test1" + +tests: + - description: bulkWrite + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - insertOne: + namespace: *namespace0 + document: { _id: 8, x: 88 } + - updateOne: + namespace: *namespace0 + filter: { _id: 1 } + update: { $inc: { x: 1 } } + - updateMany: + namespace: *namespace1 + filter: + $and: [ { _id: { $gt: 1 } }, { _id: { $lte: 3 } } ] + update: { $inc: { x: 2 } } + - replaceOne: + namespace: *namespace1 + filter: { _id: 4 } + replacement: { x: 44 } + upsert: true + - deleteOne: + namespace: *namespace0 + filter: { _id: 5 } + - deleteMany: + namespace: *namespace1 + filter: + $and: [ { _id: { $gt: 5 } }, { _id: { $lte: 7 } } ] + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: bulkWrite admin + attributes: + db.system: mongodb + db.namespace: admin + db.collection.name: { $$exists: false } + db.operation.name: bulkWrite + db.operation.summary: bulkWrite admin + nested: + - name: bulkWrite + attributes: + db.system: mongodb + db.namespace: admin + db.collection.name: { $$exists: false } + db.command.name: bulkWrite + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [ int, long ] } + server.type: { $$type: string } + db.query.summary: bulkWrite admin + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + bulkWrite: 1 + errorsOnly: true + ordered: true + ops: [ + { + "insert": 0, + "document": { + "_id": 8, + "x": 88 + } + }, + { + "update": 0, + "multi": false, + "filter": { + "_id": 1 + }, + "updateMods": { + "$inc": { + "x": 1 + } + } + }, + { + "update": 1, + "multi": true, + "filter": { + "$and": [ + { + "_id": { + "$gt": 1 + } + }, + { + "_id": { + "$lte": 3 + } + } + ] + }, + "updateMods": { + "$inc": { + "x": 2 + } + } + }, + { + "update": 1, + "multi": false, + "filter": { + "_id": 4 + }, + "updateMods": { + "x": 44 + }, + "upsert": true + }, + { + "delete": 0, + "multi": false, + "filter": { + "_id": 5 + } + }, + { + "delete": 1, + "multi": true, + "filter": { + "$and": [ + { + "_id": { + "$gt": 5 + } + }, + { + "_id": { + "$lte": 7 + } + } + ] + } + } + ] + nsInfo: [ + { + "ns": *namespace0 + }, + { + "ns": *namespace1 + } + ] + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/count.json b/source/open-telemetry/tests/operation/count.json new file mode 100644 index 0000000000..6b4304dfd8 --- /dev/null +++ b/source/open-telemetry/tests/operation/count.json @@ -0,0 +1,123 @@ +{ + "description": "operation count", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-count" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "operation-count", + "documents": [] + } + ], + "tests": [ + { + "description": "estimated document count", + "operations": [ + { + "object": "collection0", + "name": "estimatedDocumentCount", + "arguments": {}, + "expectResult": 0 + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "count operation-count.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-count", + "db.collection.name": "test", + "db.operation.name": "count", + "db.operation.summary": "count operation-count.test" + }, + "nested": [ + { + "name": "count", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-count", + "db.collection.name": "test", + "db.command.name": "count", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "count operation-count.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "count": "test" + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/count.yml b/source/open-telemetry/tests/operation/count.yml new file mode 100644 index 0000000000..3d2abcb04c --- /dev/null +++ b/source/open-telemetry/tests/operation/count.yml @@ -0,0 +1,63 @@ +description: operation count +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: database0 + client: *client0 + databaseName: &database0Name operation-count + - collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection0Name test +initialData: + - collectionName: *collection0Name + databaseName: *database0Name + documents: [] +tests: + - description: estimated document count + operations: + - object: *collection0 + name: estimatedDocumentCount + arguments: { } + expectResult: 0 + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: count operation-count.test + attributes: + db.system: mongodb + db.namespace: *database0Name + db.collection.name: *collection0Name + db.operation.name: count + db.operation.summary: count operation-count.test + nested: + - name: count + attributes: + db.system: mongodb + db.namespace: *database0Name + db.collection.name: *collection0Name + db.command.name: count + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [int, long] } + db.query.summary: count operation-count.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + count: test + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/create_collection.json b/source/open-telemetry/tests/operation/create_collection.json new file mode 100644 index 0000000000..fc296b4fd2 --- /dev/null +++ b/source/open-telemetry/tests/operation/create_collection.json @@ -0,0 +1,110 @@ +{ + "description": "operation create collection", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-create-collection" + } + } + ], + "tests": [ + { + "description": "create collection", + "operations": [ + { + "object": "database0", + "name": "createCollection", + "arguments": { + "collection": "newlyCreatedCollection" + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "createCollection operation-create-collection.newlyCreatedCollection", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-create-collection", + "db.collection.name": "newlyCreatedCollection", + "db.operation.name": "createCollection", + "db.operation.summary": "createCollection operation-create-collection.newlyCreatedCollection" + }, + "nested": [ + { + "name": "create", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-create-collection", + "db.collection.name": "newlyCreatedCollection", + "db.command.name": "create", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "create operation-create-collection.newlyCreatedCollection", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "create": "newlyCreatedCollection" + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/create_collection.yml b/source/open-telemetry/tests/operation/create_collection.yml new file mode 100644 index 0000000000..d0dee36051 --- /dev/null +++ b/source/open-telemetry/tests/operation/create_collection.yml @@ -0,0 +1,55 @@ +description: operation create collection +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name operation-create-collection +tests: + - description: create collection + operations: + - object: *database0 + name: createCollection + arguments: + collection: &collectionName newlyCreatedCollection + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: createCollection operation-create-collection.newlyCreatedCollection + attributes: + db.system: mongodb + db.namespace: *database0Name + db.collection.name: *collectionName + db.operation.name: createCollection + db.operation.summary: createCollection operation-create-collection.newlyCreatedCollection + nested: + - name: create + attributes: + db.system: mongodb + db.namespace: *database0Name + db.collection.name: *collectionName + db.command.name: create + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [int, long] } + db.query.summary: create operation-create-collection.newlyCreatedCollection + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + create: newlyCreatedCollection + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/create_indexes.json b/source/open-telemetry/tests/operation/create_indexes.json new file mode 100644 index 0000000000..40afac5147 --- /dev/null +++ b/source/open-telemetry/tests/operation/create_indexes.json @@ -0,0 +1,127 @@ +{ + "description": "operation create_indexes", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-create-indexes" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "tests": [ + { + "description": "create indexes", + "operations": [ + { + "object": "collection0", + "name": "createIndex", + "arguments": { + "keys": { + "x": 1 + } + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "createIndexes operation-create-indexes.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-create-indexes", + "db.collection.name": "test", + "db.operation.name": "createIndexes", + "db.operation.summary": "createIndexes operation-create-indexes.test" + }, + "nested": [ + { + "name": "createIndexes", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-create-indexes", + "db.collection.name": "test", + "db.command.name": "createIndexes", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "createIndexes operation-create-indexes.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "createIndexes": "test", + "indexes": [ + { + "key": { + "x": 1 + }, + "name": "x_1" + } + ] + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/create_indexes.yml b/source/open-telemetry/tests/operation/create_indexes.yml new file mode 100644 index 0000000000..01e23e242c --- /dev/null +++ b/source/open-telemetry/tests/operation/create_indexes.yml @@ -0,0 +1,60 @@ +description: operation create_indexes +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name operation-create-indexes + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name test +tests: + - description: create indexes + operations: + - object: *collection0 + name: createIndex + arguments: + keys: { x: 1 } + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: createIndexes operation-create-indexes.test + attributes: + db.system: mongodb + db.namespace: *database0Name + db.collection.name: *collection0Name + db.operation.name: createIndexes + db.operation.summary: createIndexes operation-create-indexes.test + nested: + - name: createIndexes + attributes: + db.system: mongodb + db.namespace: *database0Name + db.collection.name: *collection0Name + db.command.name: createIndexes + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [int, long] } + db.query.summary: createIndexes operation-create-indexes.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + createIndexes: test + indexes: [ { key: { x: 1 }, name: "x_1" } ] + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/delete.json b/source/open-telemetry/tests/operation/delete.json new file mode 100644 index 0000000000..3dec5c32ac --- /dev/null +++ b/source/open-telemetry/tests/operation/delete.json @@ -0,0 +1,103 @@ +{ + "description": "operation delete", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-delete" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "tests": [ + { + "description": "delete elements", + "operations": [ + { + "object": "collection0", + "name": "deleteMany", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + } + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "delete operation-delete.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-delete", + "db.collection.name": "test", + "db.operation.name": "delete", + "db.operation.summary": "delete operation-delete.test" + }, + "nested": [ + { + "name": "delete", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-delete", + "db.collection.name": "test", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "db.query.summary": "delete operation-delete.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "delete": "test", + "ordered": true, + "deletes": [ + { + "q": { + "_id": { + "$gt": 1 + } + }, + "limit": 0 + } + ] + } + } + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/delete.yml b/source/open-telemetry/tests/operation/delete.yml new file mode 100644 index 0000000000..eb9b866681 --- /dev/null +++ b/source/open-telemetry/tests/operation/delete.yml @@ -0,0 +1,51 @@ +description: operation delete +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: &databaseName0 operation-delete + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collectionName0 test + +tests: + - description: delete elements + operations: + - object: *collection0 + name: deleteMany + arguments: + filter: { _id: { $gt: 1 } } + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: delete operation-delete.test + attributes: + db.system: mongodb + db.namespace: *databaseName0 + db.collection.name: *collectionName0 + db.operation.name: delete + db.operation.summary: delete operation-delete.test + nested: + - name: delete + attributes: + db.system: mongodb + db.namespace: operation-delete + db.collection.name: test + server.address: { $$type: string } + server.port: { $$type: [ long, string ] } + db.query.summary: delete operation-delete.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + delete: test + ordered: true + deletes: [ { q: { _id: { $gt: 1 } }, limit: 0 } ] diff --git a/source/open-telemetry/tests/operation/distinct.json b/source/open-telemetry/tests/operation/distinct.json new file mode 100644 index 0000000000..8478d569fe --- /dev/null +++ b/source/open-telemetry/tests/operation/distinct.json @@ -0,0 +1,127 @@ +{ + "description": "operation distinct", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-distinct" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "operation-distinct", + "documents": [] + } + ], + "tests": [ + { + "description": "distinct on a field", + "operations": [ + { + "object": "collection0", + "name": "distinct", + "arguments": { + "fieldName": "x", + "filter": {} + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "distinct operation-distinct.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-distinct", + "db.collection.name": "test", + "db.operation.name": "distinct", + "db.operation.summary": "distinct operation-distinct.test" + }, + "nested": [ + { + "name": "distinct", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-distinct", + "db.collection.name": "test", + "db.command.name": "distinct", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "distinct operation-distinct.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "distinct": "test", + "key": "x", + "query": {} + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/distinct.yml b/source/open-telemetry/tests/operation/distinct.yml new file mode 100644 index 0000000000..0b78cecca9 --- /dev/null +++ b/source/open-telemetry/tests/operation/distinct.yml @@ -0,0 +1,66 @@ +description: operation distinct +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: database0 + client: *client0 + databaseName: operation-distinct + - collection: + id: &collection0 collection0 + database: database0 + collectionName: test +initialData: + - collectionName: test + databaseName: operation-distinct + documents: [] +tests: + - description: distinct on a field + operations: + - object: *collection0 + name: distinct + arguments: + fieldName: x + filter: {} + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: distinct operation-distinct.test + attributes: + db.system: mongodb + db.namespace: operation-distinct + db.collection.name: test + db.operation.name: distinct + db.operation.summary: distinct operation-distinct.test + nested: + - name: distinct + attributes: + db.system: mongodb + db.namespace: operation-distinct + db.collection.name: test + db.command.name: distinct + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [int, long] } + db.query.summary: distinct operation-distinct.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + distinct: test + key: x + query: { } + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/drop_collection.json b/source/open-telemetry/tests/operation/drop_collection.json new file mode 100644 index 0000000000..ce4ffe686a --- /dev/null +++ b/source/open-telemetry/tests/operation/drop_collection.json @@ -0,0 +1,117 @@ +{ + "description": "operation drop collection", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-drop-collection" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "tests": [ + { + "description": "drop collection", + "operations": [ + { + "object": "database0", + "name": "dropCollection", + "arguments": { + "collection": "test" + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "dropCollection operation-drop-collection.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-drop-collection", + "db.collection.name": "test", + "db.operation.name": "dropCollection", + "db.operation.summary": "dropCollection operation-drop-collection.test" + }, + "nested": [ + { + "name": "drop", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-drop-collection", + "db.collection.name": "test", + "db.command.name": "drop", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "drop operation-drop-collection.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "drop": "test" + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/drop_collection.yml b/source/open-telemetry/tests/operation/drop_collection.yml new file mode 100644 index 0000000000..26c33715df --- /dev/null +++ b/source/open-telemetry/tests/operation/drop_collection.yml @@ -0,0 +1,60 @@ +description: operation drop collection +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-drop-collection + + - collection: + id: collection0 + database: *database0 + collectionName: &collection_name test +tests: + - description: drop collection + operations: + - object: *database0 + name: dropCollection + arguments: + collection: *collection_name + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: dropCollection operation-drop-collection.test + attributes: + db.system: mongodb + db.namespace: operation-drop-collection + db.collection.name: test + db.operation.name: dropCollection + db.operation.summary: dropCollection operation-drop-collection.test + nested: + - name: drop + attributes: + db.system: mongodb + db.namespace: operation-drop-collection + db.collection.name: test + db.command.name: drop + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [int, long] } + db.query.summary: drop operation-drop-collection.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + drop: test + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/drop_indexes.json b/source/open-telemetry/tests/operation/drop_indexes.json new file mode 100644 index 0000000000..efc865b322 --- /dev/null +++ b/source/open-telemetry/tests/operation/drop_indexes.json @@ -0,0 +1,145 @@ +{ + "description": "operation drop indexes", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-drop-indexes" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "client": { + "id": "clientWithoutTracing", + "useMultipleMongoses": false + } + }, + { + "database": { + "id": "databaseWithoutTracing", + "client": "clientWithoutTracing", + "databaseName": "operation-drop-indexes" + } + }, + { + "collection": { + "id": "collectionWithoutTracing", + "database": "databaseWithoutTracing", + "collectionName": "test" + } + } + ], + "tests": [ + { + "description": "drop indexes", + "operations": [ + { + "name": "createIndex", + "object": "collectionWithoutTracing", + "arguments": { + "keys": { + "x": 1 + }, + "name": "x_1" + } + }, + { + "name": "dropIndexes", + "object": "collection0" + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": true, + "spans": [ + { + "name": "dropIndexes operation-drop-indexes.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-drop-indexes", + "db.collection.name": "test", + "db.operation.name": "dropIndexes", + "db.operation.summary": "dropIndexes operation-drop-indexes.test" + }, + "nested": [ + { + "name": "dropIndexes", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-drop-indexes", + "db.collection.name": "test", + "db.command.name": "dropIndexes", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "dropIndexes operation-drop-indexes.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "dropIndexes": "test", + "index": "*" + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/drop_indexes.yml b/source/open-telemetry/tests/operation/drop_indexes.yml new file mode 100644 index 0000000000..519995b743 --- /dev/null +++ b/source/open-telemetry/tests/operation/drop_indexes.yml @@ -0,0 +1,78 @@ +description: operation drop indexes +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-drop-indexes + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: test + - client: + id: &clientWithoutTracing clientWithoutTracing + useMultipleMongoses: false + - database: + id: &databaseWithoutTracing databaseWithoutTracing + client: *clientWithoutTracing + databaseName: operation-drop-indexes + - collection: + id: &collectionWithoutTracing collectionWithoutTracing + database: *databaseWithoutTracing + collectionName: test + +tests: + - description: drop indexes + operations: + - name: createIndex + object: *collectionWithoutTracing + arguments: + keys: + x: 1 + name: x_1 + + - name: dropIndexes + object: *collection0 + + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: true + spans: + - name: dropIndexes operation-drop-indexes.test + attributes: + db.system: mongodb + db.namespace: operation-drop-indexes + db.collection.name: test + db.operation.name: dropIndexes + db.operation.summary: dropIndexes operation-drop-indexes.test + nested: + - name: dropIndexes + attributes: + db.system: mongodb + db.namespace: operation-drop-indexes + db.collection.name: test + db.command.name: dropIndexes + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [int, long] } + db.query.summary: dropIndexes operation-drop-indexes.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + dropIndexes: test + index: '*' + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/find.json b/source/open-telemetry/tests/operation/find.json new file mode 100644 index 0000000000..53dfcb1d24 --- /dev/null +++ b/source/open-telemetry/tests/operation/find.json @@ -0,0 +1,306 @@ +{ + "description": "operation find", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-find" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "operation-find", + "documents": [] + } + ], + "tests": [ + { + "description": "find an element", + "operations": [ + { + "name": "find", + "object": "collection0", + "arguments": { + "filter": { + "x": 1 + } + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "find operation-find.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-find", + "db.collection.name": "test", + "db.operation.name": "find", + "db.operation.summary": "find operation-find.test" + }, + "nested": [ + { + "name": "find", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-find", + "db.collection.name": "test", + "db.command.name": "find", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "find operation-find.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "find": "test", + "filter": { + "x": 1 + } + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + }, + { + "description": "find an element retrying failed command", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "find" + ], + "errorCode": 89, + "errorLabels": [ + "RetryableWriteError" + ] + } + } + } + }, + { + "name": "find", + "object": "collection0", + "arguments": { + "filter": { + "x": 1 + } + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": true, + "spans": [ + { + "name": "find operation-find.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-find", + "db.collection.name": "test", + "db.operation.name": "find", + "db.operation.summary": "find operation-find.test" + }, + "nested": [ + { + "name": "find", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-find", + "db.collection.name": "test", + "db.command.name": "find", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": "89", + "exception.message": { + "$$type": "string" + }, + "exception.type": { + "$$type": "string" + }, + "exception.stacktrace": { + "$$type": "string" + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "find operation-find.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "find": "test", + "filter": { + "x": 1 + } + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "name": "find", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-find", + "db.collection.name": "test", + "db.command.name": "find", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "find operation-find.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "find": "test", + "filter": { + "x": 1 + } + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/find.yml b/source/open-telemetry/tests/operation/find.yml new file mode 100644 index 0000000000..82f42b90cf --- /dev/null +++ b/source/open-telemetry/tests/operation/find.yml @@ -0,0 +1,148 @@ +description: operation find +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-find + - collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection0Name test +initialData: + - collectionName: test + databaseName: operation-find + documents: [] +tests: + - description: find an element + operations: + - name: find + object: *collection0 + arguments: { filter: { x: 1 } } + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: find operation-find.test + attributes: + db.system: mongodb + db.namespace: operation-find + db.collection.name: test + db.operation.name: find + db.operation.summary: find operation-find.test + nested: + - name: find + attributes: + db.system: mongodb + db.namespace: operation-find + db.collection.name: test + db.command.name: find + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [int, long] } + server.type: { $$type: string } + db.query.summary: find operation-find.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + find: test + filter: + x: 1 + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] + + - description: find an element retrying failed command + operations: + - name: failPoint + object: testRunner + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ find ] + errorCode: 89 + errorLabels: [ RetryableWriteError ] + + - name: find + object: *collection0 + arguments: + filter: { x: 1 } + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: true + spans: + - name: find operation-find.test + attributes: + db.system: mongodb + db.namespace: operation-find + db.collection.name: test + db.operation.name: find + db.operation.summary: find operation-find.test + nested: + - name: find + attributes: + db.system: mongodb + db.namespace: operation-find + db.collection.name: test + db.command.name: find + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: '89' + exception.message: { $$type: string } + exception.type: { $$type: string } + exception.stacktrace: { $$type: string } + server.address: { $$type: string } + server.port: { $$type: [ long, string ] } + server.type: { $$type: string } + db.query.summary: find operation-find.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + find: test + filter: + x: 1 + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] + - name: find + attributes: + db.system: mongodb + db.namespace: operation-find + db.collection.name: test + db.command.name: find + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [ int, long ] } + server.type: { $$type: string } + db.query.summary: find operation-find.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + find: test + filter: + x: 1 + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/find_and_modify.json b/source/open-telemetry/tests/operation/find_and_modify.json new file mode 100644 index 0000000000..20d5958498 --- /dev/null +++ b/source/open-telemetry/tests/operation/find_and_modify.json @@ -0,0 +1,138 @@ +{ + "description": "operation find_one_and_update", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-aggregate" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "tests": [ + { + "description": "findOneAndUpdate", + "operations": [ + { + "name": "findOneAndUpdate", + "object": "collection0", + "arguments": { + "filter": { + "_id": 1 + }, + "update": [ + { + "$set": { + "x": 5 + } + } + ], + "comment": "comment" + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "findAndModify operation-aggregate.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-aggregate", + "db.collection.name": "test", + "db.operation.name": "findAndModify", + "db.operation.summary": "findAndModify operation-aggregate.test" + }, + "nested": [ + { + "name": "findAndModify", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-aggregate", + "db.collection.name": "test", + "db.command.name": "findAndModify", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "findAndModify operation-aggregate.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "findAndModify": "test", + "query": { + "_id": 1 + }, + "update": [ + { + "$set": { + "x": 5 + } + } + ], + "comment": "comment" + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/find_and_modify.yml b/source/open-telemetry/tests/operation/find_and_modify.yml new file mode 100644 index 0000000000..d36cd053d8 --- /dev/null +++ b/source/open-telemetry/tests/operation/find_and_modify.yml @@ -0,0 +1,67 @@ +description: operation find_one_and_update +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-aggregate + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: test + +tests: + - description: findOneAndUpdate + operations: + - name: findOneAndUpdate + object: *collection0 + arguments: + filter: &filter + _id: 1 + update: &update + - $set: { x: 5 } + comment: "comment" + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: findAndModify operation-aggregate.test + attributes: + db.system: mongodb + db.namespace: operation-aggregate + db.collection.name: test + db.operation.name: findAndModify + db.operation.summary: findAndModify operation-aggregate.test + nested: + - name: findAndModify + attributes: + db.system: mongodb + db.namespace: operation-aggregate + db.collection.name: test + db.command.name: findAndModify + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [ int, long ] } + db.query.summary: findAndModify operation-aggregate.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + findAndModify: test + query: *filter + update: *update + comment: "comment" + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/find_without_query_text.json b/source/open-telemetry/tests/operation/find_without_query_text.json new file mode 100644 index 0000000000..df50865cef --- /dev/null +++ b/source/open-telemetry/tests/operation/find_without_query_text.json @@ -0,0 +1,113 @@ +{ + "description": "operation find without db.query.text", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": false + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-find" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "operation-find", + "documents": [] + } + ], + "tests": [ + { + "description": "find an element", + "operations": [ + { + "name": "find", + "object": "collection0", + "arguments": { + "filter": { + "x": 1 + } + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "find operation-find.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-find", + "db.collection.name": "test", + "db.operation.name": "find", + "db.operation.summary": "find operation-find.test" + }, + "nested": [ + { + "name": "find", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-find", + "db.collection.name": "test", + "db.command.name": "find", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "find operation-find.test", + "db.query.text": { + "$$exists": false + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/find_without_query_text.yml b/source/open-telemetry/tests/operation/find_without_query_text.yml new file mode 100644 index 0000000000..26b53b979d --- /dev/null +++ b/source/open-telemetry/tests/operation/find_without_query_text.yml @@ -0,0 +1,56 @@ +description: operation find without db.query.text +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: false + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-find + - collection: + id: &collection0 collection0 + database: database0 + collectionName: &collection0Name test +initialData: + - collectionName: test + databaseName: operation-find + documents: [] +tests: + - description: find an element + operations: + - name: find + object: *collection0 + arguments: { filter: { x: 1 } } + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: find operation-find.test + attributes: + db.system: mongodb + db.namespace: operation-find + db.collection.name: test + db.operation.name: find + db.operation.summary: find operation-find.test + nested: + - name: find + attributes: + db.system: mongodb + db.namespace: operation-find + db.collection.name: test + db.command.name: find + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [int, long] } + server.type: { $$type: string } + db.query.summary: find operation-find.test + db.query.text: { $$exists: false } diff --git a/source/open-telemetry/tests/operation/insert.json b/source/open-telemetry/tests/operation/insert.json new file mode 100644 index 0000000000..52e659e1d0 --- /dev/null +++ b/source/open-telemetry/tests/operation/insert.json @@ -0,0 +1,117 @@ +{ + "description": "operation insert", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-insert" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "operation-insert", + "documents": [] + } + ], + "tests": [ + { + "description": "insert one element", + "operations": [ + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "document": { + "_id": 1 + } + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "insert operation-insert.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-insert", + "db.collection.name": "test", + "db.operation.name": "insert", + "db.operation.summary": "insert operation-insert.test" + }, + "nested": [ + { + "name": "insert", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-insert", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "insert operation-insert.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "insert": "test", + "ordered": true, + "txnNumber": 1, + "documents": [ + { + "_id": 1 + } + ] + } + } + } + } + } + ] + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "operation-insert", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/insert.yml b/source/open-telemetry/tests/operation/insert.yml new file mode 100644 index 0000000000..15019edafc --- /dev/null +++ b/source/open-telemetry/tests/operation/insert.yml @@ -0,0 +1,61 @@ +description: operation insert +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-insert + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: test +initialData: + - collectionName: test + databaseName: operation-insert + documents: [ ] +tests: + - description: insert one element + operations: + - object: *collection0 + name: insertOne + arguments: { document: { _id: 1 } } + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: insert operation-insert.test + attributes: + db.system: mongodb + db.namespace: operation-insert + db.collection.name: test + db.operation.name: insert + db.operation.summary: insert operation-insert.test + nested: + - name: insert + attributes: + db.system: mongodb + db.namespace: operation-insert + server.address: { $$type: string } + server.port: { $$type: [ long, string ] } + server.type: { $$type: string } + db.query.summary: insert operation-insert.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + insert: test + ordered: true + txnNumber: 1 + documents: + - _id: 1 + + outcome: + - collectionName: test + databaseName: operation-insert + documents: + - _id: 1 diff --git a/source/open-telemetry/tests/operation/list_collections.json b/source/open-telemetry/tests/operation/list_collections.json new file mode 100644 index 0000000000..3d064c3dfc --- /dev/null +++ b/source/open-telemetry/tests/operation/list_collections.json @@ -0,0 +1,106 @@ +{ + "description": "operation list_collections", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-list-collections" + } + } + ], + "tests": [ + { + "description": "List collections", + "operations": [ + { + "object": "database0", + "name": "listCollections" + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "listCollections operation-list-collections", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-list-collections", + "db.operation.name": "listCollections", + "db.operation.summary": "listCollections operation-list-collections" + }, + "nested": [ + { + "name": "listCollections", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-list-collections", + "db.command.name": "listCollections", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "listCollections operation-list-collections", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "listCollections": 1, + "cursor": {} + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/list_collections.yml b/source/open-telemetry/tests/operation/list_collections.yml new file mode 100644 index 0000000000..20c9afa5ea --- /dev/null +++ b/source/open-telemetry/tests/operation/list_collections.yml @@ -0,0 +1,52 @@ +description: operation list_collections +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-list-collections +tests: + - description: List collections + operations: + - object: *database0 + name: listCollections + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: listCollections operation-list-collections + attributes: + db.system: mongodb + db.namespace: operation-list-collections + db.operation.name: listCollections + db.operation.summary: listCollections operation-list-collections + nested: + - name: listCollections + attributes: + db.system: mongodb + db.namespace: operation-list-collections + db.command.name: listCollections + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [ int, long ] } + db.query.summary: listCollections operation-list-collections + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + listCollections: 1 + cursor: {} + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/list_databases.json b/source/open-telemetry/tests/operation/list_databases.json new file mode 100644 index 0000000000..f06ea2cf3e --- /dev/null +++ b/source/open-telemetry/tests/operation/list_databases.json @@ -0,0 +1,101 @@ +{ + "description": "operation list_databases", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + } + ], + "tests": [ + { + "description": "list databases", + "operations": [ + { + "object": "client0", + "name": "listDatabases" + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "listDatabases admin", + "attributes": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.operation.name": "listDatabases", + "db.operation.summary": "listDatabases admin" + }, + "nested": [ + { + "name": "listDatabases", + "attributes": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": { + "$$exists": false + }, + "db.command.name": "listDatabases", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "listDatabases admin", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "listDatabases": 1 + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/list_databases.yml b/source/open-telemetry/tests/operation/list_databases.yml new file mode 100644 index 0000000000..77f0a56500 --- /dev/null +++ b/source/open-telemetry/tests/operation/list_databases.yml @@ -0,0 +1,48 @@ +description: operation list_databases +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true +tests: + - description: list databases + operations: + - object: *client0 + name: listDatabases + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: listDatabases admin + attributes: + db.system: mongodb + db.namespace: admin + db.operation.name: listDatabases + db.operation.summary: listDatabases admin + nested: + - name: listDatabases + attributes: + db.system: mongodb + db.namespace: admin + db.collection.name: { $$exists: false } + db.command.name: listDatabases + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [ int, long ] } + db.query.summary: listDatabases admin + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + listDatabases: 1 + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/list_indexes.json b/source/open-telemetry/tests/operation/list_indexes.json new file mode 100644 index 0000000000..3e364b7895 --- /dev/null +++ b/source/open-telemetry/tests/operation/list_indexes.json @@ -0,0 +1,121 @@ +{ + "description": "operation list_indexes", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-list-indexes" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "operation-list-indexes", + "documents": [] + } + ], + "tests": [ + { + "description": "List indexes", + "operations": [ + { + "object": "collection0", + "name": "listIndexes" + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "listIndexes operation-list-indexes.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-list-indexes", + "db.collection.name": "test", + "db.operation.name": "listIndexes", + "db.operation.summary": "listIndexes operation-list-indexes.test" + }, + "nested": [ + { + "name": "listIndexes", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-list-indexes", + "db.collection.name": "test", + "db.command.name": "listIndexes", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "listIndexes operation-list-indexes.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "listIndexes": "test" + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/list_indexes.yml b/source/open-telemetry/tests/operation/list_indexes.yml new file mode 100644 index 0000000000..60f8ac23d8 --- /dev/null +++ b/source/open-telemetry/tests/operation/list_indexes.yml @@ -0,0 +1,61 @@ +description: operation list_indexes +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-list-indexes + - collection: + id: &collection0 collection0 + database: database0 + collectionName: test +initialData: + - collectionName: test + databaseName: operation-list-indexes + documents: [ ] +tests: + - description: List indexes + operations: + - object: *collection0 + name: listIndexes + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: listIndexes operation-list-indexes.test + attributes: + db.system: mongodb + db.namespace: operation-list-indexes + db.collection.name: test + db.operation.name: listIndexes + db.operation.summary: listIndexes operation-list-indexes.test + nested: + - name: listIndexes + attributes: + db.system: mongodb + db.namespace: operation-list-indexes + db.collection.name: test + db.command.name: listIndexes + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [ int, long ] } + db.query.summary: listIndexes operation-list-indexes.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + listIndexes: test + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/map_reduce.json b/source/open-telemetry/tests/operation/map_reduce.json new file mode 100644 index 0000000000..d5ae4f677a --- /dev/null +++ b/source/open-telemetry/tests/operation/map_reduce.json @@ -0,0 +1,180 @@ +{ + "description": "operation map_reduce", + "schemaVersion": "1.27", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "single", + "replicaset" + ] + }, + { + "minServerVersion": "4.1.7", + "serverless": "forbid", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-map-reduce" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "operation-map-reduce", + "documents": [ + { + "_id": 1, + "x": 0 + }, + { + "_id": 2, + "x": 1 + }, + { + "_id": 3, + "x": 2 + } + ] + } + ], + "tests": [ + { + "description": "mapReduce", + "operations": [ + { + "object": "collection0", + "name": "mapReduce", + "arguments": { + "map": { + "$code": "function inc() { return emit(0, this.x + 1) }" + }, + "reduce": { + "$code": "function sum(key, values) { return values.reduce((acc, x) => acc + x); }" + }, + "out": { + "inline": 1 + } + }, + "expectResult": [ + { + "_id": 0, + "value": 6 + } + ] + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "mapReduce operation-map-reduce.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-map-reduce", + "db.collection.name": "test", + "db.operation.name": "mapReduce", + "db.operation.summary": "mapReduce operation-map-reduce.test" + }, + "nested": [ + { + "name": "mapReduce", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-map-reduce", + "db.collection.name": "test", + "db.command.name": "mapReduce", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "mapReduce operation-map-reduce.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "mapReduce": "test", + "map": { + "$code": "function inc() { return emit(0, this.x + 1) }" + }, + "reduce": { + "$code": "function sum(key, values) { return values.reduce((acc, x) => acc + x); }" + }, + "out": { + "inline": 1 + } + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/map_reduce.yml b/source/open-telemetry/tests/operation/map_reduce.yml new file mode 100644 index 0000000000..d96756f9fb --- /dev/null +++ b/source/open-telemetry/tests/operation/map_reduce.yml @@ -0,0 +1,99 @@ +description: operation map_reduce +schemaVersion: '1.27' +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - single + - replicaset + - + minServerVersion: 4.1.7 + # serverless proxy does not support mapReduce operation + serverless: forbid + topologies: + - sharded + - load-balanced + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-map-reduce + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: test +initialData: + - + collectionName: test + databaseName: operation-map-reduce + documents: + - + _id: 1 + x: 0 + - + _id: 2 + x: 1 + - + _id: 3 + x: 2 +tests: + - description: mapReduce + operations: + - object: *collection0 + name: mapReduce + arguments: + map: + $code: 'function inc() { return emit(0, this.x + 1) }' + reduce: + $code: 'function sum(key, values) { return values.reduce((acc, x) => acc + x); }' + out: + inline: 1 + expectResult: + - + _id: 0 + value: 6 + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: mapReduce operation-map-reduce.test + attributes: + db.system: mongodb + db.namespace: operation-map-reduce + db.collection.name: test + db.operation.name: mapReduce + db.operation.summary: mapReduce operation-map-reduce.test + nested: + - name: mapReduce + attributes: + db.system: mongodb + db.namespace: operation-map-reduce + db.collection.name: test + db.command.name: mapReduce + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [ int, long ] } + server.type: { $$type: string } + db.query.summary: mapReduce operation-map-reduce.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + mapReduce: test + map: { $code: 'function inc() { return emit(0, this.x + 1) }' } + reduce: { $code: 'function sum(key, values) { return values.reduce((acc, x) => acc + x); }' } + out: { inline: 1 } + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/retries.json b/source/open-telemetry/tests/operation/retries.json new file mode 100644 index 0000000000..97b0174fbc --- /dev/null +++ b/source/open-telemetry/tests/operation/retries.json @@ -0,0 +1,212 @@ +{ + "description": "retries", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "client": { + "id": "failPointClient", + "useMultipleMongoses": false + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-find-retries" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "operation-find-retries", + "documents": [] + } + ], + "tests": [ + { + "description": "find an element with retries", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "failPointClient", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "find" + ], + "errorCode": 89, + "errorLabels": [ + "RetryableWriteError" + ] + } + } + } + }, + { + "name": "find", + "object": "collection0", + "arguments": { + "filter": { + "x": 1 + } + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": true, + "spans": [ + { + "name": "find operation-find-retries.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-find-retries", + "db.collection.name": "test", + "db.operation.name": "find", + "db.operation.summary": "find operation-find-retries.test" + }, + "nested": [ + { + "name": "find", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-find-retries", + "db.collection.name": "test", + "db.command.name": "find", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": "89", + "exception.message": { + "$$exists": true + }, + "exception.type": { + "$$exists": true + }, + "exception.stacktrace": { + "$$exists": true + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "db.query.summary": "find operation-find-retries.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "find": "test", + "filter": { + "x": 1 + } + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "name": "find", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-find-retries", + "db.collection.name": "test", + "db.command.name": "find", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "exception.message": { + "$$exists": false + }, + "exception.type": { + "$$exists": false + }, + "exception.stacktrace": { + "$$exists": false + }, + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "int", + "long" + ] + }, + "db.query.summary": "find operation-find-retries.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "find": "test", + "filter": { + "x": 1 + } + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/retries.yml b/source/open-telemetry/tests/operation/retries.yml new file mode 100644 index 0000000000..8d391c1b0a --- /dev/null +++ b/source/open-telemetry/tests/operation/retries.yml @@ -0,0 +1,105 @@ +description: retries +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - client: + id: &failPointClient failPointClient + useMultipleMongoses: false + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name operation-find-retries + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection0Name test +initialData: + - collectionName: test + databaseName: operation-find-retries + documents: [ ] +tests: + - description: find an element with retries + operations: + - name: failPoint + object: testRunner + arguments: + client: *failPointClient + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ find ] + errorCode: 89 + errorLabels: [ RetryableWriteError ] + + - name: find + object: *collection0 + arguments: + filter: { x: 1 } + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: true + spans: + - name: find operation-find-retries.test + attributes: + db.system: mongodb + db.namespace: *database0Name + db.collection.name: *collection0Name + db.operation.name: find + db.operation.summary: find operation-find-retries.test + nested: + - name: find + attributes: + db.system: mongodb + db.namespace: *database0Name + db.collection.name: *collection0Name + db.command.name: find + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: '89' + exception.message: { $$exists: true } + exception.type: { $$exists: true } + exception.stacktrace: { $$exists: true } + server.address: { $$type: string } + server.port: { $$type: [ long, string ] } + db.query.summary: find operation-find-retries.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + find: test + filter: + x: 1 + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] + - name: find + attributes: + db.system: mongodb + db.namespace: *database0Name + db.collection.name: *collection0Name + db.command.name: find + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + exception.message: { $$exists: false } + exception.type: { $$exists: false } + exception.stacktrace: { $$exists: false } + server.address: { $$type: string } + server.port: { $$type: [ int, long ] } + db.query.summary: find operation-find-retries.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + find: test + filter: + x: 1 + db.mongodb.server_connection_id: + $$type: [ int, long ] + db.mongodb.driver_connection_id: + $$type: [ int, long ] diff --git a/source/open-telemetry/tests/operation/update.json b/source/open-telemetry/tests/operation/update.json new file mode 100644 index 0000000000..869812fb6e --- /dev/null +++ b/source/open-telemetry/tests/operation/update.json @@ -0,0 +1,108 @@ +{ + "description": "operation update", + "schemaVersion": "1.27", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-update" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "tests": [ + { + "description": "update one element", + "operations": [ + { + "object": "collection0", + "name": "updateOne", + "arguments": { + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "x": 1 + } + } + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "update operation-update.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-update", + "db.collection.name": "test", + "db.operation.name": "update", + "db.operation.summary": "update operation-update.test" + }, + "nested": [ + { + "name": "update", + "attributes": { + "db.system": "mongodb", + "db.namespace": "operation-update", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "db.query.summary": "update operation-update.test", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "update": "test", + "ordered": true, + "txnNumber": 1, + "updates": [ + { + "q": { + "_id": 1 + }, + "u": { + "$inc": { + "x": 1 + } + } + } + ] + } + } + } + } + } + ] + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/operation/update.yml b/source/open-telemetry/tests/operation/update.yml new file mode 100644 index 0000000000..1d8e38e3ac --- /dev/null +++ b/source/open-telemetry/tests/operation/update.yml @@ -0,0 +1,53 @@ +description: operation update +schemaVersion: '1.27' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: &databaseName0 operation-update + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collectionName0 test + +tests: + - description: update one element + operations: + - + object: *collection0 + name: updateOne + arguments: + filter: { _id: 1 } + update: { $inc: { x: 1 } } + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: update operation-update.test + attributes: + db.system: mongodb + db.namespace: *databaseName0 + db.collection.name: *collectionName0 + db.operation.name: update + db.operation.summary: update operation-update.test + nested: + - name: update + attributes: + db.system: mongodb + db.namespace: operation-update + server.address: { $$type: string } + server.port: { $$type: [ long, string ] } + db.query.summary: update operation-update.test + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + update: test + ordered: true + txnNumber: 1 + updates: [ { "q": { "_id": 1 }, "u": { "$inc": { "x": 1 } } } ] diff --git a/source/open-telemetry/tests/transaction/convenient.json b/source/open-telemetry/tests/transaction/convenient.json new file mode 100644 index 0000000000..f3d8994d74 --- /dev/null +++ b/source/open-telemetry/tests/transaction/convenient.json @@ -0,0 +1,237 @@ +{ + "description": "convenient transactions", + "schemaVersion": "1.27", + "runOnRequirements": [ + { + "minServerVersion": "4.4", + "topologies": [ + "replicaset", + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database", + "client": "client", + "databaseName": "convenient-transaction-tests" + } + }, + { + "collection": { + "id": "collection", + "database": "database", + "collectionName": "test" + } + }, + { + "session": { + "id": "session", + "client": "client" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "convenient-transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "withTransaction", + "operations": [ + { + "name": "withTransaction", + "object": "session", + "arguments": { + "callback": [ + { + "name": "insertOne", + "object": "collection", + "arguments": { + "document": { + "_id": 1 + }, + "session": "session" + } + } + ] + } + }, + { + "name": "find", + "object": "collection", + "arguments": { + "filter": { + "x": 1 + } + } + } + ], + "expectTracingMessages": [ + { + "client": "client", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "transaction", + "attributes": { + "db.system": "mongodb" + }, + "nested": [ + { + "name": "insert convenient-transaction-tests.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "convenient-transaction-tests", + "db.collection.name": "test", + "db.operation.name": "insert", + "db.operation.summary": "insert convenient-transaction-tests.test" + }, + "nested": [ + { + "name": "insert", + "attributes": { + "db.system": "mongodb", + "db.namespace": "convenient-transaction-tests", + "db.collection.name": "test", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "insert convenient-transaction-tests.test", + "db.mongodb.lsid": { + "$$sessionLsid": "session" + }, + "db.mongodb.txn_number": 1, + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "insert": "test", + "ordered": true, + "txnNumber": 1, + "startTransaction": true, + "autocommit": false, + "documents": [ + { + "_id": 1 + } + ] + } + } + } + } + } + ] + }, + { + "name": "commitTransaction admin", + "attributes": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": { + "$$exists": false + }, + "db.operation.name": "commitTransaction" + }, + "nested": [ + { + "name": "commitTransaction", + "attributes": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": { + "$$exists": false + }, + "db.query.summary": "commitTransaction admin", + "db.command.name": "commitTransaction", + "db.mongodb.lsid": { + "$$sessionLsid": "session" + }, + "db.mongodb.txn_number": 1, + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "commitTransaction": 1, + "txnNumber": 1, + "autocommit": false + } + } + } + } + } + ] + } + ] + }, + { + "name": "find convenient-transaction-tests.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "convenient-transaction-tests", + "db.collection.name": "test", + "db.operation.summary": "find convenient-transaction-tests.test", + "db.operation.name": "find" + }, + "nested": [ + { + "name": "find", + "attributes": { + "db.system": "mongodb", + "db.namespace": "convenient-transaction-tests", + "db.collection.name": "test", + "db.command.name": "find", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "find convenient-transaction-tests.test" + } + } + ] + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "convenient-transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/transaction/convenient.yml b/source/open-telemetry/tests/transaction/convenient.yml new file mode 100644 index 0000000000..a9b09cd696 --- /dev/null +++ b/source/open-telemetry/tests/transaction/convenient.yml @@ -0,0 +1,132 @@ +description: convenient transactions + +schemaVersion: "1.27" + +runOnRequirements: + - minServerVersion: "4.4" + topologies: ["replicaset", "sharded"] + +createEntities: + - client: + id: &client client + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database database + client: *client + databaseName: &databaseName convenient-transaction-tests + - collection: + id: &collection collection + database: *database + collectionName: &collectionName test + - session: + id: &session session + client: *client + +initialData: + - collectionName: *collectionName + databaseName: *databaseName + documents: [] + +tests: + - description: "withTransaction" + operations: + - name: withTransaction + object: *session + arguments: + callback: + - name: insertOne + object: *collection + arguments: + document: + _id: 1 + session: *session + - name: find + object: *collection + arguments: { filter: { x: 1 } } + + expectTracingMessages: + - client: *client + ignoreExtraSpans: false + spans: + - name: transaction + attributes: + db.system: mongodb + nested: + - name: insert convenient-transaction-tests.test + attributes: + db.system: mongodb + db.namespace: *databaseName + db.collection.name: *collectionName + db.operation.name: insert + db.operation.summary: insert convenient-transaction-tests.test + nested: + - name: insert + attributes: + db.system: mongodb + db.namespace: *databaseName + db.collection.name: *collectionName + server.address: { $$type: string } + server.port: { $$type: [ 'long', 'string' ] } + server.type: { $$type: string } + db.query.summary: insert convenient-transaction-tests.test + db.mongodb.lsid: { $$sessionLsid: *session } + db.mongodb.txn_number: 1 + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + insert: test + ordered: true + txnNumber: 1 + startTransaction: true + autocommit: false + documents: + - _id: 1 + - name: commitTransaction admin + attributes: + db.system: mongodb + db.namespace: admin + db.collection.name: { $$exists: false } + db.operation.name: commitTransaction + nested: + - name: commitTransaction + attributes: + db.system: mongodb + db.namespace: admin + db.collection.name: { $$exists: false } + db.query.summary: commitTransaction admin + db.command.name: commitTransaction + db.mongodb.lsid: { $$sessionLsid: *session } + db.mongodb.txn_number: 1 + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + commitTransaction: 1 + txnNumber: 1 + autocommit: false + + - name: find convenient-transaction-tests.test + attributes: + db.system: mongodb + db.namespace: *databaseName + db.collection.name: *collectionName + db.operation.summary: find convenient-transaction-tests.test + db.operation.name: find + nested: + - name: find + attributes: + db.system: mongodb + db.namespace: *databaseName + db.collection.name: *collectionName + db.command.name: find + server.address: { $$type: string } + server.port: { $$type: [ 'long', 'string' ] } + server.type: { $$type: string } + db.query.summary: find convenient-transaction-tests.test + + outcome: + - collectionName: test + databaseName: convenient-transaction-tests + documents: + - _id: 1 diff --git a/source/open-telemetry/tests/transaction/core_api.json b/source/open-telemetry/tests/transaction/core_api.json new file mode 100644 index 0000000000..5491c9d660 --- /dev/null +++ b/source/open-telemetry/tests/transaction/core_api.json @@ -0,0 +1,380 @@ +{ + "description": "transaction spans", + "schemaVersion": "1.27", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "commit transaction", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "name": "find", + "object": "collection0", + "arguments": { + "filter": { + "x": 1 + } + } + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "transaction", + "attributes": { + "db.system": "mongodb" + }, + "nested": [ + { + "name": "insert transaction-tests.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "transaction-tests", + "db.collection.name": "test", + "db.operation.name": "insert", + "db.operation.summary": "insert transaction-tests.test" + }, + "nested": [ + { + "name": "insert", + "attributes": { + "db.system": "mongodb", + "db.namespace": "transaction-tests", + "db.collection.name": "test", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "insert transaction-tests.test", + "db.mongodb.lsid": { + "$$sessionLsid": "session0" + }, + "db.mongodb.txn_number": 1, + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "insert": "test", + "ordered": true, + "txnNumber": 1, + "startTransaction": true, + "autocommit": false, + "documents": [ + { + "_id": 1 + } + ] + } + } + } + } + } + ] + }, + { + "name": "commitTransaction admin", + "attributes": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": { + "$$exists": false + }, + "db.operation.name": "commitTransaction" + }, + "nested": [ + { + "name": "commitTransaction", + "attributes": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": { + "$$exists": false + }, + "db.query.summary": "commitTransaction admin", + "db.command.name": "commitTransaction", + "db.mongodb.lsid": { + "$$sessionLsid": "session0" + }, + "db.mongodb.txn_number": 1, + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "commitTransaction": 1, + "txnNumber": 1, + "autocommit": false + } + } + } + } + } + ] + } + ] + }, + { + "name": "find transaction-tests.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "transaction-tests", + "db.collection.name": "test", + "db.operation.summary": "find transaction-tests.test", + "db.operation.name": "find" + }, + "nested": [ + { + "name": "find", + "attributes": { + "db.system": "mongodb", + "db.namespace": "transaction-tests", + "db.collection.name": "test", + "db.command.name": "find", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "find transaction-tests.test" + } + } + ] + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "abort transaction", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectTracingMessages": [ + { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "transaction", + "attributes": { + "db.system": "mongodb" + }, + "nested": [ + { + "name": "insert transaction-tests.test", + "attributes": { + "db.system": "mongodb", + "db.namespace": "transaction-tests", + "db.collection.name": "test", + "db.operation.name": "insert", + "db.operation.summary": "insert transaction-tests.test" + }, + "nested": [ + { + "name": "insert", + "attributes": { + "db.system": "mongodb", + "db.namespace": "transaction-tests", + "db.collection.name": "test", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "insert transaction-tests.test", + "db.mongodb.lsid": { + "$$sessionLsid": "session0" + }, + "db.mongodb.txn_number": 1, + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "insert": "test", + "ordered": true, + "txnNumber": 1, + "startTransaction": true, + "autocommit": false, + "documents": [ + { + "_id": 1 + } + ] + } + } + } + } + } + ] + }, + { + "name": "abortTransaction admin", + "attributes": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": { + "$$exists": false + }, + "db.operation.name": "abortTransaction" + }, + "nested": [ + { + "name": "abortTransaction", + "attributes": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": { + "$$exists": false + }, + "db.query.summary": "abortTransaction admin", + "db.command.name": "abortTransaction", + "db.mongodb.lsid": { + "$$sessionLsid": "session0" + }, + "db.mongodb.txn_number": 1, + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "abortTransaction": 1, + "txnNumber": 1, + "autocommit": false + } + } + } + } + } + ] + } + ] + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/transaction/core_api.yml b/source/open-telemetry/tests/transaction/core_api.yml new file mode 100644 index 0000000000..63ce1e93dc --- /dev/null +++ b/source/open-telemetry/tests/transaction/core_api.yml @@ -0,0 +1,208 @@ +description: transaction spans +schemaVersion: '1.27' +runOnRequirements: + - minServerVersion: '4.0' + topologies: + - replicaset + - minServerVersion: '4.1.8' + topologies: + - sharded + - load-balanced +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: transaction-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: test + - session: + id: &session0 session0 + client: client0 +initialData: + - collectionName: test + databaseName: transaction-tests + documents: [] +tests: + - description: commit transaction + operations: + - object: *session0 + name: startTransaction + - object: *collection0 + name: insertOne + arguments: + session: *session0 + document: + _id: 1 + - object: *session0 + name: commitTransaction + - name: find + object: *collection0 + arguments: { filter: { x: 1 } } + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: transaction + attributes: + db.system: mongodb + nested: + - name: insert transaction-tests.test + attributes: + db.system: mongodb + db.namespace: transaction-tests + db.collection.name: test + db.operation.name: insert + db.operation.summary: insert transaction-tests.test + nested: + - name: insert + attributes: + db.system: mongodb + db.namespace: transaction-tests + db.collection.name: test + server.address: { $$type: string } + server.port: { $$type: ['long', 'string'] } + server.type: { $$type: string } + db.query.summary: insert transaction-tests.test + db.mongodb.lsid: { $$sessionLsid: *session0 } + db.mongodb.txn_number: 1 + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + insert: test + ordered: true + txnNumber: 1 + startTransaction: true + autocommit: false + documents: + - _id: 1 + - name: commitTransaction admin + attributes: + db.system: mongodb + db.namespace: admin + db.collection.name: { $$exists: false } + db.operation.name: commitTransaction + nested: + - name: commitTransaction + attributes: + db.system: mongodb + db.namespace: admin + db.collection.name: { $$exists: false } + db.query.summary: commitTransaction admin + db.command.name: commitTransaction + db.mongodb.lsid: { $$sessionLsid: *session0 } + db.mongodb.txn_number: 1 + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + commitTransaction: 1 + txnNumber: 1 + autocommit: false + - name: find transaction-tests.test + attributes: + db.system: mongodb + db.namespace: transaction-tests + db.collection.name: test + db.operation.summary: find transaction-tests.test + db.operation.name: find + nested: + - name: find + attributes: + db.system: mongodb + db.namespace: transaction-tests + db.collection.name: test + db.command.name: find + server.address: { $$type: string } + server.port: { $$type: ['long', 'string'] } + server.type: { $$type: string } + db.query.summary: find transaction-tests.test + outcome: + - collectionName: test + databaseName: transaction-tests + documents: + - _id: 1 + + - description: abort transaction + operations: + - object: *session0 + name: startTransaction + - object: *collection0 + name: insertOne + arguments: + session: *session0 + document: + _id: 1 + - object: *session0 + name: abortTransaction + + expectTracingMessages: + - client: *client0 + ignoreExtraSpans: false + spans: + - name: transaction + attributes: + db.system: mongodb + nested: + - name: insert transaction-tests.test + attributes: + db.system: mongodb + db.namespace: transaction-tests + db.collection.name: test + db.operation.name: insert + db.operation.summary: insert transaction-tests.test + nested: + - name: insert + attributes: + db.system: mongodb + db.namespace: transaction-tests + db.collection.name: test + server.address: { $$type: string } + server.port: { $$type: ['long', 'string'] } + server.type: { $$type: string } + db.query.summary: insert transaction-tests.test + db.mongodb.lsid: { $$sessionLsid: *session0 } + db.mongodb.txn_number: 1 + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + insert: test + ordered: true + txnNumber: 1 + startTransaction: true + autocommit: false + documents: + - _id: 1 + - name: abortTransaction admin + attributes: + db.system: mongodb + db.namespace: admin + db.collection.name: { $$exists: false } + db.operation.name: abortTransaction + nested: + - name: abortTransaction + attributes: + db.system: mongodb + db.namespace: admin + db.collection.name: { $$exists: false } + db.query.summary: abortTransaction admin + db.command.name: abortTransaction + db.mongodb.lsid: { $$sessionLsid: *session0 } + db.mongodb.txn_number: 1 + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + abortTransaction: 1 + txnNumber: 1 + autocommit: false + + outcome: + - collectionName: test + databaseName: transaction-tests + documents: [] diff --git a/source/unified-test-format/schema-1.27.json b/source/unified-test-format/schema-1.27.json new file mode 100644 index 0000000000..d195ba5af0 --- /dev/null +++ b/source/unified-test-format/schema-1.27.json @@ -0,0 +1,1242 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema#", + "title": "Unified Test Format", + "type": "object", + "additionalProperties": false, + "required": [ + "description", + "schemaVersion", + "tests" + ], + "properties": { + "description": { + "type": "string" + }, + "schemaVersion": { + "$ref": "#/definitions/version" + }, + "runOnRequirements": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/runOnRequirement" + } + }, + "createEntities": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/entity" + } + }, + "initialData": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/collectionData" + } + }, + "tests": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/test" + } + }, + "_yamlAnchors": { + "type": "object", + "additionalProperties": true + } + }, + "definitions": { + "version": { + "type": "string", + "pattern": "^[0-9]+(\\.[0-9]+){1,2}$" + }, + "runOnRequirement": { + "type": "object", + "additionalProperties": false, + "minProperties": 1, + "properties": { + "maxServerVersion": { + "$ref": "#/definitions/version" + }, + "minServerVersion": { + "$ref": "#/definitions/version" + }, + "topologies": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "enum": [ + "single", + "replicaset", + "sharded", + "sharded-replicaset", + "load-balanced" + ] + } + }, + "serverless": { + "type": "string", + "enum": [ + "require", + "forbid", + "allow" + ] + }, + "serverParameters": { + "type": "object", + "minProperties": 1 + }, + "auth": { + "type": "boolean" + }, + "authMechanism": { + "type": "string" + }, + "csfle": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "object", + "additionalProperties": false, + "minProperties": 1, + "properties": { + "minLibmongocryptVersion": { + "$ref": "#/definitions/version" + } + } + } + ] + } + } + }, + "entity": { + "type": "object", + "additionalProperties": false, + "maxProperties": 1, + "minProperties": 1, + "properties": { + "client": { + "type": "object", + "additionalProperties": false, + "required": [ + "id" + ], + "properties": { + "id": { + "type": "string" + }, + "uriOptions": { + "type": "object" + }, + "useMultipleMongoses": { + "type": "boolean" + }, + "observeEvents": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "enum": [ + "commandStartedEvent", + "commandSucceededEvent", + "commandFailedEvent", + "poolCreatedEvent", + "poolReadyEvent", + "poolClearedEvent", + "poolClosedEvent", + "connectionCreatedEvent", + "connectionReadyEvent", + "connectionClosedEvent", + "connectionCheckOutStartedEvent", + "connectionCheckOutFailedEvent", + "connectionCheckedOutEvent", + "connectionCheckedInEvent", + "serverDescriptionChangedEvent", + "topologyDescriptionChangedEvent", + "topologyOpeningEvent", + "topologyClosedEvent" + ] + } + }, + "ignoreCommandMonitoringEvents": { + "type": "array", + "minItems": 1, + "items": { + "type": "string" + } + }, + "storeEventsAsEntities": { + "deprecated": true, + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/storeEventsAsEntity" + } + }, + "observeLogMessages": { + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "properties": { + "command": { + "$ref": "#/definitions/logSeverityLevel" + }, + "topology": { + "$ref": "#/definitions/logSeverityLevel" + }, + "serverSelection": { + "$ref": "#/definitions/logSeverityLevel" + }, + "connection": { + "$ref": "#/definitions/logSeverityLevel" + } + } + }, + "observeTracingMessages": { + "type": "object", + "additionalProperties": false, + "properties": { + "enableCommandPayload": { + "type": "boolean" + } + } + }, + "serverApi": { + "$ref": "#/definitions/serverApi" + }, + "observeSensitiveCommands": { + "type": "boolean" + }, + "autoEncryptOpts": { + "type": "object", + "additionalProperties": false, + "required": [ + "keyVaultNamespace", + "kmsProviders" + ], + "properties": { + "keyVaultNamespace": { + "type": "string" + }, + "bypassAutoEncryption": { + "type": "boolean" + }, + "kmsProviders": { + "$ref": "#/definitions/kmsProviders" + }, + "schemaMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "extraOptions": { + "type": "object" + }, + "encryptedFieldsMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "bypassQueryAnalysis": { + "type": "boolean" + }, + "keyExpirationMS": { + "type": "integer" + } + } + }, + "awaitMinPoolSizeMS": { + "type": "integer" + } + } + }, + "clientEncryption": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "clientEncryptionOpts" + ], + "properties": { + "id": { + "type": "string" + }, + "clientEncryptionOpts": { + "$ref": "#/definitions/clientEncryptionOpts" + } + } + }, + "database": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "client", + "databaseName" + ], + "properties": { + "id": { + "type": "string" + }, + "client": { + "type": "string" + }, + "databaseName": { + "type": "string" + }, + "databaseOptions": { + "$ref": "#/definitions/collectionOrDatabaseOptions" + } + } + }, + "collection": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "database", + "collectionName" + ], + "properties": { + "id": { + "type": "string" + }, + "database": { + "type": "string" + }, + "collectionName": { + "type": "string" + }, + "collectionOptions": { + "$ref": "#/definitions/collectionOrDatabaseOptions" + } + } + }, + "session": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "client" + ], + "properties": { + "id": { + "type": "string" + }, + "client": { + "type": "string" + }, + "sessionOptions": { + "type": "object" + } + } + }, + "bucket": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "database" + ], + "properties": { + "id": { + "type": "string" + }, + "database": { + "type": "string" + }, + "bucketOptions": { + "type": "object" + } + } + }, + "thread": { + "type": "object", + "additionalProperties": false, + "required": [ + "id" + ], + "properties": { + "id": { + "type": "string" + } + } + } + } + }, + "logComponent": { + "type": "string", + "enum": [ + "command", + "topology", + "serverSelection", + "connection" + ] + }, + "spanComponent": { + "type": "object", + "additionalProperties": false, + "required": [ + "name", + "attributes" + ], + "properties": { + "name": { + "type": "string" + }, + "attributes": { + "type": "object" + }, + "nested": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/spanComponent" + } + } + } + }, + "logSeverityLevel": { + "type": "string", + "enum": [ + "emergency", + "alert", + "critical", + "error", + "warning", + "notice", + "info", + "debug", + "trace" + ] + }, + "clientEncryptionOpts": { + "type": "object", + "additionalProperties": false, + "required": [ + "keyVaultClient", + "keyVaultNamespace", + "kmsProviders" + ], + "properties": { + "keyVaultClient": { + "type": "string" + }, + "keyVaultNamespace": { + "type": "string" + }, + "kmsProviders": { + "$ref": "#/definitions/kmsProviders" + }, + "keyExpirationMS": { + "type": "integer" + } + } + }, + "kmsProviders": { + "$defs": { + "stringOrPlaceholder": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "$$placeholder" + ], + "properties": { + "$$placeholder": {} + } + } + ] + } + }, + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^aws(:[a-zA-Z0-9_]+)?$": { + "type": "object", + "additionalProperties": false, + "properties": { + "accessKeyId": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + }, + "secretAccessKey": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + }, + "sessionToken": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + } + } + }, + "^azure(:[a-zA-Z0-9_]+)?$": { + "type": "object", + "additionalProperties": false, + "properties": { + "tenantId": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + }, + "clientId": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + }, + "clientSecret": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + }, + "identityPlatformEndpoint": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + } + } + }, + "^gcp(:[a-zA-Z0-9_]+)?$": { + "type": "object", + "additionalProperties": false, + "properties": { + "email": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + }, + "privateKey": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + }, + "endpoint": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + } + } + }, + "^kmip(:[a-zA-Z0-9_]+)?$": { + "type": "object", + "additionalProperties": false, + "properties": { + "endpoint": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + } + } + }, + "^local(:[a-zA-Z0-9_]+)?$": { + "type": "object", + "additionalProperties": false, + "properties": { + "key": { + "$ref": "#/definitions/kmsProviders/$defs/stringOrPlaceholder" + } + } + } + } + }, + "storeEventsAsEntity": { + "deprecated": true, + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "events" + ], + "properties": { + "id": { + "type": "string" + }, + "events": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "enum": [ + "PoolCreatedEvent", + "PoolReadyEvent", + "PoolClearedEvent", + "PoolClosedEvent", + "ConnectionCreatedEvent", + "ConnectionReadyEvent", + "ConnectionClosedEvent", + "ConnectionCheckOutStartedEvent", + "ConnectionCheckOutFailedEvent", + "ConnectionCheckedOutEvent", + "ConnectionCheckedInEvent", + "CommandStartedEvent", + "CommandSucceededEvent", + "CommandFailedEvent", + "ServerDescriptionChangedEvent", + "TopologyDescriptionChangedEvent" + ] + } + } + } + }, + "collectionData": { + "type": "object", + "additionalProperties": false, + "required": [ + "collectionName", + "databaseName", + "documents" + ], + "properties": { + "collectionName": { + "type": "string" + }, + "databaseName": { + "type": "string" + }, + "createOptions": { + "type": "object", + "properties": { + "writeConcern": false + } + }, + "documents": { + "type": "array", + "items": { + "type": "object" + } + } + } + }, + "expectedEventsForClient": { + "type": "object", + "additionalProperties": false, + "required": [ + "client", + "events" + ], + "properties": { + "client": { + "type": "string" + }, + "eventType": { + "type": "string", + "enum": [ + "command", + "cmap", + "sdam" + ] + }, + "events": { + "type": "array" + }, + "ignoreExtraEvents": { + "type": "boolean" + } + }, + "oneOf": [ + { + "required": [ + "eventType" + ], + "properties": { + "eventType": { + "const": "command" + }, + "events": { + "type": "array", + "items": { + "$ref": "#/definitions/expectedCommandEvent" + } + } + } + }, + { + "required": [ + "eventType" + ], + "properties": { + "eventType": { + "const": "cmap" + }, + "events": { + "type": "array", + "items": { + "$ref": "#/definitions/expectedCmapEvent" + } + } + } + }, + { + "required": [ + "eventType" + ], + "properties": { + "eventType": { + "const": "sdam" + }, + "events": { + "type": "array", + "items": { + "$ref": "#/definitions/expectedSdamEvent" + } + } + } + }, + { + "additionalProperties": false, + "properties": { + "client": { + "type": "string" + }, + "events": { + "type": "array", + "items": { + "$ref": "#/definitions/expectedCommandEvent" + } + }, + "ignoreExtraEvents": { + "type": "boolean" + } + } + } + ] + }, + "expectedCommandEvent": { + "type": "object", + "additionalProperties": false, + "maxProperties": 1, + "minProperties": 1, + "properties": { + "commandStartedEvent": { + "type": "object", + "additionalProperties": false, + "properties": { + "command": { + "type": "object" + }, + "commandName": { + "type": "string" + }, + "databaseName": { + "type": "string" + }, + "hasServiceId": { + "type": "boolean" + }, + "hasServerConnectionId": { + "type": "boolean" + } + } + }, + "commandSucceededEvent": { + "type": "object", + "additionalProperties": false, + "properties": { + "reply": { + "type": "object" + }, + "commandName": { + "type": "string" + }, + "databaseName": { + "type": "string" + }, + "hasServiceId": { + "type": "boolean" + }, + "hasServerConnectionId": { + "type": "boolean" + } + } + }, + "commandFailedEvent": { + "type": "object", + "additionalProperties": false, + "properties": { + "commandName": { + "type": "string" + }, + "databaseName": { + "type": "string" + }, + "hasServiceId": { + "type": "boolean" + }, + "hasServerConnectionId": { + "type": "boolean" + } + } + } + } + }, + "expectedCmapEvent": { + "type": "object", + "additionalProperties": false, + "maxProperties": 1, + "minProperties": 1, + "properties": { + "poolCreatedEvent": { + "type": "object", + "additionalProperties": false, + "properties": {} + }, + "poolReadyEvent": { + "type": "object", + "additionalProperties": false, + "properties": {} + }, + "poolClearedEvent": { + "type": "object", + "additionalProperties": false, + "properties": { + "hasServiceId": { + "type": "boolean" + }, + "interruptInUseConnections": { + "type": "boolean" + } + } + }, + "poolClosedEvent": { + "type": "object", + "additionalProperties": false, + "properties": {} + }, + "connectionCreatedEvent": { + "type": "object", + "additionalProperties": false, + "properties": {} + }, + "connectionReadyEvent": { + "type": "object", + "additionalProperties": false, + "properties": {} + }, + "connectionClosedEvent": { + "type": "object", + "additionalProperties": false, + "properties": { + "reason": { + "type": "string" + } + } + }, + "connectionCheckOutStartedEvent": { + "type": "object", + "additionalProperties": false, + "properties": {} + }, + "connectionCheckOutFailedEvent": { + "type": "object", + "additionalProperties": false, + "properties": { + "reason": { + "type": "string" + } + } + }, + "connectionCheckedOutEvent": { + "type": "object", + "additionalProperties": false, + "properties": {} + }, + "connectionCheckedInEvent": { + "type": "object", + "additionalProperties": false, + "properties": {} + } + } + }, + "expectedSdamEvent": { + "type": "object", + "additionalProperties": false, + "maxProperties": 1, + "minProperties": 1, + "properties": { + "serverDescriptionChangedEvent": { + "type": "object", + "additionalProperties": false, + "properties": { + "previousDescription": { + "$ref": "#/definitions/serverDescription" + }, + "newDescription": { + "$ref": "#/definitions/serverDescription" + } + } + }, + "topologyDescriptionChangedEvent": { + "type": "object", + "additionalProperties": false, + "properties": { + "previousDescription": { + "$ref": "#/definitions/topologyDescription" + }, + "newDescription": { + "$ref": "#/definitions/topologyDescription" + } + } + }, + "serverHeartbeatStartedEvent": { + "type": "object", + "additionalProperties": false, + "properties": { + "awaited": { + "type": "boolean" + } + } + }, + "serverHeartbeatSucceededEvent": { + "type": "object", + "additionalProperties": false, + "properties": { + "awaited": { + "type": "boolean" + } + } + }, + "serverHeartbeatFailedEvent": { + "type": "object", + "additionalProperties": false, + "properties": { + "awaited": { + "type": "boolean" + } + } + }, + "topologyOpeningEvent": { + "type": "object", + "additionalProperties": false, + "properties": {} + }, + "topologyClosedEvent": { + "type": "object", + "additionalProperties": false, + "properties": {} + } + } + }, + "serverDescription": { + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "type": "string", + "enum": [ + "Standalone", + "Mongos", + "PossiblePrimary", + "RSPrimary", + "RSSecondary", + "RSOther", + "RSArbiter", + "RSGhost", + "LoadBalancer", + "Unknown" + ] + } + } + }, + "topologyDescription": { + "type": "object", + "additionalProperties": false, + "properties": { + "type": { + "type": "string", + "enum": [ + "Single", + "Unknown", + "ReplicaSetNoPrimary", + "ReplicaSetWithPrimary", + "Sharded", + "LoadBalanced" + ] + } + } + }, + "expectedLogMessagesForClient": { + "type": "object", + "additionalProperties": false, + "required": [ + "client", + "messages" + ], + "properties": { + "client": { + "type": "string" + }, + "messages": { + "type": "array", + "items": { + "$ref": "#/definitions/expectedLogMessage" + } + }, + "ignoreExtraMessages": { + "type": "boolean" + }, + "ignoreMessages": { + "type": "array", + "items": { + "$ref": "#/definitions/expectedLogMessage" + } + } + } + }, + "expectTracingMessagesForClient": { + "additionalProperties": false, + "type": "object", + "required": [ + "client", + "spans" + ], + "properties": { + "client": { + "type": "string" + }, + "ignoreExtraSpans": { + "type": "boolean" + }, + "spans": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/spanComponent" + } + } + } + }, + "expectedLogMessage": { + "type": "object", + "additionalProperties": false, + "required": [ + "level", + "component", + "data" + ], + "properties": { + "level": { + "$ref": "#/definitions/logSeverityLevel" + }, + "component": { + "$ref": "#/definitions/logComponent" + }, + "data": { + "type": "object" + }, + "failureIsRedacted": { + "type": "boolean" + } + } + }, + "collectionOrDatabaseOptions": { + "type": "object", + "additionalProperties": false, + "properties": { + "readConcern": { + "type": "object" + }, + "readPreference": { + "type": "object" + }, + "writeConcern": { + "type": "object" + }, + "timeoutMS": { + "type": "integer" + } + } + }, + "serverApi": { + "type": "object", + "additionalProperties": false, + "required": [ + "version" + ], + "properties": { + "version": { + "type": "string" + }, + "strict": { + "type": "boolean" + }, + "deprecationErrors": { + "type": "boolean" + } + } + }, + "operation": { + "type": "object", + "additionalProperties": false, + "required": [ + "name", + "object" + ], + "properties": { + "name": { + "type": "string" + }, + "object": { + "type": "string" + }, + "arguments": { + "type": "object" + }, + "ignoreResultAndError": { + "type": "boolean" + }, + "expectError": { + "$ref": "#/definitions/expectedError" + }, + "expectResult": {}, + "saveResultAsEntity": { + "type": "string" + } + }, + "allOf": [ + { + "not": { + "required": [ + "expectError", + "expectResult" + ] + } + }, + { + "not": { + "required": [ + "expectError", + "saveResultAsEntity" + ] + } + }, + { + "not": { + "required": [ + "ignoreResultAndError", + "expectResult" + ] + } + }, + { + "not": { + "required": [ + "ignoreResultAndError", + "expectError" + ] + } + }, + { + "not": { + "required": [ + "ignoreResultAndError", + "saveResultAsEntity" + ] + } + } + ] + }, + "expectedError": { + "type": "object", + "additionalProperties": false, + "minProperties": 1, + "properties": { + "isError": { + "type": "boolean", + "const": true + }, + "isClientError": { + "type": "boolean" + }, + "isTimeoutError": { + "type": "boolean" + }, + "errorContains": { + "type": "string" + }, + "errorCode": { + "type": "integer" + }, + "errorCodeName": { + "type": "string" + }, + "errorLabelsContain": { + "type": "array", + "minItems": 1, + "items": { + "type": "string" + } + }, + "errorLabelsOmit": { + "type": "array", + "minItems": 1, + "items": { + "type": "string" + } + }, + "writeErrors": { + "type": "object" + }, + "writeConcernErrors": { + "type": "array", + "items": { + "type": "object" + } + }, + "errorResponse": { + "type": "object" + }, + "expectResult": {} + } + }, + "test": { + "type": "object", + "additionalProperties": false, + "required": [ + "description", + "operations" + ], + "properties": { + "description": { + "type": "string" + }, + "runOnRequirements": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/runOnRequirement" + } + }, + "skipReason": { + "type": "string" + }, + "operations": { + "type": "array", + "items": { + "$ref": "#/definitions/operation" + } + }, + "expectEvents": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/expectedEventsForClient" + } + }, + "expectLogMessages": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/expectedLogMessagesForClient" + } + }, + "expectTracingMessages": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/expectTracingMessagesForClient" + } + }, + "outcome": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/collectionData" + } + } + } + } + } +} diff --git a/source/unified-test-format/schema-latest.json b/source/unified-test-format/schema-latest.json index c4e2b539ef..d195ba5af0 100644 --- a/source/unified-test-format/schema-latest.json +++ b/source/unified-test-format/schema-latest.json @@ -198,6 +198,15 @@ } } }, + "observeTracingMessages": { + "type": "object", + "additionalProperties": false, + "properties": { + "enableCommandPayload": { + "type": "boolean" + } + } + }, "serverApi": { "$ref": "#/definitions/serverApi" }, @@ -372,6 +381,29 @@ "connection" ] }, + "spanComponent": { + "type": "object", + "additionalProperties": false, + "required": [ + "name", + "attributes" + ], + "properties": { + "name": { + "type": "string" + }, + "attributes": { + "type": "object" + }, + "nested": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/spanComponent" + } + } + } + }, "logSeverityLevel": { "type": "string", "enum": [ @@ -943,6 +975,29 @@ } } }, + "expectTracingMessagesForClient": { + "additionalProperties": false, + "type": "object", + "required": [ + "client", + "spans" + ], + "properties": { + "client": { + "type": "string" + }, + "ignoreExtraSpans": { + "type": "boolean" + }, + "spans": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/spanComponent" + } + } + } + }, "expectedLogMessage": { "type": "object", "additionalProperties": false, @@ -1167,6 +1222,13 @@ "$ref": "#/definitions/expectedLogMessagesForClient" } }, + "expectTracingMessages": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/expectTracingMessagesForClient" + } + }, "outcome": { "type": "array", "minItems": 1, diff --git a/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalProperties.json b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalProperties.json new file mode 100644 index 0000000000..aa8046d28e --- /dev/null +++ b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalProperties.json @@ -0,0 +1,20 @@ +{ + "description": "entity-client-observeTracingMessages-additionalProperties", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0", + "observeTracingMessages": { + "foo": "bar" + } + } + } + ], + "tests": [ + { + "description": "observeTracingMessages must not have additional properties'", + "operations": [] + } + ] +} diff --git a/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalProperties.yml b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalProperties.yml new file mode 100644 index 0000000000..3ec4cd1691 --- /dev/null +++ b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalProperties.yml @@ -0,0 +1,13 @@ +description: "entity-client-observeTracingMessages-additionalProperties" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + observeTracingMessages: + foo: "bar" + +tests: + - description: "observeTracingMessages must not have additional properties'" + operations: [ ] diff --git a/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalPropertyType.json b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalPropertyType.json new file mode 100644 index 0000000000..0b3a65f587 --- /dev/null +++ b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalPropertyType.json @@ -0,0 +1,20 @@ +{ + "description": "entity-client-observeTracingMessages-additionalPropertyType", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0", + "observeTracingMessages": { + "enableCommandPayload": 0 + } + } + } + ], + "tests": [ + { + "description": "observeTracingMessages enableCommandPayload must be boolean", + "operations": [] + } + ] +} diff --git a/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalPropertyType.yml b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalPropertyType.yml new file mode 100644 index 0000000000..8327458aee --- /dev/null +++ b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-additionalPropertyType.yml @@ -0,0 +1,13 @@ +description: "entity-client-observeTracingMessages-additionalPropertyType" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + observeTracingMessages: + enableCommandPayload: 0 + +tests: + - description: "observeTracingMessages enableCommandPayload must be boolean" + operations: [ ] diff --git a/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-type.json b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-type.json new file mode 100644 index 0000000000..de3ef39ab1 --- /dev/null +++ b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-type.json @@ -0,0 +1,18 @@ +{ + "description": "entity-client-observeTracingMessages-type", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0", + "observeTracingMessages": "foo" + } + } + ], + "tests": [ + { + "description": "observeTracingMessages must be an object", + "operations": [] + } + ] +} diff --git a/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-type.yml b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-type.yml new file mode 100644 index 0000000000..e4dbeae64e --- /dev/null +++ b/source/unified-test-format/tests/invalid/entity-client-observeTracingMessages-type.yml @@ -0,0 +1,12 @@ +description: "entity-client-observeTracingMessages-type" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + observeTracingMessages: "foo" + +tests: + - description: "observeTracingMessages must be an object" + operations: [ ] diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-additionalProperties.json b/source/unified-test-format/tests/invalid/expectedTracingSpans-additionalProperties.json new file mode 100644 index 0000000000..5947a286b2 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-additionalProperties.json @@ -0,0 +1,30 @@ +{ + "description": "expectedTracingSpans-additionalProperties", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0" + } + } + ], + "tests": [ + { + "description": "additional property foo not allowed in expectTracingMessages", + "operations": [], + "expectTracingMessages": { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "command", + "tags": { + "db.system": "mongodb" + } + } + ], + "foo": 0 + } + } + ] +} diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-additionalProperties.yml b/source/unified-test-format/tests/invalid/expectedTracingSpans-additionalProperties.yml new file mode 100644 index 0000000000..a00a79f257 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-additionalProperties.yml @@ -0,0 +1,16 @@ +description: "expectedTracingSpans-additionalProperties" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + +tests: + - description: "additional property foo not allowed in expectTracingMessages" + operations: [] + expectTracingMessages: + client: *client0 + ignoreExtraSpans: false + spans: [ { name: "command", tags: { db.system: mongodb } } ] + foo: 0 diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-clientType.json b/source/unified-test-format/tests/invalid/expectedTracingSpans-clientType.json new file mode 100644 index 0000000000..2fe7faea34 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-clientType.json @@ -0,0 +1,28 @@ +{ + "description": "expectedTracingSpans-clientType", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0" + } + } + ], + "tests": [ + { + "description": "client type must be string", + "operations": [], + "expectTracingMessages": { + "client": 0, + "spans": [ + { + "name": "command", + "tags": { + "db.system": "mongodb" + } + } + ] + } + } + ] +} diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-clientType.yml b/source/unified-test-format/tests/invalid/expectedTracingSpans-clientType.yml new file mode 100644 index 0000000000..41af5de8bc --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-clientType.yml @@ -0,0 +1,14 @@ +description: "expectedTracingSpans-clientType" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + +tests: + - description: "client type must be string" + operations: [] + expectTracingMessages: + client: 0 + spans: [ { name: "command", tags: { db.system: mongodb } } ] diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-emptyNestedSpan.json b/source/unified-test-format/tests/invalid/expectedTracingSpans-emptyNestedSpan.json new file mode 100644 index 0000000000..8a98d5ba81 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-emptyNestedSpan.json @@ -0,0 +1,29 @@ +{ + "description": "expectedTracingSpans-emptyNestedSpan", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0" + } + } + ], + "tests": [ + { + "description": "nested spans must not have fewer than 1 items'", + "operations": [], + "expectTracingMessages": { + "client": "client0", + "spans": [ + { + "name": "command", + "tags": { + "db.system": "mongodb" + }, + "nested": [] + } + ] + } + } + ] +} diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-emptyNestedSpan.yml b/source/unified-test-format/tests/invalid/expectedTracingSpans-emptyNestedSpan.yml new file mode 100644 index 0000000000..abc9f8b3b8 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-emptyNestedSpan.yml @@ -0,0 +1,14 @@ +description: "expectedTracingSpans-emptyNestedSpan" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + +tests: + - description: "nested spans must not have fewer than 1 items'" + operations: [] + expectTracingMessages: + client: *client0 + spans: [ { name: "command", tags: { db.system: mongodb }, nested:[] } ] diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-invalidNestedSpan.json b/source/unified-test-format/tests/invalid/expectedTracingSpans-invalidNestedSpan.json new file mode 100644 index 0000000000..79a86744fb --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-invalidNestedSpan.json @@ -0,0 +1,31 @@ +{ + "description": "expectedTracingSpans-invalidNestedSpan", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0" + } + } + ], + "tests": [ + { + "description": "nested span must have required property name", + "operations": [], + "expectTracingMessages": { + "client": "client0", + "spans": [ + { + "name": "command", + "tags": { + "db.system": "mongodb" + }, + "nested": [ + {} + ] + } + ] + } + } + ] +} diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-invalidNestedSpan.yml b/source/unified-test-format/tests/invalid/expectedTracingSpans-invalidNestedSpan.yml new file mode 100644 index 0000000000..6490c30502 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-invalidNestedSpan.yml @@ -0,0 +1,14 @@ +description: "expectedTracingSpans-invalidNestedSpan" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + +tests: + - description: "nested span must have required property name" + operations: [] + expectTracingMessages: + client: *client0 + spans: [ { name: "command", tags: { db.system: mongodb }, nested: [ { } ] } ] diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertyClient.json b/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertyClient.json new file mode 100644 index 0000000000..2fb1cd5bbc --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertyClient.json @@ -0,0 +1,27 @@ +{ + "description": "expectedTracingSpans-missingPropertyClient", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0" + } + } + ], + "tests": [ + { + "description": "missing required property client", + "operations": [], + "expectTracingMessages": { + "spans": [ + { + "name": "command", + "tags": { + "db.system": "mongodb" + } + } + ] + } + } + ] +} diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertyClient.yml b/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertyClient.yml new file mode 100644 index 0000000000..cb0a46f1da --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertyClient.yml @@ -0,0 +1,13 @@ +description: "expectedTracingSpans-missingPropertyClient" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + +tests: + - description: "missing required property client" + operations: [] + expectTracingMessages: + spans: [ { name: "command", tags: { db.system: mongodb } } ] diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertySpans.json b/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertySpans.json new file mode 100644 index 0000000000..acd1030736 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertySpans.json @@ -0,0 +1,20 @@ +{ + "description": "expectedTracingSpans-missingPropertySpans", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0" + } + } + ], + "tests": [ + { + "description": "missing required property spans", + "operations": [], + "expectTracingMessages": { + "client": "client0" + } + } + ] +} diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertySpans.yml b/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertySpans.yml new file mode 100644 index 0000000000..b58f471189 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-missingPropertySpans.yml @@ -0,0 +1,13 @@ +description: "expectedTracingSpans-missingPropertySpans" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + +tests: + - description: "missing required property spans" + operations: [] + expectTracingMessages: + client: *client0 diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedAdditionalProperties.json b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedAdditionalProperties.json new file mode 100644 index 0000000000..17299f8622 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedAdditionalProperties.json @@ -0,0 +1,28 @@ +{ + "description": "expectedTracingSpans-spanMalformedAdditionalProperties", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0" + } + } + ], + "tests": [ + { + "description": "Span must not have additional properties", + "operations": [], + "expectTracingMessages": { + "client": "client0", + "spans": [ + { + "name": "foo", + "tags": {}, + "nested": [], + "foo": "bar" + } + ] + } + } + ] +} diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedAdditionalProperties.yml b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedAdditionalProperties.yml new file mode 100644 index 0000000000..fe209cc82f --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedAdditionalProperties.yml @@ -0,0 +1,19 @@ +description: "expectedTracingSpans-spanMalformedAdditionalProperties" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + +tests: + - description: "Span must not have additional properties" + operations: [] + expectTracingMessages: + client: *client0 + spans: + - name: "foo" + tags: {} + nested: [] + foo: "bar" + diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingName.json b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingName.json new file mode 100644 index 0000000000..0257cd9b3d --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingName.json @@ -0,0 +1,27 @@ +{ + "description": "expectedTracingSpans-spanMalformedMissingName", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0" + } + } + ], + "tests": [ + { + "description": "missing required span name", + "operations": [], + "expectTracingMessages": { + "client": "client0", + "spans": [ + { + "tags": { + "db.system": "mongodb" + } + } + ] + } + } + ] +} diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingName.yml b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingName.yml new file mode 100644 index 0000000000..e983a2e074 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingName.yml @@ -0,0 +1,16 @@ +description: "expectedTracingSpans-spanMalformedMissingName" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + +tests: + - description: "missing required span name" + operations: [] + expectTracingMessages: + client: *client0 + spans: + - tags: { db.system: mongodb } + diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingTags.json b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingTags.json new file mode 100644 index 0000000000..a09ca31c95 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingTags.json @@ -0,0 +1,25 @@ +{ + "description": "expectedTracingSpans-spanMalformedMissingTags", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0" + } + } + ], + "tests": [ + { + "description": "missing required span tags", + "operations": [], + "expectTracingMessages": { + "client": "client0", + "spans": [ + { + "name": "foo" + } + ] + } + } + ] +} diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingTags.yml b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingTags.yml new file mode 100644 index 0000000000..5d82e5b360 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedMissingTags.yml @@ -0,0 +1,15 @@ +description: "expectedTracingSpans-spanMalformedMissingTags" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + +tests: + - description: "missing required span tags" + operations: [] + expectTracingMessages: + client: *client0 + spans: + - name: "foo" diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedNestedMustBeArray.json b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedNestedMustBeArray.json new file mode 100644 index 0000000000..ccff04108d --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedNestedMustBeArray.json @@ -0,0 +1,27 @@ +{ + "description": "expectedTracingSpans-spanMalformedNestedMustBeArray", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0" + } + } + ], + "tests": [ + { + "description": "nested spans must be an array", + "operations": [], + "expectTracingMessages": { + "client": "client0", + "spans": [ + { + "name": "foo", + "tags": {}, + "nested": {} + } + ] + } + } + ] +} diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedNestedMustBeArray.yml b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedNestedMustBeArray.yml new file mode 100644 index 0000000000..c5eed9a491 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedNestedMustBeArray.yml @@ -0,0 +1,18 @@ +description: "expectedTracingSpans-spanMalformedNestedMustBeArray" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + +tests: + - description: "nested spans must be an array" + operations: [] + expectTracingMessages: + client: *client0 + spans: + - name: "foo" + tags: {} + nested: {} + diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedTagsMustBeObject.json b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedTagsMustBeObject.json new file mode 100644 index 0000000000..72af1c29b1 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedTagsMustBeObject.json @@ -0,0 +1,26 @@ +{ + "description": "expectedTracingSpans-spanMalformedNestedMustBeObject", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0" + } + } + ], + "tests": [ + { + "description": "span tags must be an object", + "operations": [], + "expectTracingMessages": { + "client": "client0", + "spans": [ + { + "name": "foo", + "tags": [] + } + ] + } + } + ] +} diff --git a/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedTagsMustBeObject.yml b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedTagsMustBeObject.yml new file mode 100644 index 0000000000..b34bdc2b82 --- /dev/null +++ b/source/unified-test-format/tests/invalid/expectedTracingSpans-spanMalformedTagsMustBeObject.yml @@ -0,0 +1,17 @@ +description: "expectedTracingSpans-spanMalformedNestedMustBeObject" + +schemaVersion: "1.26" + +createEntities: + - client: + id: &client0 "client0" + +tests: + - description: "span tags must be an object" + operations: [] + expectTracingMessages: + client: *client0 + spans: + - name: "foo" + tags: [] + diff --git a/source/unified-test-format/unified-test-format.md b/source/unified-test-format/unified-test-format.md index 9701a51c8d..59700ff510 100644 --- a/source/unified-test-format/unified-test-format.md +++ b/source/unified-test-format/unified-test-format.md @@ -2,7 +2,7 @@ - Status: Accepted - Minimum Server Version: N/A -- Current Schema Version: 1.26.0 +- Current Schema Version: 1.27.0 ______________________________________________________________________ @@ -523,6 +523,15 @@ The structure of this object is as follows: Messages for unspecified components and/or with lower severity levels than those specified MUST be ignored by this client's log collector(s) and SHOULD NOT be included in [test.expectLogMessages](#test_expectLogMessages) for this client. + + - `observeTracingMessages`: Optional object that configures tracing behavior for the client. The structure of this + object is as follows: + + - `enableCommandPayload`: Optional boolean. When set to `true`, enables capturing of command payload details in + tracing spans. + - If `true`, the test runner SHOULD capture detailed command payload information in tracing spans. + - If `false` or omitted, the test runner SHOULD exclude command payload details. + - `serverApi`: Optional [serverApi](#serverapi) object. @@ -774,6 +783,26 @@ The structure of this object is as follows: Tests SHOULD NOT specify multiple [expectedLogMessagesForClient](#expectedlogmessagesforclient) objects for a single client entity. + + +- `expectTracingMessages`: Optional object that defines expected tracing [spans](../open-telemetry/open-telemetry.md) + for a test. The structure of this object is as follows: + + - `client`: Required string. The ID of the client entity associated with these tracing spans. + + - `ignoreExtraSpans`: Optional boolean. + + - If `true`, additional unexpected spans are allowed. + - If `false` or omitted, the test runner MUST fail if any unexpected spans are detected. + + - `spans`: Required array of span objects. Each span describes an expected tracing event. + + Span object properties: + + - `name`: Required string. The name of the tracing span. + - `attributes`: Required object. Key-value pairs describing span metadata. + - `nested`: Optional array of nested span objects, following the same structure. + - `outcome`: Optional array of one or more [collectionData](#collectiondata) objects. Data that is expected to exist in @@ -3430,6 +3459,11 @@ other specs *and* collating spec changes developed in parallel or during the sam ## Changelog +- 2025-09-17: **Schema version 1.27.** + + Add `observeTracingMessages` configuration for clients and `expectTracingMessages` for test expectations. This allows + capturing and validating detailed tracing information during test execution. + - 2025-09-16: **Schema version 1.26.** Add `awaitMinPoolSize` client parameter to await on connection pool population. - 2025-09-15: Remove note about Atlas Data Lake since Atlas Data Lake testing is removed.