mongo 2.9.2 → 2.10.0.rc0
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.tar.gz.sig +0 -0
- data/lib/mongo.rb +1 -0
- data/lib/mongo/auth/user/view.rb +4 -4
- data/lib/mongo/bulk_write.rb +14 -8
- data/lib/mongo/bulk_write/result.rb +1 -1
- data/lib/mongo/bulk_write/result_combiner.rb +2 -2
- data/lib/mongo/bulk_write/transformable.rb +17 -9
- data/lib/mongo/client.rb +107 -16
- data/lib/mongo/cluster.rb +47 -25
- data/lib/mongo/cluster/topology/replica_set_no_primary.rb +1 -1
- data/lib/mongo/cluster_time.rb +139 -0
- data/lib/mongo/collection.rb +84 -25
- data/lib/mongo/collection/view.rb +7 -3
- data/lib/mongo/collection/view/aggregation.rb +4 -4
- data/lib/mongo/collection/view/builder/aggregation.rb +31 -6
- data/lib/mongo/collection/view/builder/find_command.rb +4 -1
- data/lib/mongo/collection/view/builder/map_reduce.rb +4 -1
- data/lib/mongo/collection/view/change_stream.rb +54 -66
- data/lib/mongo/collection/view/iterable.rb +2 -2
- data/lib/mongo/collection/view/map_reduce.rb +6 -4
- data/lib/mongo/collection/view/readable.rb +36 -16
- data/lib/mongo/collection/view/writable.rb +68 -22
- data/lib/mongo/cursor.rb +87 -20
- data/lib/mongo/database.rb +47 -43
- data/lib/mongo/database/view.rb +54 -11
- data/lib/mongo/error.rb +13 -4
- data/lib/mongo/error/invalid_write_concern.rb +2 -2
- data/lib/mongo/error/operation_failure.rb +65 -11
- data/lib/mongo/error/parser.rb +41 -8
- data/lib/mongo/grid/fs_bucket.rb +26 -6
- data/lib/mongo/grid/stream/read.rb +9 -2
- data/lib/mongo/grid/stream/write.rb +21 -5
- data/lib/mongo/index/view.rb +3 -3
- data/lib/mongo/lint.rb +10 -3
- data/lib/mongo/operation.rb +2 -0
- data/lib/mongo/operation/aggregate/result.rb +19 -6
- data/lib/mongo/operation/collections_info.rb +1 -1
- data/lib/mongo/operation/get_more/result.rb +9 -0
- data/lib/mongo/operation/list_collections/command.rb +1 -3
- data/lib/mongo/operation/list_collections/op_msg.rb +1 -2
- data/lib/mongo/operation/parallel_scan/command.rb +4 -1
- data/lib/mongo/operation/parallel_scan/op_msg.rb +4 -1
- data/lib/mongo/operation/result.rb +27 -4
- data/lib/mongo/operation/shared/executable.rb +19 -5
- data/lib/mongo/operation/shared/executable_no_validate.rb +1 -2
- data/lib/mongo/operation/shared/executable_transaction_label.rb +0 -9
- data/lib/mongo/operation/shared/polymorphic_result.rb +9 -1
- data/lib/mongo/operation/shared/result/aggregatable.rb +2 -2
- data/lib/mongo/operation/shared/sessions_supported.rb +42 -32
- data/lib/mongo/operation/shared/specifiable.rb +40 -0
- data/lib/mongo/operation/shared/unpinnable.rb +39 -0
- data/lib/mongo/operation/shared/write.rb +1 -1
- data/lib/mongo/protocol/update.rb +6 -2
- data/lib/mongo/retryable.rb +79 -39
- data/lib/mongo/server/connection.rb +10 -3
- data/lib/mongo/server/description.rb +25 -1
- data/lib/mongo/server/monitor/connection.rb +1 -1
- data/lib/mongo/server_selector.rb +10 -0
- data/lib/mongo/server_selector/selectable.rb +172 -32
- data/lib/mongo/session.rb +654 -581
- data/lib/mongo/session/session_pool.rb +1 -1
- data/lib/mongo/socket.rb +7 -28
- data/lib/mongo/socket/ssl.rb +26 -1
- data/lib/mongo/socket/tcp.rb +3 -0
- data/lib/mongo/socket/unix.rb +3 -0
- data/lib/mongo/uri.rb +112 -265
- data/lib/mongo/uri/srv_protocol.rb +4 -1
- data/lib/mongo/version.rb +1 -1
- data/lib/mongo/write_concern.rb +10 -29
- data/lib/mongo/write_concern/acknowledged.rb +12 -0
- data/lib/mongo/write_concern/base.rb +17 -13
- data/lib/mongo/write_concern/unacknowledged.rb +12 -0
- data/spec/atlas/atlas_connectivity_spec.rb +7 -37
- data/spec/atlas/operations_spec.rb +25 -0
- data/spec/integration/change_stream_examples_spec.rb +45 -31
- data/spec/integration/change_stream_spec.rb +305 -5
- data/spec/integration/client_spec.rb +44 -0
- data/spec/integration/command_monitoring_spec.rb +1 -0
- data/spec/integration/command_spec.rb +7 -1
- data/spec/integration/mmapv1_spec.rb +28 -0
- data/spec/integration/mongos_pinning_spec.rb +34 -0
- data/spec/integration/operation_failure_code_spec.rb +2 -2
- data/spec/integration/{read_concern.rb → read_concern_spec.rb} +7 -1
- data/spec/integration/read_preference_spec.rb +485 -0
- data/spec/integration/retryable_writes_spec.rb +8 -19
- data/spec/integration/sdam_error_handling_spec.rb +1 -1
- data/spec/integration/sdam_events_spec.rb +2 -2
- data/spec/integration/server_description_spec.rb +14 -17
- data/spec/integration/server_selector_spec.rb +7 -3
- data/spec/integration/server_spec.rb +48 -0
- data/spec/integration/ssl_uri_options_spec.rb +1 -1
- data/spec/integration/step_down_spec.rb +10 -4
- data/spec/integration/transactions_examples_spec.rb +11 -10
- data/spec/lite_spec_helper.rb +19 -16
- data/spec/mongo/auth/scram/negotiation_spec.rb +11 -8
- data/spec/mongo/bulk_write/ordered_combiner_spec.rb +6 -6
- data/spec/mongo/bulk_write/unordered_combiner_spec.rb +4 -4
- data/spec/mongo/bulk_write_spec.rb +12 -2
- data/spec/mongo/client_construction_spec.rb +160 -8
- data/spec/mongo/client_spec.rb +5 -4
- data/spec/mongo/cluster_spec.rb +6 -6
- data/spec/mongo/cluster_time_spec.rb +148 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +34 -15
- data/spec/mongo/collection/view/change_stream_spec.rb +62 -3
- data/spec/mongo/collection/view/map_reduce_spec.rb +7 -5
- data/spec/mongo/collection/view/readable_spec.rb +4 -4
- data/spec/mongo/collection_spec.rb +331 -14
- data/spec/mongo/cursor_spec.rb +117 -5
- data/spec/mongo/database_spec.rb +240 -8
- data/spec/mongo/error/operation_failure_spec.rb +47 -1
- data/spec/mongo/error/parser_spec.rb +160 -23
- data/spec/mongo/operation/insert/bulk_spec.rb +2 -1
- data/spec/mongo/operation/result_spec.rb +27 -0
- data/spec/mongo/operation/update/bulk_spec.rb +1 -0
- data/spec/mongo/retryable_spec.rb +2 -0
- data/spec/mongo/server/app_metadata_spec.rb +2 -2
- data/spec/mongo/server/connection_spec.rb +13 -17
- data/spec/mongo/server/monitor/connection_spec.rb +13 -10
- data/spec/mongo/server_selector_spec.rb +34 -2
- data/spec/mongo/session/session_pool_spec.rb +14 -3
- data/spec/mongo/session_spec.rb +3 -3
- data/spec/mongo/session_transaction_spec.rb +4 -3
- data/spec/mongo/socket/ssl_spec.rb +19 -5
- data/spec/mongo/socket_spec.rb +1 -62
- data/spec/mongo/uri/srv_protocol_spec.rb +14 -20
- data/spec/mongo/uri_option_parsing_spec.rb +94 -8
- data/spec/mongo/uri_spec.rb +23 -10
- data/spec/mongo/write_concern_spec.rb +56 -3
- data/spec/spec_tests/change_streams_spec.rb +2 -1
- data/spec/spec_tests/cmap_spec.rb +1 -1
- data/spec/spec_tests/crud_spec.rb +12 -2
- data/spec/spec_tests/data/change_streams/change-streams-errors.yml +24 -1
- data/spec/spec_tests/data/change_streams/change-streams.yml +172 -3
- data/spec/spec_tests/data/command_monitoring/bulkWrite.yml +1 -1
- data/spec/spec_tests/data/command_monitoring/updateMany.yml +0 -2
- data/spec/spec_tests/data/command_monitoring/updateOne.yml +0 -5
- data/spec/spec_tests/data/crud/read/aggregate-out.yml +0 -6
- data/spec/spec_tests/data/crud/read/count-empty.yml +29 -0
- data/spec/spec_tests/data/crud/write/bulkWrite-arrayFilters.yml +1 -0
- data/spec/spec_tests/data/crud/write/bulkWrite-collation.yml +101 -0
- data/spec/spec_tests/data/crud/write/bulkWrite.yml +401 -0
- data/spec/spec_tests/data/crud/write/insertMany.yml +58 -2
- data/spec/spec_tests/data/crud/write/updateMany-arrayFilters.yml +3 -0
- data/spec/spec_tests/data/crud/write/updateOne-arrayFilters.yml +6 -1
- data/spec/spec_tests/data/crud_v2/aggregate-merge.yml +103 -0
- data/spec/spec_tests/data/crud_v2/aggregate-out-readConcern.yml +110 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-arrayFilters.yml +81 -0
- data/spec/spec_tests/data/crud_v2/db-aggregate.yml +38 -0
- data/spec/spec_tests/data/crud_v2/updateWithPipelines.yml +92 -0
- data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +2 -2
- data/spec/spec_tests/data/transactions/abort.yml +3 -0
- data/spec/spec_tests/data/transactions/bulk.yml +3 -8
- data/spec/spec_tests/data/transactions/causal-consistency.yml +3 -8
- data/spec/spec_tests/data/transactions/commit.yml +3 -1
- data/spec/spec_tests/data/transactions/count.yml +3 -0
- data/spec/spec_tests/data/transactions/delete.yml +3 -0
- data/spec/spec_tests/data/transactions/error-labels.yml +4 -1
- data/spec/spec_tests/data/transactions/errors-client.yml +56 -0
- data/spec/spec_tests/data/transactions/errors.yml +3 -0
- data/spec/spec_tests/data/transactions/findOneAndDelete.yml +3 -0
- data/spec/spec_tests/data/transactions/findOneAndReplace.yml +3 -0
- data/spec/spec_tests/data/transactions/findOneAndUpdate.yml +3 -0
- data/spec/spec_tests/data/transactions/insert.yml +3 -0
- data/spec/spec_tests/data/transactions/isolation.yml +3 -0
- data/spec/spec_tests/data/transactions/mongos-pin-auto.yml +1671 -0
- data/spec/spec_tests/data/transactions/mongos-recovery-token.yml +347 -0
- data/spec/spec_tests/data/transactions/pin-mongos.yml +557 -0
- data/spec/spec_tests/data/transactions/read-concern.yml +3 -0
- data/spec/spec_tests/data/transactions/read-pref.yml +3 -0
- data/spec/spec_tests/data/transactions/reads.yml +3 -0
- data/spec/spec_tests/data/transactions/retryable-abort.yml +5 -2
- data/spec/spec_tests/data/transactions/retryable-commit.yml +4 -1
- data/spec/spec_tests/data/transactions/retryable-writes.yml +3 -0
- data/spec/spec_tests/data/transactions/run-command.yml +3 -0
- data/spec/spec_tests/data/transactions/transaction-options.yml +6 -0
- data/spec/spec_tests/data/transactions/update.yml +3 -8
- data/spec/spec_tests/data/transactions/write-concern.yml +348 -38
- data/spec/spec_tests/data/transactions_api/callback-aborts.yml +6 -0
- data/spec/spec_tests/data/transactions_api/callback-commits.yml +5 -0
- data/spec/spec_tests/data/transactions_api/callback-retry.yml +7 -2
- data/spec/spec_tests/data/transactions_api/commit-retry.yml +70 -15
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +3 -0
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +3 -0
- data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +59 -109
- data/spec/spec_tests/data/transactions_api/commit.yml +5 -0
- data/spec/spec_tests/data/transactions_api/transaction-options.yml +10 -0
- data/spec/spec_tests/retryable_reads_spec.rb +5 -2
- data/spec/spec_tests/retryable_writes_spec.rb +5 -2
- data/spec/spec_tests/sdam_monitoring_spec.rb +3 -3
- data/spec/spec_tests/sdam_spec.rb +2 -2
- data/spec/spec_tests/transactions_api_spec.rb +1 -67
- data/spec/spec_tests/transactions_spec.rb +2 -66
- data/spec/support/authorization.rb +4 -0
- data/spec/support/change_streams.rb +30 -10
- data/spec/support/change_streams/operation.rb +27 -0
- data/spec/support/client_registry.rb +44 -25
- data/spec/support/cluster_config.rb +25 -14
- data/spec/support/cluster_tools.rb +32 -10
- data/spec/support/command_monitoring.rb +1 -1
- data/spec/support/common_shortcuts.rb +30 -0
- data/spec/support/connection_string.rb +8 -3
- data/spec/support/constraints.rb +34 -0
- data/spec/support/crud.rb +31 -16
- data/spec/support/crud/context.rb +23 -0
- data/spec/support/crud/operation.rb +311 -14
- data/spec/support/crud/spec.rb +2 -1
- data/spec/support/crud/test.rb +24 -27
- data/spec/support/crud/test_base.rb +22 -0
- data/spec/support/crud/verifier.rb +15 -1
- data/spec/support/event_subscriber.rb +12 -0
- data/spec/support/sdam_formatter_integration.rb +12 -6
- data/spec/support/shared/server_selector.rb +10 -0
- data/spec/support/shared/session.rb +13 -12
- data/spec/support/spec_config.rb +32 -22
- data/spec/support/spec_setup.rb +2 -2
- data/spec/support/transactions.rb +87 -0
- data/spec/support/transactions/context.rb +33 -0
- data/spec/support/transactions/operation.rb +99 -349
- data/spec/support/transactions/spec.rb +1 -3
- data/spec/support/transactions/test.rb +110 -49
- data/spec/support/utils.rb +74 -1
- metadata +52 -10
- metadata.gz.sig +0 -0
- data/spec/support/crud/read.rb +0 -265
- data/spec/support/crud/write.rb +0 -284
@@ -13,6 +13,12 @@ require 'spec_helper'
|
|
13
13
|
describe 'Retryable writes integration tests' do
|
14
14
|
include PrimarySocket
|
15
15
|
|
16
|
+
require_wired_tiger_on_36
|
17
|
+
|
18
|
+
# These tests override server selector, which fails if there are multiple
|
19
|
+
# eligible servers as would be the case in a multi-shard sharded cluster
|
20
|
+
require_no_multi_shard
|
21
|
+
|
16
22
|
before do
|
17
23
|
authorized_collection.delete_many
|
18
24
|
end
|
@@ -114,8 +120,8 @@ describe 'Retryable writes integration tests' do
|
|
114
120
|
context 'when the selected server does not support retryable writes' do
|
115
121
|
|
116
122
|
before do
|
117
|
-
legacy_primary = double('legacy primary', :
|
118
|
-
|
123
|
+
legacy_primary = double('legacy primary', :retry_writes? => false)
|
124
|
+
expect(collection).to receive(:select_server).and_return(primary_server, legacy_primary)
|
119
125
|
expect(primary_socket).to receive(:write).and_raise(error)
|
120
126
|
end
|
121
127
|
|
@@ -688,21 +694,4 @@ describe 'Retryable writes integration tests' do
|
|
688
694
|
|
689
695
|
it_behaves_like 'an operation that does not support retryable writes'
|
690
696
|
end
|
691
|
-
|
692
|
-
context 'when the operation is database#command' do
|
693
|
-
|
694
|
-
let(:operation) do
|
695
|
-
collection.database.command(ping: 1)
|
696
|
-
end
|
697
|
-
|
698
|
-
let(:expectation) do
|
699
|
-
0
|
700
|
-
end
|
701
|
-
|
702
|
-
let(:unsuccessful_retry_value) do
|
703
|
-
0
|
704
|
-
end
|
705
|
-
|
706
|
-
it_behaves_like 'an operation that does not support retryable writes'
|
707
|
-
end
|
708
697
|
end
|
@@ -7,7 +7,7 @@ describe 'SDAM error handling' do
|
|
7
7
|
|
8
8
|
# These tests operate on specific servers, and don't work in a multi
|
9
9
|
# shard cluster where multiple servers are equally eligible
|
10
|
-
|
10
|
+
require_no_multi_shard
|
11
11
|
|
12
12
|
let(:client) { authorized_client_without_any_retries }
|
13
13
|
|
@@ -17,7 +17,7 @@ describe 'SDAM events' do
|
|
17
17
|
client.database.command(ismaster: 1)
|
18
18
|
expect(subscriber.events).to be_empty
|
19
19
|
|
20
|
-
client.close
|
20
|
+
client.close(true)
|
21
21
|
|
22
22
|
expect(subscriber.events).not_to be_empty
|
23
23
|
event = subscriber.first_event('server_closed_event')
|
@@ -35,7 +35,7 @@ describe 'SDAM events' do
|
|
35
35
|
client.database.command(ismaster: 1)
|
36
36
|
expect(subscriber.events).to be_empty
|
37
37
|
|
38
|
-
client.close
|
38
|
+
client.close(true)
|
39
39
|
|
40
40
|
expect(subscriber.events).not_to be_empty
|
41
41
|
event = subscriber.first_event('topology_closed_event')
|
@@ -1,15 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Server description' do
|
4
|
+
clean_slate
|
5
|
+
|
6
|
+
let(:client) { ClientRegistry.instance.global_client('authorized') }
|
7
|
+
let(:desc) do
|
8
|
+
client.cluster.next_primary.description
|
9
|
+
end
|
10
|
+
|
11
|
+
let!(:start_time) { Time.now }
|
12
|
+
|
4
13
|
describe '#op_time' do
|
5
14
|
require_topology :replica_set
|
6
15
|
min_server_fcv '3.4'
|
7
16
|
|
8
|
-
let(:client) { ClientRegistry.instance.global_client('authorized') }
|
9
|
-
let(:desc) { client.cluster.servers.first.description }
|
10
|
-
|
11
17
|
it 'is set' do
|
12
|
-
|
18
|
+
expect(desc).not_to be_unknown
|
13
19
|
|
14
20
|
expect(desc.op_time).to be_a(BSON::Timestamp)
|
15
21
|
end
|
@@ -19,30 +25,21 @@ describe 'Server description' do
|
|
19
25
|
require_topology :replica_set
|
20
26
|
min_server_fcv '3.4'
|
21
27
|
|
22
|
-
let(:client) { ClientRegistry.instance.global_client('authorized') }
|
23
|
-
let(:desc) { client.cluster.servers.first.description }
|
24
|
-
|
25
28
|
it 'is set' do
|
26
|
-
|
29
|
+
expect(desc).not_to be_unknown
|
27
30
|
|
28
31
|
expect(desc.last_write_date).to be_a(Time)
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
32
35
|
describe '#last_update_time' do
|
33
|
-
before do
|
34
|
-
ClientRegistry.instance.close_all_clients
|
35
|
-
end
|
36
|
-
|
37
|
-
let(:client) { ClientRegistry.instance.global_client('authorized') }
|
38
|
-
let(:desc) { client.cluster.next_primary.description }
|
39
36
|
|
40
37
|
it 'is set' do
|
41
|
-
|
38
|
+
expect(desc).not_to be_unknown
|
42
39
|
|
43
40
|
expect(desc.last_update_time).to be_a(Time)
|
44
|
-
# checked
|
45
|
-
expect(
|
41
|
+
# checked while this test was running
|
42
|
+
expect(desc.last_update_time).to be > start_time
|
46
43
|
end
|
47
44
|
end
|
48
45
|
end
|
@@ -6,6 +6,10 @@ describe 'Server selector' do
|
|
6
6
|
let(:cluster) { client.cluster }
|
7
7
|
|
8
8
|
describe '#select_server' do
|
9
|
+
# These tests operate on specific servers, and don't work in a multi
|
10
|
+
# shard cluster where multiple servers are equally eligible
|
11
|
+
require_no_multi_shard
|
12
|
+
|
9
13
|
let(:result) { selector.select_server(cluster) }
|
10
14
|
|
11
15
|
it 'selects' do
|
@@ -13,7 +17,7 @@ describe 'Server selector' do
|
|
13
17
|
end
|
14
18
|
|
15
19
|
context 'no servers in the cluster' do
|
16
|
-
let(:client) {
|
20
|
+
let(:client) { new_local_client_nmio([], server_selection_timeout: 2) }
|
17
21
|
|
18
22
|
it 'raises NoServerAvailable with a message explaining the situation' do
|
19
23
|
expect do
|
@@ -35,7 +39,7 @@ describe 'Server selector' do
|
|
35
39
|
context 'there is a known primary' do
|
36
40
|
before do
|
37
41
|
client.cluster.next_primary
|
38
|
-
client.close
|
42
|
+
client.close(true)
|
39
43
|
expect(client.cluster.connected?).to be false
|
40
44
|
end
|
41
45
|
|
@@ -47,7 +51,7 @@ describe 'Server selector' do
|
|
47
51
|
context 'there is no known primary' do
|
48
52
|
before do
|
49
53
|
primary_server = client.cluster.next_primary
|
50
|
-
client.close
|
54
|
+
client.close(true)
|
51
55
|
expect(client.cluster.connected?).to be false
|
52
56
|
primary_server.unknown!
|
53
57
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Server' do
|
4
|
+
let(:client) { authorized_client }
|
5
|
+
|
6
|
+
let(:server) { client.cluster.next_primary }
|
7
|
+
|
8
|
+
let(:collection) { client['collection'] }
|
9
|
+
let(:view) { Mongo::Collection::View.new(collection) }
|
10
|
+
|
11
|
+
describe 'operations when client/cluster are disconnected' do
|
12
|
+
# Server versions lower than 3.4 use the legacy find result
|
13
|
+
min_server_fcv '3.4'
|
14
|
+
|
15
|
+
context 'normal server' do
|
16
|
+
it 'can be used for reads' do
|
17
|
+
result = view.send(:send_initial_query, server)
|
18
|
+
expect(result).to be_a(Mongo::Operation::Find::Result)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'known server in disconnected cluster' do
|
23
|
+
before do
|
24
|
+
client.close
|
25
|
+
expect(server).not_to be_unknown
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'can be used for reads' do
|
29
|
+
result = view.send(:send_initial_query, server)
|
30
|
+
expect(result).to be_a(Mongo::Operation::Find::Result)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'unknown server in disconnected cluster' do
|
35
|
+
before do
|
36
|
+
client.close
|
37
|
+
server.unknown!
|
38
|
+
expect(server).to be_unknown
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'can be used for reads' do
|
42
|
+
result = view.send(:send_initial_query, server)
|
43
|
+
# Driver falls back to the oldest MongoDB protocol
|
44
|
+
expect(result).to be_a(Mongo::Operation::Find::Legacy::Result)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -19,7 +19,7 @@ describe 'SSL connections with URI options' do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'successfully connects and runs an operation' do
|
22
|
-
client =
|
22
|
+
client = new_local_client(uri)
|
23
23
|
expect { client[:foo].count_documents({}) }.not_to raise_error
|
24
24
|
end
|
25
25
|
end
|
@@ -3,12 +3,19 @@ require 'spec_helper'
|
|
3
3
|
describe 'Step down behavior' do
|
4
4
|
require_topology :replica_set
|
5
5
|
|
6
|
-
|
6
|
+
# This setup reduces the runtime of the test and makes execution more
|
7
|
+
# reliable. The spec as written requests a simple brute force step down,
|
8
|
+
# but this causes intermittent failures.
|
7
9
|
before(:all) do
|
8
10
|
# These before/after blocks are run even if the tests themselves are
|
9
11
|
# skipped due to server version not being appropriate
|
10
12
|
if ClusterConfig.instance.fcv_ish >= '4.2' && ClusterConfig.instance.topology == :replica_set
|
11
|
-
|
13
|
+
# It seems that a short election timeout can cause unintended elections,
|
14
|
+
# which makes the server close connections which causes the driver to
|
15
|
+
# reconnect which then fails the step down test.
|
16
|
+
# The election timeout here is greater than the catch up period and
|
17
|
+
# step down timeout specified in cluster tools.
|
18
|
+
ClusterTools.instance.set_election_timeout(5)
|
12
19
|
ClusterTools.instance.set_election_handoff(false)
|
13
20
|
end
|
14
21
|
end
|
@@ -20,7 +27,6 @@ describe 'Step down behavior' do
|
|
20
27
|
ClusterTools.instance.reset_priorities
|
21
28
|
end
|
22
29
|
end
|
23
|
-
=end
|
24
30
|
|
25
31
|
let(:event_subscriber) { EventSubscriber.new }
|
26
32
|
|
@@ -70,7 +76,7 @@ describe 'Step down behavior' do
|
|
70
76
|
expect(connection_created_events).not_to be_empty
|
71
77
|
|
72
78
|
current_primary = subscribed_client.cluster.next_primary
|
73
|
-
ClusterTools.instance.
|
79
|
+
ClusterTools.instance.change_primary
|
74
80
|
|
75
81
|
EventSubscriber.clear_events!
|
76
82
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Transactions examples' do
|
4
|
+
require_wired_tiger
|
4
5
|
require_transaction_support
|
5
6
|
|
6
7
|
let(:hr) do
|
@@ -44,8 +45,8 @@ describe 'Transactions examples' do
|
|
44
45
|
session.commit_transaction
|
45
46
|
puts 'Transaction committed.'
|
46
47
|
rescue Mongo::Error => e
|
47
|
-
if e.label?(
|
48
|
-
puts "
|
48
|
+
if e.label?('UnknownTransactionCommitResult')
|
49
|
+
puts "UnknownTransactionCommitResult, retrying commit operation..."
|
49
50
|
retry
|
50
51
|
else
|
51
52
|
puts 'Error during commit ...'
|
@@ -80,9 +81,9 @@ describe 'Transactions examples' do
|
|
80
81
|
rescue Mongo::Error => e
|
81
82
|
|
82
83
|
puts 'Transaction aborted. Caught exception during transaction.'
|
83
|
-
raise unless e.label?(
|
84
|
+
raise unless e.label?('TransientTransactionError')
|
84
85
|
|
85
|
-
puts "
|
86
|
+
puts "TransientTransactionError, retrying transaction ..."
|
86
87
|
retry
|
87
88
|
end
|
88
89
|
end
|
@@ -110,8 +111,8 @@ describe 'Transactions examples' do
|
|
110
111
|
session.commit_transaction
|
111
112
|
puts 'Transaction committed.'
|
112
113
|
rescue Mongo::Error=> e
|
113
|
-
if e.label?(
|
114
|
-
puts "
|
114
|
+
if e.label?('UnknownTransactionCommitResult')
|
115
|
+
puts "UnknownTransactionCommitResult, retrying commit operation..."
|
115
116
|
retry
|
116
117
|
else
|
117
118
|
puts 'Error during commit ...'
|
@@ -154,8 +155,8 @@ describe 'Transactions examples' do
|
|
154
155
|
yield session # performs transaction
|
155
156
|
rescue Mongo::Error => e
|
156
157
|
puts 'Transaction aborted. Caught exception during transaction.'
|
157
|
-
raise unless e.label?(
|
158
|
-
puts "
|
158
|
+
raise unless e.label?('TransientTransactionError')
|
159
|
+
puts "TransientTransactionError, retrying transaction ..."
|
159
160
|
retry
|
160
161
|
end
|
161
162
|
end
|
@@ -165,8 +166,8 @@ describe 'Transactions examples' do
|
|
165
166
|
session.commit_transaction
|
166
167
|
puts 'Transaction committed.'
|
167
168
|
rescue Mongo::Error => e
|
168
|
-
if e.label?(
|
169
|
-
puts "
|
169
|
+
if e.label?('UnknownTransactionCommitResult')
|
170
|
+
puts "UnknownTransactionCommitResult, retrying commit operation ..."
|
170
171
|
retry
|
171
172
|
else
|
172
173
|
puts 'Error during commit ...'
|
data/spec/lite_spec_helper.rb
CHANGED
@@ -1,24 +1,27 @@
|
|
1
1
|
COVERAGE_MIN = 90
|
2
2
|
CURRENT_PATH = File.expand_path(File.dirname(__FILE__))
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
|
4
|
+
SERVER_DISCOVERY_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/sdam/**/*.yml").sort
|
5
|
+
SDAM_MONITORING_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/sdam_monitoring/*.yml").sort
|
6
|
+
SERVER_SELECTION_RTT_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/server_selection_rtt/*.yml").sort
|
7
|
+
SERVER_SELECTION_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/server_selection/**/*.yml").sort
|
8
|
+
MAX_STALENESS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/max_staleness/**/*.yml").sort
|
9
|
+
CRUD_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/crud/**/*.yml").sort
|
10
|
+
CRUD2_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/crud_v2/**/*.yml").sort
|
11
|
+
RETRYABLE_WRITES_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/retryable_writes/**/*.yml").sort
|
10
12
|
RETRYABLE_READS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/retryable_reads/**/*.yml").sort
|
11
|
-
COMMAND_MONITORING_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/command_monitoring/**/*.yml")
|
12
|
-
CONNECTION_STRING_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/connection_string/*.yml")
|
13
|
-
URI_OPTIONS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/uri_options/*.yml")
|
14
|
-
DNS_SEEDLIST_DISCOVERY_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/dns_seedlist_discovery/*.yml")
|
15
|
-
GRIDFS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/gridfs/*.yml")
|
16
|
-
TRANSACTIONS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/transactions/*.yml")
|
17
|
-
TRANSACTIONS_API_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/transactions_api/*.yml")
|
18
|
-
CHANGE_STREAMS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/change_streams/*.yml")
|
19
|
-
CMAP_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/cmap/*.yml")
|
13
|
+
COMMAND_MONITORING_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/command_monitoring/**/*.yml").sort
|
14
|
+
CONNECTION_STRING_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/connection_string/*.yml").sort
|
15
|
+
URI_OPTIONS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/uri_options/*.yml").sort
|
16
|
+
DNS_SEEDLIST_DISCOVERY_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/dns_seedlist_discovery/*.yml").sort
|
17
|
+
GRIDFS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/gridfs/*.yml").sort
|
18
|
+
TRANSACTIONS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/transactions/*.yml").sort
|
19
|
+
TRANSACTIONS_API_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/transactions_api/*.yml").sort
|
20
|
+
CHANGE_STREAMS_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/change_streams/*.yml").sort
|
21
|
+
CMAP_TESTS = Dir.glob("#{CURRENT_PATH}/spec_tests/data/cmap/*.yml").sort
|
20
22
|
|
21
23
|
require 'mongo'
|
24
|
+
require 'pp'
|
22
25
|
|
23
26
|
unless ENV['CI']
|
24
27
|
begin
|
@@ -1,11 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
# This test should set cleanup: false on all clients, because due to
|
4
|
+
# https://jira.mongodb.org/browse/RUBY-1772 we may be getting connections
|
5
|
+
# established after the client is closed which screws up our assertions on
|
6
|
+
# the auth calls. When 1772 is fixed, the cleanup should happen on existing
|
7
|
+
# connections and thus should no longer interfere with auth assertions.
|
8
|
+
|
3
9
|
describe 'SCRAM-SHA auth mechanism negotiation' do
|
4
10
|
min_server_fcv '4.0'
|
5
|
-
|
6
|
-
before(:all) do
|
7
|
-
ClientRegistry.instance.close_all_clients
|
8
|
-
end
|
11
|
+
clean_slate
|
9
12
|
|
10
13
|
URI_OPTION_MAP = {
|
11
14
|
:auth_source => 'authsource',
|
@@ -13,7 +16,7 @@ describe 'SCRAM-SHA auth mechanism negotiation' do
|
|
13
16
|
}
|
14
17
|
|
15
18
|
let(:create_user!) do
|
16
|
-
|
19
|
+
root_authorized_admin_client.tap do |client|
|
17
20
|
users = client.database.users
|
18
21
|
if users.info(user.name).any?
|
19
22
|
users.remove(user.name)
|
@@ -24,7 +27,7 @@ describe 'SCRAM-SHA auth mechanism negotiation' do
|
|
24
27
|
roles: ['root'],
|
25
28
|
mechanisms: server_user_auth_mechanisms,
|
26
29
|
)
|
27
|
-
client.close
|
30
|
+
client.close(true)
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
@@ -49,7 +52,7 @@ describe 'SCRAM-SHA auth mechanism negotiation' do
|
|
49
52
|
|
50
53
|
new_local_client(
|
51
54
|
SpecConfig.instance.addresses,
|
52
|
-
SpecConfig.instance.test_options.merge(opts)
|
55
|
+
SpecConfig.instance.test_options.merge(opts).update(cleanup: false)
|
53
56
|
)
|
54
57
|
end
|
55
58
|
|
@@ -332,7 +335,7 @@ describe 'SCRAM-SHA auth mechanism negotiation' do
|
|
332
335
|
end
|
333
336
|
|
334
337
|
let(:client) do
|
335
|
-
new_local_client(uri, SpecConfig.instance.ssl_options)
|
338
|
+
new_local_client(uri, SpecConfig.instance.ssl_options.merge(cleanup: false))
|
336
339
|
end
|
337
340
|
|
338
341
|
context 'when the user exists' do
|
@@ -150,8 +150,8 @@ describe Mongo::BulkWrite::OrderedCombiner do
|
|
150
150
|
[
|
151
151
|
{
|
152
152
|
replace_one: [
|
153
|
-
{ 'q' => { _id: 0 }, 'u' => { name: 'test' },
|
154
|
-
{ 'q' => { _id: 1 }, 'u' => { name: 'test' },
|
153
|
+
{ 'q' => { _id: 0 }, 'u' => { name: 'test' }, },
|
154
|
+
{ 'q' => { _id: 1 }, 'u' => { name: 'test' }, },
|
155
155
|
]
|
156
156
|
}
|
157
157
|
]
|
@@ -192,8 +192,8 @@ describe Mongo::BulkWrite::OrderedCombiner do
|
|
192
192
|
[
|
193
193
|
{
|
194
194
|
update_one: [
|
195
|
-
{ 'q' => { _id: 0 }, 'u' => { '$set' => { name: 'test' }},
|
196
|
-
{ 'q' => { _id: 1 }, 'u' => { '$set' => { name: 'test' }},
|
195
|
+
{ 'q' => { _id: 0 }, 'u' => { '$set' => { name: 'test' }}, },
|
196
|
+
{ 'q' => { _id: 1 }, 'u' => { '$set' => { name: 'test' }}, },
|
197
197
|
]
|
198
198
|
}
|
199
199
|
]
|
@@ -234,8 +234,8 @@ describe Mongo::BulkWrite::OrderedCombiner do
|
|
234
234
|
[
|
235
235
|
{
|
236
236
|
update_many: [
|
237
|
-
{ 'q' => { _id: 0 }, 'u' => { '$set' => { name: 'test' }}, 'multi' => true,
|
238
|
-
{ 'q' => { _id: 1 }, 'u' => { '$set' => { name: 'test' }}, 'multi' => true,
|
237
|
+
{ 'q' => { _id: 0 }, 'u' => { '$set' => { name: 'test' }}, 'multi' => true, },
|
238
|
+
{ 'q' => { _id: 1 }, 'u' => { '$set' => { name: 'test' }}, 'multi' => true, },
|
239
239
|
]
|
240
240
|
}
|
241
241
|
]
|