mongo 2.16.1 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +1 -1
- data/lib/mongo/auth/aws/request.rb +0 -1
- data/lib/mongo/client.rb +4 -0
- data/lib/mongo/collection/view/aggregation.rb +62 -17
- data/lib/mongo/collection/view/builder/aggregation.rb +11 -13
- data/lib/mongo/collection/view/builder/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +7 -3
- data/lib/mongo/collection/view/iterable.rb +2 -3
- data/lib/mongo/collection/view/map_reduce.rb +2 -0
- data/lib/mongo/collection/view/readable.rb +24 -1
- data/lib/mongo/collection/view/writable.rb +23 -0
- data/lib/mongo/collection.rb +21 -1
- data/lib/mongo/database/view.rb +4 -2
- data/lib/mongo/database.rb +6 -6
- data/lib/mongo/error/snapshot_session_invalid_server_version.rb +31 -0
- data/lib/mongo/error/snapshot_session_transaction_prohibited.rb +30 -0
- data/lib/mongo/error.rb +2 -0
- data/lib/mongo/operation/delete/op_msg.rb +2 -1
- data/lib/mongo/operation/find/builder/command.rb +1 -0
- data/lib/mongo/operation/result.rb +6 -0
- data/lib/mongo/operation/shared/executable.rb +4 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +18 -2
- data/lib/mongo/operation/update/op_msg.rb +2 -1
- data/lib/mongo/server/description/features.rb +3 -1
- data/lib/mongo/server_selector/base.rb +26 -4
- data/lib/mongo/session.rb +19 -0
- data/lib/mongo/socket/ocsp_cache.rb +2 -3
- data/lib/mongo/socket.rb +1 -5
- data/lib/mongo/utils.rb +0 -6
- data/lib/mongo/version.rb +1 -1
- data/mongo.gemspec +1 -1
- data/spec/integration/read_preference_spec.rb +16 -12
- data/spec/mongo/collection/view/aggregation_spec.rb +71 -95
- data/spec/mongo/collection/view/change_stream_spec.rb +1 -1
- data/spec/mongo/collection/view/map_reduce_spec.rb +14 -1
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +24 -1
- data/spec/mongo/server_selector_spec.rb +136 -15
- data/spec/mongo/socket/ssl_spec.rb +26 -58
- data/spec/mongo/utils_spec.rb +0 -14
- data/spec/runners/crud/verifier.rb +1 -2
- data/spec/runners/unified/assertions.rb +3 -1
- data/spec/runners/unified/crud_operations.rb +77 -23
- data/spec/runners/unified/ddl_operations.rb +29 -1
- data/spec/runners/unified/entity_map.rb +3 -3
- data/spec/runners/unified/support_operations.rb +6 -1
- data/spec/runners/unified/test.rb +15 -3
- data/spec/spec_tests/data/crud_unified/aggregate-let.yml +138 -0
- data/spec/spec_tests/data/crud_unified/aggregate-write-readPreference.yml +155 -0
- data/spec/spec_tests/data/crud_unified/db-aggregate-write-readPreference.yml +151 -0
- data/spec/spec_tests/data/crud_unified/deleteMany-let.yml +91 -0
- data/spec/spec_tests/data/crud_unified/deleteOne-let.yml +89 -0
- data/spec/spec_tests/data/crud_unified/find-let.yml +71 -0
- data/spec/spec_tests/data/crud_unified/findOneAndDelete-let.yml +88 -0
- data/spec/spec_tests/data/crud_unified/findOneAndReplace-let.yml +94 -0
- data/spec/spec_tests/data/crud_unified/findOneAndUpdate-let.yml +96 -0
- data/spec/spec_tests/data/crud_unified/updateMany-let.yml +103 -0
- data/spec/spec_tests/data/crud_unified/updateOne-let.yml +98 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Secondary.yml +4 -4
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +4 -4
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat2.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +2 -2
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +5 -5
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +5 -5
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +3 -3
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +2 -2
- data/spec/spec_tests/data/max_staleness/Sharded/SmallMaxStaleness.yml +2 -2
- data/spec/spec_tests/data/max_staleness/Single/SmallMaxStaleness.yml +1 -1
- data/spec/spec_tests/data/max_staleness/Unknown/SmallMaxStaleness.yml +1 -1
- data/spec/spec_tests/data/sessions_unified/snapshot-sessions-not-supported-client-error.yml +69 -0
- data/spec/spec_tests/data/sessions_unified/snapshot-sessions-not-supported-server-error.yml +102 -0
- data/spec/spec_tests/data/sessions_unified/snapshot-sessions-unsupported-ops.yml +258 -0
- data/spec/spec_tests/data/sessions_unified/snapshot-sessions.yml +482 -0
- data/spec/spec_tests/sessions_unified_spec.rb +13 -0
- data.tar.gz.sig +0 -0
- metadata +36 -2
- metadata.gz.sig +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
description: "aggregate-let"
|
|
2
|
+
|
|
3
|
+
schemaVersion: "1.4"
|
|
4
|
+
|
|
5
|
+
createEntities:
|
|
6
|
+
- client:
|
|
7
|
+
id: &client0 client0
|
|
8
|
+
observeEvents: [ commandStartedEvent ]
|
|
9
|
+
- database:
|
|
10
|
+
id: &database0 database0
|
|
11
|
+
client: *client0
|
|
12
|
+
databaseName: &database0Name crud-tests
|
|
13
|
+
- collection:
|
|
14
|
+
id: &collection0 collection0
|
|
15
|
+
database: *database0
|
|
16
|
+
collectionName: &collection0Name coll0
|
|
17
|
+
- collection:
|
|
18
|
+
id: &collection1 collection1
|
|
19
|
+
database: *database0
|
|
20
|
+
collectionName: &collection1Name coll1
|
|
21
|
+
|
|
22
|
+
initialData: &initialData
|
|
23
|
+
- collectionName: *collection0Name
|
|
24
|
+
databaseName: *database0Name
|
|
25
|
+
documents:
|
|
26
|
+
- { _id: 1 }
|
|
27
|
+
- collectionName: *collection1Name
|
|
28
|
+
databaseName: *database0Name
|
|
29
|
+
documents: [ ]
|
|
30
|
+
|
|
31
|
+
tests:
|
|
32
|
+
- description: "Aggregate with let option"
|
|
33
|
+
runOnRequirements:
|
|
34
|
+
- minServerVersion: "5.0"
|
|
35
|
+
operations:
|
|
36
|
+
- name: aggregate
|
|
37
|
+
object: *collection0
|
|
38
|
+
arguments:
|
|
39
|
+
pipeline: &pipeline0
|
|
40
|
+
# $match takes a query expression, so $expr is necessary to utilize
|
|
41
|
+
# an aggregate expression context and access "let" variables.
|
|
42
|
+
- $match: { $expr: { $eq: ["$_id", "$$id"] } }
|
|
43
|
+
- $project: { _id: 0, x: "$$x", y: "$$y", rand: "$$rand" }
|
|
44
|
+
# Values in "let" must be constant or closed expressions that do not
|
|
45
|
+
# depend on document values. This test demonstrates a basic constant
|
|
46
|
+
# value, a value wrapped with $literal (to avoid expression parsing),
|
|
47
|
+
# and a closed expression (e.g. $rand).
|
|
48
|
+
let: &let0
|
|
49
|
+
id: 1
|
|
50
|
+
x: foo
|
|
51
|
+
y: { $literal: "$bar" }
|
|
52
|
+
rand: { $rand: {} }
|
|
53
|
+
expectResult:
|
|
54
|
+
- { x: "foo", y: "$bar", rand: { $$type: "double" } }
|
|
55
|
+
expectEvents:
|
|
56
|
+
- client: *client0
|
|
57
|
+
events:
|
|
58
|
+
- commandStartedEvent:
|
|
59
|
+
command:
|
|
60
|
+
aggregate: *collection0Name
|
|
61
|
+
pipeline: *pipeline0
|
|
62
|
+
let: *let0
|
|
63
|
+
|
|
64
|
+
- description: "Aggregate with let option unsupported (server-side error)"
|
|
65
|
+
runOnRequirements:
|
|
66
|
+
- minServerVersion: "2.6.0"
|
|
67
|
+
maxServerVersion: "4.4.99"
|
|
68
|
+
operations:
|
|
69
|
+
- name: aggregate
|
|
70
|
+
object: *collection0
|
|
71
|
+
arguments:
|
|
72
|
+
pipeline: &pipeline1
|
|
73
|
+
- $match: { _id: 1 }
|
|
74
|
+
let: &let1
|
|
75
|
+
x: foo
|
|
76
|
+
expectError:
|
|
77
|
+
# Older server versions may not report an error code, but the error
|
|
78
|
+
# message is consistent between 2.6.x and 4.4.x server versions.
|
|
79
|
+
errorContains: "unrecognized field 'let'"
|
|
80
|
+
isClientError: false
|
|
81
|
+
expectEvents:
|
|
82
|
+
- client: *client0
|
|
83
|
+
events:
|
|
84
|
+
- commandStartedEvent:
|
|
85
|
+
command:
|
|
86
|
+
aggregate: *collection0Name
|
|
87
|
+
pipeline: *pipeline1
|
|
88
|
+
let: *let1
|
|
89
|
+
|
|
90
|
+
- description: "Aggregate to collection with let option"
|
|
91
|
+
runOnRequirements:
|
|
92
|
+
- minServerVersion: "5.0"
|
|
93
|
+
serverless: "forbid"
|
|
94
|
+
operations:
|
|
95
|
+
- name: aggregate
|
|
96
|
+
object: *collection0
|
|
97
|
+
arguments:
|
|
98
|
+
pipeline: &pipeline2
|
|
99
|
+
- $match: { $expr: { $eq: ["$_id", "$$id"] } }
|
|
100
|
+
- $project: { _id: 1 }
|
|
101
|
+
- $out: *collection1Name
|
|
102
|
+
let: &let2
|
|
103
|
+
id: 1
|
|
104
|
+
expectEvents:
|
|
105
|
+
- client: *client0
|
|
106
|
+
events:
|
|
107
|
+
- commandStartedEvent:
|
|
108
|
+
command:
|
|
109
|
+
aggregate: *collection0Name
|
|
110
|
+
pipeline: *pipeline2
|
|
111
|
+
let: *let2
|
|
112
|
+
outcome:
|
|
113
|
+
- collectionName: *collection1Name
|
|
114
|
+
databaseName: *database0Name
|
|
115
|
+
documents:
|
|
116
|
+
- { _id: 1 }
|
|
117
|
+
|
|
118
|
+
- description: "Aggregate to collection with let option unsupported (server-side error)"
|
|
119
|
+
runOnRequirements:
|
|
120
|
+
- minServerVersion: "2.6.0"
|
|
121
|
+
maxServerVersion: "4.4.99"
|
|
122
|
+
operations:
|
|
123
|
+
- name: aggregate
|
|
124
|
+
object: *collection0
|
|
125
|
+
arguments:
|
|
126
|
+
pipeline: *pipeline2
|
|
127
|
+
let: *let2
|
|
128
|
+
expectError:
|
|
129
|
+
errorContains: "unrecognized field 'let'"
|
|
130
|
+
isClientError: false
|
|
131
|
+
expectEvents:
|
|
132
|
+
- client: *client0
|
|
133
|
+
events:
|
|
134
|
+
- commandStartedEvent:
|
|
135
|
+
command:
|
|
136
|
+
aggregate: *collection0Name
|
|
137
|
+
pipeline: *pipeline2
|
|
138
|
+
let: *let2
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
description: aggregate-write-readPreference
|
|
2
|
+
|
|
3
|
+
schemaVersion: '1.4'
|
|
4
|
+
|
|
5
|
+
runOnRequirements:
|
|
6
|
+
# 3.6+ non-standalone is needed to utilize $readPreference in OP_MSG
|
|
7
|
+
- minServerVersion: "3.6"
|
|
8
|
+
topologies: [ replicaset, sharded, load-balanced ]
|
|
9
|
+
|
|
10
|
+
_yamlAnchors:
|
|
11
|
+
readConcern: &readConcern
|
|
12
|
+
level: &readConcernLevel "local"
|
|
13
|
+
writeConcern: &writeConcern
|
|
14
|
+
w: &writeConcernW 1
|
|
15
|
+
|
|
16
|
+
createEntities:
|
|
17
|
+
- client:
|
|
18
|
+
id: &client0 client0
|
|
19
|
+
observeEvents:
|
|
20
|
+
- commandStartedEvent
|
|
21
|
+
# Used to test that read and write concerns are still inherited
|
|
22
|
+
uriOptions:
|
|
23
|
+
readConcernLevel: *readConcernLevel
|
|
24
|
+
w: *writeConcernW
|
|
25
|
+
- database:
|
|
26
|
+
id: &database0 database0
|
|
27
|
+
client: *client0
|
|
28
|
+
databaseName: &database0Name db0
|
|
29
|
+
- collection:
|
|
30
|
+
id: &collection0 collection0
|
|
31
|
+
database: *database0
|
|
32
|
+
collectionName: &collection0Name coll0
|
|
33
|
+
collectionOptions:
|
|
34
|
+
readPreference: &readPreference
|
|
35
|
+
# secondaryPreferred is specified for compatibility with clusters that
|
|
36
|
+
# may not have a secondary (e.g. each shard is only a primary).
|
|
37
|
+
mode: secondaryPreferred
|
|
38
|
+
# maxStalenessSeconds is specified to ensure that drivers forward the
|
|
39
|
+
# read preference to mongos or a load balancer. That would not be the
|
|
40
|
+
# case with only secondaryPreferred.
|
|
41
|
+
maxStalenessSeconds: 600
|
|
42
|
+
- collection:
|
|
43
|
+
id: &collection1 collection1
|
|
44
|
+
database: *database0
|
|
45
|
+
collectionName: &collection1Name coll1
|
|
46
|
+
|
|
47
|
+
initialData:
|
|
48
|
+
- collectionName: *collection0Name
|
|
49
|
+
databaseName: *database0Name
|
|
50
|
+
documents:
|
|
51
|
+
- { _id: 1, x: 11 }
|
|
52
|
+
- { _id: 2, x: 22 }
|
|
53
|
+
- { _id: 3, x: 33 }
|
|
54
|
+
- collectionName: *collection1Name
|
|
55
|
+
databaseName: *database0Name
|
|
56
|
+
documents: []
|
|
57
|
+
|
|
58
|
+
tests:
|
|
59
|
+
- description: "Aggregate with $out includes read preference for 5.0+ server"
|
|
60
|
+
runOnRequirements:
|
|
61
|
+
- minServerVersion: "5.0"
|
|
62
|
+
serverless: "forbid"
|
|
63
|
+
operations:
|
|
64
|
+
- object: *collection0
|
|
65
|
+
name: aggregate
|
|
66
|
+
arguments:
|
|
67
|
+
pipeline: &outPipeline
|
|
68
|
+
- { $match: { _id: { $gt: 1 } } }
|
|
69
|
+
- { $sort: { x: 1 } }
|
|
70
|
+
- { $out: *collection1Name }
|
|
71
|
+
expectEvents:
|
|
72
|
+
- client: *client0
|
|
73
|
+
events:
|
|
74
|
+
- commandStartedEvent:
|
|
75
|
+
command:
|
|
76
|
+
aggregate: *collection0Name
|
|
77
|
+
pipeline: *outPipeline
|
|
78
|
+
$readPreference: *readPreference
|
|
79
|
+
readConcern: *readConcern
|
|
80
|
+
writeConcern: *writeConcern
|
|
81
|
+
outcome: &outcome
|
|
82
|
+
- collectionName: *collection1Name
|
|
83
|
+
databaseName: *database0Name
|
|
84
|
+
documents:
|
|
85
|
+
- { _id: 2, x: 22 }
|
|
86
|
+
- { _id: 3, x: 33 }
|
|
87
|
+
|
|
88
|
+
- description: "Aggregate with $out omits read preference for pre-5.0 server"
|
|
89
|
+
runOnRequirements:
|
|
90
|
+
# MongoDB 4.2 introduced support for read concerns and write stages.
|
|
91
|
+
# Pre-4.2 servers may allow a "local" read concern anyway, but some
|
|
92
|
+
# drivers may avoid inheriting a client-level read concern for pre-4.2.
|
|
93
|
+
- minServerVersion: "4.2"
|
|
94
|
+
maxServerVersion: "4.4.99"
|
|
95
|
+
serverless: "forbid"
|
|
96
|
+
operations:
|
|
97
|
+
- object: *collection0
|
|
98
|
+
name: aggregate
|
|
99
|
+
arguments:
|
|
100
|
+
pipeline: *outPipeline
|
|
101
|
+
expectEvents:
|
|
102
|
+
- client: *client0
|
|
103
|
+
events:
|
|
104
|
+
- commandStartedEvent:
|
|
105
|
+
command:
|
|
106
|
+
aggregate: *collection0Name
|
|
107
|
+
pipeline: *outPipeline
|
|
108
|
+
$readPreference: { $$exists: false }
|
|
109
|
+
readConcern: *readConcern
|
|
110
|
+
writeConcern: *writeConcern
|
|
111
|
+
outcome: *outcome
|
|
112
|
+
|
|
113
|
+
- description: "Aggregate with $merge includes read preference for 5.0+ server"
|
|
114
|
+
runOnRequirements:
|
|
115
|
+
- minServerVersion: "5.0"
|
|
116
|
+
operations:
|
|
117
|
+
- object: *collection0
|
|
118
|
+
name: aggregate
|
|
119
|
+
arguments:
|
|
120
|
+
pipeline: &mergePipeline
|
|
121
|
+
- { $match: { _id: { $gt: 1 } } }
|
|
122
|
+
- { $sort: { x: 1 } }
|
|
123
|
+
- { $merge: { into: *collection1Name } }
|
|
124
|
+
expectEvents:
|
|
125
|
+
- client: *client0
|
|
126
|
+
events:
|
|
127
|
+
- commandStartedEvent:
|
|
128
|
+
command:
|
|
129
|
+
aggregate: *collection0Name
|
|
130
|
+
pipeline: *mergePipeline
|
|
131
|
+
$readPreference: *readPreference
|
|
132
|
+
readConcern: *readConcern
|
|
133
|
+
writeConcern: *writeConcern
|
|
134
|
+
outcome: *outcome
|
|
135
|
+
|
|
136
|
+
- description: "Aggregate with $merge omits read preference for pre-5.0 server"
|
|
137
|
+
runOnRequirements:
|
|
138
|
+
- minServerVersion: "4.2"
|
|
139
|
+
maxServerVersion: "4.4.99"
|
|
140
|
+
operations:
|
|
141
|
+
- object: *collection0
|
|
142
|
+
name: aggregate
|
|
143
|
+
arguments:
|
|
144
|
+
pipeline: *mergePipeline
|
|
145
|
+
expectEvents:
|
|
146
|
+
- client: *client0
|
|
147
|
+
events:
|
|
148
|
+
- commandStartedEvent:
|
|
149
|
+
command:
|
|
150
|
+
aggregate: *collection0Name
|
|
151
|
+
pipeline: *mergePipeline
|
|
152
|
+
$readPreference: { $$exists: false }
|
|
153
|
+
readConcern: *readConcern
|
|
154
|
+
writeConcern: *writeConcern
|
|
155
|
+
outcome: *outcome
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
description: db-aggregate-write-readPreference
|
|
2
|
+
|
|
3
|
+
schemaVersion: '1.4'
|
|
4
|
+
|
|
5
|
+
runOnRequirements:
|
|
6
|
+
# 3.6+ non-standalone is needed to utilize $readPreference in OP_MSG.
|
|
7
|
+
# Serverless does not support $listLocalSessions and $currentOp stages, and
|
|
8
|
+
# mongos does not allow combining them with $out or $merge.
|
|
9
|
+
- minServerVersion: "3.6"
|
|
10
|
+
topologies: [ replicaset ]
|
|
11
|
+
serverless: forbid
|
|
12
|
+
|
|
13
|
+
_yamlAnchors:
|
|
14
|
+
readConcern: &readConcern
|
|
15
|
+
level: &readConcernLevel "local"
|
|
16
|
+
writeConcern: &writeConcern
|
|
17
|
+
w: &writeConcernW 1
|
|
18
|
+
|
|
19
|
+
createEntities:
|
|
20
|
+
- client:
|
|
21
|
+
id: &client0 client0
|
|
22
|
+
observeEvents:
|
|
23
|
+
- commandStartedEvent
|
|
24
|
+
# Used to test that read and write concerns are still inherited
|
|
25
|
+
uriOptions:
|
|
26
|
+
readConcernLevel: *readConcernLevel
|
|
27
|
+
w: *writeConcernW
|
|
28
|
+
- database:
|
|
29
|
+
id: &database0 database0
|
|
30
|
+
client: *client0
|
|
31
|
+
databaseName: &database0Name db0
|
|
32
|
+
databaseOptions:
|
|
33
|
+
readPreference: &readPreference
|
|
34
|
+
# secondaryPreferred is specified for compatibility with clusters that
|
|
35
|
+
# may not have a secondary (e.g. each shard is only a primary).
|
|
36
|
+
mode: secondaryPreferred
|
|
37
|
+
# maxStalenessSeconds is specified to ensure that drivers forward the
|
|
38
|
+
# read preference to mongos or a load balancer. That would not be the
|
|
39
|
+
# case with only secondaryPreferred.
|
|
40
|
+
maxStalenessSeconds: 600
|
|
41
|
+
- collection:
|
|
42
|
+
id: &collection0 collection0
|
|
43
|
+
database: *database0
|
|
44
|
+
collectionName: &collection0Name coll0
|
|
45
|
+
|
|
46
|
+
initialData:
|
|
47
|
+
- collectionName: *collection0Name
|
|
48
|
+
databaseName: *database0Name
|
|
49
|
+
documents: []
|
|
50
|
+
|
|
51
|
+
tests:
|
|
52
|
+
- description: "Database-level aggregate with $out includes read preference for 5.0+ server"
|
|
53
|
+
runOnRequirements:
|
|
54
|
+
- minServerVersion: "5.0"
|
|
55
|
+
serverless: "forbid"
|
|
56
|
+
operations:
|
|
57
|
+
- object: *database0
|
|
58
|
+
name: aggregate
|
|
59
|
+
arguments:
|
|
60
|
+
pipeline: &outPipeline
|
|
61
|
+
- { $listLocalSessions: {} }
|
|
62
|
+
- { $limit: 1 }
|
|
63
|
+
- { $addFields: { _id: 1 } }
|
|
64
|
+
- { $project: { _id: 1 } }
|
|
65
|
+
- { $out: *collection0Name }
|
|
66
|
+
expectEvents:
|
|
67
|
+
- client: *client0
|
|
68
|
+
events:
|
|
69
|
+
- commandStartedEvent:
|
|
70
|
+
command:
|
|
71
|
+
aggregate: 1
|
|
72
|
+
pipeline: *outPipeline
|
|
73
|
+
$readPreference: *readPreference
|
|
74
|
+
readConcern: *readConcern
|
|
75
|
+
writeConcern: *writeConcern
|
|
76
|
+
outcome: &outcome
|
|
77
|
+
- collectionName: *collection0Name
|
|
78
|
+
databaseName: *database0Name
|
|
79
|
+
documents:
|
|
80
|
+
- { _id: 1 }
|
|
81
|
+
|
|
82
|
+
- description: "Database-level aggregate with $out omits read preference for pre-5.0 server"
|
|
83
|
+
runOnRequirements:
|
|
84
|
+
# MongoDB 4.2 introduced support for read concerns and write stages.
|
|
85
|
+
# Pre-4.2 servers may allow a "local" read concern anyway, but some
|
|
86
|
+
# drivers may avoid inheriting a client-level read concern for pre-4.2.
|
|
87
|
+
- minServerVersion: "4.2"
|
|
88
|
+
maxServerVersion: "4.4.99"
|
|
89
|
+
serverless: "forbid"
|
|
90
|
+
operations:
|
|
91
|
+
- object: *database0
|
|
92
|
+
name: aggregate
|
|
93
|
+
arguments:
|
|
94
|
+
pipeline: *outPipeline
|
|
95
|
+
expectEvents:
|
|
96
|
+
- client: *client0
|
|
97
|
+
events:
|
|
98
|
+
- commandStartedEvent:
|
|
99
|
+
command:
|
|
100
|
+
aggregate: 1
|
|
101
|
+
pipeline: *outPipeline
|
|
102
|
+
$readPreference: { $$exists: false }
|
|
103
|
+
readConcern: *readConcern
|
|
104
|
+
writeConcern: *writeConcern
|
|
105
|
+
outcome: *outcome
|
|
106
|
+
|
|
107
|
+
- description: "Database-level aggregate with $merge includes read preference for 5.0+ server"
|
|
108
|
+
runOnRequirements:
|
|
109
|
+
- minServerVersion: "5.0"
|
|
110
|
+
operations:
|
|
111
|
+
- object: *database0
|
|
112
|
+
name: aggregate
|
|
113
|
+
arguments:
|
|
114
|
+
pipeline: &mergePipeline
|
|
115
|
+
- { $listLocalSessions: {} }
|
|
116
|
+
- { $limit: 1 }
|
|
117
|
+
- { $addFields: { _id: 1 } }
|
|
118
|
+
- { $project: { _id: 1 } }
|
|
119
|
+
- { $merge: { into: *collection0Name } }
|
|
120
|
+
expectEvents:
|
|
121
|
+
- client: *client0
|
|
122
|
+
events:
|
|
123
|
+
- commandStartedEvent:
|
|
124
|
+
command:
|
|
125
|
+
aggregate: 1
|
|
126
|
+
pipeline: *mergePipeline
|
|
127
|
+
$readPreference: *readPreference
|
|
128
|
+
readConcern: *readConcern
|
|
129
|
+
writeConcern: *writeConcern
|
|
130
|
+
outcome: *outcome
|
|
131
|
+
|
|
132
|
+
- description: "Database-level aggregate with $merge omits read preference for pre-5.0 server"
|
|
133
|
+
runOnRequirements:
|
|
134
|
+
- minServerVersion: "4.2"
|
|
135
|
+
maxServerVersion: "4.4.99"
|
|
136
|
+
operations:
|
|
137
|
+
- object: *database0
|
|
138
|
+
name: aggregate
|
|
139
|
+
arguments:
|
|
140
|
+
pipeline: *mergePipeline
|
|
141
|
+
expectEvents:
|
|
142
|
+
- client: *client0
|
|
143
|
+
events:
|
|
144
|
+
- commandStartedEvent:
|
|
145
|
+
command:
|
|
146
|
+
aggregate: 1
|
|
147
|
+
pipeline: *mergePipeline
|
|
148
|
+
$readPreference: { $$exists: false }
|
|
149
|
+
readConcern: *readConcern
|
|
150
|
+
writeConcern: *writeConcern
|
|
151
|
+
outcome: *outcome
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
description: "deleteMany-let"
|
|
2
|
+
|
|
3
|
+
schemaVersion: "1.0"
|
|
4
|
+
|
|
5
|
+
createEntities:
|
|
6
|
+
- client:
|
|
7
|
+
id: &client0 client0
|
|
8
|
+
observeEvents: [ commandStartedEvent ]
|
|
9
|
+
- database:
|
|
10
|
+
id: &database0 database0
|
|
11
|
+
client: *client0
|
|
12
|
+
databaseName: &database0Name crud-tests
|
|
13
|
+
- collection:
|
|
14
|
+
id: &collection0 collection0
|
|
15
|
+
database: *database0
|
|
16
|
+
collectionName: &collection0Name coll0
|
|
17
|
+
|
|
18
|
+
initialData: &initialData
|
|
19
|
+
- collectionName: *collection0Name
|
|
20
|
+
databaseName: *database0Name
|
|
21
|
+
documents:
|
|
22
|
+
- { _id: 1 }
|
|
23
|
+
- { _id: 2, name: "name" }
|
|
24
|
+
- { _id: 3, name: "name" }
|
|
25
|
+
|
|
26
|
+
tests:
|
|
27
|
+
- description: "deleteMany with let option"
|
|
28
|
+
runOnRequirements:
|
|
29
|
+
- minServerVersion: "5.0"
|
|
30
|
+
operations:
|
|
31
|
+
- name: deleteMany
|
|
32
|
+
object: *collection0
|
|
33
|
+
arguments:
|
|
34
|
+
filter: &filter
|
|
35
|
+
$expr:
|
|
36
|
+
$eq: [ "$name", "$$name" ]
|
|
37
|
+
let: &let0
|
|
38
|
+
name: "name"
|
|
39
|
+
expectResult:
|
|
40
|
+
deletedCount: 2
|
|
41
|
+
expectEvents:
|
|
42
|
+
- client: *client0
|
|
43
|
+
events:
|
|
44
|
+
- commandStartedEvent:
|
|
45
|
+
command:
|
|
46
|
+
delete: *collection0Name
|
|
47
|
+
deletes:
|
|
48
|
+
-
|
|
49
|
+
q: *filter
|
|
50
|
+
let: *let0
|
|
51
|
+
outcome:
|
|
52
|
+
-
|
|
53
|
+
collectionName: *collection0Name
|
|
54
|
+
databaseName: *database0Name
|
|
55
|
+
documents:
|
|
56
|
+
- { _id: 1 }
|
|
57
|
+
|
|
58
|
+
- description: "deleteMany with let option unsupported (server-side error)"
|
|
59
|
+
runOnRequirements:
|
|
60
|
+
- minServerVersion: "3.6.0"
|
|
61
|
+
maxServerVersion: "4.4.99"
|
|
62
|
+
operations:
|
|
63
|
+
- name: deleteMany
|
|
64
|
+
object: *collection0
|
|
65
|
+
arguments:
|
|
66
|
+
filter: &filter1
|
|
67
|
+
$expr:
|
|
68
|
+
$eq: [ "$name", "$$name" ]
|
|
69
|
+
let: &let1
|
|
70
|
+
name: "name"
|
|
71
|
+
expectError:
|
|
72
|
+
errorContains: "'delete.let' is an unknown field"
|
|
73
|
+
isClientError: false
|
|
74
|
+
expectEvents:
|
|
75
|
+
- client: *client0
|
|
76
|
+
events:
|
|
77
|
+
- commandStartedEvent:
|
|
78
|
+
command:
|
|
79
|
+
delete: *collection0Name
|
|
80
|
+
deletes:
|
|
81
|
+
-
|
|
82
|
+
q: *filter1
|
|
83
|
+
let: *let1
|
|
84
|
+
outcome:
|
|
85
|
+
-
|
|
86
|
+
collectionName: *collection0Name
|
|
87
|
+
databaseName: *database0Name
|
|
88
|
+
documents:
|
|
89
|
+
- { _id: 1 }
|
|
90
|
+
- { _id: 2, name: "name" }
|
|
91
|
+
- { _id: 3, name: "name" }
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
description: "deleteOne-let"
|
|
2
|
+
|
|
3
|
+
schemaVersion: "1.0"
|
|
4
|
+
|
|
5
|
+
createEntities:
|
|
6
|
+
- client:
|
|
7
|
+
id: &client0 client0
|
|
8
|
+
observeEvents: [ commandStartedEvent ]
|
|
9
|
+
- database:
|
|
10
|
+
id: &database0 database0
|
|
11
|
+
client: *client0
|
|
12
|
+
databaseName: &database0Name crud-tests
|
|
13
|
+
- collection:
|
|
14
|
+
id: &collection0 collection0
|
|
15
|
+
database: *database0
|
|
16
|
+
collectionName: &collection0Name coll0
|
|
17
|
+
|
|
18
|
+
initialData: &initialData
|
|
19
|
+
- collectionName: *collection0Name
|
|
20
|
+
databaseName: *database0Name
|
|
21
|
+
documents:
|
|
22
|
+
- { _id: 1 }
|
|
23
|
+
- { _id: 2 }
|
|
24
|
+
|
|
25
|
+
tests:
|
|
26
|
+
- description: "deleteOne with let option"
|
|
27
|
+
runOnRequirements:
|
|
28
|
+
- minServerVersion: "5.0"
|
|
29
|
+
operations:
|
|
30
|
+
- name: deleteOne
|
|
31
|
+
object: *collection0
|
|
32
|
+
arguments:
|
|
33
|
+
filter: &filter
|
|
34
|
+
$expr:
|
|
35
|
+
$eq: [ "$_id", "$$id" ]
|
|
36
|
+
let: &let0
|
|
37
|
+
id: 1
|
|
38
|
+
expectResult:
|
|
39
|
+
deletedCount: 1
|
|
40
|
+
expectEvents:
|
|
41
|
+
- client: *client0
|
|
42
|
+
events:
|
|
43
|
+
- commandStartedEvent:
|
|
44
|
+
command:
|
|
45
|
+
delete: *collection0Name
|
|
46
|
+
deletes:
|
|
47
|
+
-
|
|
48
|
+
q: *filter
|
|
49
|
+
let: *let0
|
|
50
|
+
outcome:
|
|
51
|
+
-
|
|
52
|
+
collectionName: *collection0Name
|
|
53
|
+
databaseName: *database0Name
|
|
54
|
+
documents:
|
|
55
|
+
- { _id: 2 }
|
|
56
|
+
|
|
57
|
+
- description: "deleteOne with let option unsupported (server-side error)"
|
|
58
|
+
runOnRequirements:
|
|
59
|
+
- minServerVersion: "3.6.0"
|
|
60
|
+
maxServerVersion: "4.4.99"
|
|
61
|
+
operations:
|
|
62
|
+
- name: deleteOne
|
|
63
|
+
object: *collection0
|
|
64
|
+
arguments:
|
|
65
|
+
filter: &filter1
|
|
66
|
+
$expr:
|
|
67
|
+
$eq: [ "$_id", "$$id" ]
|
|
68
|
+
let: &let1
|
|
69
|
+
id: 1
|
|
70
|
+
expectError:
|
|
71
|
+
errorContains: "'delete.let' is an unknown field"
|
|
72
|
+
isClientError: false
|
|
73
|
+
expectEvents:
|
|
74
|
+
- client: *client0
|
|
75
|
+
events:
|
|
76
|
+
- commandStartedEvent:
|
|
77
|
+
command:
|
|
78
|
+
delete: *collection0Name
|
|
79
|
+
deletes:
|
|
80
|
+
-
|
|
81
|
+
q: *filter1
|
|
82
|
+
let: *let1
|
|
83
|
+
outcome:
|
|
84
|
+
-
|
|
85
|
+
collectionName: *collection0Name
|
|
86
|
+
databaseName: *database0Name
|
|
87
|
+
documents:
|
|
88
|
+
- { _id: 1 }
|
|
89
|
+
- { _id: 2 }
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
description: "find-let"
|
|
2
|
+
|
|
3
|
+
schemaVersion: "1.0"
|
|
4
|
+
|
|
5
|
+
createEntities:
|
|
6
|
+
- client:
|
|
7
|
+
id: &client0 client0
|
|
8
|
+
observeEvents: [ commandStartedEvent ]
|
|
9
|
+
- database:
|
|
10
|
+
id: &database0 database0
|
|
11
|
+
client: *client0
|
|
12
|
+
databaseName: &database0Name crud-tests
|
|
13
|
+
- collection:
|
|
14
|
+
id: &collection0 collection0
|
|
15
|
+
database: *database0
|
|
16
|
+
collectionName: &collection0Name coll0
|
|
17
|
+
|
|
18
|
+
initialData: &initialData
|
|
19
|
+
- collectionName: *collection0Name
|
|
20
|
+
databaseName: *database0Name
|
|
21
|
+
documents:
|
|
22
|
+
- { _id: 1 }
|
|
23
|
+
- { _id: 2 }
|
|
24
|
+
|
|
25
|
+
tests:
|
|
26
|
+
- description: "Find with let option"
|
|
27
|
+
runOnRequirements:
|
|
28
|
+
- minServerVersion: "5.0"
|
|
29
|
+
operations:
|
|
30
|
+
- name: find
|
|
31
|
+
object: *collection0
|
|
32
|
+
arguments:
|
|
33
|
+
filter: &filter
|
|
34
|
+
$expr:
|
|
35
|
+
$eq: [ "$_id", "$$id" ]
|
|
36
|
+
let: &let0
|
|
37
|
+
id: 1
|
|
38
|
+
expectResult:
|
|
39
|
+
- { _id: 1 }
|
|
40
|
+
expectEvents:
|
|
41
|
+
- client: *client0
|
|
42
|
+
events:
|
|
43
|
+
- commandStartedEvent:
|
|
44
|
+
command:
|
|
45
|
+
find: *collection0Name
|
|
46
|
+
filter: *filter
|
|
47
|
+
let: *let0
|
|
48
|
+
|
|
49
|
+
- description: "Find with let option unsupported (server-side error)"
|
|
50
|
+
runOnRequirements:
|
|
51
|
+
- minServerVersion: "3.6.0"
|
|
52
|
+
maxServerVersion: "4.4.99"
|
|
53
|
+
operations:
|
|
54
|
+
- name: find
|
|
55
|
+
object: *collection0
|
|
56
|
+
arguments:
|
|
57
|
+
filter: &filter1
|
|
58
|
+
_id: 1
|
|
59
|
+
let: &let1
|
|
60
|
+
x: 1
|
|
61
|
+
expectError:
|
|
62
|
+
errorContains: "Unrecognized field 'let'"
|
|
63
|
+
isClientError: false
|
|
64
|
+
expectEvents:
|
|
65
|
+
- client: *client0
|
|
66
|
+
events:
|
|
67
|
+
- commandStartedEvent:
|
|
68
|
+
command:
|
|
69
|
+
find: *collection0Name
|
|
70
|
+
filter: *filter1
|
|
71
|
+
let: *let1
|