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..4cdeca84bb --- /dev/null +++ b/source/open-telemetry/open-telemetry.md @@ -0,0 +1,282 @@ +# 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. + +#### Tracer + +A Tracer is responsible for creating spans, and using a tracer is the only way to create a span. A Tracer is not +responsible for configuration; this should be the responsibility of the TracerProvider instead. + +**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. + +### Implementation Requirements + +#### External Dependencies + +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 and Disabling 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, for example, + `tracing.enabled`. +- **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. + +#### 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`: The version of the driver. + +#### 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. + +##### Cursors + +If the driver operation returns a cursor, spans for all the subsequent operations on the cursor SHOULD be nested into +the operation span. This includes operations such as `getMore`, `next`, `close`. + +##### `withTransaction` + +The `withTransaction` operation is a special case because it may include other operations that are executed "in scope" +of `withTransaction`. In this case, spans for operations that are executed inside the callbacks SHOULD be nested into +the `withTransaction` span. + +##### Span Name + +The span name SHOULD be: + +- `driver_operation_name db.collection_name` if the command is executed on a collection (e.g., + `findOneAndDelete warehouse.users`). +- `db.driver_operation_name` if there is no specific collection for the command (e.g., `warehouse.runCommand`). + +##### Span Kind + +Span kind MUST be "client". + +##### 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 | +| `db.mongodb.cursor_id` | `int64` | If a cursor is created or used in the operation | Required if available | + +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. + +##### Exceptions + +If the driver operation fails with an exception, drivers MUST record an exception to the current operation 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. + +##### Span Name + +The span name SHOULD be: + +- `server_command db.collection_name` if the command is executed on a collection (e.g., + `findAndModify warehouse.users`). +- `db.server_command` if there is no specific collection for the command. + +##### Span Kind + +Span kind MUST be "client". + +##### 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 | +| `error.type` | `string` | Describes a class of error the operation ended with. This attribute should be added only if an error happens. Examples: `timeout; java.net.UnknownHostException; server_certificate_invalid; 500`. | 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` | Equivalent to span name | 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.response.status_code and error.type + +These attributes should be added only if the command was not successful. The content of `error.type` is language +specific; a driver decides what best describes the error. + +##### 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. + +##### Exception Handling + +Exceptions MUST be added to the parent span of the command span, which is the driver operation span. + +## 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. + +Although users can implement their own debug logging support via existing driver events (SDAM, APM, etc), this requires +code changes. It is often difficult to quickly implement and deploy such changes in production at the time they are +needed, and to remove the changes afterward. Additionally, there are useful scenarios to log that do not correspond to +existing events. Standardizing on debug log messages that drivers produce and how to enable/configure logging will +provide TSEs, CEs, and MongoDB users an easier way to get debugging information out of our drivers, facilitate support +of drivers for our internal teams, and improve our documentation around troubleshooting. + +## Test Plan + +See [OpenTelemetry Tests](tests/README.md) for the test plan. + +## Covered operations + +The OpenTelemetry specification covers the following operations: + +| Operation | Test | +| :----------------------- | :----------------------------------------------------------------------------------- | +| `aggregate` | [tests/transaction/aggregate.yml](tests/operation/aggregate.yml) | +| `findAndModify` | [tests/transaction/find_one_and_update.yml](tests/operation/find_one_and_update.yml) | +| `bulkWrite` | [tests/transaction/bulk_write.yml](tests/operation/bulk_write.yml) | +| `commitTransaction` | [tests/transaction/transaction.yml](tests/transaction/transaction.yml) | +| `abortTransaction` | [tests/transaction/transaction.yml](tests/transaction/transaction.yml) | +| `createCollection` | [tests/transaction/create_collection.yml](tests/operation/create_collection.yml) | +| `createIndexes` | [tests/transaction/create_indexes.yml](tests/operation/create_indexes.yml) | +| `createView` | [tests/transaction/create_view.yml](tests/operation/create_view.yml) | +| `distinct` | [tests/transaction/distinct.yml](tests/operation/distinct.yml) | +| `dropCollection` | [tests/transaction/drop_collection.yml](tests/operation/drop_collection.yml) | +| `dropIndexes` | [tests/transaction/drop_indexes.yml](tests/operation/drop_indexes.yml) | +| `find` | [tests/transaction/find.yml](tests/operation/find.yml) | +| `listCollections` | [tests/transaction/list_collections.yml](tests/operation/list_collections.yml) | +| `listDatabases` | [tests/transaction/list_databases.yml](tests/operation/list_databases.yml) | +| `listIndexes` | [tests/transaction/list_indexes.yml](tests/operation/list_indexes.yml) | +| `mapReduce` | [tests/transaction/map_reduce.yml](tests/operation/map_reduce.yml) | +| `estimatedDocumentCount` | [tests/transaction/count.yml](tests/operation/count.yml) | +| `insert` | [tests/transaction/insert.yml](tests/operation/insert.yml) | +| `delete` | [tests/transaction/delete.yml](tests/operation/delete.yml) | +| `update` | [tests/transaction/update.yml](tests/operation/update.yml) | +| `createSearchIndexes` | [tests/transaction/atlas_search.yml](tests/operation/atlas_search.yml) | +| `dropSearchIndex` | [tests/transaction/atlas_search.yml](tests/operation/atlas_search.yml) | +| `updateSearchIndex` | [tests/transaction/delete.yml](tests/operation/delete.yml) | +| `delete` | [tests/transaction/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. diff --git a/source/open-telemetry/tests/README.md b/source/open-telemetry/tests/README.md new file mode 100644 index 0000000000..c3d14f6c93 --- /dev/null +++ b/source/open-telemetry/tests/README.md @@ -0,0 +1,34 @@ +# 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#span) 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: + ... +``` diff --git a/source/open-telemetry/tests/cursor/cursor.json b/source/open-telemetry/tests/cursor/cursor.json new file mode 100644 index 0000000000..b0d6eaca15 --- /dev/null +++ b/source/open-telemetry/tests/cursor/cursor.json @@ -0,0 +1,300 @@ +{ + "description": "cursor retrieval", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "cursor" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "cursor", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + }, + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + ], + "tests": [ + { + "description": "find with a cursor", + "operations": [ + { + "name": "find", + "object": "collection0", + "arguments": { + "filter": { + "_id": { + "$gt": 1 + } + }, + "batchSize": 2 + }, + "expectResult": [ + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + }, + { + "_id": 5 + }, + { + "_id": 6 + } + ] + } + ], + "expectTracingMessages": { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "find cursor.test", + "tags": { + "db.system": "mongodb", + "db.namespace": "cursor", + "db.collection.name": "test", + "db.operation.name": "find", + "db.operation.summary": "find cursor.test" + }, + "nested": [ + { + "name": "command find", + "tags": { + "db.system": "mongodb", + "db.namespace": "cursor", + "db.collection.name": "cursor.$cmd", + "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", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "find": "test", + "filter": { + "_id": { + "$gt": 1 + } + }, + "batchSize": 2 + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "name": "command getMore", + "tags": { + "db.system": "mongodb", + "db.namespace": "cursor", + "db.collection.name": "cursor.$cmd", + "db.command.name": "getMore", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$type": [ + "int", + "long" + ] + }, + "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": "getMore", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "getMore": { + "$$type": "long" + }, + "collection": "test", + "batchSize": 2 + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "name": "command getMore", + "tags": { + "db.system": "mongodb", + "db.namespace": "cursor", + "db.collection.name": "cursor.$cmd", + "db.command.name": "getMore", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$type": [ + "int", + "long" + ] + }, + "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": "getMore", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "getMore": { + "$$type": "long" + }, + "collection": "test", + "batchSize": 2 + } + } + }, + "db.mongodb.server_connection_id": { + "$$type": [ + "int", + "long" + ] + }, + "db.mongodb.driver_connection_id": { + "$$type": [ + "int", + "long" + ] + } + } + } + ] + } + ] + } + } + ] +} diff --git a/source/open-telemetry/tests/cursor/cursor.yml b/source/open-telemetry/tests/cursor/cursor.yml new file mode 100644 index 0000000000..a78d50d01e --- /dev/null +++ b/source/open-telemetry/tests/cursor/cursor.yml @@ -0,0 +1,132 @@ +description: cursor retrieval +schemaVersion: '1.26' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: cursor + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: test +initialData: + - collectionName: test + databaseName: cursor + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + - { _id: 5 } + - { _id: 6 } +tests: + - description: find with a cursor + operations: + - name: find + object: *collection0 + arguments: + filter: { _id: { $gt: 1 } } + batchSize: 2 + expectResult: + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + - { _id: 5 } + - { _id: 6 } + + expectTracingMessages: + client: *client0 + ignoreExtraSpans: false + spans: + - name: find cursor.test + tags: + db.system: mongodb + db.namespace: cursor + db.collection.name: test + db.operation.name: find + db.operation.summary: find cursor.test + nested: + - name: command find + tags: + db.system: mongodb + db.namespace: cursor + db.collection.name: cursor.$cmd + 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 + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + find: test + filter: { _id: { $gt: 1 } } + batchSize: 2 + db.mongodb.server_connection_id: + $$type: [ 'int', 'long' ] + db.mongodb.driver_connection_id: + $$type: [ 'int', 'long' ] + + - name: command getMore + tags: + db.system: mongodb + db.namespace: cursor + db.collection.name: cursor.$cmd + db.command.name: getMore + network.transport: tcp + db.mongodb.cursor_id: { $$type: [ 'int', 'long' ] } + 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: getMore + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + getMore: { $$type: long } + collection: test + batchSize: 2 + db.mongodb.server_connection_id: + $$type: [ 'int', 'long' ] + db.mongodb.driver_connection_id: + $$type: [ 'int', 'long' ] + - name: command getMore + tags: + db.system: mongodb + db.namespace: cursor + db.collection.name: cursor.$cmd + db.command.name: getMore + network.transport: tcp + db.mongodb.cursor_id: { $$type: [ 'int', 'long' ] } + 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: getMore + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + getMore: { $$type: long } + collection: test + batchSize: 2 + 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.json b/source/open-telemetry/tests/operation/aggregate.json new file mode 100644 index 0000000000..a27d52d8cb --- /dev/null +++ b/source/open-telemetry/tests/operation/aggregate.json @@ -0,0 +1,131 @@ +{ + "description": "operation aggregate", + "schemaVersion": "1.26", + "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", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-aggregate", + "db.collection.name": "test", + "db.operation.name": "aggregate", + "db.operation.summary": "aggregate operation-aggregate.test" + }, + "nested": [ + { + "name": "command aggregate", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-aggregate", + "db.collection.name": "operation-aggregate.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "aggregate", + "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..e9e267dfab --- /dev/null +++ b/source/open-telemetry/tests/operation/aggregate.yml @@ -0,0 +1,63 @@ +description: operation aggregate +schemaVersion: '1.26' +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: aggregation + operations: + - name: aggregate + object: *collection0 + arguments: + pipeline: &pipeline1 + - $match: { _id: 1 } + + expectTracingMessages: + client: *client0 + ignoreExtraSpans: false + spans: + - name: aggregate operation-aggregate.test + tags: + db.system: mongodb + db.namespace: operation-aggregate + db.collection.name: test + db.operation.name: aggregate + db.operation.summary: aggregate operation-aggregate.test + nested: + - name: command aggregate + tags: + db.system: mongodb + db.namespace: operation-aggregate + db.collection.name: operation-aggregate.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: aggregate + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + aggregate: test + pipeline: *pipeline1 + 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..6c68b1951a --- /dev/null +++ b/source/open-telemetry/tests/operation/atlas_search.json @@ -0,0 +1,234 @@ +{ + "description": "operation atlas search", + "schemaVersion": "1.26", + "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", + "tags": { + "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": "command createSearchIndexes", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-atlas-search", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "createSearchIndexes", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "createSearchIndexes": "test", + "indexes": [ + { + "type": "search", + "definition": { + "mappings": { + "dynamic": true + } + } + } + ] + } + } + } + } + } + ] + }, + { + "name": "updateSearchIndex operation-atlas-search.test", + "tags": { + "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": "command updateSearchIndex", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-atlas-search", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "updateSearchIndex", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "updateSearchIndex": "test", + "name": "test index", + "definition": {} + } + } + } + } + } + ] + }, + { + "name": "dropSearchIndex operation-atlas-search.test", + "tags": { + "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": "command dropSearchIndex", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-atlas-search", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "dropSearchIndex", + "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..ab3f85e243 --- /dev/null +++ b/source/open-telemetry/tests/operation/atlas_search.yml @@ -0,0 +1,136 @@ +description: operation atlas search +schemaVersion: '1.26' +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 + tags: + 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: command createSearchIndexes + tags: + db.system: mongodb + db.namespace: operation-atlas-search + server.address: { $$type: string } + server.port: { $$type: [ 'long', 'string' ] } + server.type: { $$type: string } + db.query.summary: createSearchIndexes + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + createSearchIndexes: test + indexes: [ { "type": "search", "definition": { "mappings": { "dynamic": true } } } ] + + - name: updateSearchIndex operation-atlas-search.test + tags: + 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: command updateSearchIndex + tags: + db.system: mongodb + db.namespace: operation-atlas-search + server.address: { $$type: string } + server.port: { $$type: [ 'long', 'string' ] } + server.type: { $$type: string } + db.query.summary: updateSearchIndex + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + updateSearchIndex: test + name: test index + definition: {} + + - name: dropSearchIndex operation-atlas-search.test + tags: + 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: command dropSearchIndex + tags: + db.system: mongodb + db.namespace: operation-atlas-search + server.address: { $$type: string } + server.port: { $$type: [ 'long', 'string' ] } + server.type: { $$type: string } + db.query.summary: dropSearchIndex + 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..ca814e4f99 --- /dev/null +++ b/source/open-telemetry/tests/operation/bulk_write.json @@ -0,0 +1,302 @@ +{ + "description": "operation bulkwrite", + "schemaVersion": "1.26", + "runOnRequirements": [ + { + "minServerVersion": "8.0", + "serverless": "forbid" + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-bulk-write" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "operation-bulk-write", + "documents": [] + } + ], + "_yamlAnchors": { + "namespace": "operation-bulk-write.test" + }, + "tests": [ + { + "description": "bulkWrite", + "operations": [ + { + "object": "client0", + "name": "clientBulkWrite", + "arguments": { + "models": [ + { + "insertOne": { + "namespace": "operation-bulk-write.test", + "document": { + "_id": 8, + "x": 88 + } + } + }, + { + "updateOne": { + "namespace": "operation-bulk-write.test", + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "x": 1 + } + } + } + }, + { + "updateMany": { + "namespace": "operation-bulk-write.test", + "filter": { + "$and": [ + { + "_id": { + "$gt": 1 + } + }, + { + "_id": { + "$lte": 3 + } + } + ] + }, + "update": { + "$inc": { + "x": 2 + } + } + } + }, + { + "replaceOne": { + "namespace": "operation-bulk-write.test", + "filter": { + "_id": 4 + }, + "replacement": { + "x": 44 + }, + "upsert": true + } + }, + { + "deleteOne": { + "namespace": "operation-bulk-write.test", + "filter": { + "_id": 5 + } + } + }, + { + "deleteMany": { + "namespace": "operation-bulk-write.test", + "filter": { + "$and": [ + { + "_id": { + "$gt": 5 + } + }, + { + "_id": { + "$lte": 7 + } + } + ] + } + } + } + ] + } + } + ], + "expectTracingMessages": { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "bulkWrite operation-bulk-write.test", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-bulk-write", + "db.collection.name": "test", + "db.operation.name": "bulkWrite", + "db.operation.summary": "bulkWrite operation-bulk-write.test" + }, + "nested": [ + { + "name": "command bulkWrite", + "tags": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": "admin.$cmd", + "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", + "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": 0, + "multi": true, + "filter": { + "$and": [ + { + "_id": { + "$gt": 1 + } + }, + { + "_id": { + "$lte": 3 + } + } + ] + }, + "updateMods": { + "$inc": { + "x": 2 + } + } + }, + { + "update": 0, + "multi": false, + "filter": { + "_id": 4 + }, + "updateMods": { + "x": 44 + }, + "upsert": true + }, + { + "delete": 0, + "multi": false, + "filter": { + "_id": 5 + } + }, + { + "delete": 0, + "multi": true, + "filter": { + "$and": [ + { + "_id": { + "$gt": 5 + } + }, + { + "_id": { + "$lte": 7 + } + } + ] + } + } + ] + } + } + }, + "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..1f93b9fdff --- /dev/null +++ b/source/open-telemetry/tests/operation/bulk_write.yml @@ -0,0 +1,107 @@ +description: operation bulkwrite +schemaVersion: '1.26' +runOnRequirements: + - minServerVersion: "8.0" + serverless: forbid + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: &databaseName operation-bulk-write + - collection: + id: collection0 + database: *database0 + collectionName: &collectionName test +initialData: + - collectionName: *collectionName + databaseName: *databaseName + documents: [] + +_yamlAnchors: + namespace: &namespace "operation-bulk-write.test" + +tests: + - description: bulkWrite + operations: + - object: *client0 + name: clientBulkWrite + arguments: + models: + - insertOne: + namespace: *namespace + document: { _id: 8, x: 88 } + - updateOne: + namespace: *namespace + filter: { _id: 1 } + update: { $inc: { x: 1 } } + - updateMany: + namespace: *namespace + filter: + $and: [ { _id: { $gt: 1 } }, { _id: { $lte: 3 } } ] + update: { $inc: { x: 2 } } + - replaceOne: + namespace: *namespace + filter: { _id: 4 } + replacement: { x: 44 } + upsert: true + - deleteOne: + namespace: *namespace + filter: { _id: 5 } + - deleteMany: + namespace: *namespace + filter: + $and: [ { _id: { $gt: 5 } }, { _id: { $lte: 7 } } ] + + expectTracingMessages: + client: *client0 + ignoreExtraSpans: false + spans: + - name: bulkWrite operation-bulk-write.test + tags: + db.system: mongodb + db.namespace: operation-bulk-write + db.collection.name: test + db.operation.name: bulkWrite + db.operation.summary: bulkWrite operation-bulk-write.test + nested: + - name: command bulkWrite + tags: + db.system: mongodb + db.namespace: admin + db.collection.name: admin.$cmd + 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 + 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": 0, "multi": true, "filter": { "$and": [ { "_id": { "$gt": 1 } }, { "_id": { "$lte": 3 } } ] }, + "updateMods": { "$inc": { "x": 2 } } }, + { "update": 0, "multi": false, "filter": { "_id": 4 }, + "updateMods": { "x": 44 }, "upsert": true }, + { "delete": 0, "multi": false, "filter": { "_id": 5 } }, + { "delete": 0, "multi": true, "filter": { "$and": [ + { "_id": { "$gt": 5 } }, { "_id": { "$lte": 7 } } ] } } ] + 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..507a9e4746 --- /dev/null +++ b/source/open-telemetry/tests/operation/count.json @@ -0,0 +1,124 @@ +{ + "description": "operation count", + "schemaVersion": "1.26", + "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", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-count", + "db.collection.name": "test", + "db.operation.name": "count", + "db.operation.summary": "count operation-count.test" + }, + "nested": [ + { + "name": "command count", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-count", + "db.collection.name": "operation-count.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "count", + "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..4b0ed558d7 --- /dev/null +++ b/source/open-telemetry/tests/operation/count.yml @@ -0,0 +1,64 @@ +description: operation count +schemaVersion: '1.26' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: database0 + client: *client0 + databaseName: operation-count + - collection: + id: &collection0 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 + tags: + db.system: mongodb + db.namespace: operation-count + db.collection.name: test + db.operation.name: count + db.operation.summary: count operation-count.test + nested: + - name: command count + tags: + db.system: mongodb + db.namespace: operation-count + db.collection.name: operation-count.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: count + 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..1b510bebbb --- /dev/null +++ b/source/open-telemetry/tests/operation/create_collection.json @@ -0,0 +1,112 @@ +{ + "description": "operation create collection", + "schemaVersion": "1.26", + "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", + "tags": { + "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": "command create", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-create-collection", + "db.collection.name": "operation-create-collection.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "create", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "create": "newlyCreatedCollection", + "capped": false + } + } + }, + "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..c3f39e55e5 --- /dev/null +++ b/source/open-telemetry/tests/operation/create_collection.yml @@ -0,0 +1,57 @@ +description: operation create collection +schemaVersion: '1.26' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 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 + tags: + 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: command create + tags: + db.system: mongodb + db.namespace: operation-create-collection + db.collection.name: operation-create-collection.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: create + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + create: newlyCreatedCollection + capped: false + 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..83dcd89c27 --- /dev/null +++ b/source/open-telemetry/tests/operation/create_indexes.json @@ -0,0 +1,127 @@ +{ + "description": "operation create indexes", + "schemaVersion": "1.26", + "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", + "tags": { + "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": "command createIndexes", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-create-indexes", + "db.collection.name": "operation-create-indexes.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "createIndexes", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "createIndexes": "test", + "indexes": [ + { + "key": { + "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..5a011dd794 --- /dev/null +++ b/source/open-telemetry/tests/operation/create_indexes.yml @@ -0,0 +1,61 @@ +description: operation create indexes +schemaVersion: '1.26' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-create-indexes + - collection: + id: &collection0 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 + tags: + 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: command createIndexes + tags: + db.system: mongodb + db.namespace: operation-create-indexes + db.collection.name: operation-create-indexes.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: createIndexes + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + createIndexes: test + indexes: [ { key: { 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_view.json b/source/open-telemetry/tests/operation/create_view.json new file mode 100644 index 0000000000..3d7dbe7f57 --- /dev/null +++ b/source/open-telemetry/tests/operation/create_view.json @@ -0,0 +1,138 @@ +{ + "description": "operation create view", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "operation-create-view" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + } + ], + "tests": [ + { + "description": "create view", + "operations": [ + { + "name": "createCollection", + "object": "database0", + "arguments": { + "collection": "my_view", + "viewOn": "test", + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 1 + } + } + } + ] + } + } + ], + "expectTracingMessages": { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "createView operation-create-view.my_view", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-create-view", + "db.collection.name": "my_view", + "db.operation.name": "createView", + "db.operation.summary": "createView operation-create-view.my_view" + }, + "nested": [ + { + "name": "command create", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-create-view", + "db.collection.name": "operation-create-view.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "create", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "create": "my_view", + "viewOn": "test", + "pipeline": [ + { + "$match": { + "_id": { + "$gt": 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_view.yml b/source/open-telemetry/tests/operation/create_view.yml new file mode 100644 index 0000000000..feb5a67b61 --- /dev/null +++ b/source/open-telemetry/tests/operation/create_view.yml @@ -0,0 +1,65 @@ +description: operation create view +schemaVersion: '1.26' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-create-view + - collection: + id: collection0 + database: *database0 + collectionName: &collection_name test +tests: + - description: create view + operations: + - name: createCollection + object: *database0 + arguments: + collection: my_view + viewOn: *collection_name + pipeline: &pipeline + - { $match: { _id: { $gt: 1 } } } + + expectTracingMessages: + client: *client0 + ignoreExtraSpans: false + spans: + - name: createView operation-create-view.my_view + tags: + db.system: mongodb + db.namespace: operation-create-view + db.collection.name: my_view + db.operation.name: createView + db.operation.summary: createView operation-create-view.my_view + nested: + - name: command create + tags: + db.system: mongodb + db.namespace: operation-create-view + db.collection.name: operation-create-view.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: create + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + create: my_view + viewOn: test + pipeline: *pipeline + 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..80f780e905 --- /dev/null +++ b/source/open-telemetry/tests/operation/delete.json @@ -0,0 +1,103 @@ +{ + "description": "operation delete", + "schemaVersion": "1.26", + "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", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-delete", + "db.collection.name": "test", + "db.operation.name": "delete", + "db.operation.summary": "delete operation-delete.test" + }, + "nested": [ + { + "name": "command delete", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-delete", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "delete", + "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..6b68324420 --- /dev/null +++ b/source/open-telemetry/tests/operation/delete.yml @@ -0,0 +1,51 @@ +description: operation delete +schemaVersion: '1.26' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-delete + - collection: + id: &collection0 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 + tags: + db.system: mongodb + db.namespace: operation-delete + db.collection.name: test + db.operation.name: delete + db.operation.summary: delete operation-delete.test + nested: + - name: command delete + tags: + db.system: mongodb + db.namespace: operation-delete + server.address: { $$type: string } + server.port: { $$type: [ 'long', 'string' ] } + server.type: { $$type: string } + db.query.summary: delete + 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..cc9c9630da --- /dev/null +++ b/source/open-telemetry/tests/operation/distinct.json @@ -0,0 +1,127 @@ +{ + "description": "operation distinct", + "schemaVersion": "1.26", + "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" + } + } + ], + "expectTracingMessages": { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "distinct operation-distinct.test", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-distinct", + "db.collection.name": "test", + "db.operation.name": "distinct", + "db.operation.summary": "distinct operation-distinct.test" + }, + "nested": [ + { + "name": "command distinct", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-distinct", + "db.collection.name": "operation-distinct.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "distinct", + "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..d4bf6d576a --- /dev/null +++ b/source/open-telemetry/tests/operation/distinct.yml @@ -0,0 +1,65 @@ +description: operation distinct +schemaVersion: '1.26' +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 } + + expectTracingMessages: + client: *client0 + ignoreExtraSpans: false + spans: + - name: distinct operation-distinct.test + tags: + db.system: mongodb + db.namespace: operation-distinct + db.collection.name: test + db.operation.name: distinct + db.operation.summary: distinct operation-distinct.test + nested: + - name: command distinct + tags: + db.system: mongodb + db.namespace: operation-distinct + db.collection.name: operation-distinct.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: distinct + 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..04d74f852f --- /dev/null +++ b/source/open-telemetry/tests/operation/drop_collection.json @@ -0,0 +1,118 @@ +{ + "description": "operation drop collection", + "schemaVersion": "1.26", + "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", + "tags": { + "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": "command drop", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-drop-collection", + "db.collection.name": "operation-drop-collection.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "drop", + "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..f1335c75c4 --- /dev/null +++ b/source/open-telemetry/tests/operation/drop_collection.yml @@ -0,0 +1,61 @@ +description: operation drop collection +schemaVersion: '1.26' +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 + tags: + 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: command drop + tags: + db.system: mongodb + db.namespace: operation-drop-collection + db.collection.name: operation-drop-collection.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: drop + 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..006db8ea0c --- /dev/null +++ b/source/open-telemetry/tests/operation/drop_indexes.json @@ -0,0 +1,126 @@ +{ + "description": "operation drop indexes", + "schemaVersion": "1.26", + "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" + } + } + ], + "tests": [ + { + "description": "drop indexes", + "operations": [ + { + "name": "createIndex", + "object": "collection0", + "arguments": { + "keys": { + "x": 1 + }, + "name": "x_1" + } + }, + { + "name": "dropIndexes", + "object": "collection0" + } + ], + "expectTracingMessages": { + "client": "client0", + "ignoreExtraSpans": true, + "spans": [ + { + "name": "dropIndexes operation-drop-indexes.test", + "tags": { + "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": "command dropIndexes", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-drop-indexes", + "db.collection.name": "operation-drop-indexes.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "dropIndexes", + "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..117a428863 --- /dev/null +++ b/source/open-telemetry/tests/operation/drop_indexes.yml @@ -0,0 +1,68 @@ +description: operation drop indexes +schemaVersion: '1.26' +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 + +tests: + - description: drop indexes + operations: + - name: createIndex + object: *collection0 + arguments: + keys: + x: 1 + name: x_1 + + - name: dropIndexes + object: *collection0 + + + expectTracingMessages: + client: *client0 + ignoreExtraSpans: true + spans: + - name: dropIndexes operation-drop-indexes.test + tags: + 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: command dropIndexes + tags: + db.system: mongodb + db.namespace: operation-drop-indexes + db.collection.name: operation-drop-indexes.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: dropIndexes + 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..bdf493c73f --- /dev/null +++ b/source/open-telemetry/tests/operation/find.json @@ -0,0 +1,130 @@ +{ + "description": "operation find", + "schemaVersion": "1.26", + "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", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-find", + "db.collection.name": "test", + "db.operation.name": "find", + "db.operation.summary": "find operation-find.test" + }, + "nested": [ + { + "name": "command find", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-find", + "db.collection.name": "operation-find.$cmd", + "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", + "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..4d5351df64 --- /dev/null +++ b/source/open-telemetry/tests/operation/find.yml @@ -0,0 +1,65 @@ +description: operation find +schemaVersion: '1.26' +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: 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 + tags: + db.system: mongodb + db.namespace: operation-find + db.collection.name: test + db.operation.name: find + db.operation.summary: find operation-find.test + nested: + - name: command find + tags: + db.system: mongodb + db.namespace: operation-find + db.collection.name: operation-find.$cmd + 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 + 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_one_and_update.json b/source/open-telemetry/tests/operation/find_one_and_update.json new file mode 100644 index 0000000000..b33c84095b --- /dev/null +++ b/source/open-telemetry/tests/operation/find_one_and_update.json @@ -0,0 +1,139 @@ +{ + "description": "operation findOneAndUpdate", + "schemaVersion": "1.26", + "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", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-aggregate", + "db.collection.name": "test", + "db.operation.name": "findAndModify", + "db.operation.summary": "findAndModify operation-aggregate.test" + }, + "nested": [ + { + "name": "command findAndModify", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-aggregate", + "db.collection.name": "operation-aggregate.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "findAndModify", + "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_one_and_update.yml b/source/open-telemetry/tests/operation/find_one_and_update.yml new file mode 100644 index 0000000000..72e55f3ef5 --- /dev/null +++ b/source/open-telemetry/tests/operation/find_one_and_update.yml @@ -0,0 +1,68 @@ +description: operation findOneAndUpdate +schemaVersion: '1.26' +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 + tags: + db.system: mongodb + db.namespace: operation-aggregate + db.collection.name: test + db.operation.name: findAndModify + db.operation.summary: findAndModify operation-aggregate.test + nested: + - name: command findAndModify + tags: + db.system: mongodb + db.namespace: operation-aggregate + db.collection.name: operation-aggregate.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: findAndModify + 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/insert.json b/source/open-telemetry/tests/operation/insert.json new file mode 100644 index 0000000000..c50391770d --- /dev/null +++ b/source/open-telemetry/tests/operation/insert.json @@ -0,0 +1,115 @@ +{ + "description": "operation insert", + "schemaVersion": "1.26", + "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", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-insert", + "db.collection.name": "test", + "db.operation.name": "insert", + "db.operation.summary": "insert operation-insert.test" + }, + "nested": [ + { + "name": "command insert", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-insert", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "insert", + "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..0a02a6128b --- /dev/null +++ b/source/open-telemetry/tests/operation/insert.yml @@ -0,0 +1,61 @@ +description: operation insert +schemaVersion: '1.26' +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 + tags: + db.system: mongodb + db.namespace: operation-insert + db.collection.name: test + db.operation.name: insert + db.operation.summary: insert operation-insert.test + nested: + - name: command insert + tags: + db.system: mongodb + db.namespace: operation-insert + server.address: { $$type: string } + server.port: { $$type: [ 'long', 'string' ] } + server.type: { $$type: string } + db.query.summary: insert + 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..7add74857e --- /dev/null +++ b/source/open-telemetry/tests/operation/list_collections.json @@ -0,0 +1,109 @@ +{ + "description": "operation list collections", + "schemaVersion": "1.26", + "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.$cmd", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-list-collections", + "db.collection.name": "$cmd", + "db.operation.name": "listCollections", + "db.operation.summary": "listCollections operation-list-collections.$cmd" + }, + "nested": [ + { + "name": "command listCollections", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-list-collections", + "db.collection.name": "operation-list-collections.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "listCollections", + "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..0280fa90ee --- /dev/null +++ b/source/open-telemetry/tests/operation/list_collections.yml @@ -0,0 +1,55 @@ +description: operation list collections +schemaVersion: '1.26' +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.$cmd + tags: + db.system: mongodb + db.namespace: operation-list-collections + db.collection.name: $cmd + db.operation.name: listCollections + db.operation.summary: listCollections operation-list-collections.$cmd + nested: + - name: command listCollections + tags: + db.system: mongodb + db.namespace: operation-list-collections + db.collection.name: operation-list-collections.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: listCollections + 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..4b8d48b562 --- /dev/null +++ b/source/open-telemetry/tests/operation/list_databases.json @@ -0,0 +1,101 @@ +{ + "description": "operation list databases", + "schemaVersion": "1.26", + "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.$cmd", + "tags": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": "$cmd", + "db.operation.name": "listDatabases", + "db.operation.summary": "listDatabases admin.$cmd" + }, + "nested": [ + { + "name": "command listDatabases", + "tags": { + "db.system": "mongodb", + "db.namespace": "admin", + "db.collection.name": "admin.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "listDatabases", + "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..471d7e7390 --- /dev/null +++ b/source/open-telemetry/tests/operation/list_databases.yml @@ -0,0 +1,50 @@ +description: operation list databases +schemaVersion: '1.26' +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.$cmd + tags: + db.system: mongodb + db.namespace: admin + db.collection.name: $cmd + db.operation.name: listDatabases + db.operation.summary: listDatabases admin.$cmd + nested: + - name: command listDatabases + tags: + db.system: mongodb + db.namespace: admin + db.collection.name: admin.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: listDatabases + 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..10ddf3ab25 --- /dev/null +++ b/source/open-telemetry/tests/operation/list_indexes.json @@ -0,0 +1,122 @@ +{ + "description": "operation list indexes", + "schemaVersion": "1.26", + "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", + "tags": { + "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": "command listIndexes", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-list-indexes", + "db.collection.name": "operation-list-indexes.$cmd", + "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" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "listIndexes", + "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..f7796e07da --- /dev/null +++ b/source/open-telemetry/tests/operation/list_indexes.yml @@ -0,0 +1,62 @@ +description: operation list indexes +schemaVersion: '1.26' +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 + tags: + 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: command listIndexes + tags: + db.system: mongodb + db.namespace: operation-list-indexes + db.collection.name: operation-list-indexes.$cmd + 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'] } + server.type: { $$type: string } + db.query.summary: listIndexes + 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..705973e754 --- /dev/null +++ b/source/open-telemetry/tests/operation/map_reduce.json @@ -0,0 +1,178 @@ +{ + "description": "operation map_reduce", + "schemaVersion": "1.26", + "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", + "tags": { + "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": "command mapReduce", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-map-reduce", + "db.collection.name": "operation-map-reduce.$cmd", + "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", + "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..33f119e6b8 --- /dev/null +++ b/source/open-telemetry/tests/operation/map_reduce.yml @@ -0,0 +1,99 @@ +description: operation map_reduce +schemaVersion: '1.26' +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 + tags: + 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: command mapReduce + tags: + db.system: mongodb + db.namespace: operation-map-reduce + db.collection.name: operation-map-reduce.$cmd + 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 + 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..6a00ea920f --- /dev/null +++ b/source/open-telemetry/tests/operation/retries.json @@ -0,0 +1,212 @@ +{ + "description": "retrying failed command", + "schemaVersion": "1.26", + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeTracingMessages": { + "enableCommandPayload": true + } + } + }, + { + "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": "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-retries.test", + "tags": { + "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": "command find", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-find-retries", + "db.collection.name": "operation-find-retries.$cmd", + "db.command.name": "find", + "network.transport": "tcp", + "db.mongodb.cursor_id": { + "$$exists": false + }, + "db.response.status_code": { + "$$exists": false + }, + "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", + "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": "command find", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-find-retries", + "db.collection.name": "operation-find-retries.$cmd", + "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", + "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..520f8c9d9d --- /dev/null +++ b/source/open-telemetry/tests/operation/retries.yml @@ -0,0 +1,104 @@ +description: retrying failed command +schemaVersion: '1.26' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-find-retries + - collection: + id: &collection0 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: *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-retries.test + tags: + 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: command find + tags: + db.system: mongodb + db.namespace: operation-find-retries + db.collection.name: operation-find-retries.$cmd + db.command.name: find + network.transport: tcp + db.mongodb.cursor_id: { $$exists: false } + db.response.status_code: { $$exists: false } + 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 + 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: command find + tags: + db.system: mongodb + db.namespace: operation-find-retries + db.collection.name: operation-find-retries.$cmd + 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 + 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..df26a7902e --- /dev/null +++ b/source/open-telemetry/tests/operation/update.json @@ -0,0 +1,109 @@ +{ + "description": "operation update", + "schemaVersion": "1.26", + "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", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-update", + "db.collection.name": "test", + "db.operation.name": "update", + "db.operation.summary": "update operation-update.test" + }, + "nested": [ + { + "name": "command update", + "tags": { + "db.system": "mongodb", + "db.namespace": "operation-update", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "update", + "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..faa0dbb3a3 --- /dev/null +++ b/source/open-telemetry/tests/operation/update.yml @@ -0,0 +1,54 @@ +description: operation update +schemaVersion: '1.26' +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + observeTracingMessages: + enableCommandPayload: true + - database: + id: &database0 database0 + client: *client0 + databaseName: operation-update + - collection: + id: &collection0 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 + tags: + db.system: mongodb + db.namespace: operation-update + db.collection.name: test + db.operation.name: update + db.operation.summary: update operation-update.test + nested: + - name: command update + tags: + db.system: mongodb + db.namespace: operation-update + server.address: { $$type: string } + server.port: { $$type: [ 'long', 'string' ] } + server.type: { $$type: string } + db.query.summary: update + 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/transaction.json b/source/open-telemetry/tests/transaction/transaction.json new file mode 100644 index 0000000000..248b0a24df --- /dev/null +++ b/source/open-telemetry/tests/transaction/transaction.json @@ -0,0 +1,316 @@ +{ + "description": "transaction spans", + "schemaVersion": "1.26", + "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": "observeTracingMessages around 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 + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 2 + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectTracingMessages": { + "client": "client0", + "ignoreExtraSpans": false, + "spans": [ + { + "name": "transaction", + "tags": { + "db.system": "mongodb" + }, + "nested": [ + { + "name": "insert transaction-tests.test", + "tags": { + "db.system": "mongodb", + "db.namespace": "transaction-tests", + "db.collection.name": "test", + "db.operation.name": "insert", + "db.operation.summary": "insert transaction-tests.test" + }, + "nested": [ + { + "name": "command insert", + "tags": { + "db.system": "mongodb", + "db.namespace": "transaction-tests", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "insert", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "insert": "test", + "ordered": true, + "txnNumber": 1, + "startTransaction": true, + "autocommit": false, + "documents": [ + { + "_id": 1 + } + ] + } + } + }, + "db.mongodb.lsid": { + "$$sessionLsid": "session0" + } + } + } + ] + }, + { + "name": "commitTransaction admin.$cmd", + "tags": { + "db.system": "mongodb" + }, + "nested": [ + { + "name": "command commitTransaction", + "tags": { + "db.system": "mongodb", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "commitTransaction": 1, + "txnNumber": 1, + "autocommit": false + } + } + } + } + } + ] + } + ] + }, + { + "name": "find transaction-tests.test", + "tags": {}, + "nested": [ + { + "name": "command find", + "tags": { + "db.system": "mongodb", + "db.namespace": "transaction-tests", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "find" + } + } + ] + }, + { + "name": "transaction", + "tags": { + "db.system": "mongodb" + }, + "nested": [ + { + "name": "insert transaction-tests.test", + "tags": { + "db.system": "mongodb", + "db.namespace": "transaction-tests", + "db.collection.name": "test", + "db.operation.name": "insert", + "db.operation.summary": "insert transaction-tests.test" + }, + "nested": [ + { + "name": "command insert", + "tags": { + "db.system": "mongodb", + "db.namespace": "transaction-tests", + "server.address": { + "$$type": "string" + }, + "server.port": { + "$$type": [ + "long", + "string" + ] + }, + "server.type": { + "$$type": "string" + }, + "db.query.summary": "insert", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "insert": "test", + "ordered": true, + "txnNumber": 2, + "startTransaction": true, + "autocommit": false, + "documents": [ + { + "_id": 2 + } + ] + } + } + }, + "db.mongodb.lsid": { + "$$sessionLsid": "session0" + } + } + } + ] + }, + { + "name": "abortTransaction admin.$cmd", + "tags": { + "db.system": "mongodb" + }, + "nested": [ + { + "name": "command abortTransaction", + "tags": { + "db.system": "mongodb", + "db.query.text": { + "$$matchAsDocument": { + "$$matchAsRoot": { + "abortTransaction": 1, + "txnNumber": 2, + "autocommit": false + } + } + } + } + } + ] + } + ] + } + ] + }, + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} diff --git a/source/open-telemetry/tests/transaction/transaction.yml b/source/open-telemetry/tests/transaction/transaction.yml new file mode 100644 index 0000000000..6387792a88 --- /dev/null +++ b/source/open-telemetry/tests/transaction/transaction.yml @@ -0,0 +1,167 @@ +description: transaction spans +schemaVersion: '1.26' +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: observeTracingMessages around 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 } } + + - object: *session0 + name: startTransaction + - object: *collection0 + name: insertOne + arguments: + session: *session0 + document: + _id: 2 + - object: *session0 + name: abortTransaction + + expectTracingMessages: + client: *client0 + ignoreExtraSpans: false + spans: + - name: transaction + tags: + db.system: mongodb + nested: + - name: insert transaction-tests.test + tags: + db.system: mongodb + db.namespace: transaction-tests + db.collection.name: test + db.operation.name: insert + db.operation.summary: insert transaction-tests.test + nested: + - name: command insert + tags: + db.system: mongodb + db.namespace: transaction-tests + server.address: { $$type: string } + server.port: { $$type: ['long', 'string'] } + server.type: { $$type: string } + db.query.summary: insert + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + insert: test + ordered: true + txnNumber: 1 + startTransaction: true + autocommit: false + documents: + - _id: 1 + db.mongodb.lsid: { $$sessionLsid: *session0 } + - name: commitTransaction admin.$cmd + tags: + db.system: mongodb + nested: + - name: command commitTransaction + tags: + db.system: mongodb + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + commitTransaction: 1 + txnNumber: 1 + autocommit: false + - name: find transaction-tests.test + tags: {} + nested: + - name: command find + tags: + db.system: mongodb + db.namespace: transaction-tests + server.address: { $$type: string } + server.port: { $$type: ['long', 'string'] } + server.type: { $$type: string } + db.query.summary: find + - name: transaction + tags: + db.system: mongodb + nested: + - name: insert transaction-tests.test + tags: + db.system: mongodb + db.namespace: transaction-tests + db.collection.name: test + db.operation.name: insert + db.operation.summary: insert transaction-tests.test + nested: + - name: command insert + tags: + db.system: mongodb + db.namespace: transaction-tests + server.address: { $$type: string } + server.port: { $$type: ['long', 'string'] } + server.type: { $$type: string } + db.query.summary: insert + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + insert: test + ordered: true + txnNumber: 2 + startTransaction: true + autocommit: false + documents: + - _id: 2 + db.mongodb.lsid: { $$sessionLsid: *session0 } + - name: abortTransaction admin.$cmd + tags: + db.system: mongodb + nested: + - name: command abortTransaction + tags: + db.system: mongodb + db.query.text: + $$matchAsDocument: + $$matchAsRoot: + abortTransaction: 1 + txnNumber: 2 + autocommit: false + outcome: + - collectionName: test + databaseName: transaction-tests + documents: + - _id: 1 diff --git a/source/unified-test-format/schema-1.26.json b/source/unified-test-format/schema-1.26.json new file mode 100644 index 0000000000..25b69c05d8 --- /dev/null +++ b/source/unified-test-format/schema-1.26.json @@ -0,0 +1,1232 @@ +{ + "$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" + } + } + } + } + }, + "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", + "tags" + ], + "properties": { + "name": { + "type": "string" + }, + "tags": { + "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" + } + } + } + }, + "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": { + "additionalProperties" : false, + "type": "object", + "required": [ + "client", + "spans" + ], + "properties": { + "client": { + "type": "string" + }, + "ignoreExtraSpans": { + "type": "boolean" + }, + "spans": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/spanComponent" + } + } + } + }, + "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 3be461221e..25b69c05d8 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" }, @@ -369,6 +378,29 @@ "connection" ] }, + "spanComponent": { + "type": "object", + "additionalProperties": false, + "required": [ + "name", + "tags" + ], + "properties": { + "name": { + "type": "string" + }, + "tags": { + "type": "object" + }, + "nested": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/spanComponent" + } + } + } + }, "logSeverityLevel": { "type": "string", "enum": [ @@ -1164,6 +1196,29 @@ "$ref": "#/definitions/expectedLogMessagesForClient" } }, + "expectTracingMessages": { + "additionalProperties" : false, + "type": "object", + "required": [ + "client", + "spans" + ], + "properties": { + "client": { + "type": "string" + }, + "ignoreExtraSpans": { + "type": "boolean" + }, + "spans": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/spanComponent" + } + } + } + }, "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 e5ae243cef..281f6718ef 100644 --- a/source/unified-test-format/unified-test-format.md +++ b/source/unified-test-format/unified-test-format.md @@ -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. @@ -764,6 +773,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#span) 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. + - `tags`: 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 @@ -3422,6 +3451,11 @@ other specs *and* collating spec changes developed in parallel or during the sam ## Changelog +- 2025-08-09: **Schema version 1.26.** + + Add `observeTracingMessages` configuration for clients and `expectTracingMessages` for test expectations. This allows + capturing and validating detailed tracing information during test execution. + - 2025-07-28: **Schema version 1.25.** Add alternate form of `csfle`. Previously it was only a bool. Now it can also be an object containing