mongo 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/mongo/auth/cr/conversation.rb +0 -1
  5. data/lib/mongo/client.rb +19 -5
  6. data/lib/mongo/cluster.rb +84 -16
  7. data/lib/mongo/cluster/topology.rb +3 -4
  8. data/lib/mongo/cluster/topology/replica_set.rb +75 -0
  9. data/lib/mongo/cluster/topology/sharded.rb +60 -0
  10. data/lib/mongo/cluster/topology/single.rb +51 -0
  11. data/lib/mongo/cluster/topology/unknown.rb +62 -0
  12. data/lib/mongo/error/invalid_bulk_operation.rb +2 -1
  13. data/lib/mongo/event.rb +9 -9
  14. data/lib/mongo/event/{server_added.rb → description_changed.rb} +6 -5
  15. data/lib/mongo/event/{server_removed.rb → standalone_discovered.rb} +15 -15
  16. data/lib/mongo/operation/aggregate.rb +6 -5
  17. data/lib/mongo/operation/command.rb +5 -6
  18. data/lib/mongo/operation/kill_cursors.rb +3 -2
  19. data/lib/mongo/operation/map_reduce.rb +6 -5
  20. data/lib/mongo/operation/read/collections_info.rb +5 -4
  21. data/lib/mongo/operation/read/get_more.rb +8 -7
  22. data/lib/mongo/operation/read/indexes.rb +4 -3
  23. data/lib/mongo/operation/read/list_collections.rb +5 -4
  24. data/lib/mongo/operation/read/list_indexes.rb +7 -6
  25. data/lib/mongo/operation/read/query.rb +8 -7
  26. data/lib/mongo/operation/read_preferrable.rb +6 -2
  27. data/lib/mongo/operation/write/bulk/bulk_delete.rb +13 -12
  28. data/lib/mongo/operation/write/bulk/bulk_insert.rb +10 -9
  29. data/lib/mongo/operation/write/bulk/bulk_insert/result.rb +2 -2
  30. data/lib/mongo/operation/write/bulk/bulk_update.rb +12 -11
  31. data/lib/mongo/operation/write/create_index.rb +8 -7
  32. data/lib/mongo/operation/write/create_user.rb +4 -3
  33. data/lib/mongo/operation/write/delete.rb +13 -12
  34. data/lib/mongo/operation/write/drop_index.rb +6 -5
  35. data/lib/mongo/operation/write/insert.rb +8 -7
  36. data/lib/mongo/operation/write/insert/result.rb +1 -1
  37. data/lib/mongo/operation/write/remove_user.rb +4 -3
  38. data/lib/mongo/operation/write/update.rb +10 -9
  39. data/lib/mongo/operation/write/update_user.rb +4 -3
  40. data/lib/mongo/server.rb +8 -15
  41. data/lib/mongo/server/context.rb +2 -2
  42. data/lib/mongo/server/description.rb +65 -3
  43. data/lib/mongo/server/description/features.rb +2 -1
  44. data/lib/mongo/server/description/inspector.rb +5 -5
  45. data/lib/mongo/server/description/inspector/{server_added.rb → description_changed.rb} +3 -5
  46. data/lib/mongo/server/description/inspector/{server_removed.rb → standalone_discovered.rb} +12 -15
  47. data/lib/mongo/version.rb +1 -1
  48. data/spec/mongo/auth/cr_spec.rb +1 -1
  49. data/spec/mongo/auth/ldap_spec.rb +1 -1
  50. data/spec/mongo/auth/scram_spec.rb +1 -1
  51. data/spec/mongo/auth/x509_spec.rb +1 -1
  52. data/spec/mongo/client_spec.rb +4 -0
  53. data/spec/mongo/cluster/topology/replica_set_spec.rb +254 -4
  54. data/spec/mongo/cluster/topology/sharded_spec.rb +70 -19
  55. data/spec/mongo/cluster/topology/single_spec.rb +25 -4
  56. data/spec/mongo/cluster/topology/unknown_spec.rb +167 -0
  57. data/spec/mongo/cluster/topology_spec.rb +6 -6
  58. data/spec/mongo/cluster_spec.rb +179 -1
  59. data/spec/mongo/operation/read_preferrable_spec.rb +81 -28
  60. data/spec/mongo/operation/write/bulk/bulk_delete_spec.rb +1 -0
  61. data/spec/mongo/server/connection_pool_spec.rb +10 -10
  62. data/spec/mongo/server/connection_spec.rb +1 -1
  63. data/spec/mongo/server/description/features_spec.rb +23 -3
  64. data/spec/mongo/server/description/inspector/description_changed_spec.rb +78 -0
  65. data/spec/mongo/server/description_spec.rb +238 -0
  66. data/spec/mongo/server/monitor_spec.rb +1 -1
  67. data/spec/mongo/server_discovery_and_monitoring_spec.rb +20 -4
  68. data/spec/mongo/server_selection_spec.rb +2 -2
  69. data/spec/mongo/server_spec.rb +12 -8
  70. data/spec/support/authorization.rb +8 -8
  71. data/spec/support/sdam/rs/discover_passives.yml +36 -0
  72. data/spec/support/sdam/rs/new_primary_wrong_set_name.yml +2 -2
  73. data/spec/support/sdam/rs/primary_becomes_standalone.yml +1 -1
  74. data/spec/support/sdam/rs/primary_changes_set_name.yml +2 -2
  75. data/spec/support/sdam/rs/primary_disconnect.yml +1 -1
  76. data/spec/support/sdam/rs/primary_wrong_set_name.yml +1 -1
  77. data/spec/support/sdam/rs/secondary_wrong_set_name.yml +1 -1
  78. data/spec/support/sdam/rs/secondary_wrong_set_name_with_primary.yml +2 -2
  79. data/spec/support/sdam/sharded/single_mongos.yml +33 -0
  80. data/spec/support/shared/operation.rb +12 -4
  81. data/spec/support/shared/server_selector.rb +1 -1
  82. metadata +12 -10
  83. metadata.gz.sig +0 -0
  84. data/spec/mongo/server/description/inspector/server_added_spec.rb +0 -92
  85. data/spec/mongo/server/description/inspector/server_removed_spec.rb +0 -95
