From 053fa15e375defb90a8f0761ef4a0520910bc8a2 Mon Sep 17 00:00:00 2001 From: Sergey Zelenov Date: Wed, 28 Jan 2026 17:17:30 +0100 Subject: [PATCH 1/3] test(NODE-7393): spec tests for transaction logging --- .../logging/command.json | 330 +++++++++++++++++- .../logging/command.yml | 135 ++++++- 2 files changed, 462 insertions(+), 3 deletions(-) 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 From 03867fb96901e2c7d65d5aabbb0dc6f586c4069c Mon Sep 17 00:00:00 2001 From: Sergey Zelenov Date: Wed, 28 Jan 2026 18:38:34 +0100 Subject: [PATCH 2/3] test(NODE-7393): run spec tests only --- .../command_logging_and_monitoring.spec.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.spec.test.ts b/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.spec.test.ts index 6f2a0e6ee1d..1591b823e05 100644 --- a/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.spec.test.ts +++ b/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.spec.test.ts @@ -23,7 +23,7 @@ describe('Command Logging and Monitoring Spec', function () { ); }); - describe('Command Logging Spec', () => { + describe.only('Command Logging Spec', () => { const tests = loadSpecTests(path.join('command-logging-and-monitoring', 'logging')); runUnifiedSuite(tests, test => { if ( From 5c8b9985027c96cd7c30c045243d2a501b1e7ca2 Mon Sep 17 00:00:00 2001 From: Sergey Zelenov Date: Wed, 28 Jan 2026 20:29:01 +0100 Subject: [PATCH 3/3] test(NODE-7393): run all tests --- .../command_logging_and_monitoring.spec.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.spec.test.ts b/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.spec.test.ts index 1591b823e05..6f2a0e6ee1d 100644 --- a/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.spec.test.ts +++ b/test/integration/command-logging-and-monitoring/command_logging_and_monitoring.spec.test.ts @@ -23,7 +23,7 @@ describe('Command Logging and Monitoring Spec', function () { ); }); - describe.only('Command Logging Spec', () => { + describe('Command Logging Spec', () => { const tests = loadSpecTests(path.join('command-logging-and-monitoring', 'logging')); runUnifiedSuite(tests, test => { if (