Skip to content

Commit d695ddc

Browse files
committed
updated command monitoring tests.
1 parent 705e3ed commit d695ddc

File tree

7 files changed

+274
-182
lines changed

7 files changed

+274
-182
lines changed
Lines changed: 145 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,161 @@
11
{
2-
"data": [
2+
"data": [
3+
{
4+
"_id": 1,
5+
"x": 11
6+
},
7+
{
8+
"_id": 2,
9+
"x": 22
10+
},
11+
{
12+
"_id": 3,
13+
"x": 33
14+
}
15+
],
16+
"collection_name": "test",
17+
"database_name": "command-monitoring-tests",
18+
"tests": [
19+
{
20+
"description": "A successful mixed bulk write",
21+
"operation": {
22+
"name": "bulkWrite",
23+
"arguments": {
24+
"requests": [
25+
{
26+
"insertOne": {
27+
"document": {
28+
"_id": 4,
29+
"x": 44
30+
}
31+
}
32+
},
33+
{
34+
"updateOne": {
35+
"filter": {
36+
"_id": 3
37+
},
38+
"update": {
39+
"$set": {
40+
"x": 333
41+
}
42+
}
43+
}
44+
}
45+
]
46+
}
47+
},
48+
"expectations": [
349
{
4-
"_id": 1,
5-
"x": 11
50+
"command_started_event": {
51+
"command": {
52+
"insert": "test",
53+
"documents": [
54+
{
55+
"_id": 4,
56+
"x": 44
57+
}
58+
],
59+
"ordered": true
60+
},
61+
"command_name": "insert",
62+
"database_name": "command-monitoring-tests"
63+
}
664
},
765
{
8-
"_id": 2,
9-
"x": 22
66+
"command_succeeded_event": {
67+
"reply": {
68+
"ok": 1.0,
69+
"n": 1
70+
},
71+
"command_name": "insert"
72+
}
1073
},
1174
{
12-
"_id": 3,
13-
"x": 33
14-
}
15-
],
16-
"collection_name": "test",
17-
"database_name": "command-monitoring-tests",
18-
"tests": [
19-
{
20-
"description": "A successful mixed bulk write",
21-
"operation": {
22-
"name": "bulkWrite",
23-
"arguments": {
24-
"requests": [
25-
{
26-
"insertOne": {
27-
"document": {
28-
"_id": 4,
29-
"x": 44
30-
}
31-
}
32-
},
33-
{
34-
"updateOne": {
35-
"filter": {
36-
"_id": 3
37-
},
38-
"update": {
39-
"$set": {
40-
"x": 333
41-
}
42-
}
43-
}
44-
}
45-
]
46-
}
47-
},
48-
"expectations": [
49-
{
50-
"command_started_event": {
51-
"command": {
52-
"insert": "test",
53-
"documents": [
54-
{
55-
"_id": 4,
56-
"x": 44
57-
}
58-
],
59-
"ordered": true
60-
},
61-
"command_name": "insert",
62-
"database_name": "command-monitoring-tests"
63-
}
64-
},
65-
{
66-
"command_succeeded_event": {
67-
"reply": {
68-
"ok": 1.0,
69-
"n": 1
70-
},
71-
"command_name": "insert"
72-
}
73-
},
75+
"command_started_event": {
76+
"command": {
77+
"update": "test",
78+
"updates": [
7479
{
75-
"command_started_event": {
76-
"command": {
77-
"update": "test",
78-
"updates": [
79-
{
80-
"q": {
81-
"_id": 3
82-
},
83-
"u": {
84-
"$set": {
85-
"x": 333
86-
}
87-
},
88-
"upsert": false,
89-
"multi": false
90-
}
91-
],
92-
"ordered": true
93-
},
94-
"command_name": "update",
95-
"database_name": "command-monitoring-tests"
96-
}
97-
},
98-
{
99-
"command_succeeded_event": {
100-
"reply": {
101-
"ok": 1.0,
102-
"n": 1
103-
},
104-
"command_name": "update"
80+
"q": {
81+
"_id": 3
82+
},
83+
"u": {
84+
"$set": {
85+
"x": 333
10586
}
87+
},
88+
"upsert": false,
89+
"multi": false
10690
}
107-
]
91+
],
92+
"ordered": true
93+
},
94+
"command_name": "update",
95+
"database_name": "command-monitoring-tests"
96+
}
10897
},
10998
{
110-
"description": "A successful unordered bulk write with an unacknowledged write concern",
111-
"operation": {
112-
"name": "bulkWrite",
113-
"arguments": {
114-
"requests": [
115-
{
116-
"insertOne": {
117-
"document": {
118-
"_id": 4,
119-
"x": 44
120-
}
121-
}
122-
}
123-
],
124-
"ordered": false,
125-
"writeConcern": {
126-
"w": 0
127-
}
128-
}
99+
"command_succeeded_event": {
100+
"reply": {
101+
"ok": 1.0,
102+
"n": 1
129103
},
130-
"expectations": [
131-
{
132-
"command_started_event": {
133-
"command": {
134-
"insert": "test",
135-
"documents": [
136-
{
137-
"_id": 4,
138-
"x": 44
139-
}
140-
],
141-
"ordered": false,
142-
"writeConcern": {
143-
"w": 0
144-
}
145-
},
146-
"command_name": "insert",
147-
"database_name": "command-monitoring-tests"
148-
}
149-
},
104+
"command_name": "update"
105+
}
106+
}
107+
]
108+
},
109+
{
110+
"description": "A successful unordered bulk write with an unacknowledged write concern",
111+
"operation": {
112+
"name": "bulkWrite",
113+
"arguments": {
114+
"requests": [
115+
{
116+
"insertOne": {
117+
"document": {
118+
"_id": 4,
119+
"x": 44
120+
}
121+
}
122+
}
123+
],
124+
"ordered": false,
125+
"writeConcern": {
126+
"w": 0
127+
}
128+
}
129+
},
130+
"expectations": [
131+
{
132+
"command_started_event": {
133+
"command": {
134+
"insert": "test",
135+
"documents": [
150136
{
151-
"command_succeeded_event": {
152-
"reply": {
153-
"ok": 1.0
154-
},
155-
"command_name": "insert"
156-
}
137+
"_id": 4,
138+
"x": 44
157139
}
158-
]
140+
],
141+
"ordered": false,
142+
"writeConcern": {
143+
"w": 0
144+
}
145+
},
146+
"command_name": "insert",
147+
"database_name": "command-monitoring-tests"
148+
}
149+
},
150+
{
151+
"command_succeeded_event": {
152+
"reply": {
153+
"ok": 1.0
154+
},
155+
"command_name": "insert"
156+
}
159157
}
160-
]
158+
]
159+
}
160+
]
161161
}

src/MongoDB.Driver.Tests/Specifications/command-monitoring/tests/command.json

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,43 @@
7171
}
7272
}
7373
]
74-
}
74+
},
75+
{
76+
"description": "A successful command with a non-primary read preference",
77+
"operation": {
78+
"name": "count",
79+
"arguments": {
80+
"filter": {
81+
"_id": 1
82+
}
83+
},
84+
"read_preference": {
85+
"mode": "primaryPreferred"
86+
}
87+
},
88+
"expectations": [
89+
{
90+
"command_started_event": {
91+
"command": {
92+
"count": "test",
93+
"query": {
94+
"_id": 1
95+
}
96+
},
97+
"command_name": "count",
98+
"database_name": "command-monitoring-tests"
99+
}
100+
},
101+
{
102+
"command_succeeded_event": {
103+
"reply": {
104+
"ok": 1.0,
105+
"n": 1
106+
},
107+
"command_name": "count"
108+
}
109+
}
110+
]
111+
},
75112
]
76113
}

src/MongoDB.Driver.Tests/Specifications/command-monitoring/tests/command.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,22 @@ tests:
4040
-
4141
command_failed_event:
4242
command_name: "count"
43+
-
44+
description: "A successful command with a non-primary read preference"
45+
operation:
46+
name: "count"
47+
arguments:
48+
filter: { _id: 1 }
49+
read_preference: { mode: "primaryPreferred" }
50+
expectations:
51+
-
52+
command_started_event:
53+
command:
54+
count: *collection_name
55+
query: { _id: 1 }
56+
command_name: "count"
57+
database_name: *database_name
58+
-
59+
command_succeeded_event:
60+
reply: { ok: 1.0, n: 1 }
61+
command_name: "count"

0 commit comments

Comments
 (0)