metadata.gz.sig CHANGED
Binary file
@@ -1,92 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Mongo::Server::Description::Inspector::ServerAdded do
4
-
5
- let(:listeners) do
6
- Mongo::Event::Listeners.new
7
- end
8
-
9
- let(:inspection) do
10
- described_class.new(listeners)
11
- end
12
-
13
- let(:address) do
14
- Mongo::Address.new('127.0.0.1:27017')
15
- end
16
-
17
- describe '#run' do
18
-
19
- let(:config) do
20
- {
21
- 'ismaster' => true,
22
- 'secondary' => false,
23
- 'hosts' => [ '127.0.0.1:27018', '127.0.0.1:27019' ],
24
- 'setName' => 'test'
25
- }
26
- end
27
-
28
- let(:description) do
29
- Mongo::Server::Description.new(address, config, listeners)
30
- end
31
-
32
- let(:updated) do
33
- Mongo::Server::Description.new(address, new_config, listeners)
34
- end
35
-
36
- let(:listener) do
37
- double('listener')
38
- end
39
-
40
- before do
41
- listeners.add_listener(Mongo::Event::SERVER_ADDED, listener)
42
- end
43
-
44
- context 'when a host is added' do
45
-
46
- let(:new_config) do
47
- { 'hosts' => [ '127.0.0.1:27019', '127.0.0.1:27020' ] }
48
- end
49
-
50
- it 'fires a server added event' do
51
- expect(listener).to receive(:handle).with('127.0.0.1:27020')
52
- inspection.run(description, updated)
53
- end
54
- end
55
-
56
- context 'when an arbiter is added' do
57
-
58
- let(:new_config) do
59
- { 'arbiters' => [ '127.0.0.1:27020' ] }
60
- end
61
-
62
- it 'fires a server added event' do
63
- expect(listener).to receive(:handle).with('127.0.0.1:27020')
64
- inspection.run(description, updated)
65
- end
66
- end
67
-
68
- context 'when a passive is added' do
69
-
70
- let(:new_config) do
71
- { 'passives' => [ '127.0.0.1:27020' ] }
72
- end
73
-
74
- it 'fires a server added event' do
75
- expect(listener).to receive(:handle).with('127.0.0.1:27020')
76
- inspection.run(description, updated)
77
- end
78
- end
79
-
80
- context 'when no server is added' do
81
-
82
- let(:new_config) do
83
- { 'hosts' => [ '127.0.0.1:27018', '127.0.0.1:27019' ] }
84
- end
85
-
86
- it 'fires no event' do
87
- expect(listener).to_not receive(:handle)
88
- inspection.run(description, updated)
89
- end
90
- end
91
- end
92
- end
@@ -1,95 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Mongo::Server::Description::Inspector::ServerRemoved do
4
-
5
- let(:listeners) do
6
- Mongo::Event::Listeners.new
7
- end
8
-
9
- let(:inspection) do
10
- described_class.new(listeners)
11
- end
12
-
13
- let(:address) do
14
- Mongo::Address.new('127.0.0.1:27017')
15
- end
16
-
17
- describe '.run' do
18
-
19
- let(:config) do
20
- {
21
- 'ismaster' => true,
22
- 'secondary' => false,
23
- 'hosts' => [ '127.0.0.1:27018', '127.0.0.1:27019' ],
24
- 'setName' => 'test'
25
- }
26
- end
27
-
28
- let(:description) do
29
- Mongo::Server::Description.new(address, config, listeners)
30
- end
31
-
32
- let(:updated) do
33
- Mongo::Server::Description.new(address, new_config, listeners)
34
- end
35
-
36
- let(:listener) do
37
- double('listener')
38
- end
39
-
40
- before do
41
- listeners.add_listener(Mongo::Event::SERVER_REMOVED, listener)
42
- end
43
-
44
- context 'when no server is removed' do
45
-
46
- let(:new_config) do
47
- {
48
- 'hosts' => [ '127.0.0.1:27018', '127.0.0.1:27019' ],
49
- 'ismaster' => true,
50
- 'setName' => 'test'
51
- }
52
- end
53
-
54
- it 'does not fire a server removed event' do
55
- expect(listener).to_not receive(:handle)
56
- inspection.run(description, updated)
57
- end
58
- end
59
-
60
- context 'when a server is removed' do
61
-
62
- context 'when the server is a primary' do
63
-
64
- let(:new_config) do
65
- {
66
- 'hosts' => [ '127.0.0.1:27019', '127.0.0.1:27020' ],
67
- 'ismaster' => true,
68
- 'setName' => 'test'
69
- }
70
- end
71
-
72
- it 'fires a server removed event' do
73
- expect(listener).to receive(:handle).with('127.0.0.1:27018')
74
- inspection.run(description, updated)
75
- end
76
- end
77
-
78
- context 'when the server is not a primary' do
79
-
80
- let(:new_config) do
81
- {
82
- 'hosts' => [ '127.0.0.1:27019', '127.0.0.1:27020' ],
83
- 'secondary' => true,
84
- 'setName' => 'test'
85
- }
86
- end
87
-
88
- it 'does not fire a server removed event' do
89
- expect(listener).to_not receive(:handle)
90
- inspection.run(description, updated)
91
- end
92
- end
93
- end
94
- end
95
- end