Skip to content

Commit ed4e62b

Browse files
author
Divjot Arora
authored
DRIVERS-720 Unified test format changes for LB support (#957)
1 parent c945e53 commit ed4e62b

File tree

85 files changed

+2361
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+2361
-129
lines changed

source/unified-test-format/schema-1.2.json renamed to source/unified-test-format/schema-1.3.json

+138-12
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@
5252
"minItems": 1,
5353
"items": {
5454
"type": "string",
55-
"enum": ["single", "replicaset", "sharded", "sharded-replicaset"]
55+
"enum": ["single", "replicaset", "sharded", "sharded-replicaset", "load-balanced"]
5656
}
5757
},
5858
"serverParameters": {
5959
"type": "object",
6060
"minProperties": 1
61-
}
61+
},
62+
"auth": { "type": "boolean" }
6263
}
6364
},
6465

@@ -81,7 +82,22 @@
8182
"minItems": 1,
8283
"items": {
8384
"type": "string",
84-
"enum": ["commandStartedEvent", "commandSucceededEvent", "commandFailedEvent"]
85+
"enum": [
86+
"commandStartedEvent",
87+
"commandSucceededEvent",
88+
"commandFailedEvent",
89+
"poolCreatedEvent",
90+
"poolReadyEvent",
91+
"poolClearedEvent",
92+
"poolClosedEvent",
93+
"connectionCreatedEvent",
94+
"connectionReadyEvent",
95+
"connectionClosedEvent",
96+
"connectionCheckOutStartedEvent",
97+
"connectionCheckOutFailedEvent",
98+
"connectionCheckedOutEvent",
99+
"connectionCheckedInEvent"
100+
]
85101
}
86102
},
87103
"ignoreCommandMonitoringEvents": {
@@ -194,14 +210,47 @@
194210
"required": ["client", "events"],
195211
"properties": {
196212
"client": { "type": "string" },
197-
"events": {
198-
"type": "array",
199-
"items": { "$ref": "#/definitions/expectedEvent" }
213+
"eventType": {
214+
"type": "string",
215+
"enum": ["command", "cmap"]
216+
},
217+
"events": { "type": "array" }
218+
},
219+
"oneOf": [
220+
{
221+
"required": ["eventType"],
222+
"properties": {
223+
"eventType": { "const": "command" },
224+
"events": {
225+
"type": "array",
226+
"items": { "$ref": "#/definitions/expectedCommandEvent" }
227+
}
228+
}
229+
},
230+
{
231+
"required": ["eventType"],
232+
"properties": {
233+
"eventType": { "const": "cmap" },
234+
"events": {
235+
"type": "array",
236+
"items": { "$ref": "#/definitions/expectedCmapEvent" }
237+
}
238+
}
239+
},
240+
{
241+
"additionalProperties": false,
242+
"properties": {
243+
"client": { "type": "string" },
244+
"events": {
245+
"type": "array",
246+
"items": { "$ref": "#/definitions/expectedCommandEvent" }
247+
}
248+
}
200249
}
201-
}
250+
]
202251
},
203252

204-
"expectedEvent": {
253+
"expectedCommandEvent": {
205254
"type": "object",
206255
"additionalProperties": false,
207256
"maxProperties": 1,
@@ -213,27 +262,100 @@
213262
"properties": {
214263
"command": { "type": "object" },
215264
"commandName": { "type": "string" },
216-
"databaseName": { "type": "string" }
265+
"databaseName": { "type": "string" },
266+
"hasServiceId": { "type": "boolean" }
217267
}
218268
},
219269
"commandSucceededEvent": {
220270
"type": "object",
221271
"additionalProperties": false,
222272
"properties": {
223273
"reply": { "type": "object" },
224-
"commandName": { "type": "string" }
274+
"commandName": { "type": "string" },
275+
"hasServiceId": { "type": "boolean" }
225276
}
226277
},
227278
"commandFailedEvent": {
228279
"type": "object",
229280
"additionalProperties": false,
230281
"properties": {
231-
"commandName": { "type": "string" }
282+
"commandName": { "type": "string" },
283+
"hasServiceId": { "type": "boolean" }
232284
}
233285
}
234286
}
235287
},
236288

