PYTHON-3351 Provide access to raw result document when the server returns an error for a command (#1125)
This commit is contained in:
parent
26efc0f43d
commit
ccade9bc05
90
test/crud/unified/aggregate-merge-errorResponse.json
Normal file
90
test/crud/unified/aggregate-merge-errorResponse.json
Normal file
@ -0,0 +1,90 @@
|
||||
{
|
||||
"description": "aggregate-merge-errorResponse",
|
||||
"schemaVersion": "1.12",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": 1
|
||||
},
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "aggregate $merge DuplicateKey error is accessible",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.1",
|
||||
"topologies": [
|
||||
"single",
|
||||
"replicaset"
|
||||
]
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "aggregate",
|
||||
"object": "database0",
|
||||
"arguments": {
|
||||
"pipeline": [
|
||||
{
|
||||
"$documents": [
|
||||
{
|
||||
"_id": 2,
|
||||
"x": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"$merge": {
|
||||
"into": "test",
|
||||
"whenMatched": "fail"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectError": {
|
||||
"errorCode": 11000,
|
||||
"errorResponse": {
|
||||
"keyPattern": {
|
||||
"_id": 1
|
||||
},
|
||||
"keyValue": {
|
||||
"_id": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
88
test/crud/unified/bulkWrite-errorResponse.json
Normal file
88
test/crud/unified/bulkWrite-errorResponse.json
Normal file
@ -0,0 +1,88 @@
|
||||
{
|
||||
"description": "bulkWrite-errorResponse",
|
||||
"schemaVersion": "1.12",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"useMultipleMongoses": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "bulkWrite operations support errorResponse assertions",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "4.0.0",
|
||||
"topologies": [
|
||||
"single",
|
||||
"replicaset"
|
||||
]
|
||||
},
|
||||
{
|
||||
"minServerVersion": "4.2.0",
|
||||
"topologies": [
|
||||
"sharded"
|
||||
]
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "failPoint",
|
||||
"object": "testRunner",
|
||||
"arguments": {
|
||||
"client": "client0",
|
||||
"failPoint": {
|
||||
"configureFailPoint": "failCommand",
|
||||
"mode": {
|
||||
"times": 1
|
||||
},
|
||||
"data": {
|
||||
"failCommands": [
|
||||
"insert"
|
||||
],
|
||||
"errorCode": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "bulkWrite",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"requests": [
|
||||
{
|
||||
"insertOne": {
|
||||
"document": {
|
||||
"_id": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expectError": {
|
||||
"errorCode": 8,
|
||||
"errorResponse": {
|
||||
"code": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
82
test/crud/unified/deleteOne-errorResponse.json
Normal file
82
test/crud/unified/deleteOne-errorResponse.json
Normal file
@ -0,0 +1,82 @@
|
||||
{
|
||||
"description": "deleteOne-errorResponse",
|
||||
"schemaVersion": "1.12",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"useMultipleMongoses": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "delete operations support errorResponse assertions",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "4.0.0",
|
||||
"topologies": [
|
||||
"single",
|
||||
"replicaset"
|
||||
]
|
||||
},
|
||||
{
|
||||
"minServerVersion": "4.2.0",
|
||||
"topologies": [
|
||||
"sharded"
|
||||
]
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "failPoint",
|
||||
"object": "testRunner",
|
||||
"arguments": {
|
||||
"client": "client0",
|
||||
"failPoint": {
|
||||
"configureFailPoint": "failCommand",
|
||||
"mode": {
|
||||
"times": 1
|
||||
},
|
||||
"data": {
|
||||
"failCommands": [
|
||||
"delete"
|
||||
],
|
||||
"errorCode": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "deleteOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"errorCode": 8,
|
||||
"errorResponse": {
|
||||
"code": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -64,7 +64,11 @@
|
||||
"key": "value"
|
||||
}
|
||||
},
|
||||
"expectResult": [ 11, 22, 33 ]
|
||||
"expectResult": [
|
||||
11,
|
||||
22,
|
||||
33
|
||||
]
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
@ -105,7 +109,11 @@
|
||||
"filter": {},
|
||||
"comment": "comment"
|
||||
},
|
||||
"expectResult": [ 11, 22, 33 ]
|
||||
"expectResult": [
|
||||
11,
|
||||
22,
|
||||
33
|
||||
]
|
||||
}
|
||||
],
|
||||
"expectEvents": [
|
||||
|
||||
132
test/crud/unified/findOneAndUpdate-errorResponse.json
Normal file
132
test/crud/unified/findOneAndUpdate-errorResponse.json
Normal file
@ -0,0 +1,132 @@
|
||||
{
|
||||
"description": "findOneAndUpdate-errorResponse",
|
||||
"schemaVersion": "1.12",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"initialData": [
|
||||
{
|
||||
"collectionName": "test",
|
||||
"databaseName": "crud-tests",
|
||||
"documents": [
|
||||
{
|
||||
"_id": 1,
|
||||
"x": "foo"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "findOneAndUpdate DuplicateKey error is accessible",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "4.2"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "createIndex",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"keys": {
|
||||
"x": 1
|
||||
},
|
||||
"unique": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "findOneAndUpdate",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 2
|
||||
},
|
||||
"update": {
|
||||
"$set": {
|
||||
"x": "foo"
|
||||
}
|
||||
},
|
||||
"upsert": true
|
||||
},
|
||||
"expectError": {
|
||||
"errorCode": 11000,
|
||||
"errorResponse": {
|
||||
"keyPattern": {
|
||||
"x": 1
|
||||
},
|
||||
"keyValue": {
|
||||
"x": "foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "findOneAndUpdate document validation errInfo is accessible",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "5.0"
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "modifyCollection",
|
||||
"object": "database0",
|
||||
"arguments": {
|
||||
"collection": "test",
|
||||
"validator": {
|
||||
"x": {
|
||||
"$type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "findOneAndUpdate",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": {
|
||||
"$set": {
|
||||
"x": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"errorCode": 121,
|
||||
"errorResponse": {
|
||||
"errInfo": {
|
||||
"failingDocumentId": 1,
|
||||
"details": {
|
||||
"$$type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
82
test/crud/unified/insertOne-errorResponse.json
Normal file
82
test/crud/unified/insertOne-errorResponse.json
Normal file
@ -0,0 +1,82 @@
|
||||
{
|
||||
"description": "insertOne-errorResponse",
|
||||
"schemaVersion": "1.12",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"useMultipleMongoses": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "insert operations support errorResponse assertions",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "4.0.0",
|
||||
"topologies": [
|
||||
"single",
|
||||
"replicaset"
|
||||
]
|
||||
},
|
||||
{
|
||||
"minServerVersion": "4.2.0",
|
||||
"topologies": [
|
||||
"sharded"
|
||||
]
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "failPoint",
|
||||
"object": "testRunner",
|
||||
"arguments": {
|
||||
"client": "client0",
|
||||
"failPoint": {
|
||||
"configureFailPoint": "failCommand",
|
||||
"mode": {
|
||||
"times": 1
|
||||
},
|
||||
"data": {
|
||||
"failCommands": [
|
||||
"insert"
|
||||
],
|
||||
"errorCode": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "insertOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"document": {
|
||||
"_id": 1
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"errorCode": 8,
|
||||
"errorResponse": {
|
||||
"code": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
87
test/crud/unified/updateOne-errorResponse.json
Normal file
87
test/crud/unified/updateOne-errorResponse.json
Normal file
@ -0,0 +1,87 @@
|
||||
{
|
||||
"description": "updateOne-errorResponse",
|
||||
"schemaVersion": "1.12",
|
||||
"createEntities": [
|
||||
{
|
||||
"client": {
|
||||
"id": "client0",
|
||||
"useMultipleMongoses": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"database": {
|
||||
"id": "database0",
|
||||
"client": "client0",
|
||||
"databaseName": "crud-tests"
|
||||
}
|
||||
},
|
||||
{
|
||||
"collection": {
|
||||
"id": "collection0",
|
||||
"database": "database0",
|
||||
"collectionName": "test"
|
||||
}
|
||||
}
|
||||
],
|
||||
"tests": [
|
||||
{
|
||||
"description": "update operations support errorResponse assertions",
|
||||
"runOnRequirements": [
|
||||
{
|
||||
"minServerVersion": "4.0.0",
|
||||
"topologies": [
|
||||
"single",
|
||||
"replicaset"
|
||||
]
|
||||
},
|
||||
{
|
||||
"minServerVersion": "4.2.0",
|
||||
"topologies": [
|
||||
"sharded"
|
||||
]
|
||||
}
|
||||
],
|
||||
"operations": [
|
||||
{
|
||||
"name": "failPoint",
|
||||
"object": "testRunner",
|
||||
"arguments": {
|
||||
"client": "client0",
|
||||
"failPoint": {
|
||||
"configureFailPoint": "failCommand",
|
||||
"mode": {
|
||||
"times": 1
|
||||
},
|
||||
"data": {
|
||||
"failCommands": [
|
||||
"update"
|
||||
],
|
||||
"errorCode": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "updateOne",
|
||||
"object": "collection0",
|
||||
"arguments": {
|
||||
"filter": {
|
||||
"_id": 1
|
||||
},
|
||||
"update": {
|
||||
"$set": {
|
||||
"x": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"expectError": {
|
||||
"errorCode": 8,
|
||||
"errorResponse": {
|
||||
"code": 8
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -862,7 +862,7 @@ class UnifiedSpecTestMixinV1(IntegrationTest):
|
||||
a class attribute ``TEST_SPEC``.
|
||||
"""
|
||||
|
||||
SCHEMA_VERSION = Version.from_string("1.10")
|
||||
SCHEMA_VERSION = Version.from_string("1.12")
|
||||
RUN_ON_LOAD_BALANCER = True
|
||||
RUN_ON_SERVERLESS = True
|
||||
TEST_SPEC: Any
|
||||
@ -994,6 +994,10 @@ class UnifiedSpecTestMixinV1(IntegrationTest):
|
||||
error_labels_contain = spec.get("errorLabelsContain")
|
||||
error_labels_omit = spec.get("errorLabelsOmit")
|
||||
expect_result = spec.get("expectResult")
|
||||
error_response = spec.get("errorResponse")
|
||||
if error_response:
|
||||
for k in error_response.keys():
|
||||
self.assertEqual(error_response[k], exception.details[k])
|
||||
|
||||
if is_error:
|
||||
# already satisfied because exception was raised
|
||||
|
||||
Loading…
Reference in New Issue
Block a user