diff --git a/test/spec/command-logging-and-monitoring/logging/command.json b/test/spec/command-logging-and-monitoring/logging/command.json index d2970df692f..9ba0ead2eb1 100644 --- a/test/spec/command-logging-and-monitoring/logging/command.json +++ b/test/spec/command-logging-and-monitoring/logging/command.json @@ -23,6 +23,12 @@ "database": "database", "collectionName": "logging-tests-collection" } + }, + { + "session": { + "id": "session", + "client": "client" + } } ], "initialData": [ @@ -210,6 +216,328 @@ ] } ] + }, + { + "description": "A successful commitTransaction command", + "runOnRequirements": [ + { + "topologies": [ + "replicaset", + "sharded" + ] + } + ], + "operations": [ + { + "name": "startTransaction", + "object": "session" + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "session": "session", + "document": { + "_id": 2, + "x": 22 + } + } + }, + { + "name": "commitTransaction", + "object": "session" + } + ], + "expectLogMessages": [ + { + "client": "client", + "messages": [ + { + "level": "debug", + "component": "command", + "data": { + "message": "Command started", + "databaseName": "logging-tests", + "commandName": "insert", + "command": { + "$$type": "string" + }, + "requestId": { + "$$type": [ + "int", + "long" + ] + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "command", + "data": { + "message": "Command succeeded", + "databaseName": "logging-tests", + "commandName": "insert", + "reply": { + "$$type": "string" + }, + "requestId": { + "$$type": [ + "int", + "long" + ] + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "durationMS": { + "$$type": [ + "double", + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "command", + "data": { + "message": "Command started", + "databaseName": "admin", + "commandName": "commitTransaction", + "command": { + "$$type": "string" + }, + "requestId": { + "$$type": [ + "int", + "long" + ] + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "command", + "data": { + "message": "Command succeeded", + "databaseName": "admin", + "commandName": "commitTransaction", + "reply": { + "$$type": "string" + }, + "requestId": { + "$$type": [ + "int", + "long" + ] + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "durationMS": { + "$$type": [ + "double", + "int", + "long" + ] + } + } + } + ] + } + ] + }, + { + "description": "A successful abortTransaction command", + "runOnRequirements": [ + { + "topologies": [ + "replicaset", + "sharded" + ] + } + ], + "operations": [ + { + "name": "startTransaction", + "object": "session" + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "session": "session", + "document": { + "_id": 3, + "x": 33 + } + } + }, + { + "name": "abortTransaction", + "object": "session" + } + ], + "expectLogMessages": [ + { + "client": "client", + "messages": [ + { + "level": "debug", + "component": "command", + "data": { + "message": "Command started", + "databaseName": "logging-tests", + "commandName": "insert", + "command": { + "$$type": "string" + }, + "requestId": { + "$$type": [ + "int", + "long" + ] + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "command", + "data": { + "message": "Command succeeded", + "databaseName": "logging-tests", + "commandName": "insert", + "reply": { + "$$type": "string" + }, + "requestId": { + "$$type": [ + "int", + "long" + ] + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "durationMS": { + "$$type": [ + "double", + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "command", + "data": { + "message": "Command started", + "databaseName": "admin", + "commandName": "abortTransaction", + "command": { + "$$type": "string" + }, + "requestId": { + "$$type": [ + "int", + "long" + ] + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + } + } + }, + { + "level": "debug", + "component": "command", + "data": { + "message": "Command succeeded", + "databaseName": "admin", + "commandName": "abortTransaction", + "reply": { + "$$type": "string" + }, + "requestId": { + "$$type": [ + "int", + "long" + ] + }, + "serverHost": { + "$$type": "string" + }, + "serverPort": { + "$$type": [ + "int", + "long" + ] + }, + "durationMS": { + "$$type": [ + "double", + "int", + "long" + ] + } + } + } + ] + } + ] } ] -} +} \ No newline at end of file diff --git a/test/spec/command-logging-and-monitoring/logging/command.yml b/test/spec/command-logging-and-monitoring/logging/command.yml index 3e3410b06d3..e52f9d93027 100644 --- a/test/spec/command-logging-and-monitoring/logging/command.yml +++ b/test/spec/command-logging-and-monitoring/logging/command.yml @@ -15,6 +15,9 @@ createEntities: id: &collection collection database: *database collectionName: &collectionName logging-tests-collection + - session: + id: &session session + client: *client initialData: - collectionName: *collectionName @@ -78,7 +81,7 @@ tests: databaseName: *databaseName commandName: *commandName command: { $$type: string } - requestId: { $$type: [int, long] } + requestId: { $$type: [int, long] } serverHost: { $$type: string } serverPort: { $$type: [int, long] } @@ -89,7 +92,135 @@ tests: databaseName: *databaseName commandName: *commandName failure: { $$exists: true } - requestId: { $$type: [int, long] } + requestId: { $$type: [int, long] } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } + + - description: "A successful commitTransaction command" + runOnRequirements: + - topologies: + - replicaset + - sharded + operations: + - name: startTransaction + object: *session + - name: insertOne + object: *collection + arguments: + session: *session + document: { _id: 2, x: 22 } + - name: commitTransaction + object: *session + expectLogMessages: + - client: *client + messages: + - level: debug + component: command + data: + message: "Command started" + databaseName: *databaseName + commandName: insert + command: { $$type: string } + requestId: { $$type: [int, long] } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + + - level: debug + component: command + data: + message: "Command succeeded" + databaseName: *databaseName + commandName: insert + reply: { $$type: string } + requestId: { $$type: [int, long] } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } + + - level: debug + component: command + data: + message: "Command started" + databaseName: admin + commandName: commitTransaction + command: { $$type: string } + requestId: { $$type: [int, long] } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + + - level: debug + component: command + data: + message: "Command succeeded" + databaseName: admin + commandName: commitTransaction + reply: { $$type: string } + requestId: { $$type: [int, long] } serverHost: { $$type: string } serverPort: { $$type: [int, long] } durationMS: { $$type: [double, int, long] } + + - description: "A successful abortTransaction command" + runOnRequirements: + - topologies: + - replicaset + - sharded + operations: + - name: startTransaction + object: *session + - name: insertOne + object: *collection + arguments: + session: *session + document: { _id: 3, x: 33 } + - name: abortTransaction + object: *session + expectLogMessages: + - client: *client + messages: + - level: debug + component: command + data: + message: "Command started" + databaseName: *databaseName + commandName: insert + command: { $$type: string } + requestId: { $$type: [int, long] } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + + - level: debug + component: command + data: + message: "Command succeeded" + databaseName: *databaseName + commandName: insert + reply: { $$type: string } + requestId: { $$type: [int, long] } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } + + - level: debug + component: command + data: + message: "Command started" + databaseName: admin + commandName: abortTransaction + command: { $$type: string } + requestId: { $$type: [int, long] } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + + - level: debug + component: command + data: + message: "Command succeeded" + databaseName: admin + commandName: abortTransaction + reply: { $$type: string } + requestId: { $$type: [int, long] } + serverHost: { $$type: string } + serverPort: { $$type: [int, long] } + durationMS: { $$type: [double, int, long] } \ No newline at end of file