Skip to content

Commit dfe3d89

Browse files
committed
Add unified tests for errorResponse
JAVA-4676
1 parent 087576b commit dfe3d89

File tree

11 files changed

+801
-6
lines changed

11 files changed

+801
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"description": "modifyCollection-errorResponse",
3+
"schemaVersion": "1.12",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"observeEvents": [
9+
"commandStartedEvent"
10+
]
11+
}
12+
},
13+
{
14+
"database": {
15+
"id": "database0",
16+
"client": "client0",
17+
"databaseName": "collMod-tests"
18+
}
19+
},
20+
{
21+
"collection": {
22+
"id": "collection0",
23+
"database": "database0",
24+
"collectionName": "test"
25+
}
26+
}
27+
],
28+
"initialData": [
29+
{
30+
"collectionName": "test",
31+
"databaseName": "collMod-tests",
32+
"documents": [
33+
{
34+
"_id": 1,
35+
"x": 1
36+
},
37+
{
38+
"_id": 2,
39+
"x": 1
40+
}
41+
]
42+
}
43+
],
44+
"tests": [
45+
{
46+
"description": "modifyCollection prepareUnique violations are accessible",
47+
"runOnRequirements": [
48+
{
49+
"minServerVersion": "5.2"
50+
}
51+
],
52+
"operations": [
53+
{
54+
"name": "createIndex",
55+
"object": "collection0",
56+
"arguments": {
57+
"keys": {
58+
"x": 1
59+
}
60+
}
61+
},
62+
{
63+
"name": "modifyCollection",
64+
"object": "database0",
65+
"arguments": {
66+
"collection": "test",
67+
"index": {
68+
"keyPattern": {
69+
"x": 1
70+
},
71+
"prepareUnique": true
72+
}
73+
}
74+
},
75+
{
76+
"name": "insertOne",
77+
"object": "collection0",
78+
"arguments": {
79+
"document": {
80+
"_id": 3,
81+
"x": 1
82+
}
83+
},
84+
"expectError": {
85+
"errorCode": 11000
86+
}
87+
},
88+
{
89+
"name": "modifyCollection",
90+
"object": "database0",
91+
"arguments": {
92+
"collection": "test",
93+
"index": {
94+
"keyPattern": {
95+
"x": 1
96+
},
97+
"unique": true
98+
}
99+
},
100+
"expectError": {
101+
"isClientError": false,
102+
"errorCode": 359,
103+
"errorResponse": {
104+
"violations": [
105+
{
106+
"ids": [
107+
1,
108+
2
109+
]
110+
}
111+
]
112+
}
113+
}
114+
}
115+
]
116+
}
117+
]
118+
}
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+
}

0 commit comments

Comments
 (0)