Skip to content

Commit 11022ca

Browse files
DRIVERS-943 Convert retryable writes command construction tests to unified format (#1697)
Co-authored-by: Kevin Albertson <[email protected]>
1 parent ffe8b9e commit 11022ca

29 files changed

+1003
-50
lines changed

source/retryable-writes/tests/README.md

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -63,42 +63,9 @@ insert command (because all documents in the first command will be processed in
6363
or delete that is split into two commands, the `skip` should be set to the number of statements in the first command to
6464
allow the fail point to trigger on the second command.
6565

66-
## Command Construction Tests
67-
68-
Drivers should also assert that command documents are properly constructed with or without a transaction ID, depending
69-
on whether the write operation is supported.
70-
[Command Logging and Monitoring](../../command-logging-and-monitoring/command-logging-and-monitoring.md) may be used to
71-
check for the presence of a `txnNumber` field in the command document. Note that command documents may always include an
72-
`lsid` field per the [Driver Session](../../sessions/driver-sessions.md) specification.
73-
74-
These tests may be run against both a replica set and shard cluster.
75-
76-
Drivers should test that transaction IDs are never included in commands for unsupported write operations:
77-
78-
- Write commands with unacknowledged write concerns (e.g. `{w: 0}`)
79-
- Unsupported single-statement write operations
80-
- `updateMany()`
81-
- `deleteMany()`
82-
- Unsupported multi-statement write operations
83-
- `bulkWrite()` that includes `UpdateMany` or `DeleteMany`
84-
- Unsupported write commands
85-
- `aggregate` with write stage (e.g. `$out`, `$merge`)
86-
87-
Drivers should test that transactions IDs are always included in commands for supported write operations:
88-
89-
- Supported single-statement write operations
90-
- `insertOne()`
91-
- `updateOne()`
92-
- `replaceOne()`
93-
- `deleteOne()`
94-
- `findOneAndDelete()`
95-
- `findOneAndReplace()`
96-
- `findOneAndUpdate()`
97-
- Supported multi-statement write operations
98-
- `insertMany()` with `ordered=true`
99-
- `insertMany()` with `ordered=false`
100-
- `bulkWrite()` with `ordered=true` (no `UpdateMany` or `DeleteMany`)
101-
- `bulkWrite()` with `ordered=false` (no `UpdateMany` or `DeleteMany`)
66+
## ~~Command Construction Tests~~
67+
68+
The command construction prose tests have been removed in favor of command event assertions in the unified format tests.
10269

10370
## Prose Tests
10471

@@ -297,6 +264,8 @@ debugger, code coverage tool, etc.
297264

298265
## Changelog
299266

267+
- 2024-10-29: Convert command construction tests to unified format.
268+
300269
- 2024-05-30: Migrated from reStructuredText to Markdown.
301270

302271
- 2024-02-27: Convert legacy retryable writes tests to unified format.

source/retryable-writes/tests/unified/aggregate-out-merge.json

Lines changed: 144 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
description: "aggregate with $out/$merge does not set txnNumber"
2+
3+
schemaVersion: "1.3"
4+
5+
runOnRequirements:
6+
- minServerVersion: "3.6"
7+
topologies:
8+
- replicaset
9+
- sharded
10+
- load-balanced
11+
12+
createEntities:
13+
- client:
14+
id: &client0 client0
15+
observeEvents: [ commandStartedEvent ]
16+
- database:
17+
id: &database0 database0
18+
client: *client0
19+
databaseName: &database0Name retryable-writes-tests
20+
- collection:
21+
id: &collection0 collection0
22+
database: *database0
23+
collectionName: &collection0Name coll0
24+
25+
initialData:
26+
# The output collection must already exist for $merge on a sharded cluster
27+
- collectionName: &mergeCollection mergeCollection
28+
databaseName: *database0Name
29+
documents: []
30+
31+
tests:
32+
- description: "aggregate with $out does not set txnNumber"
33+
operations:
34+
- object: *collection0
35+
name: aggregate
36+
arguments:
37+
pipeline:
38+
- { $sort: { x: 1 } }
39+
- { $match: { _id: { $gt: 1 } } }
40+
- { $out: outCollection }
41+
expectEvents:
42+
- client: client0
43+
events:
44+
- commandStartedEvent:
45+
commandName: aggregate
46+
command:
47+
txnNumber: { $$exists: false }
48+
- description: "aggregate with $merge does not set txnNumber"
49+
runOnRequirements:
50+
- minServerVersion: "4.1.11"
51+
operations:
52+
- object: *collection0
53+
name: aggregate
54+
arguments:
55+
pipeline:
56+
- { $sort: { x: 1 } }
57+
- { $match: { _id: { $gt: 1 } } }
58+
- { $merge: { into: *mergeCollection } }
59+
expectEvents:
60+
- client: client0
61+
events:
62+
- commandStartedEvent:
63+
commandName: aggregate
64+
command:
65+
txnNumber: { $$exists: false }

0 commit comments

Comments
 (0)