Skip to content

Commit cebc834

Browse files
committed
Merge branch 'master' of https://github.com/mongodb/specifications into mkbook
2 parents 161c043 + 290ee48 commit cebc834

1 file changed

Lines changed: 54 additions & 42 deletions

File tree

source/mongodb-handshake/tests/README.md

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ the following sets of environment variables:
8888
Drivers that do not emit events for commands issued as part of the handshake with the server will need to create a
8989
test-only backdoor mechanism to intercept the handshake `hello` command for verification purposes.
9090

91+
Client metadata specified as part of a "Create a `MongoClient` instance" step MUST use an API which appends the
92+
specified metadata _during_ `MongoClient` initialization.
93+
94+
Client metadata specified as part of an "Append the `DriverInfoOptions`" step MUST use an API which appends the
95+
specified metadata _after_ `MongoClient` initialization.
96+
9197
### Test 1: Test that the driver updates metadata
9298

9399
Drivers should verify that metadata provided after `MongoClient` initialization is appended, not replaced, and is
@@ -102,7 +108,7 @@ Before each test case, perform the setup.
102108

103109
- `maxIdleTimeMS` set to `1ms`
104110

105-
- Wrapping library metadata:
111+
- Client metadata appended with the following `DriverInfoOptions`:
106112

107113
| Field | Value |
108114
| -------- | ---------------- |
@@ -172,7 +178,7 @@ Before each test case, perform the setup.
172178

173179
3. Send a `ping` command to the server and verify that the command succeeds.
174180

175-
4. Save intercepted `client` document as `updatedClientMetadata`.
181+
4. Save intercepted `client` document as `clientMetadata`.
176182

177183
5. Wait 5ms for the connection to become idle.
178184

@@ -206,7 +212,7 @@ Before each test case, perform the setup.
206212
- If test case's platform is non-null: `Library Platform|<platform>`
207213
- Otherwise, the field remains unchanged: `Library Platform`
208214

209-
- All other subfields in the `client` document remain unchanged from `updatedClientMetadata`.
215+
- All other subfields in the `client` document remain unchanged from `clientMetadata`.
210216

211217
### Test 3: Multiple Successive Metadata Updates with Duplicate Data
212218

@@ -319,13 +325,14 @@ Before each test case, perform the setup.
319325
1. Create a `MongoClient` instance with:
320326

321327
- `maxIdleTimeMS` set to `1ms`
322-
- `driverInfo` set to the following:
323328

324-
| Field | Value |
325-
| -------- | ---------------- |
326-
| name | library |
327-
| version | 1.2 |
328-
| platform | Library Platform |
329+
- Client metadata appended with the following `DriverInfoOptions`:
330+
331+
| Field | Value |
332+
| -------- | ---------------- |
333+
| name | library |
334+
| version | 1.2 |
335+
| platform | Library Platform |
329336

330337
2. Send a `ping` command to the server and verify that the command succeeds.
331338

@@ -352,13 +359,14 @@ Before each test case, perform the setup.
352359
1. Create a `MongoClient` instance with:
353360

354361
- `maxIdleTimeMS` set to `1ms`
355-
- `driverInfo` set to the following:
356362

357-
| Field | Value |
358-
| -------- | ---------------- |
359-
| name | library |
360-
| version | 1.2 |
361-
| platform | Library Platform |
363+
- Client metadata appended with the following `DriverInfoOptions`:
364+
365+
| Field | Value |
366+
| -------- | ---------------- |
367+
| name | library |
368+
| version | 1.2 |
369+
| platform | Library Platform |
362370

363371
2. Send a `ping` command to the server and verify that the command succeeds.
364372

@@ -402,43 +410,46 @@ Before each test case, perform the setup.
402410

403411
##### Parameterized test cases
404412

405-
###### Initial metadata
413+
> [!NOTE]
414+
> Drivers whose API allows `client.driver.name` to be unset MAY implement Case 1.
406415
407-
| Case | Name | Version | Platform |
408-
| ---- | ------- | ------- | ---------------- |
409-
| 1 | null | 1.2 | Library Platform |
410-
| 2 | library | null | Library Platform |
411-
| 3 | library | 1.2 | null |
416+
###### Appended metadata
412417