289+
"expectedCmapEvent": {
290+
"type": "object",
291+
"additionalProperties": false,
292+
"maxProperties": 1,
293+
"minProperties": 1,
294+
"properties": {
295+
"poolCreatedEvent": {
296+
"type": "object",
297+
"additionalProperties": false,
298+
"properties": {}
299+
},
300+
"poolReadyEvent": {
301+
"type": "object",
302+
"additionalProperties": false,
303+
"properties": {}
304+
},
305+
"poolClearedEvent": {
306+
"type": "object",
307+
"additionalProperties": false,
308+
"properties": {
309+
"hasServiceId": { "type": "boolean" }
310+
}
311+
},
312+
"poolClosedEvent": {
313+
"type": "object",
314+
"additionalProperties": false,
315+
"properties": {}
316+
},
317+
"connectionCreatedEvent": {
318+
"type": "object",
319+
"additionalProperties": false,
320+
"properties": {}
321+
},
322+
"connectionReadyEvent": {
323+
"type": "object",
324+
"additionalProperties": false,
325+
"properties": {}
326+
},
327+
"connectionClosedEvent": {
328+
"type": "object",
329+
"additionalProperties": false,
330+
"properties": {
331+
"reason": { "type": "string" }
332+
}
333+
},
334+
"connectionCheckOutStartedEvent": {
335+
"type": "object",
336+
"additionalProperties": false,
337+
"properties": {}
338+
},
339+
"connectionCheckOutFailedEvent": {
340+
"type": "object",
341+
"additionalProperties": false,
342+
"properties": {
343+
"reason": { "type": "string" }
344+
}
345+
},
346+
"connectionCheckedOutEvent": {
347+
"type": "object",
348+
"additionalProperties": false,
349+
"properties": {}
350+
},
351+
"connectionCheckedInEvent": {
352+
"type": "object",
353+
"additionalProperties": false,
354+
"properties": {}
355+
}
356+
}
357+
},
358+
237359
"collectionOrDatabaseOptions": {
238360
"type": "object",
239361
"additionalProperties": false,
@@ -263,13 +385,17 @@
263385
"name": { "type": "string" },
264386
"object": { "type": "string" },
265387
"arguments": { "type": "object" },
388+
"ignoreResultAndError": { "type": "boolean" },
266389
"expectError": { "$ref": "#/definitions/expectedError" },
267390
"expectResult": {},
268391
"saveResultAsEntity": { "type": "string" }
269392
},
270393
"allOf": [
271394
{ "not": { "required": ["expectError", "expectResult"] } },
272-
{ "not": { "required": ["expectError", "saveResultAsEntity"] } }
395+
{ "not": { "required": ["expectError", "saveResultAsEntity"] } },
396+
{ "not": { "required": ["ignoreResultAndError", "expectResult"] } },
397+
{ "not": { "required": ["ignoreResultAndError", "expectError"] } },
398+
{ "not": { "required": ["ignoreResultAndError", "saveResultAsEntity"] } }
273399
]
274400
},
275401

source/unified-test-format/tests/Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
SCHEMA=../schema-1.2.json
1+
SCHEMA=../schema-1.3.json
22

33
.PHONY: all invalid valid-fail valid-pass versioned-api HAS_AJV
44

5-
all: invalid valid-fail valid-pass versioned-api
5+
all: invalid valid-fail valid-pass versioned-api load-balancers
66

77
invalid: HAS_AJV
88
@# Redirect stdout to hide expected validation errors
@@ -17,6 +17,9 @@ valid-pass: HAS_AJV
1717
versioned-api: HAS_AJV
1818
@ajv test -s $(SCHEMA) -d "../../versioned-api/tests/*.yml" --valid
1919

