Skip to content

Commit dfde2d1

Browse files
committed
Add additional test-cases.
1 parent 0b7fbfa commit dfde2d1

File tree

1 file changed

+62
-30
lines changed

1 file changed

+62
-30
lines changed

source/mongodb-handshake/tests/README.md

Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -110,48 +110,80 @@ Before each test case, perform the setup.
110110
| version | 1.2 |
111111
| platform | Library Platform |
112112

113-
2. Send a `ping` command to the server and verify:
114-
115-
- The command succeeds.
116-
- The wrapping library metadata is appended to the respective `client.driver` fields of the `hello` command.
113+
2. Send a `ping` command to the server and verify that the command succeeds.
117114

118115
3. Save intercepted `client` document as `initialClientMetadata`.
119116

120117
4. Wait 5ms for the connection to become idle.
121118

122119
#### Parameterized test cases
123120

124-
**Case 1**
121+
| Case | Name | Version | Platform |
122+
| ---- | --------- | ------- | ------------------ |
123+
| 1 | framework | 2.0 | Framework Platform |
124+
| 2 | framework | 2.0 | null |
125+
| 3 | framework | null | Framework Platform |
126+
| 4 | framework | null | null |
127+
128+
#### Running a test case
129+
130+
1. Append the `DriverInfoOptions` from the selected test case to the `MongoClient` metadata.
131+
132+
2. Send a `ping` command to the server and verify:
133+
134+
- The command succeeds.
135+
136+
- The framework metadata is appended to the existing `DriverInfoOptions` in the `client.driver` fields of the `hello`
137+
command, with values separated by a pipe `|`.
138+
139+
- `client.driver.name`:
140+
- If test case's name is non-null: `library|<name>`
141+
- Otherwise, the field remains unchanged: `library`
142+
- `client.driver.version`:
143+
- If test case's version is non-null: `1.2|<version>`
144+
- Otherwise, the field remains unchanged: `1.2`
145+
- `client.driver.platform`:
146+
- If test case's platform is non-null: `Library Platform|<platform>`
147+
- Otherwise, the field remains unchanged: `Library Platform`
148+
149+
- All other subfields in the `client` document remain unchanged from `initialClientMetadata`.
125150

126-
| Field | Value |
127-
| -------- | ------------------ |
128-
| name | framework |
129-
| version | 2.0 |
130-
| platform | Framework Platform |
151+
## Test 2: Multiple Successive Metadata Updates
131152

132-
**Case 2**
153+
Drivers should verify that after `MongoClient` initialization, metadata can be updated multiple times, not replaced, and
154+
is visible in the `hello` command of new connections.
133155

134-
| Field | Value |
135-
| -------- | --------- |
136-
| name | framework |
137-
| version | 2.0 |
138-
| platform | null |
156+
There are multiple test cases parameterized with `DriverInfoOptions` to be appended after a previous metadata update.
157+
Before each test case, perform the setup.
139158

140-
**Case 3**
159+
### Setup
141160

142-
| Field | Value |
143-
| -------- | ------------------ |
144-
| name | framework |
145-
| version | null |
146-
| platform | Framework Platform |
161+
1. Create a `MongoClient` instance with:
147162

148-
**Case 4**
163+
- `maxIdleTimeMS` set to `1ms`
149164

150-
| Field | Value |
151-
| -------- | --------- |
152-
| name | framework |
153-
| version | null |
154-
| platform | null |
165+
2. Append the following `DriverInfoOptions` to the `MongoClient` metadata:
166+
167+
| Field | Value |
168+
| -------- | ---------------- |
169+
| name | library |
170+
| version | 1.2 |
171+
| platform | Library Platform |
172+
173+
3. Send a `ping` command to the server and verify that the command succeeds.
174+
175+
4. Save intercepted `client` document as `updatedClientMetadata`.
176+
177+
5. Wait 5ms for the connection to become idle.
178+
179+
#### Parameterized test cases
180+
181+
| Case | Name | Version | Platform |
182+
| ---- | --------- | ------- | ------------------ |
183+
| 1 | framework | 2.0 | Framework Platform |
184+
| 2 | framework | 2.0 | null |
185+
| 3 | framework | null | Framework Platform |
186+
| 4 | framework | null | null |
155187

156188
#### Running a test case
157189

@@ -174,9 +206,9 @@ Before each test case, perform the setup.
174206
- If test case's platform is non-null: `Library Platform|<platform>`
175207
- Otherwise, the field remains unchanged: `Library Platform`
176208

177-
- All other subfields in the `client` document remain unchanged from `initialClientMetadata`.
209+
- All other subfields in the `client` document remain unchanged from `updatedClientMetadata`.
178210

179-
### Test 2: Test that metadata is not updated on established connections
211+
### Test 3: Test that metadata is not updated on established connections
180212

181213
Drivers should verify that appending metadata after `MongoClient` initialization does **not** close existing
182214
connections, and that no new `hello` command is sent.

0 commit comments

Comments
 (0)