Skip to content

Commit ccade9b

Browse files
authored
PYTHON-3351 Provide access to raw result document when the server returns an error for a command (#1125)
1 parent 26efc0f commit ccade9b

8 files changed

+576
-3
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"description": "aggregate-merge-errorResponse",
3+
"schemaVersion": "1.12",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0"
8+
}
9+
},
10+
{
11+
"database": {
12+
"id": "database0",
13+
"client": "client0",
14+
"databaseName": "crud-tests"
15+
}
16+
},
17+
{
18+
"collection": {
19+
"id": "collection0",
20+
"database": "database0",
21+
"collectionName": "test"
22+
}
23+
}
24+
],
25+
"initialData": [
26+
{
27+
"collectionName": "test",
28+
"databaseName": "crud-tests",
29+
"documents": [
30+
{
31+
"_id": 1,
32+
"x": 1
33+
},
34+
{
35+
"_id": 2,
36+
"x": 1
37+
}
38+
]
39+
}
40+
],
41+
"tests": [
42+
{
43+
"description": "aggregate $merge DuplicateKey error is accessible",
44+
"runOnRequirements": [
45+
{
46+
"minServerVersion": "5.1",
47+
"topologies": [
48+
"single",
49+
"replicaset"
50+
]
51+
}
52+
],
53+
"operations": [
54+
{
55+
"name": "aggregate",
56+
"object": "database0",
57+
"arguments": {
58+
"pipeline": [
59+
{
60+
"$documents": [
61+
{
62+
"_id": 2,
63+
"x": 1
64+
}
65+
]
66+
},
67+
{
68+
"$merge": {
69+
"into": "test",
70+
"whenMatched": "fail"
71+
}
72+
}
73+
]
74+
},
75+
"expectError": {
76+
"errorCode": 11000,
77+
"errorResponse": {
78+
"keyPattern": {
79+
"_id": 1
80+
},
81+
"keyValue": {
82+
"_id": 2
83+
}
84+
}
85+
}
86+
}
87+
]
88+
}
89+
]
90+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"description": "bulkWrite-errorResponse",
3+
"schemaVersion": "1.12",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"useMultipleMongoses": false
9+
}
10+
},
11+
{
12+
"database": {
13+
"id": "database0",
14+
"client": "client0",
15+
"databaseName": "crud-tests"
16+
}
17+
},
18+
{
19+
"collection": {
20+
"id": "collection0",
21+
"database": "database0",
22+
"collectionName": "test"
23+
}
24+
}
25+
],
26+
"tests": [
27+
{
28+
"description": "bulkWrite operations support errorResponse assertions",
29+
"runOnRequirements": [
30+
{
31+
"minServerVersion": "4.0.0",
32+
"topologies": [
33+
"single",
34+
"replicaset"
35+
]
36+
},
37+
{
38+
"minServerVersion": "4.2.0",
39+
"topologies": [
40+
"sharded"
41+
]
42+
}
43+
],
44+
"operations": [
45+
{
46+
"name": "failPoint",
47+
"object": "testRunner",
48+
"arguments": {
49+
"client": "client0",
50+
"failPoint": {
51+
"configureFailPoint": "failCommand",
52+
"mode": {
53+
"times": 1
54+
},
55+
"data": {
56+
"failCommands": [
57+
"insert"
58+
],
59+
"errorCode": 8
60+
}
61+
}
62+
}
63+
},
64+
{
65+
"name": "bulkWrite",
66+
"object": "collection0",
67+
"arguments": {
68+
"requests": [
69+
{
70+
"insertOne": {
71+
"document": {
72+
"_id": 1
73+
}
74+
}
75+
}
76+
]
77+
},
78+
"expectError": {
79+
"errorCode": 8,
80+
"errorResponse": {
81+
"code": 8
82+
}
83+
}
84+
}
85+
]
86+
}
87+
]
88+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"description": "deleteOne-errorResponse",
3+
"schemaVersion": "1.12",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"useMultipleMongoses": false
9+
}
10+
},
11+
{
12+
"database": {
13+
"id": "database0",
14+
"client": "client0",
15+
"databaseName": "crud-tests"
16+
}
17+
},
18+
{
19+
"collection": {
20+
"id": "collection0",
21+
"database": "database0",
22+
"collectionName": "test"
23+
}
24+
}
25+
],
26+
"tests": [
27+
{
28+
"description": "delete operations support errorResponse assertions",
29+
"runOnRequirements": [
30+
{
31+
"minServerVersion": "4.0.0",
32+
"topologies": [
33+
"single",
34+
"replicaset"
35+
]
36+
},
37+
{
38+
"minServerVersion": "4.2.0",
39+
"topologies": [
40+
"sharded"
41+
]
42+
}
43+
],
44+
"operations": [
45+
{
46+
"name": "failPoint",
47+
"object": "testRunner",
48+
"arguments": {
49+
"client": "client0",
50+
"failPoint": {
51+
"configureFailPoint": "failCommand",
52+
"mode": {
53+
"times": 1
54+
},
55+
"data": {
56+
"failCommands": [
57+
"delete"
58+
],
59+
"errorCode": 8
60+
}
61+
}
62+
}
63+
},
64+
{
65+
"name": "deleteOne",
66+
"object": "collection0",
67+
"arguments": {
68+
"filter": {
69+
"_id": 1
70+
}
71+
},
72+
"expectError": {
73+
"errorCode": 8,
74+
"errorResponse": {
75+
"code": 8
76+
}
77+
}
78+
}
79+
]
80+
}
81+
]
82+
}

test/crud/unified/distinct-comment.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@
6464
"key": "value"
6565
}
6666
},
67-
"expectResult": [ 11, 22, 33 ]
67+
"expectResult": [
68+
11,
69+
22,
70+
33
71+
]
6872
}
6973
],
7074
"expectEvents": [
@@ -105,7 +109,11 @@
105109
"filter": {},
106110
"comment": "comment"
107111
},
108-
"expectResult": [ 11, 22, 33 ]
112+
"expectResult": [
113+
11,
114+
22,
115+
33
116+
]
109117
}
110118
],
111119
"expectEvents": [

0 commit comments

Comments
 (0)