mongo 2.5.1 → 2.5.2
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 +3 -2
- data.tar.gz.sig +0 -0
- data/Rakefile +1 -1
- data/lib/mongo/auth/user/view.rb +4 -4
- data/lib/mongo/bulk_write.rb +14 -19
- data/lib/mongo/cluster.rb +4 -2
- data/lib/mongo/cluster/app_metadata.rb +1 -1
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +1 -1
- data/lib/mongo/collection.rb +13 -13
- data/lib/mongo/collection/view.rb +2 -1
- data/lib/mongo/collection/view/aggregation.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +1 -1
- data/lib/mongo/collection/view/iterable.rb +4 -4
- data/lib/mongo/collection/view/map_reduce.rb +3 -3
- data/lib/mongo/collection/view/readable.rb +26 -20
- data/lib/mongo/collection/view/writable.rb +12 -12
- data/lib/mongo/cursor.rb +4 -7
- data/lib/mongo/database.rb +2 -2
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/grid/stream/write.rb +1 -1
- data/lib/mongo/index/view.rb +3 -3
- data/lib/mongo/operation.rb +38 -24
- data/lib/mongo/operation/aggregate.rb +53 -0
- data/lib/mongo/operation/aggregate/command.rb +59 -0
- data/lib/mongo/operation/aggregate/op_msg.rb +54 -0
- data/lib/mongo/operation/aggregate/result.rb +87 -0
- data/lib/mongo/operation/collections_info.rb +62 -0
- data/lib/mongo/operation/collections_info/result.rb +39 -0
- data/lib/mongo/operation/{executable.rb → command.rb} +16 -13
- data/lib/mongo/operation/command/command.rb +38 -0
- data/lib/mongo/operation/command/op_msg.rb +53 -0
- data/lib/mongo/operation/count.rb +48 -0
- data/lib/mongo/operation/count/command.rb +38 -0
- data/lib/mongo/operation/count/op_msg.rb +38 -0
- data/lib/mongo/operation/create.rb +48 -0
- data/lib/mongo/operation/create/command.rb +38 -0
- data/lib/mongo/operation/create/op_msg.rb +37 -0
- data/lib/mongo/operation/create_index.rb +48 -0
- data/lib/mongo/operation/create_index/command.rb +42 -0
- data/lib/mongo/operation/create_index/op_msg.rb +41 -0
- data/lib/mongo/operation/create_user.rb +48 -0
- data/lib/mongo/operation/{commands → create_user}/command.rb +13 -19
- data/lib/mongo/operation/create_user/op_msg.rb +41 -0
- data/lib/mongo/operation/delete.rb +38 -0
- data/lib/mongo/operation/delete/bulk_result.rb +46 -0
- data/lib/mongo/operation/delete/command.rb +59 -0
- data/lib/mongo/operation/delete/legacy.rb +69 -0
- data/lib/mongo/operation/delete/op_msg.rb +60 -0
- data/lib/mongo/operation/{write/delete → delete}/result.rb +18 -16
- data/lib/mongo/operation/distinct.rb +48 -0
- data/lib/mongo/operation/distinct/command.rb +38 -0
- data/lib/mongo/operation/distinct/op_msg.rb +38 -0
- data/lib/mongo/operation/drop.rb +48 -0
- data/lib/mongo/operation/drop/command.rb +38 -0
- data/lib/mongo/operation/{commands/count.rb → drop/op_msg.rb} +16 -6
- data/lib/mongo/operation/drop_database.rb +48 -0
- data/lib/mongo/operation/drop_database/command.rb +38 -0
- data/lib/mongo/operation/drop_database/op_msg.rb +37 -0
- data/lib/mongo/operation/drop_index.rb +48 -0
- data/lib/mongo/operation/drop_index/command.rb +42 -0
- data/lib/mongo/operation/{limited.rb → drop_index/op_msg.rb} +19 -15
- data/lib/mongo/operation/explain.rb +52 -0
- data/lib/mongo/operation/explain/command.rb +54 -0
- data/lib/mongo/operation/explain/legacy.rb +53 -0
- data/lib/mongo/operation/explain/op_msg.rb +54 -0
- data/lib/mongo/operation/explain/result.rb +50 -0
- data/lib/mongo/operation/find.rb +52 -0
- data/lib/mongo/operation/find/command.rb +54 -0
- data/lib/mongo/operation/find/legacy.rb +55 -0
- data/lib/mongo/operation/{read/query → find/legacy}/result.rb +3 -3
- data/lib/mongo/operation/find/op_msg.rb +59 -0
- data/lib/mongo/operation/find/result.rb +60 -0
- data/lib/mongo/operation/{commands/users_info/result.rb → get_more.rb} +20 -22
- data/lib/mongo/operation/get_more/command.rb +54 -0
- data/lib/mongo/operation/{commands/find.rb → get_more/legacy.rb} +15 -8
- data/lib/mongo/operation/get_more/op_msg.rb +58 -0
- data/lib/mongo/operation/get_more/result.rb +60 -0
- data/lib/mongo/operation/indexes.rb +52 -0
- data/lib/mongo/operation/indexes/command.rb +54 -0
- data/lib/mongo/operation/indexes/legacy.rb +57 -0
- data/lib/mongo/operation/indexes/op_msg.rb +54 -0
- data/lib/mongo/operation/indexes/result.rb +97 -0
- data/lib/mongo/operation/insert.rb +40 -0
- data/lib/mongo/operation/insert/bulk_result.rb +70 -0
- data/lib/mongo/operation/insert/command.rb +65 -0
- data/lib/mongo/operation/insert/legacy.rb +72 -0
- data/lib/mongo/operation/insert/op_msg.rb +61 -0
- data/lib/mongo/operation/insert/result.rb +64 -0
- data/lib/mongo/operation/kill_cursors.rb +25 -14
- data/lib/mongo/operation/{takes_write_concern.rb → kill_cursors/command.rb} +14 -12
- data/lib/mongo/operation/kill_cursors/legacy.rb +37 -0
- data/lib/mongo/operation/kill_cursors/op_msg.rb +37 -0
- data/lib/mongo/operation/list_collections.rb +49 -0
- data/lib/mongo/operation/list_collections/command.rb +60 -0
- data/lib/mongo/operation/list_collections/op_msg.rb +53 -0
- data/lib/mongo/operation/list_collections/result.rb +92 -0
- data/lib/mongo/operation/map_reduce.rb +49 -0
- data/lib/mongo/operation/map_reduce/command.rb +55 -0
- data/lib/mongo/operation/map_reduce/op_msg.rb +54 -0
- data/lib/mongo/operation/map_reduce/result.rb +129 -0
- data/lib/mongo/operation/parallel_scan.rb +49 -0
- data/lib/mongo/operation/parallel_scan/command.rb +67 -0
- data/lib/mongo/operation/parallel_scan/op_msg.rb +61 -0
- data/lib/mongo/operation/parallel_scan/result.rb +61 -0
- data/lib/mongo/operation/remove_user.rb +48 -0
- data/lib/mongo/operation/remove_user/command.rb +42 -0
- data/lib/mongo/operation/remove_user/op_msg.rb +41 -0
- data/lib/mongo/operation/result.rb +3 -1
- data/lib/mongo/operation/shared/bypass_document_validation.rb +36 -0
- data/lib/mongo/operation/{causally_consistent.rb → shared/causal_consistency_supported.rb} +5 -5
- data/lib/mongo/operation/shared/executable.rb +45 -0
- data/lib/mongo/operation/shared/idable.rb +64 -0
- data/lib/mongo/operation/{commands/distinct.rb → shared/limited.rb} +10 -7
- data/lib/mongo/operation/{object_id_generator.rb → shared/object_id_generator.rb} +2 -2
- data/lib/mongo/operation/{read_preference.rb → shared/read_preference_supported.rb} +14 -24
- data/lib/mongo/operation/shared/result/aggregatable.rb +75 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +79 -0
- data/lib/mongo/operation/{specifiable.rb → shared/specifiable.rb} +40 -4
- data/lib/mongo/operation/shared/write.rb +81 -0
- data/lib/mongo/operation/shared/write_concern_supported.rb +39 -0
- data/lib/mongo/operation/update.rb +38 -0
- data/lib/mongo/operation/update/bulk_result.rb +126 -0
- data/lib/mongo/operation/update/command.rb +60 -0
- data/lib/mongo/operation/update/legacy.rb +80 -0
- data/lib/mongo/operation/{write/update → update/legacy}/result.rb +4 -82
- data/lib/mongo/operation/update/op_msg.rb +60 -0
- data/lib/mongo/operation/update/result.rb +102 -0
- data/lib/mongo/operation/update_user.rb +48 -0
- data/lib/mongo/operation/update_user/command.rb +41 -0
- data/lib/mongo/operation/update_user/op_msg.rb +41 -0
- data/lib/mongo/operation/users_info.rb +49 -0
- data/lib/mongo/operation/users_info/command.rb +58 -0
- data/lib/mongo/operation/users_info/op_msg.rb +57 -0
- data/lib/mongo/operation/{commands/collections_info → users_info}/result.rb +18 -17
- data/lib/mongo/server.rb +3 -5
- data/lib/mongo/server/connectable.rb +3 -3
- data/lib/mongo/server/connection.rb +14 -0
- data/lib/mongo/server_selector.rb +1 -1
- data/lib/mongo/server_selector/selectable.rb +3 -12
- data/lib/mongo/session.rb +13 -1
- data/lib/mongo/session/session_pool.rb +1 -1
- data/lib/mongo/version.rb +1 -1
- data/spec/mongo/client_spec.rb +15 -22
- data/spec/mongo/cluster/app_metadata_spec.rb +19 -3
- data/spec/mongo/cluster/cursor_reaper_spec.rb +37 -0
- data/spec/mongo/cluster_spec.rb +2 -2
- data/spec/mongo/collection/view/change_stream_spec.rb +2 -2
- data/spec/mongo/collection_spec.rb +105 -14
- data/spec/mongo/cursor_spec.rb +11 -11
- data/spec/mongo/grid/fs_bucket_spec.rb +5 -0
- data/spec/mongo/max_staleness_spec.rb +3 -1
- data/spec/mongo/operation/{commands/aggregate → aggregate}/result_spec.rb +1 -1
- data/spec/mongo/operation/{commands/aggregate_spec.rb → aggregate_spec.rb} +1 -1
- data/spec/mongo/operation/{commands/collections_info_spec.rb → collections_info_spec.rb} +4 -2
- data/spec/mongo/operation/{commands/command_spec.rb → command_spec.rb} +1 -1
- data/spec/mongo/operation/{write/command/create_index_spec.rb → create_index_spec.rb} +1 -1
- data/spec/mongo/operation/{write/create_user_spec.rb → create_user_spec.rb} +1 -1
- data/spec/mongo/operation/{write/bulk/delete_spec.rb → delete/bulk_spec.rb} +8 -8
- data/spec/mongo/operation/delete/command_spec.rb +111 -0
- data/spec/mongo/operation/{write/command/delete_spec.rb → delete/op_msg_spec.rb} +40 -34
- data/spec/mongo/operation/{write/delete_spec.rb → delete_spec.rb} +7 -7
- data/spec/mongo/operation/{write/command/drop_index_spec.rb → drop_index_spec.rb} +1 -1
- data/spec/mongo/operation/{read/query_spec.rb → find/legacy_spec.rb} +2 -2
- data/spec/mongo/operation/{read/get_more_spec.rb → get_more_spec.rb} +3 -3
- data/spec/mongo/operation/{commands/indexes_spec.rb → indexes_spec.rb} +6 -4
- data/spec/mongo/operation/{write/bulk/insert_spec.rb → insert/bulk_spec.rb} +9 -9
- data/spec/mongo/operation/insert/command_spec.rb +110 -0
- data/spec/mongo/operation/{write/command/insert_spec.rb → insert/op_msg_spec.rb} +51 -41
- data/spec/mongo/operation/{write/insert_spec.rb → insert_spec.rb} +2 -2
- data/spec/mongo/operation/kill_cursors_spec.rb +2 -2
- data/spec/mongo/operation/limited_spec.rb +3 -3
- data/spec/mongo/operation/{commands/map_reduce_spec.rb → map_reduce_spec.rb} +1 -1
- data/spec/mongo/operation/read_preference_spec.rb +2 -2
- data/spec/mongo/operation/{write/command/remove_user_spec.rb → remove_user_spec.rb} +1 -1
- data/spec/mongo/operation/{write/bulk/update_spec.rb → update/bulk_spec.rb} +8 -8
- data/spec/mongo/operation/update/command_spec.rb +114 -0
- data/spec/mongo/operation/{write/command/update_spec.rb → update/op_msg_spec.rb} +49 -40
- data/spec/mongo/operation/{write/update_spec.rb → update_spec.rb} +6 -6
- data/spec/mongo/operation/{write/command/update_user_spec.rb → update_user_spec.rb} +1 -1
- data/spec/mongo/server/connection_spec.rb +0 -22
- data/spec/mongo/server_selector_spec.rb +55 -0
- data/spec/mongo/server_spec.rb +0 -42
- data/spec/mongo/session/session_pool_spec.rb +1 -1
- data/spec/mongo/uri/srv_protocol_spec.rb +2 -2
- data/spec/mongo/uri_spec.rb +2 -2
- data/spec/support/gridfs_tests/delete.yml +4 -38
- data/spec/support/gridfs_tests/download.yml +12 -30
- data/spec/support/server_selection.rb +1 -1
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Nearest.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Nearest_multiple.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Nearest_non_matching.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/PossiblePrimary.yml +15 -0
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/PossiblePrimaryNearest.yml +15 -0
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Primary.yml +0 -3
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/PrimaryPreferred.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/PrimaryPreferred_non_matching.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/SecondaryPreferred.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/SecondaryPreferred_non_matching.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary_non_matching.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Nearest.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Nearest_multiple.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Nearest_non_matching.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Primary.yml +0 -3
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/PrimaryPreferred.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/PrimaryPreferred_non_matching.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Secondary.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/SecondaryPreferred.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/SecondaryPreferred_non_matching.yml +0 -1
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Secondary_non_matching.yml +0 -1
- data/spec/support/server_selection/selection/Sharded/read/Nearest.yml +21 -0
- data/spec/support/server_selection/selection/Sharded/read/Primary.yml +19 -0
- data/spec/support/server_selection/selection/Sharded/read/PrimaryPreferred.yml +21 -0
- data/spec/support/server_selection/selection/Sharded/read/Secondary.yml +21 -0
- data/spec/support/server_selection/selection/Sharded/read/SecondaryPreferred.yml +0 -5
- data/spec/support/server_selection/selection/Single/read/SecondaryPreferred.yml +0 -1
- data/spec/support/server_selection/selection/Unknown/read/SecondaryPreferred.yml +0 -1
- data/spec/support/shared/session.rb +46 -5
- metadata +174 -116
- metadata.gz.sig +1 -2
- data/lib/mongo/operation/commands.rb +0 -31
- data/lib/mongo/operation/commands/aggregate.rb +0 -63
- data/lib/mongo/operation/commands/aggregate/result.rb +0 -89
- data/lib/mongo/operation/commands/collections_info.rb +0 -71
- data/lib/mongo/operation/commands/create.rb +0 -49
- data/lib/mongo/operation/commands/drop.rb +0 -49
- data/lib/mongo/operation/commands/drop_database.rb +0 -49
- data/lib/mongo/operation/commands/explain.rb +0 -27
- data/lib/mongo/operation/commands/explain/result.rb +0 -52
- data/lib/mongo/operation/commands/find/result.rb +0 -62
- data/lib/mongo/operation/commands/get_more.rb +0 -27
- data/lib/mongo/operation/commands/get_more/result.rb +0 -62
- data/lib/mongo/operation/commands/indexes.rb +0 -73
- data/lib/mongo/operation/commands/list_collections.rb +0 -48
- data/lib/mongo/operation/commands/list_collections/result.rb +0 -94
- data/lib/mongo/operation/commands/list_indexes.rb +0 -48
- data/lib/mongo/operation/commands/list_indexes/result.rb +0 -98
- data/lib/mongo/operation/commands/map_reduce.rb +0 -65
- data/lib/mongo/operation/commands/map_reduce/result.rb +0 -131
- data/lib/mongo/operation/commands/parallel_scan.rb +0 -54
- data/lib/mongo/operation/commands/parallel_scan/result.rb +0 -64
- data/lib/mongo/operation/commands/users_info.rb +0 -52
- data/lib/mongo/operation/read.rb +0 -16
- data/lib/mongo/operation/read/get_more.rb +0 -52
- data/lib/mongo/operation/read/query.rb +0 -55
- data/lib/mongo/operation/uses_command_op_msg.rb +0 -78
- data/lib/mongo/operation/write.rb +0 -22
- data/lib/mongo/operation/write/bulk.rb +0 -20
- data/lib/mongo/operation/write/bulk/bulkable.rb +0 -82
- data/lib/mongo/operation/write/bulk/delete.rb +0 -71
- data/lib/mongo/operation/write/bulk/delete/result.rb +0 -71
- data/lib/mongo/operation/write/bulk/insert.rb +0 -96
- data/lib/mongo/operation/write/bulk/insert/result.rb +0 -129
- data/lib/mongo/operation/write/bulk/legacy_mergable.rb +0 -87
- data/lib/mongo/operation/write/bulk/mergable.rb +0 -73
- data/lib/mongo/operation/write/bulk/update.rb +0 -81
- data/lib/mongo/operation/write/bulk/update/result.rb +0 -196
- data/lib/mongo/operation/write/command.rb +0 -23
- data/lib/mongo/operation/write/command/create_index.rb +0 -79
- data/lib/mongo/operation/write/command/create_user.rb +0 -61
- data/lib/mongo/operation/write/command/delete.rb +0 -79
- data/lib/mongo/operation/write/command/drop_index.rb +0 -80
- data/lib/mongo/operation/write/command/insert.rb +0 -69
- data/lib/mongo/operation/write/command/remove_user.rb +0 -60
- data/lib/mongo/operation/write/command/update.rb +0 -77
- data/lib/mongo/operation/write/command/update_user.rb +0 -61
- data/lib/mongo/operation/write/command/writable.rb +0 -70
- data/lib/mongo/operation/write/delete.rb +0 -75
- data/lib/mongo/operation/write/gle.rb +0 -49
- data/lib/mongo/operation/write/idable.rb +0 -63
- data/lib/mongo/operation/write/insert.rb +0 -74
- data/lib/mongo/operation/write/insert/result.rb +0 -62
- data/lib/mongo/operation/write/update.rb +0 -91
- data/lib/mongo/operation/write/write_command_enabled.rb +0 -77
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongo::Operation::
|
3
|
+
describe Mongo::Operation::Find::Legacy, unless: op_msg_enabled? do
|
4
4
|
|
5
5
|
let(:selector) { { foo: 1 } }
|
6
6
|
let(:query_options) { {} }
|
@@ -95,7 +95,7 @@ describe Mongo::Operation::Read::Query, unless: op_msg_enabled? do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'does not raise an exception' do
|
98
|
-
expect(op.execute(authorized_primary)).to be_a(Mongo::Operation::
|
98
|
+
expect(op.execute(authorized_primary)).to be_a(Mongo::Operation::Find::Legacy::Result)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongo::Operation::
|
3
|
+
describe Mongo::Operation::GetMore::Legacy do
|
4
4
|
|
5
5
|
let(:to_return) do
|
6
6
|
50
|
@@ -46,8 +46,8 @@ describe Mongo::Operation::Read::GetMore do
|
|
46
46
|
describe '#message' do
|
47
47
|
|
48
48
|
it 'creates a get more wire protocol message with correct specs' do
|
49
|
-
expect(Mongo::Protocol::GetMore).to receive(:new).with(TEST_DB, TEST_COLL, to_return, cursor_id)
|
50
|
-
op.
|
49
|
+
expect(Mongo::Protocol::GetMore).to receive(:new).with(TEST_DB, TEST_COLL, to_return, cursor_id).and_call_original
|
50
|
+
begin; op.execute(authorized_primary); rescue; end
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongo::Operation::
|
3
|
+
describe Mongo::Operation::Indexes do
|
4
4
|
|
5
5
|
describe '#execute' do
|
6
6
|
|
7
|
-
let(:
|
7
|
+
let(:index_spec) do
|
8
8
|
{ name: 1 }
|
9
9
|
end
|
10
10
|
|
11
11
|
before do
|
12
|
-
authorized_collection.indexes.create_one(
|
12
|
+
authorized_collection.indexes.create_one(index_spec, unique: true)
|
13
13
|
end
|
14
14
|
|
15
15
|
after do
|
@@ -17,7 +17,9 @@ describe Mongo::Operation::Commands::Indexes do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
let(:operation) do
|
20
|
-
described_class.new(
|
20
|
+
described_class.new({ selector: { listIndexes: TEST_COLL },
|
21
|
+
coll_name: TEST_COLL,
|
22
|
+
db_name: TEST_DB })
|
21
23
|
end
|
22
24
|
|
23
25
|
let(:indexes) do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongo::Operation::
|
3
|
+
describe Mongo::Operation::Insert do
|
4
4
|
|
5
5
|
let(:documents) do
|
6
6
|
[{ :name => 'test' }]
|
@@ -87,7 +87,7 @@ describe Mongo::Operation::Write::Bulk::Insert do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
let(:inserted_ids) do
|
90
|
-
op.
|
90
|
+
op.bulk_execute(authorized_primary).inserted_ids
|
91
91
|
end
|
92
92
|
|
93
93
|
let(:collection_ids) do
|
@@ -100,7 +100,7 @@ describe Mongo::Operation::Write::Bulk::Insert do
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
describe '#
|
103
|
+
describe '#bulk_execute' do
|
104
104
|
|
105
105
|
before do
|
106
106
|
authorized_collection.indexes.create_one({ name: 1 }, { unique: true })
|
@@ -116,7 +116,7 @@ describe Mongo::Operation::Write::Bulk::Insert do
|
|
116
116
|
context 'when the insert succeeds' do
|
117
117
|
|
118
118
|
let(:response) do
|
119
|
-
op.
|
119
|
+
op.bulk_execute(authorized_primary)
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'inserts the documents into the database' do
|
@@ -134,7 +134,7 @@ describe Mongo::Operation::Write::Bulk::Insert do
|
|
134
134
|
end
|
135
135
|
|
136
136
|
let(:response) do
|
137
|
-
op.
|
137
|
+
op.bulk_execute(authorized_primary)
|
138
138
|
end
|
139
139
|
|
140
140
|
it 'inserts the documents into the database' do
|
@@ -171,7 +171,7 @@ describe Mongo::Operation::Write::Bulk::Insert do
|
|
171
171
|
context 'when the insert fails' do
|
172
172
|
|
173
173
|
it 'aborts after first error' do
|
174
|
-
failing_insert.
|
174
|
+
failing_insert.bulk_execute(authorized_primary)
|
175
175
|
expect(authorized_collection.find.count).to eq(1)
|
176
176
|
end
|
177
177
|
end
|
@@ -186,7 +186,7 @@ describe Mongo::Operation::Write::Bulk::Insert do
|
|
186
186
|
context 'when the insert fails' do
|
187
187
|
|
188
188
|
it 'aborts after first error' do
|
189
|
-
failing_insert.
|
189
|
+
failing_insert.bulk_execute(authorized_primary)
|
190
190
|
expect(authorized_collection.find.count).to eq(1)
|
191
191
|
end
|
192
192
|
end
|
@@ -217,7 +217,7 @@ describe Mongo::Operation::Write::Bulk::Insert do
|
|
217
217
|
context 'when the insert fails' do
|
218
218
|
|
219
219
|
it 'does not abort after first error' do
|
220
|
-
failing_insert.
|
220
|
+
failing_insert.bulk_execute(authorized_primary)
|
221
221
|
expect(authorized_collection.find.count).to eq(2)
|
222
222
|
end
|
223
223
|
end
|
@@ -232,7 +232,7 @@ describe Mongo::Operation::Write::Bulk::Insert do
|
|
232
232
|
context 'when the insert fails' do
|
233
233
|
|
234
234
|
it 'does not after first error' do
|
235
|
-
failing_insert.
|
235
|
+
failing_insert.bulk_execute(authorized_primary)
|
236
236
|
expect(authorized_collection.find.count).to eq(2)
|
237
237
|
end
|
238
238
|
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mongo::Operation::Insert::Command do
|
4
|
+
|
5
|
+
let(:documents) { [{ :_id => 1, :foo => 1 }] }
|
6
|
+
let(:session) { nil }
|
7
|
+
let(:spec) do
|
8
|
+
{ :documents => documents,
|
9
|
+
:db_name => authorized_collection.database.name,
|
10
|
+
:coll_name => authorized_collection.name,
|
11
|
+
:write_concern => write_concern,
|
12
|
+
:ordered => true,
|
13
|
+
:session => session
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:write_concern) do
|
18
|
+
Mongo::WriteConcern.get(WRITE_CONCERN)
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:op) { described_class.new(spec) }
|
22
|
+
|
23
|
+
describe '#initialize' do
|
24
|
+
|
25
|
+
context 'spec' do
|
26
|
+
|
27
|
+
it 'sets the spec' do
|
28
|
+
expect(op.spec).to eq(spec)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#==' do
|
34
|
+
|
35
|
+
context 'spec' do
|
36
|
+
|
37
|
+
context 'when two ops have the same specs' do
|
38
|
+
let(:other) { described_class.new(spec) }
|
39
|
+
|
40
|
+
it 'returns true' do
|
41
|
+
expect(op).to eq(other)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when two ops have different specs' do
|
46
|
+
let(:other_documents) { [{ :bar => 1 }] }
|
47
|
+
let(:other_spec) do
|
48
|
+
{ :documents => other_documents,
|
49
|
+
:db_name => authorized_collection.database.name,
|
50
|
+
:insert => authorized_collection.name,
|
51
|
+
:write_concern => write_concern.options,
|
52
|
+
:ordered => true
|
53
|
+
}
|
54
|
+
end
|
55
|
+
let(:other) { described_class.new(other_spec) }
|
56
|
+
|
57
|
+
it 'returns false' do
|
58
|
+
expect(op).not_to eq(other)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'write concern' do
|
65
|
+
|
66
|
+
context 'when write concern is not specified' do
|
67
|
+
|
68
|
+
let(:spec) do
|
69
|
+
{ :documents => documents,
|
70
|
+
:db_name => authorized_collection.database.name,
|
71
|
+
:coll_name => authorized_collection.name,
|
72
|
+
:ordered => true
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'does not include write concern in the selector' do
|
77
|
+
expect(op.send(:command, double('server'))[:writeConcern]).to be_nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when write concern is specified' do
|
82
|
+
|
83
|
+
it 'includes write concern in the selector' do
|
84
|
+
expect(op.send(:command, double('server'))[:writeConcern]).to eq(write_concern.options)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#message' do
|
90
|
+
|
91
|
+
context 'when the server does not support OP_MSG' do
|
92
|
+
|
93
|
+
let(:expected_selector) do
|
94
|
+
{ :documents => documents,
|
95
|
+
:insert => authorized_collection.name,
|
96
|
+
:writeConcern => write_concern.options,
|
97
|
+
:ordered => true
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'creates a query wire protocol message with correct specs', unless: op_msg_enabled? do
|
102
|
+
expect(Mongo::Protocol::Query).to receive(:new).with(authorized_collection.database.name,
|
103
|
+
'$cmd',
|
104
|
+
expected_selector,
|
105
|
+
{ limit: -1, validating_keys: true })
|
106
|
+
op.send(:message, authorized_primary)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongo::Operation::
|
3
|
+
describe Mongo::Operation::Insert::OpMsg do
|
4
4
|
|
5
5
|
let(:documents) { [{ :_id => 1, :foo => 1 }] }
|
6
6
|
let(:session) { nil }
|
@@ -74,14 +74,14 @@ describe Mongo::Operation::Write::Command::Insert do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'does not include write concern in the selector' do
|
77
|
-
expect(op.send(:
|
77
|
+
expect(op.send(:command, authorized_primary)[:writeConcern]).to be_nil
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
context 'when write concern is specified' do
|
82
82
|
|
83
83
|
it 'includes write concern in the selector' do
|
84
|
-
expect(op.send(:
|
84
|
+
expect(op.send(:command, authorized_primary)[:writeConcern]).to eq(write_concern.options)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -91,7 +91,7 @@ describe Mongo::Operation::Write::Command::Insert do
|
|
91
91
|
context 'when the server supports OP_MSG', if: op_msg_enabled? do
|
92
92
|
|
93
93
|
let(:documents) do
|
94
|
-
[ { foo: 1}, { bar: 2 }]
|
94
|
+
[ { foo: 1 }, { bar: 2 }]
|
95
95
|
end
|
96
96
|
|
97
97
|
let(:global_args) do
|
@@ -104,11 +104,11 @@ describe Mongo::Operation::Write::Command::Insert do
|
|
104
104
|
}
|
105
105
|
end
|
106
106
|
|
107
|
-
let(:expected_payload_1) do
|
107
|
+
let!(:expected_payload_1) do
|
108
108
|
{
|
109
109
|
type: 1,
|
110
110
|
payload: { identifier: 'documents',
|
111
|
-
sequence: documents
|
111
|
+
sequence: op.documents
|
112
112
|
}
|
113
113
|
}
|
114
114
|
end
|
@@ -117,7 +117,7 @@ describe Mongo::Operation::Write::Command::Insert do
|
|
117
117
|
authorized_client.start_session
|
118
118
|
end
|
119
119
|
|
120
|
-
context 'when the topology is replica set or sharded', if:
|
120
|
+
context 'when the topology is replica set or sharded', if: test_sessions? do
|
121
121
|
|
122
122
|
let(:expected_global_args) do
|
123
123
|
global_args.merge(Mongo::Operation::CLUSTER_TIME => authorized_client.cluster.cluster_time)
|
@@ -133,7 +133,7 @@ describe Mongo::Operation::Write::Command::Insert do
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
context 'when the topology is standalone', if: standalone? &&
|
136
|
+
context 'when the topology is standalone', if: standalone? && sessions_enabled? do
|
137
137
|
|
138
138
|
let(:expected_global_args) do
|
139
139
|
global_args
|
@@ -177,31 +177,60 @@ describe Mongo::Operation::Write::Command::Insert do
|
|
177
177
|
Mongo::WriteConcern.get(w: 0)
|
178
178
|
end
|
179
179
|
|
180
|
-
context 'when the
|
180
|
+
context 'when the session is implicit' do
|
181
181
|
|
182
|
-
let(:
|
183
|
-
|
184
|
-
|
182
|
+
let(:session) do
|
183
|
+
# Use client#get_session so the session is implicit
|
184
|
+
authorized_client.send(:get_session)
|
185
185
|
end
|
186
186
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
187
|
+
context 'when the topology is replica set or sharded', if: test_sessions? do
|
188
|
+
|
189
|
+
let(:expected_global_args) do
|
190
|
+
global_args.delete(:lsid)
|
191
|
+
global_args.merge(Mongo::Operation::CLUSTER_TIME => authorized_client.cluster.cluster_time)
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'does not send a session id in the command' do
|
195
|
+
authorized_client.command(ping:1)
|
196
|
+
expect(Mongo::Protocol::Msg).to receive(:new).with([:more_to_come],
|
197
|
+
{ validating_keys: true },
|
198
|
+
expected_global_args,
|
199
|
+
expected_payload_1)
|
200
|
+
op.send(:message, authorized_primary)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
context 'when the topology is standalone', if: standalone? && sessions_enabled? do
|
205
|
+
|
206
|
+
let(:expected_global_args) do
|
207
|
+
global_args.delete(:lsid)
|
208
|
+
global_args
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'creates the correct OP_MSG message' do
|
212
|
+
authorized_client.command(ping:1)
|
213
|
+
expect(Mongo::Protocol::Msg).to receive(:new).with([:more_to_come],
|
214
|
+
{ validating_keys: true },
|
215
|
+
expected_global_args,
|
216
|
+
expected_payload_1)
|
217
|
+
op.send(:message, authorized_primary)
|
218
|
+
end
|
194
219
|
end
|
195
220
|
end
|
196
221
|
|
197
|
-
context 'when the
|
222
|
+
context 'when the session is explicit', if: test_sessions? do
|
223
|
+
|
224
|
+
let(:session) do
|
225
|
+
authorized_client.start_session
|
226
|
+
end
|
198
227
|
|
199
228
|
let(:expected_global_args) do
|
200
229
|
global_args.delete(:lsid)
|
201
|
-
global_args
|
230
|
+
global_args.merge(Mongo::Operation::CLUSTER_TIME => authorized_client.cluster.cluster_time)
|
202
231
|
end
|
203
232
|
|
204
|
-
it '
|
233
|
+
it 'does not send a session id in the command' do
|
205
234
|
authorized_client.command(ping:1)
|
206
235
|
expect(Mongo::Protocol::Msg).to receive(:new).with([:more_to_come],
|
207
236
|
{ validating_keys: true },
|
@@ -212,24 +241,5 @@ describe Mongo::Operation::Write::Command::Insert do
|
|
212
241
|
end
|
213
242
|
end
|
214
243
|
end
|
215
|
-
|
216
|
-
context 'when the server does not support OP_MSG' do
|
217
|
-
|
218
|
-
let(:expected_selector) do
|
219
|
-
{ :documents => documents,
|
220
|
-
:insert => authorized_collection.name,
|
221
|
-
:writeConcern => write_concern.options,
|
222
|
-
:ordered => true
|
223
|
-
}
|
224
|
-
end
|
225
|
-
|
226
|
-
it 'creates a query wire protocol message with correct specs', unless: op_msg_enabled? do
|
227
|
-
expect(Mongo::Protocol::Query).to receive(:new).with(authorized_collection.database.name,
|
228
|
-
'$cmd',
|
229
|
-
expected_selector,
|
230
|
-
{ limit: -1, validating_keys: true })
|
231
|
-
op.send(:message, authorized_primary)
|
232
|
-
end
|
233
|
-
end
|
234
244
|
end
|
235
245
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongo::Operation::
|
3
|
+
describe Mongo::Operation::Insert do
|
4
4
|
|
5
5
|
let(:documents) do
|
6
6
|
[{ '_id' => 1,
|
@@ -268,7 +268,7 @@ describe Mongo::Operation::Write::Insert do
|
|
268
268
|
end
|
269
269
|
|
270
270
|
before do
|
271
|
-
expect(
|
271
|
+
expect(Mongo::Operation::Insert::Legacy).to receive(:new).and_call_original
|
272
272
|
end
|
273
273
|
|
274
274
|
let(:response) do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Mongo::Operation::KillCursors do
|
3
|
+
describe Mongo::Operation::KillCursors::Legacy do
|
4
4
|
|
5
5
|
let(:spec) do
|
6
6
|
{ coll_name: TEST_COLL,
|
@@ -35,7 +35,7 @@ describe Mongo::Operation::KillCursors do
|
|
35
35
|
|
36
36
|
it 'creates a kill cursors wire protocol message with correct specs' do
|
37
37
|
expect(Mongo::Protocol::KillCursors).to receive(:new).with(TEST_COLL, TEST_DB, spec[:cursor_ids])
|
38
|
-
op.send(:message,
|
38
|
+
op.send(:message, double('server'))
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|