From 47d1822236caf2cd90e9124047dda2e6b03471f4 Mon Sep 17 00:00:00 2001 From: Jeremy Mikola Date: Mon, 4 Nov 2024 11:26:19 -0500 Subject: [PATCH] DRIVERS-1555: Test that isClientError considers network errors (#1720) Also use isClientError in estimatedDocumentCount network error tests --- .../tests/unified/estimatedDocumentCount.json | 2 +- .../tests/unified/estimatedDocumentCount.yml | 2 +- .../tests/unified/estimatedDocumentCount.json | 4 +- .../tests/unified/estimatedDocumentCount.yml | 2 +- .../expectedError-isClientError.json | 74 +++++++++++++++++++ .../expectedError-isClientError.yml | 39 ++++++++++ 6 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 source/unified-test-format/tests/valid-pass/expectedError-isClientError.json create mode 100644 source/unified-test-format/tests/valid-pass/expectedError-isClientError.yml diff --git a/source/crud/tests/unified/estimatedDocumentCount.json b/source/crud/tests/unified/estimatedDocumentCount.json index 1b650c1cb6..3577d9006b 100644 --- a/source/crud/tests/unified/estimatedDocumentCount.json +++ b/source/crud/tests/unified/estimatedDocumentCount.json @@ -249,7 +249,7 @@ "name": "estimatedDocumentCount", "object": "collection0", "expectError": { - "isError": true + "isClientError": true } } ], diff --git a/source/crud/tests/unified/estimatedDocumentCount.yml b/source/crud/tests/unified/estimatedDocumentCount.yml index 12f33cc7e5..22e1d3587f 100644 --- a/source/crud/tests/unified/estimatedDocumentCount.yml +++ b/source/crud/tests/unified/estimatedDocumentCount.yml @@ -130,7 +130,7 @@ tests: - name: estimatedDocumentCount object: *collection0 expectError: - isError: true + isClientError: true expectEvents: - client: *client0 events: diff --git a/source/retryable-reads/tests/unified/estimatedDocumentCount.json b/source/retryable-reads/tests/unified/estimatedDocumentCount.json index 75a676b9b6..2ee29f6799 100644 --- a/source/retryable-reads/tests/unified/estimatedDocumentCount.json +++ b/source/retryable-reads/tests/unified/estimatedDocumentCount.json @@ -195,7 +195,7 @@ "object": "collection1", "name": "estimatedDocumentCount", "expectError": { - "isError": true + "isClientError": true } } ], @@ -241,7 +241,7 @@ "object": "collection0", "name": "estimatedDocumentCount", "expectError": { - "isError": true + "isClientError": true } } ], diff --git a/source/retryable-reads/tests/unified/estimatedDocumentCount.yml b/source/retryable-reads/tests/unified/estimatedDocumentCount.yml index a4cac5a64e..13ad4061e8 100644 --- a/source/retryable-reads/tests/unified/estimatedDocumentCount.yml +++ b/source/retryable-reads/tests/unified/estimatedDocumentCount.yml @@ -116,7 +116,7 @@ tests: object: *collection1 name: estimatedDocumentCount expectError: - isError: true + isClientError: true expectEvents: - client: *client1 diff --git a/source/unified-test-format/tests/valid-pass/expectedError-isClientError.json b/source/unified-test-format/tests/valid-pass/expectedError-isClientError.json new file mode 100644 index 0000000000..9c6beda588 --- /dev/null +++ b/source/unified-test-format/tests/valid-pass/expectedError-isClientError.json @@ -0,0 +1,74 @@ +{ + "description": "expectedError-isClientError", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "single", + "replicaset" + ] + }, + { + "minServerVersion": "4.1.7", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "test" + } + } + ], + "tests": [ + { + "description": "isClientError considers network errors", + "operations": [ + { + "name": "failPoint", + "object": "testRunner", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "ping" + ], + "closeConnection": true + } + } + } + }, + { + "name": "runCommand", + "object": "database0", + "arguments": { + "commandName": "ping", + "command": { + "ping": 1 + } + }, + "expectError": { + "isClientError": true + } + } + ] + } + ] +} diff --git a/source/unified-test-format/tests/valid-pass/expectedError-isClientError.yml b/source/unified-test-format/tests/valid-pass/expectedError-isClientError.yml new file mode 100644 index 0000000000..3bc12e73f9 --- /dev/null +++ b/source/unified-test-format/tests/valid-pass/expectedError-isClientError.yml @@ -0,0 +1,39 @@ +description: "expectedError-isClientError" + +schemaVersion: "1.3" + +runOnRequirements: + - minServerVersion: "4.0" + topologies: [single, replicaset] + - minServerVersion: "4.1.7" + topologies: [sharded, load-balanced] + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: false + - database: + id: &database0 database0 + client: *client0 + databaseName: &database0Name test + +tests: + - description: "isClientError considers network errors" + operations: + - name: failPoint + object: testRunner + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ ping ] + closeConnection: true + - name: runCommand + object: *database0 + arguments: + commandName: ping + command: { ping: 1 } + expectError: + isClientError: true