413-
###### Appended Metadata
418+
| Case | Name | Version | Platform |
419+
| ----- | -------- | ------- | -------------------- |
420+
| ~~1~~ | ~~null~~ | ~~1.2~~ | ~~Library Platform~~ |
421+
| 2 | library | null | Library Platform |
422+
| 3 | library | 1.2 | null |
423+
424+
###### Duplicate Metadata
414425

415-
| Case | Name | Version | Platform |
416-
| ---- | ------- | ------- | ---------------- |
417-
| 1 | "" | 1.2 | Library Platform |
418-
| 2 | library | "" | Library Platform |
419-
| 3 | library | 1.2 | "" |
426+
| Case | Name | Version | Platform |
427+
| ----- | ------- | ------- | -------------------- |
428+
| ~~1~~ | ~~""~~ | ~~1.2~~ | ~~Library Platform~~ |
429+
| 2 | library | "" | Library Platform |
430+
| 3 | library | 1.2 | "" |
420431

421432
##### Running a test case
422433

423434
1. Create a `MongoClient` instance with:
424435

425436
- `maxIdleTimeMS` set to `1ms`
426437

427-
2. Append the `DriverInfoOptions` from the selected test case from the initial metadata section.
438+
2. Append the `DriverInfoOptions` from the selected test case from the appended metadata section.
428439

429440
3. Send a `ping` command to the server and verify that the command succeeds.
430441

431-
4. Save intercepted `client` document as `initialClientMetadata`.
442+
4. Save intercepted `client` document as `clientMetadata`.
432443

433444
5. Wait 5ms for the connection to become idle.
434445

435-
6. Append the `DriverInfoOptions` from the selected test case from the appended metadata section.
446+
6. Append the `DriverInfoOptions` from the selected test case from the duplicate metadata section.
436447

437448
7. Send a `ping` command to the server and verify the command succeeds.
438449

439450
8. Store the response as `updatedClientMetadata`.
440451

441-
9. Assert that `initialClientMetadata` is identical to `updatedClientMetadata`.
452+
9. Assert that `clientMetadata` is identical to `updatedClientMetadata`.
442453

443454
### Test 8: Empty strings are considered unset when appending metadata identical to initial metadata
444455

@@ -452,26 +463,27 @@ Before each test case, perform the setup.
452463

453464
###### Initial metadata
454465

455-
| Case | Name | Version | Platform |
456-
| ---- | ------- | ------- | ---------------- |
457-
| 1 | null | 1.2 | Library Platform |
458-
| 2 | library | null | Library Platform |
459-
| 3 | library | 1.2 | null |
466+
| Case | Name | Version | Platform |
467+
| ----- | -------- | ------- | -------------------- |
468+
| ~~1~~ | ~~null~~ | ~~1.2~~ | ~~Library Platform~~ |
469+
| 2 | library | null | Library Platform |
470+
| 3 | library | 1.2 | null |
460471

461472
###### Appended Metadata
462473

463-
| Case | Name | Version | Platform |
464-
| ---- | ------- | ------- | ---------------- |
465-
| 1 | "" | 1.2 | Library Platform |
466-
| 2 | library | "" | Library Platform |
467-
| 3 | library | 1.2 | "" |
474+
| Case | Name | Version | Platform |
475+
| ----- | -------- | ------- | -------------------- |
476+
| ~~1~~ | ~~null~~ | ~~1.2~~ | ~~Library Platform~~ |
477+
| 2 | library | "" | Library Platform |
478+
| 3 | library | 1.2 | "" |
468479

469480
##### Running a test case
470481

471482
1. Create a `MongoClient` instance with:
472483

473484
- `maxIdleTimeMS` set to `1ms`
474-
- `driverInfo` set to the `DriverInfoOptions` from the selected test case from the initial metadata section.
485+
- Client metadata appended with the `DriverInfoOptions` from the selected test case from the initial metadata
486+
section.
475487

476488
2. Send a `ping` command to the server and verify that the command succeeds.
477489

0 commit comments

Comments
 (0)