20+
load-balancers: HAS_AJV
21+
@ajv test -s $(SCHEMA) -d "../../load-balancers/tests/*.yml" --valid
22+
2023
HAS_AJV:
2124
@if ! command -v ajv > /dev/null; then \
2225
echo 'Error: need "npm install -g ajv-cli"' 1>&2; \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"description": "expectedCmapEvent-connectionCheckOutFailedEvent-reason-type",
3+
"schemaVersion": "1.3",
4+
"tests": [
5+
{
6+
"description": "foo",
7+
"operations": [],
8+
"expectEvents": [
9+
{
10+
"client": "client0",
11+
"eventType": "cmap",
12+
"events": [
13+
{
14+
"connectionCheckOutFailedEvent": {
15+
"reason": 10
16+
}
17+
}
18+
]
19+
}
20+
]
21+
}
22+
]
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
description: expectedCmapEvent-connectionCheckOutFailedEvent-reason-type
2+
3+
schemaVersion: '1.3'
4+
5+
tests:
6+
- description: foo
7+
operations: []
8+
expectEvents:
9+
- client: client0
10+
eventType: cmap
11+
events:
12+
- connectionCheckOutFailedEvent:
13+
reason: 10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"description": "expectedCmapEvent-connectionCheckOutStartedEvent-additionalProperties",
3+
"schemaVersion": "1.3",
4+
"tests": [
5+
{
6+
"description": "foo",
7+
"operations": [],
8+
"expectEvents": [
9+
{
10+
"client": "client0",
11+
"eventType": "cmap",
12+
"events": [
13+
{
14+
"connectionCheckOutStartedEvent": {
15+
"foo": "bar"
16+
}
17+
}
18+
]
19+
}
20+
]
21+
}
22+
]
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
description: expectedCmapEvent-connectionCheckOutStartedEvent-additionalProperties
2+
3+
schemaVersion: '1.3'
4+
5+
tests:
6+
- description: foo
7+
operations: []
8+
expectEvents:
9+
- client: client0
10+
eventType: cmap
11+
events:
12+
- connectionCheckOutStartedEvent:
13+
foo: bar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"description": "expectedCmapEvent-connectionCheckedInEvent-additionalProperties",
3+
"schemaVersion": "1.3",
4+
"tests": [
5+
{
6+
"description": "foo",
7+
"operations": [],
8+
"expectEvents": [
9+
{
10+
"client": "client0",
11+
"eventType": "cmap",
12+
"events": [
13+
{
14+
"connectionCheckedInEvent": {
15+
"foo": "bar"
16+
}
17+
}
18+
]
19+
}
20+
]
21+
}
22+
]
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
description: expectedCmapEvent-connectionCheckedInEvent-additionalProperties
2+
3+
schemaVersion: '1.3'
4+
5+
tests:
6+
- description: foo
7+
operations: []
8+
expectEvents:
9+
- client: client0
10+
eventType: cmap
11+
events:
12+
- connectionCheckedInEvent:
13+
foo: bar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"description": "expectedCmapEvent-connectionCheckedOutEvent-additionalProperties",
3+
"schemaVersion": "1.3",
4+
"tests": [
5+
{
6+
"description": "foo",
7+
"operations": [],
8+
"expectEvents": [
9+
{
10+
"client": "client0",
11+
"eventType": "cmap",
12+
"events": [
13+
{
14+
"connectionCheckedOutEvent": {
15+
"foo": "bar"
16+
}
17+
}
18+
]
19+
}
20+
]
21+
}
22+
]
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
description: expectedCmapEvent-connectionCheckedOutEvent-additionalProperties
2+
3+
schemaVersion: '1.3'
4+
5+
tests:
6+
- description: foo
7+
operations: []
8+
expectEvents:
9+
- client: client0
10+
eventType: cmap
11+
events:
12+
- connectionCheckedOutEvent:
13+
foo: bar

0 commit comments

Comments
 (0)