Skip to content

Commit e9d72e5

Browse files
committed
Add load balancer unified test files
1 parent 3d2bf27 commit e9d72e5

File tree

8 files changed

+3911
-0
lines changed

8 files changed

+3911
-0
lines changed

Tests/Specs/load-balancers/tests/cursors.json

Lines changed: 1228 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
{
2+
"description": "monitoring events include correct fields",
3+
"schemaVersion": "1.3",
4+
"runOnRequirements": [
5+
{
6+
"topologies": [
7+
"load-balanced"
8+
]
9+
}
10+
],
11+
"createEntities": [
12+
{
13+
"client": {
14+
"id": "client0",
15+
"useMultipleMongoses": true,
16+
"uriOptions": {
17+
"retryReads": false
18+
},
19+
"observeEvents": [
20+
"commandStartedEvent",
21+
"commandSucceededEvent",
22+
"commandFailedEvent",
23+
"poolClearedEvent"
24+
]
25+
}
26+
},
27+
{
28+
"database": {
29+
"id": "database0",
30+
"client": "client0",
31+
"databaseName": "database0"
32+
}
33+
},
34+
{
35+
"collection": {
36+
"id": "collection0",
37+
"database": "database0",
38+
"collectionName": "coll0"
39+
}
40+
}
41+
],
42+
"initialData": [
43+
{
44+
"databaseName": "database0",
45+
"collectionName": "coll0",
46+
"documents": []
47+
}
48+
],
49+
"tests": [
50+
{
51+
"description": "command started and succeeded events include serviceId",
52+
"operations": [
53+
{
54+
"name": "insertOne",
55+
"object": "collection0",
56+
"arguments": {
57+
"document": {
58+
"x": 1
59+
}
60+
}
61+
}
62+
],
63+
"expectEvents": [
64+
{
65+
"client": "client0",
66+
"events": [
67+
{
68+
"commandStartedEvent": {
69+
"commandName": "insert",
70+
"hasServiceId": true
71+
}
72+
},
73+
{
74+
"commandSucceededEvent": {
75+
"commandName": "insert",
76+
"hasServiceId": true
77+
}
78+
}
79+
]
80+
}
81+
]
82+
},
83+
{
84+
"description": "command failed events include serviceId",
85+
"operations": [
86+
{
87+
"name": "find",
88+
"object": "collection0",
89+
"arguments": {
90+
"filter": {
91+
"$or": true
92+
}
93+
},
94+
"expectError": {
95+
"isError": true
96+
}
97+
}
98+
],
99+
"expectEvents": [
100+
{
101+
"client": "client0",
102+
"events": [
103+
{
104+
"commandStartedEvent": {
105+
"commandName": "find",
106+
"hasServiceId": true
107+
}
108+
},
109+
{
110+
"commandFailedEvent": {
111+
"commandName": "find",
112+
"hasServiceId": true
113+
}
114+
}
115+
]
116+
}
117+
]
118+
},
119+
{
120+
"description": "poolClearedEvent events include serviceId",
121+
"operations": [
122+
{
123+
"name": "failPoint",
124+
"object": "testRunner",
125+
"arguments": {
126+
"client": "client0",
127+
"failPoint": {
128+
"configureFailPoint": "failCommand",
129+
"mode": {
130+
"times": 1
131+
},
132+
"data": {
133+
"failCommands": [
134+
"find"
135+
],
136+
"closeConnection": true
137+
}
138+
}
139+
}
140+
},
141+
{
142+
"name": "find",
143+
"object": "collection0",
144+
"arguments": {
145+
"filter": {}
146+
},
147+
"expectError": {
148+
"isClientError": true
149+
}
150+
}
151+
],
152+
"expectEvents": [
153+
{
154+
"client": "client0",
155+
"events": [
156+
{
157+
"commandStartedEvent": {
158+
"commandName": "find",
159+
"hasServiceId": true
160+
}
161+
},
162+
{
163+
"commandFailedEvent": {
164+
"commandName": "find",
165+
"hasServiceId": true
166+
}
167+
}
168+
]
169+
},
170+
{
171+
"client": "client0",
172+
"eventType": "cmap",
173+
"events": [
174+
{
175+
"poolClearedEvent": {
176+
"hasServiceId": true
177+
}
178+
}
179+
]
180+
}
181+
]
182+
}
183+
]
184+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"description": "connection establishment for load-balanced clusters",
3+
"schemaVersion": "1.3",
4+
"runOnRequirements": [
5+
{
6+
"topologies": [
7+
"load-balanced"
8+
]
9+
}
10+
],
11+
"createEntities": [
12+
{
13+
"client": {
14+
"id": "client0",
15+
"uriOptions": {
16+
"loadBalanced": false
17+
},
18+
"observeEvents": [
19+
"commandStartedEvent"
20+
]
21+
}
22+
},
23+
{
24+
"database": {
25+
"id": "database0",
26+
"client": "client0",
27+
"databaseName": "database0"
28+
}
29+
}
30+
],
31+
"tests": [
32+
{
33+
"description": "operations against load balancers fail if URI contains loadBalanced=false",
34+
"skipReason": "servers have not implemented LB support yet so they will not fail the connection handshake in this case",
35+
"operations": [
36+
{
37+
"name": "runCommand",
38+
"object": "database0",
39+
"arguments": {
40+
"commandName": "ping",
41+
"command": {
42+
"ping": 1
43+
}
44+
},
45+
"expectError": {
46+
"isClientError": false
47+
}
48+
}
49+
],
50+
"expectEvents": [
51+
{
52+
"client": "client0",
53+
"events": []
54+
}
55+
]
56+
}
57+
]
58+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"description": "connection establishment if loadBalanced is specified for non-load balanced clusters",
3+
"schemaVersion": "1.3",
4+
"runOnRequirements": [
5+
{
6+
"topologies": [
7+
"single",
8+
"sharded"
9+
]
10+
}
11+
],
12+
"createEntities": [
13+
{
14+
"client": {
15+
"id": "lbTrueClient",
16+
"useMultipleMongoses": false,
17+
"uriOptions": {
18+
"loadBalanced": true
19+
}
20+
}
21+
},
22+
{
23+
"database": {
24+
"id": "lbTrueDatabase",
25+
"client": "lbTrueClient",
26+
"databaseName": "lbTrueDb"
27+
}
28+
},
29+
{
30+
"client": {
31+
"id": "lbFalseClient",
32+
"uriOptions": {
33+
"loadBalanced": false
34+
}
35+
}
36+
},
37+
{
38+
"database": {
39+
"id": "lbFalseDatabase",
40+
"client": "lbFalseClient",
41+
"databaseName": "lbFalseDb"
42+
}
43+
}
44+
],
45+
"_yamlAnchors": {
46+
"runCommandArguments": [
47+
{
48+
"arguments": {
49+
"commandName": "ping",
50+
"command": {
51+
"ping": 1
52+
}
53+
}
54+
}
55+
]
56+
},
57+
"tests": [
58+
{
59+
"description": "operations against non-load balanced clusters fail if URI contains loadBalanced=true",
60+
"operations": [
61+
{
62+
"name": "runCommand",
63+
"object": "lbTrueDatabase",
64+
"arguments": {
65+
"commandName": "ping",
66+
"command": {
67+
"ping": 1
68+
}
69+
},
70+
"expectError": {
71+
"errorContains": "Driver attempted to initialize in load balancing mode, but the server does not support this mode"
72+
}
73+
}
74+
]
75+
},
76+
{
77+
"description": "operations against non-load balanced clusters succeed if URI contains loadBalanced=false",
78+
"operations": [
79+
{
80+
"name": "runCommand",
81+
"object": "lbFalseDatabase",
82+
"arguments": {
83+
"commandName": "ping",
84+
"command": {
85+
"ping": 1
86+
}
87+
}
88+
}
89+
]
90+
}
91+
]
92+
}

0 commit comments

Comments
 (0)