Skip to content

Commit 082b2e8

Browse files
committed
Additional tests for expectedError.errorResponse
Adds basic tests for expectedError.errorResponse under the unified test format, which are derived from the operation-failure tests in valid-fail. Also adds tests for write operations (i.e. insert, update, delete, and bulkWrite), which may be problematic for some drivers that use special exceptions such as BulkWriteException, which may not provide direct access to a single response. Note that tests should avoid using errorResponse assertions for such operations and permit drivers to skip those tests as needed.
1 parent 17eea3c commit 082b2e8

11 files changed

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

0 commit comments

Comments
 (0)