mongo 2.16.2 → 2.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +1 -1
  4. data/lib/mongo/auth/aws/request.rb +0 -1
  5. data/lib/mongo/client.rb +4 -0
  6. data/lib/mongo/collection/view/aggregation.rb +62 -17
  7. data/lib/mongo/collection/view/builder/aggregation.rb +11 -13
  8. data/lib/mongo/collection/view/builder/map_reduce.rb +5 -8
  9. data/lib/mongo/collection/view/change_stream.rb +7 -3
  10. data/lib/mongo/collection/view/iterable.rb +2 -3
  11. data/lib/mongo/collection/view/map_reduce.rb +3 -14
  12. data/lib/mongo/collection/view/readable.rb +24 -1
  13. data/lib/mongo/collection/view/writable.rb +23 -0
  14. data/lib/mongo/collection.rb +21 -1
  15. data/lib/mongo/database/view.rb +4 -2
  16. data/lib/mongo/database.rb +6 -6
  17. data/lib/mongo/error/snapshot_session_invalid_server_version.rb +31 -0
  18. data/lib/mongo/error/snapshot_session_transaction_prohibited.rb +30 -0
  19. data/lib/mongo/error.rb +2 -0
  20. data/lib/mongo/operation/delete/op_msg.rb +2 -1
  21. data/lib/mongo/operation/find/builder/command.rb +1 -0
  22. data/lib/mongo/operation/result.rb +6 -0
  23. data/lib/mongo/operation/shared/executable.rb +4 -0
  24. data/lib/mongo/operation/shared/sessions_supported.rb +18 -2
  25. data/lib/mongo/operation/update/op_msg.rb +2 -1
  26. data/lib/mongo/server/description/features.rb +3 -1
  27. data/lib/mongo/server_selector/base.rb +26 -4
  28. data/lib/mongo/session.rb +19 -0
  29. data/lib/mongo/socket/ocsp_cache.rb +2 -3
  30. data/lib/mongo/socket.rb +1 -5
  31. data/lib/mongo/utils.rb +0 -6
  32. data/lib/mongo/version.rb +1 -1
  33. data/mongo.gemspec +1 -1
  34. data/spec/integration/read_preference_spec.rb +16 -12
  35. data/spec/lite_spec_helper.rb +0 -7
  36. data/spec/mongo/collection/view/aggregation_spec.rb +71 -95
  37. data/spec/mongo/collection/view/change_stream_spec.rb +1 -1
  38. data/spec/mongo/collection/view/map_reduce_spec.rb +14 -17
  39. data/spec/mongo/operation/read_preference_op_msg_spec.rb +24 -1
  40. data/spec/mongo/server_selector_spec.rb +136 -15
  41. data/spec/mongo/socket/ssl_spec.rb +26 -58
  42. data/spec/mongo/utils_spec.rb +0 -14
  43. data/spec/runners/auth.rb +1 -1
  44. data/spec/runners/change_streams/spec.rb +1 -1
  45. data/spec/runners/cmap.rb +1 -1
  46. data/spec/runners/command_monitoring.rb +1 -1
  47. data/spec/runners/connection_string.rb +1 -1
  48. data/spec/runners/crud/spec.rb +3 -1
  49. data/spec/runners/crud/verifier.rb +1 -2
  50. data/spec/runners/gridfs.rb +1 -1
  51. data/spec/runners/read_write_concern_document.rb +1 -1
  52. data/spec/runners/sdam.rb +1 -1
  53. data/spec/runners/server_selection.rb +1 -1
  54. data/spec/runners/server_selection_rtt.rb +1 -1
  55. data/spec/runners/unified/assertions.rb +3 -1
  56. data/spec/runners/unified/crud_operations.rb +77 -23
  57. data/spec/runners/unified/ddl_operations.rb +29 -1
  58. data/spec/runners/unified/entity_map.rb +3 -3
  59. data/spec/runners/unified/support_operations.rb +6 -1
  60. data/spec/runners/unified/test.rb +15 -3
  61. data/spec/runners/unified/test_group.rb +1 -1
  62. data/spec/spec_tests/data/crud_unified/aggregate-let.yml +138 -0
  63. data/spec/spec_tests/data/crud_unified/aggregate-write-readPreference.yml +155 -0
  64. data/spec/spec_tests/data/crud_unified/db-aggregate-write-readPreference.yml +151 -0
  65. data/spec/spec_tests/data/crud_unified/deleteMany-let.yml +91 -0
  66. data/spec/spec_tests/data/crud_unified/deleteOne-let.yml +89 -0
  67. data/spec/spec_tests/data/crud_unified/find-let.yml +71 -0
  68. data/spec/spec_tests/data/crud_unified/findOneAndDelete-let.yml +88 -0
  69. data/spec/spec_tests/data/crud_unified/findOneAndReplace-let.yml +94 -0
  70. data/spec/spec_tests/data/crud_unified/findOneAndUpdate-let.yml +96 -0
  71. data/spec/spec_tests/data/crud_unified/updateMany-let.yml +103 -0
  72. data/spec/spec_tests/data/crud_unified/updateOne-let.yml +98 -0
  73. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml +2 -2
  74. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +3 -3
  75. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest.yml +3 -3
  76. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +3 -3
  77. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +2 -2
  78. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +2 -2
  79. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Secondary.yml +4 -4
  80. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +2 -2
  81. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +4 -4
  82. data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml +2 -2
  83. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml +2 -2
  84. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +3 -3
  85. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat.yml +2 -2
  86. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat2.yml +2 -2
  87. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +2 -2
  88. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +2 -2
  89. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest.yml +3 -3
  90. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +3 -3
  91. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +2 -2
  92. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +2 -2
  93. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +2 -2
  94. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +5 -5
  95. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +3 -3
  96. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +5 -5
  97. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +3 -3
  98. data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +2 -2
  99. data/spec/spec_tests/data/max_staleness/Sharded/SmallMaxStaleness.yml +2 -2
  100. data/spec/spec_tests/data/max_staleness/Single/SmallMaxStaleness.yml +1 -1
  101. data/spec/spec_tests/data/max_staleness/Unknown/SmallMaxStaleness.yml +1 -1
  102. data/spec/spec_tests/data/sessions_unified/snapshot-sessions-not-supported-client-error.yml +69 -0
  103. data/spec/spec_tests/data/sessions_unified/snapshot-sessions-not-supported-server-error.yml +102 -0
  104. data/spec/spec_tests/data/sessions_unified/snapshot-sessions-unsupported-ops.yml +258 -0
  105. data/spec/spec_tests/data/sessions_unified/snapshot-sessions.yml +482 -0
  106. data/spec/spec_tests/seed_list_discovery_spec.rb +1 -1
  107. data/spec/spec_tests/sessions_unified_spec.rb +13 -0
  108. data/spec/support/utils.rb +0 -31
  109. data.tar.gz.sig +3 -1
  110. metadata +1051 -1018
  111. metadata.gz.sig +0 -0
