mongo 2.16.4 → 2.17.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +5 -8
- data/lib/mongo/collection/view/change_stream.rb +7 -3
- data/lib/mongo/collection/view/iterable.rb +3 -20
- data/lib/mongo/collection/view/map_reduce.rb +3 -14
- data/lib/mongo/collection/view/readable.rb +24 -1
- data/lib/mongo/collection/view/writable.rb +23 -0
- data/lib/mongo/collection/view.rb +0 -1
- 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/query_cache.rb +2 -12
- data/lib/mongo/server/description/features.rb +3 -1
- data/lib/mongo/server/monitor/connection.rb +4 -10
- 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/query_cache_spec.rb +0 -159
- data/spec/integration/read_preference_spec.rb +16 -12
- data/spec/integration/sdam_events_spec.rb +0 -40
- data/spec/lite_spec_helper.rb +0 -7
- 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 -17
- data/spec/mongo/collection/view/readable_spec.rb +0 -56
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +24 -1
- data/spec/mongo/query_cache_spec.rb +0 -165
- 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/auth.rb +1 -1
- data/spec/runners/change_streams/spec.rb +1 -1
- data/spec/runners/cmap.rb +1 -1
- data/spec/runners/command_monitoring.rb +1 -1
- data/spec/runners/connection_string.rb +1 -1
- data/spec/runners/crud/spec.rb +3 -1
- data/spec/runners/crud/verifier.rb +1 -2
- data/spec/runners/gridfs.rb +1 -1
- data/spec/runners/read_write_concern_document.rb +1 -1
- data/spec/runners/sdam.rb +1 -1
- data/spec/runners/server_selection.rb +1 -1
- data/spec/runners/server_selection_rtt.rb +1 -1
- 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/runners/unified/test_group.rb +1 -1
- data/spec/shared/share/Dockerfile.erb +3 -3
- data/spec/shared/shlib/server.sh +1 -1
- 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/seed_list_discovery_spec.rb +1 -1
- data/spec/spec_tests/sessions_unified_spec.rb +13 -0
- data/spec/support/certificates/atlas-ocsp-ca.crt +47 -40
- data/spec/support/certificates/atlas-ocsp.crt +106 -101
- data/spec/support/utils.rb +0 -31
- data.tar.gz.sig +0 -0
- metadata +1084 -1058
- metadata.gz.sig +0 -0
- data/spec/integration/find_options_spec.rb +0 -227
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,227 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'Find operation options' do
|
6
|
-
require_mri
|
7
|
-
require_no_auth
|
8
|
-
min_server_fcv '4.4'
|
9
|
-
|
10
|
-
let(:subscriber) { Mrss::EventSubscriber.new }
|
11
|
-
|
12
|
-
let(:seeds) do
|
13
|
-
[ SpecConfig.instance.addresses.first ]
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:client_options) do
|
17
|
-
{}
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:collection_options) do
|
21
|
-
{}
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:client) do
|
25
|
-
ClientRegistry.instance.new_local_client(
|
26
|
-
seeds,
|
27
|
-
SpecConfig.instance.test_options
|
28
|
-
.merge(database: SpecConfig.instance.test_db)
|
29
|
-
.merge(client_options)
|
30
|
-
).tap do |client|
|
31
|
-
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
let(:collection) do
|
36
|
-
client['find_options', collection_options]
|
37
|
-
end
|
38
|
-
|
39
|
-
let(:find_command) do
|
40
|
-
subscriber.started_events.find { |cmd| cmd.command_name == 'find' }
|
41
|
-
end
|
42
|
-
|
43
|
-
let(:should_create_collection) { true }
|
44
|
-
|
45
|
-
before do
|
46
|
-
client['find_options'].drop
|
47
|
-
collection.create if should_create_collection
|
48
|
-
collection.insert_many([ { a: 1 }, { a: 2 }, { a: 3 } ])
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'collation' do
|
52
|
-
let(:client_options) do
|
53
|
-
{}
|
54
|
-
end
|
55
|
-
|
56
|
-
let(:collation) do
|
57
|
-
{ 'locale' => 'en_US' }
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'when defined on the collection' do
|
61
|
-
let(:collection_options) do
|
62
|
-
{ collation: collation }
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'uses the collation defined on the collection' do
|
66
|
-
collection.find.to_a
|
67
|
-
expect(find_command.command['collation']).to be_nil
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'when defined on the operation' do
|
72
|
-
let(:collection_options) do
|
73
|
-
{}
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'uses the collation defined on the collection' do
|
77
|
-
collection.find({}, collation: collation).to_a
|
78
|
-
expect(find_command.command['collation']).to eq(collation)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'when defined on both collection and operation' do
|
83
|
-
let(:collection_options) do
|
84
|
-
{ 'locale' => 'de_AT' }
|
85
|
-
end
|
86
|
-
|
87
|
-
let(:should_create_collection) { false }
|
88
|
-
|
89
|
-
it 'uses the collation defined on the collection' do
|
90
|
-
collection.find({}, collation: collation).to_a
|
91
|
-
expect(find_command.command['collation']).to eq(collation)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe 'read concern' do
|
97
|
-
context 'when defined on the client' do
|
98
|
-
let(:client_options) do
|
99
|
-
{ read_concern: { level: :local } }
|
100
|
-
end
|
101
|
-
|
102
|
-
let(:collection_options) do
|
103
|
-
{}
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'uses the read concern defined on the client' do
|
107
|
-
collection.find.to_a
|
108
|
-
expect(find_command.command['readConcern']).to eq('level' => 'local')
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'when defined on the collection' do
|
112
|
-
let(:collection_options) do
|
113
|
-
{ read_concern: { level: :majority } }
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'uses the read concern defined on the collection' do
|
117
|
-
collection.find.to_a
|
118
|
-
expect(find_command.command['readConcern']).to eq('level' => 'majority')
|
119
|
-
end
|
120
|
-
|
121
|
-
context 'when defined on the operation' do
|
122
|
-
let(:operation_read_concern) do
|
123
|
-
{ level: :available }
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'uses the read concern defined on the operation' do
|
127
|
-
collection.find({}, read_concern: operation_read_concern).to_a
|
128
|
-
expect(find_command.command['readConcern']).to eq('level' => 'available')
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'when defined on the operation' do
|
134
|
-
let(:collection_options) do
|
135
|
-
{}
|
136
|
-
end
|
137
|
-
|
138
|
-
let(:operation_read_concern) do
|
139
|
-
{ level: :available }
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'uses the read concern defined on the operation' do
|
143
|
-
collection.find({}, read_concern: operation_read_concern).to_a
|
144
|
-
expect(find_command.command['readConcern']).to eq('level' => 'available')
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
context 'when defined on the collection' do
|
150
|
-
let(:client_options) do
|
151
|
-
{}
|
152
|
-
end
|
153
|
-
|
154
|
-
let(:collection_options) do
|
155
|
-
{ read_concern: { level: :majority } }
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'uses the read concern defined on the collection' do
|
159
|
-
collection.find.to_a
|
160
|
-
expect(find_command.command['readConcern']).to eq('level' => 'majority')
|
161
|
-
end
|
162
|
-
|
163
|
-
context 'when defined on the operation' do
|
164
|
-
let(:operation_read_concern) do
|
165
|
-
{ level: :available }
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'uses the read concern defined on the operation' do
|
169
|
-
collection.find({}, read_concern: operation_read_concern).to_a
|
170
|
-
expect(find_command.command['readConcern']).to eq('level' => 'available')
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe 'read preference' do
|
177
|
-
require_topology :replica_set
|
178
|
-
|
179
|
-
context 'when defined on the client' do
|
180
|
-
let(:client_options) do
|
181
|
-
{ read: { mode: :secondary } }
|
182
|
-
end
|
183
|
-
|
184
|
-
let(:collection_options) do
|
185
|
-
{}
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'uses the read preference defined on the client' do
|
189
|
-
collection.find.to_a
|
190
|
-
expect(find_command.command['$readPreference']).to eq('mode' => 'secondary')
|
191
|
-
end
|
192
|
-
|
193
|
-
context 'when defined on the collection' do
|
194
|
-
let(:collection_options) do
|
195
|
-
{ read: { mode: :secondary_preferred } }
|
196
|
-
end
|
197
|
-
|
198
|
-
it 'uses the read concern defined on the collection' do
|
199
|
-
collection.find.to_a
|
200
|
-
expect(find_command.command['$readPreference']).to eq('mode' => 'secondaryPreferred')
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
describe 'cursor type' do
|
207
|
-
let(:collection_options) do
|
208
|
-
{ capped: true, size: 1000 }
|
209
|
-
end
|
210
|
-
|
211
|
-
context 'when cursor type is :tailable' do
|
212
|
-
it 'sets the cursor type to tailable' do
|
213
|
-
collection.find({}, cursor_type: :tailable).first
|
214
|
-
expect(find_command.command['tailable']).to be true
|
215
|
-
expect(find_command.command['awaitData']).to be_falsey
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
context 'when cursor type is :tailable_await' do
|
220
|
-
it 'sets the cursor type to tailable' do
|
221
|
-
collection.find({}, cursor_type: :tailable_await).first
|
222
|
-
expect(find_command.command['tailable']).to be true
|
223
|
-
expect(find_command.command['awaitData']).to be true
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|