@@ -0,0 +1,102 @@
1
+ description: snapshot-sessions-not-supported-server-error
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ runOnRequirements:
6
+ - minServerVersion: "5.0"
7
+ topologies: [ single ]
8
+
9
+ createEntities:
10
+ - client:
11
+ id: &client0 client0
12
+ observeEvents: [ commandStartedEvent, commandFailedEvent ]
13
+ - database:
14
+ id: &database0Name database0
15
+ client: *client0
16
+ databaseName: *database0Name
17
+ - collection:
18
+ id: &collection0Name collection0
19
+ database: *database0Name
20
+ collectionName: *collection0Name
21
+ - session:
22
+ id: session0
23
+ client: client0
24
+ sessionOptions:
25
+ snapshot: true
26
+
27
+ initialData:
28
+ - collectionName: *collection0Name
29
+ databaseName: *database0Name
30
+ documents:
31
+ - { _id: 1, x: 11 }
32
+
33
+ tests:
34
+ - description: Server returns an error on find with snapshot
35
+ operations:
36
+ - name: find
37
+ object: collection0
38
+ arguments:
39
+ session: session0
40
+ filter: {}
41
+ expectError:
42
+ isError: true
43
+ isClientError: false
44
+ expectEvents:
45
+ - client: client0
46
+ events:
47
+ - commandStartedEvent:
48
+ command:
49
+ find: collection0
50
+ readConcern:
51
+ level: snapshot
52
+ atClusterTime:
53
+ "$$exists": false
54
+ - commandFailedEvent:
55
+ commandName: find
56
+
57
+ - description: Server returns an error on aggregate with snapshot
58
+ operations:
59
+ - name: aggregate
60
+ object: collection0
61
+ arguments:
62
+ session: session0
63
+ pipeline: []
64
+ expectError:
65
+ isError: true
66
+ isClientError: false
67
+ expectEvents:
68
+ - client: client0
69
+ events:
70
+ - commandStartedEvent:
71
+ command:
72
+ aggregate: collection0
73
+ readConcern:
74
+ level: snapshot
75
+ atClusterTime:
76
+ "$$exists": false
77
+ - commandFailedEvent:
78
+ commandName: aggregate
79
+
80
+ - description: Server returns an error on distinct with snapshot
81
+ operations:
82
+ - name: distinct
83
+ object: collection0
84
+ arguments:
85
+ fieldName: x
86
+ filter: {}
87
+ session: session0
88
+ expectError:
89
+ isError: true
90
+ isClientError: false
91
+ expectEvents:
92
+ - client: client0
93
+ events:
94
+ - commandStartedEvent:
95
+ command:
96
+ distinct: collection0
97
+ readConcern:
98
+ level: snapshot
99
+ atClusterTime:
100
+ "$$exists": false
101
+ - commandFailedEvent:
102
+ commandName: distinct
@@ -0,0 +1,258 @@
1
+ description: snapshot-sessions-unsupported-ops
2
+
3
+ schemaVersion: "1.0"
4
+
5
+ runOnRequirements:
6
+ - minServerVersion: "5.0"
7
+ topologies: [replicaset, sharded-replicaset]
8
+
9
+ createEntities:
10
+ - client:
11
+ id: &client0 client0
12
+ observeEvents: [ commandStartedEvent, commandFailedEvent ]
13
+ - database:
14
+ id: &database0Name database0
15
+ client: *client0
16
+ databaseName: *database0Name
17
+ - collection:
18
+ id: &collection0Name collection0
19
+ database: *database0Name
20
+ collectionName: *collection0Name
21
+ - session:
22
+ id: session0
23
+ client: client0
24
+ sessionOptions:
25
+ snapshot: true
26
+
27
+ initialData:
28
+ - collectionName: *collection0Name
29
+ databaseName: *database0Name
30
+ documents:
31
+ - { _id: 1, x: 11 }
32
+
33
+ tests:
34
+ - description: Server returns an error on insertOne with snapshot
35
+ # Skip on sharded clusters due to SERVER-58176.
36
+ runOnRequirements:
37
+ - topologies: [replicaset]
38
+ operations:
39
+ - name: insertOne
40
+ object: collection0
41
+ arguments:
42
+ session: session0
43
+ document:
44
+ _id: 22
45
+ x: 22
46
+ expectError:
47
+ isError: true
48
+ isClientError: false
49
+ expectEvents:
50
+ - client: client0
51
+ events:
52
+ - commandStartedEvent:
53
+ command:
54
+ insert: collection0
55
+ readConcern:
56
+ level: snapshot
57
+ atClusterTime:
58
+ "$$exists": false
59
+ - commandFailedEvent:
60
+ commandName: insert
61
+
62
+ - description: Server returns an error on insertMany with snapshot
63
+ # Skip on sharded clusters due to SERVER-58176.
64
+ runOnRequirements:
65
+ - topologies: [replicaset]
66
+ operations:
67
+ - name: insertMany
68
+ object: collection0
69
+ arguments:
70
+ session: session0
71
+ documents:
72
+ - _id: 22
73
+ x: 22
74
+ - _id: 33
75
+ x: 33
76
+ expectError:
77
+ isError: true
78
+ isClientError: false
79
+ expectEvents:
80
+ - client: client0
81
+ events:
82
+ - commandStartedEvent:
83
+ command:
84
+ insert: collection0
85
+ readConcern:
86
+ level: snapshot
87
+ atClusterTime:
88
+ "$$exists": false
89
+ - commandFailedEvent:
90
+ commandName: insert
91
+
92
+ - description: Server returns an error on deleteOne with snapshot
93
+ # Skip on sharded clusters due to SERVER-58176.
94
+ runOnRequirements:
95
+ - topologies: [replicaset]
96
+ operations:
97
+ - name: deleteOne
98
+ object: collection0
99
+ arguments:
100
+ session: session0
101
+ filter: {}
102
+ expectError:
103
+ isError: true
104
+ isClientError: false
105
+ expectEvents:
106
+ - client: client0
107
+ events:
108
+ - commandStartedEvent:
109
+ command:
110
+ delete: collection0
111
+ readConcern:
112
+ level: snapshot
113
+ atClusterTime:
114
+ "$$exists": false
115
+ - commandFailedEvent:
116
+ commandName: delete
117
+
118
+ - description: Server returns an error on updateOne with snapshot
119
+ # Skip on sharded clusters due to SERVER-58176.
120
+ runOnRequirements:
121
+ - topologies: [replicaset]
122
+ operations:
123
+ - name: updateOne
124
+ object: collection0
125
+ arguments:
126
+ session: session0
127
+ filter: { _id: 1 }
128
+ update: { $inc: { x: 1 } }
129
+ expectError:
130
+ isError: true
131
+ isClientError: false
132
+ expectEvents:
133
+ - client: client0
134
+ events:
135
+ - commandStartedEvent:
136
+ command:
137
+ update: collection0
138
+ readConcern:
139
+ level: snapshot
140
+ atClusterTime:
141
+ "$$exists": false
142
+ - commandFailedEvent:
143
+ commandName: update
144
+
145
+ - description: Server returns an error on findOneAndUpdate with snapshot
146
+ operations:
147
+ - name: findOneAndUpdate
148
+ object: collection0
149
+ arguments:
150
+ session: session0
151
+ filter: { _id: 1 }
152
+ update: { $inc: { x: 1 } }
153
+ expectError:
154
+ isError: true
155
+ isClientError: false
156
+ expectEvents:
157
+ - client: client0
158
+ events:
159
+ - commandStartedEvent:
160
+ command:
161
+ findAndModify: collection0
162
+ readConcern:
163
+ level: snapshot
164
+ atClusterTime:
165
+ "$$exists": false
166
+ - commandFailedEvent:
167
+ commandName: findAndModify
168
+
169
+ - description: Server returns an error on listDatabases with snapshot
170
+ operations:
171
+ - name: listDatabases
172
+ object: client0
173
+ arguments:
174
+ session: session0
175
+ expectError:
176
+ isError: true
177
+ isClientError: false
178
+ expectEvents:
179
+ - client: client0
180
+ events:
181
+ - commandStartedEvent:
182
+ command:
183
+ listDatabases: 1
184
+ readConcern:
185
+ level: snapshot
186
+ atClusterTime:
187
+ "$$exists": false
188
+ - commandFailedEvent:
189
+ commandName: listDatabases
190
+
191
+ - description: Server returns an error on listCollections with snapshot
192
+ operations:
193
+ - name: listCollections
194
+ object: database0
195
+ arguments:
196
+ session: session0
197
+ expectError:
198
+ isError: true
199
+ isClientError: false
200
+ expectEvents:
201
+ - client: client0
202
+ events:
203
+ - commandStartedEvent:
204
+ command:
205
+ listCollections: 1
206
+ readConcern:
207
+ level: snapshot
208
+ atClusterTime:
209
+ "$$exists": false
210
+ - commandFailedEvent:
211
+ commandName: listCollections
212
+
213
+ - description: Server returns an error on listIndexes with snapshot
214
+ operations:
215
+ - name: listIndexes
216
+ object: collection0
217
+ arguments:
218
+ session: session0
219
+ expectError:
220
+ isError: true
221
+ isClientError: false
222
+ expectEvents:
223
+ - client: client0
224
+ events:
225
+ - commandStartedEvent:
226
+ command:
227
+ listIndexes: collection0
228
+ readConcern:
229
+ level: snapshot
230
+ atClusterTime:
231
+ "$$exists": false
232
+ - commandFailedEvent:
233
+ commandName: listIndexes
234
+
235
+ - description: Server returns an error on runCommand with snapshot
236
+ operations:
237
+ - name: runCommand
238
+ object: database0
239
+ arguments:
240
+ session: session0
241
+ commandName: listCollections
242
+ command:
243
+ listCollections: 1
244
+ expectError:
245
+ isError: true
246
+ isClientError: false
247
+ expectEvents:
248
+ - client: client0
249
+ events:
250
+ - commandStartedEvent:
251
+ command:
252
+ listCollections: 1
253
+ readConcern:
254
+ level: snapshot
255
+ atClusterTime:
256
+ "$$exists": false
257
+ - commandFailedEvent:
258
+ commandName: listCollections