mongo 1.12.0.rc0 → 1.12.0.rc1
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 +1 -4
- data.tar.gz.sig +0 -0
- data/VERSION +1 -1
- data/lib/mongo/collection.rb +6 -0
- data/lib/mongo/db.rb +3 -0
- data/lib/mongo/networking.rb +4 -2
- data/test/functional/client_test.rb +39 -9
- data/test/functional/db_test.rb +2 -1
- data/test/helpers/test_unit.rb +8 -6
- data/test/replica_set/authentication_test.rb +1 -1
- data/test/replica_set/basic_test.rb +1 -1
- data/test/replica_set/client_test.rb +1 -1
- data/test/replica_set/count_test.rb +1 -1
- data/test/replica_set/cursor_test.rb +1 -1
- data/test/replica_set/insert_test.rb +1 -1
- data/test/replica_set/max_values_test.rb +1 -1
- data/test/replica_set/pinning_test.rb +1 -1
- data/test/replica_set/query_test.rb +1 -1
- data/test/replica_set/read_preference_test.rb +97 -98
- data/test/replica_set/refresh_test.rb +6 -3
- data/test/replica_set/replication_ack_test.rb +2 -2
- data/test/tools/mongo_config.rb +2 -0
- metadata +4 -6
- metadata.gz.sig +0 -0
- data/test/replica_set/complex_connect_test.rb +0 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c40b2e0b36d1dab70bbf23b20961b950469a640
|
4
|
+
data.tar.gz: e5c58505d9876a76b88ad649292e2472b78c5d4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e35166ca0624f7b166f2761ee67b166a2c4e7893c317452c529d04e270f03d986b76c22138f5b32546ef5decea0fc4f24fb26bea066ba8bdc6e0245f62727ec4
|
7
|
+
data.tar.gz: 6b49f4cceb3e1ecafe5cbaaa5e0c7a54ae295735e43d9b36cf0ad88d1167165190215468d3eccce6d57d21c9f1e904bec35167af289f2c1590ebb3df44c7b2b9
|
checksums.yaml.gz.sig
CHANGED
@@ -1,4 +1 @@
|
|
1
|
-
|
2
|
-
3��2�����:@�/d5'�"��]�:���(w�H�9
|
3
|
-
��l�c`�J��J~�MG��8�oQ�%��h&nh���I9��*R��|~y�a/��`�Oπ6F+�8�C��_t��h�AQY�Wp
|
4
|
-
�W�2���RZ��S;9�����F�y�D�4�0*�� ��#�m����"�R��c��N�R�f���w�X�}����p�S���nj��8��G����'��lf���
|
1
|
+
5pj�&:��y�?iˁ����C nܧv1��5Qi;g�d̰+��3���T�r[�l���k����z�nG��g�I�G�(�`�zSI\=%���� ��{���rP@žk3�(N��cP,�H�J-�E������/ b��h�M��>2��z!�x��:uI��=x���}���\62�ٝR��Gh���~� jT^��Ѭ�÷���%��Ƣv�6�ǔ����|^����eR���;�+�
|
data.tar.gz.sig
CHANGED
Binary file
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.12.0.
|
1
|
+
1.12.0.rc1
|
data/lib/mongo/collection.rb
CHANGED
@@ -550,6 +550,9 @@ module Mongo
|
|
550
550
|
# The option is silently ignored by the server and unique index builds using the option will
|
551
551
|
# fail if a duplicate value is detected.
|
552
552
|
#
|
553
|
+
# @note Note that the options listed may be subset of those available.
|
554
|
+
# See the MongoDB documentation for a full list of supported options by server version.
|
555
|
+
#
|
553
556
|
# @return [String] the name of the index created.
|
554
557
|
def create_index(spec, opts={})
|
555
558
|
options = opts.dup
|
@@ -581,6 +584,9 @@ module Mongo
|
|
581
584
|
# The option is silently ignored by the server and unique index builds using the option will
|
582
585
|
# fail if a duplicate value is detected.
|
583
586
|
#
|
587
|
+
# @note Note that the options listed may be subset of those available.
|
588
|
+
# See the MongoDB documentation for a full list of supported options by server version.
|
589
|
+
#
|
584
590
|
# @return [String] the name of the index.
|
585
591
|
def ensure_index(spec, opts={})
|
586
592
|
now = Time.now.utc.to_i
|
data/lib/mongo/db.rb
CHANGED
@@ -316,6 +316,9 @@ module Mongo
|
|
316
316
|
# either we're in +strict+ mode and the collection
|
317
317
|
# already exists or collection creation fails on the server.
|
318
318
|
#
|
319
|
+
# @note Note that the options listed may be subset of those available.
|
320
|
+
# Please see the MongoDB documentation for a full list of supported options by server version.
|
321
|
+
#
|
319
322
|
# @return [Mongo::Collection]
|
320
323
|
def create_collection(name, opts={})
|
321
324
|
name = name.to_s
|
data/lib/mongo/networking.rb
CHANGED
@@ -86,13 +86,15 @@ module Mongo
|
|
86
86
|
sock = checkout_writer
|
87
87
|
send_message_on_socket(packed_message, sock)
|
88
88
|
docs, num_received, cursor_id = receive(sock, last_error_id)
|
89
|
-
checkin(sock)
|
90
89
|
rescue ConnectionFailure, OperationFailure, OperationTimeout => ex
|
91
|
-
checkin(sock)
|
92
90
|
raise ex
|
93
91
|
rescue SystemStackError, NoMemoryError, SystemCallError => ex
|
94
92
|
close
|
93
|
+
sock = nil
|
95
94
|
raise ex
|
95
|
+
ensure
|
96
|
+
checkin(sock) if sock
|
97
|
+
sock = nil
|
96
98
|
end
|
97
99
|
|
98
100
|
if num_received == 1
|
@@ -452,7 +452,8 @@ class ClientTest < Test::Unit::TestCase
|
|
452
452
|
end
|
453
453
|
|
454
454
|
def test_operation_timeout_with_active
|
455
|
-
conn =
|
455
|
+
conn = MongoClient.new
|
456
|
+
authenticate_client(conn)
|
456
457
|
assert conn.active?
|
457
458
|
assert_equal Mongo::MongoClient::DEFAULT_OP_TIMEOUT, conn.op_timeout
|
458
459
|
|
@@ -518,7 +519,7 @@ class ClientTest < Test::Unit::TestCase
|
|
518
519
|
context "Socket pools" do
|
519
520
|
context "checking out writers" do
|
520
521
|
setup do
|
521
|
-
@con = standard_connection(:pool_size => 10, :pool_timeout =>
|
522
|
+
@con = standard_connection(:pool_size => 10, :pool_timeout => 2)
|
522
523
|
@coll = @con[TEST_DB]['test-connection-exceptions']
|
523
524
|
end
|
524
525
|
|
@@ -532,13 +533,42 @@ class ClientTest < Test::Unit::TestCase
|
|
532
533
|
end
|
533
534
|
end
|
534
535
|
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
536
|
+
context "with GLE" do
|
537
|
+
setup do
|
538
|
+
# Force this connection to use send_message_with_gle for these tests
|
539
|
+
@con.stubs(:use_write_command?).returns(false)
|
540
|
+
end
|
541
|
+
|
542
|
+
should "close the connection on send_message_with_gle for major exceptions" do
|
543
|
+
@con.stubs(:checkout_writer).raises(SystemStackError)
|
544
|
+
@con.stubs(:checkout_reader).raises(SystemStackError)
|
545
|
+
@con.expects(:close)
|
546
|
+
begin
|
547
|
+
@coll.insert({:foo => "bar"}, :w => 1)
|
548
|
+
rescue SystemStackError
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
should "release the connection on send_message_with_gle for connection exceptions" do
|
553
|
+
mock_writer = mock(:close => true)
|
554
|
+
mock_writer.expects(:read).raises(ConnectionFailure)
|
555
|
+
@con.expects(:send_message_on_socket)
|
556
|
+
|
557
|
+
@con.stubs(:checkout_writer).returns(mock_writer)
|
558
|
+
@con.expects(:checkin).with(mock_writer)
|
559
|
+
@coll.insert({:foo => "bar"}, :w => 1) rescue nil
|
560
|
+
end
|
561
|
+
|
562
|
+
should "release the connection on send_message_with_gle for all exceptions" do
|
563
|
+
mock_writer = mock()
|
564
|
+
mock_writer.expects(:read).raises(ArgumentError)
|
565
|
+
@con.expects(:send_message_on_socket)
|
566
|
+
@con.stubs(:checkout_writer).returns(mock_writer)
|
567
|
+
@con.expects(:checkin).with(mock_writer).once
|
568
|
+
begin
|
569
|
+
@coll.insert({:foo => "bar"}, :w => 1)
|
570
|
+
rescue ArgumentError
|
571
|
+
end
|
542
572
|
end
|
543
573
|
end
|
544
574
|
|
data/test/functional/db_test.rb
CHANGED
data/test/helpers/test_unit.rb
CHANGED
@@ -12,9 +12,10 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
TEST_HOST
|
16
|
-
TEST_DATA
|
17
|
-
|
15
|
+
TEST_HOST = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' unless defined? TEST_HOST
|
16
|
+
TEST_DATA = File.join(File.dirname(__FILE__), 'fixtures/data')
|
17
|
+
TEST_OP_TIMEOUT = 40
|
18
|
+
TEST_BASE = Test::Unit::TestCase
|
18
19
|
|
19
20
|
unless defined? TEST_PORT
|
20
21
|
TEST_PORT = if ENV['MONGO_RUBY_DRIVER_PORT']
|
@@ -89,16 +90,17 @@ class Test::Unit::TestCase
|
|
89
90
|
#
|
90
91
|
# @return [MongoClient] The client instance.
|
91
92
|
def self.standard_connection(options={}, legacy=false)
|
93
|
+
opts = options[:op_timeout] ? options : options.merge(:op_timeout => TEST_OP_TIMEOUT)
|
92
94
|
if legacy
|
93
95
|
silently do
|
94
96
|
# We have to create the Connection object directly here instead of using TEST_URI
|
95
97
|
# because Connection#from_uri ends up creating a MongoClient object.
|
96
|
-
conn = Connection.new(TEST_HOST, TEST_PORT,
|
98
|
+
conn = Connection.new(TEST_HOST, TEST_PORT, opts)
|
97
99
|
conn[TEST_DB].authenticate(TEST_USER, TEST_USER_PWD)
|
98
100
|
conn
|
99
101
|
end
|
100
102
|
else
|
101
|
-
MongoClient.from_uri(TEST_URI,
|
103
|
+
MongoClient.from_uri(TEST_URI, opts)
|
102
104
|
end
|
103
105
|
end
|
104
106
|
|
@@ -420,7 +422,7 @@ class Test::Unit::TestCase
|
|
420
422
|
not_cluster = TEST_BASE.class_eval { class_variables }.none? { |v| v =~ /@@cluster_/ }
|
421
423
|
|
422
424
|
if @@connected_single_mongod && not_cluster
|
423
|
-
client = Mongo::MongoClient.from_uri(TEST_URI)
|
425
|
+
client = Mongo::MongoClient.from_uri(TEST_URI, :op_timeout => TEST_OP_TIMEOUT)
|
424
426
|
db = client[TEST_DB]
|
425
427
|
begin
|
426
428
|
begin
|
@@ -28,7 +28,7 @@ class ReplicaSetAuthenticationTest < Test::Unit::TestCase
|
|
28
28
|
|
29
29
|
def setup
|
30
30
|
ensure_cluster(:rs)
|
31
|
-
@client = MongoReplicaSetClient.from_uri(@uri)
|
31
|
+
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
|
32
32
|
@admin = @client['admin']
|
33
33
|
@version = @client.server_version
|
34
34
|
@db = @client['ruby-test']
|
@@ -21,7 +21,7 @@ class ReplicaSetBasicTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_connect
|
24
|
-
client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :name => @rs.repl_set_name)
|
24
|
+
client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :name => @rs.repl_set_name, :op_timeout => TEST_OP_TIMEOUT)
|
25
25
|
assert client.connected?
|
26
26
|
assert_equal @rs.primary_name, client.primary.join(':')
|
27
27
|
assert_equal @rs.secondary_names.sort, client.secondaries.collect{|s| s.join(':')}.sort
|
@@ -26,7 +26,7 @@ class ReplicaSetClientTest < Test::Unit::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_reconnection
|
29
|
-
@client = MongoReplicaSetClient.from_uri(@uri)
|
29
|
+
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
|
30
30
|
assert @client.connected?
|
31
31
|
|
32
32
|
manager = @client.local_manager
|
@@ -18,7 +18,7 @@ class ReplicaSetCountTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
def setup
|
20
20
|
ensure_cluster(:rs)
|
21
|
-
@client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :read => :primary_preferred)
|
21
|
+
@client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :read => :primary_preferred, :op_timeout => TEST_OP_TIMEOUT)
|
22
22
|
authenticate_client(@client)
|
23
23
|
assert @client.primary_pool
|
24
24
|
@primary = MongoClient.new(@client.primary_pool.host, @client.primary_pool.port)
|
@@ -65,7 +65,7 @@ class ReplicaSetCursorTest < Test::Unit::TestCase
|
|
65
65
|
def setup_client(read=:primary)
|
66
66
|
route_read ||= read
|
67
67
|
# Setup ReplicaSet Connection
|
68
|
-
@client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :read => read)
|
68
|
+
@client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :read => read, :op_timeout => TEST_OP_TIMEOUT)
|
69
69
|
authenticate_client(@client)
|
70
70
|
|
71
71
|
@db = @client.db(TEST_DB)
|
@@ -18,7 +18,7 @@ class ReplicaSetInsertTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
def setup
|
20
20
|
ensure_cluster(:rs)
|
21
|
-
@client = MongoReplicaSetClient.from_uri(@uri)
|
21
|
+
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
|
22
22
|
@version = @client.server_version
|
23
23
|
@db = @client.db(TEST_DB)
|
24
24
|
@db.drop_collection("test-sets")
|
@@ -20,7 +20,7 @@ class MaxValuesTest < Test::Unit::TestCase
|
|
20
20
|
|
21
21
|
def setup
|
22
22
|
ensure_cluster(:rs)
|
23
|
-
@client = MongoReplicaSetClient.from_uri(@uri)
|
23
|
+
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
|
24
24
|
@db = new_mock_db
|
25
25
|
@client.stubs(:[]).returns(@db)
|
26
26
|
@ismaster = {
|
@@ -17,7 +17,7 @@ require 'test_helper'
|
|
17
17
|
class ReplicaSetPinningTest < Test::Unit::TestCase
|
18
18
|
def setup
|
19
19
|
ensure_cluster(:rs)
|
20
|
-
@client = MongoReplicaSetClient.from_uri(@uri)
|
20
|
+
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
|
21
21
|
@db = @client.db(TEST_DB)
|
22
22
|
@coll = @db.collection("test-sets")
|
23
23
|
@coll.insert({:a => 1})
|
@@ -18,7 +18,7 @@ class ReplicaSetQueryTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
def setup
|
20
20
|
ensure_cluster(:rs)
|
21
|
-
@client = MongoReplicaSetClient.from_uri(@uri)
|
21
|
+
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
|
22
22
|
@db = @client.db(TEST_DB)
|
23
23
|
@db.drop_collection("test-sets")
|
24
24
|
@coll = @db.collection("test-sets")
|
@@ -17,66 +17,63 @@ require 'test_helper'
|
|
17
17
|
class ReadPreferenceTest < Test::Unit::TestCase
|
18
18
|
|
19
19
|
def setup
|
20
|
-
ensure_cluster(:rs
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
conn = Connection.new(primary.host, primary.port)
|
25
|
-
authenticate_client(conn)
|
26
|
-
db = conn.db(TEST_DB)
|
27
|
-
coll = db.collection("test-sets")
|
20
|
+
ensure_cluster(:rs)
|
21
|
+
client = make_connection
|
22
|
+
db = client.db(TEST_DB)
|
23
|
+
coll = db.collection('test-sets')
|
28
24
|
coll.save({:a => 20}, {:w => 2})
|
29
25
|
end
|
30
26
|
|
31
27
|
def test_read_primary
|
32
|
-
|
28
|
+
client = make_connection
|
33
29
|
rescue_connection_failure do
|
34
|
-
assert
|
35
|
-
assert
|
30
|
+
assert client.read_primary?
|
31
|
+
assert client.primary?
|
36
32
|
end
|
37
33
|
|
38
|
-
|
34
|
+
client = make_connection(:primary_preferred)
|
39
35
|
rescue_connection_failure do
|
40
|
-
assert
|
41
|
-
assert
|
36
|
+
assert client.read_primary?
|
37
|
+
assert client.primary?
|
42
38
|
end
|
43
39
|
|
44
|
-
|
40
|
+
client = make_connection(:secondary)
|
45
41
|
rescue_connection_failure do
|
46
|
-
assert !
|
47
|
-
assert !
|
42
|
+
assert !client.read_primary?
|
43
|
+
assert !client.primary?
|
48
44
|
end
|
49
45
|
|
50
|
-
|
46
|
+
client = make_connection(:secondary_preferred)
|
51
47
|
rescue_connection_failure do
|
52
|
-
assert !
|
53
|
-
assert !
|
48
|
+
assert !client.read_primary?
|
49
|
+
assert !client.primary?
|
54
50
|
end
|
55
51
|
end
|
56
52
|
|
57
53
|
def test_connection_pools
|
58
|
-
|
59
|
-
assert
|
60
|
-
assert
|
61
|
-
assert
|
54
|
+
client = make_connection
|
55
|
+
assert client.primary_pool, "No primary pool!"
|
56
|
+
assert client.read_pool, "No read pool!"
|
57
|
+
assert client.primary_pool.port == client.read_pool.port,
|
62
58
|
"Primary port and read port are not the same!"
|
63
59
|
|
64
|
-
|
65
|
-
|
66
|
-
assert
|
67
|
-
assert
|
60
|
+
|
61
|
+
client = make_connection(:primary_preferred)
|
62
|
+
assert client.primary_pool, "No primary pool!"
|
63
|
+
assert client.read_pool, "No read pool!"
|
64
|
+
assert client.primary_pool.port == client.read_pool.port,
|
68
65
|
"Primary port and read port are not the same!"
|
69
66
|
|
70
|
-
|
71
|
-
assert
|
72
|
-
assert
|
73
|
-
assert
|
67
|
+
client = make_connection(:secondary)
|
68
|
+
assert client.primary_pool, "No primary pool!"
|
69
|
+
assert client.read_pool, "No read pool!"
|
70
|
+
assert client.primary_pool.port != client.read_pool.port,
|
74
71
|
"Primary port and read port are the same!"
|
75
72
|
|
76
|
-
|
77
|
-
assert
|
78
|
-
assert
|
79
|
-
assert
|
73
|
+
client = make_connection(:secondary_preferred)
|
74
|
+
assert client.primary_pool, "No primary pool!"
|
75
|
+
assert client.read_pool, "No read pool!"
|
76
|
+
assert client.primary_pool.port != client.read_pool.port,
|
80
77
|
"Primary port and read port are the same!"
|
81
78
|
end
|
82
79
|
|
@@ -84,97 +81,97 @@ class ReadPreferenceTest < Test::Unit::TestCase
|
|
84
81
|
prepare_routing_test
|
85
82
|
|
86
83
|
# Test that reads are going to the right members
|
87
|
-
assert_query_route(@primary,
|
88
|
-
assert_query_route(@primary_preferred,
|
89
|
-
assert_query_route(@secondary,
|
90
|
-
assert_query_route(@secondary_preferred,
|
84
|
+
assert_query_route(@primary, :primary)
|
85
|
+
assert_query_route(@primary_preferred, :primary)
|
86
|
+
assert_query_route(@secondary, :secondary)
|
87
|
+
assert_query_route(@secondary_preferred, :secondary)
|
91
88
|
end
|
92
89
|
|
93
90
|
def test_read_routing_with_primary_down
|
94
91
|
prepare_routing_test
|
95
92
|
|
96
93
|
# Test that reads are going to the right members
|
97
|
-
assert_query_route(@primary,
|
98
|
-
assert_query_route(@primary_preferred,
|
99
|
-
assert_query_route(@secondary,
|
100
|
-
assert_query_route(@secondary_preferred,
|
94
|
+
assert_query_route(@primary, :primary)
|
95
|
+
assert_query_route(@primary_preferred, :primary)
|
96
|
+
assert_query_route(@secondary, :secondary)
|
97
|
+
assert_query_route(@secondary_preferred, :secondary)
|
101
98
|
|
102
|
-
# Kill the primary so
|
99
|
+
# Kill the primary so the remaining two members are secondaries
|
103
100
|
@rs.primary.kill
|
104
|
-
|
101
|
+
sleep(2)
|
105
102
|
# Test that reads are going to the right members
|
106
103
|
assert_raise_error ConnectionFailure do
|
107
104
|
@primary[TEST_DB]['test-sets'].find_one
|
108
105
|
end
|
109
|
-
assert_query_route(@primary_preferred,
|
110
|
-
assert_query_route(@secondary,
|
111
|
-
assert_query_route(@secondary_preferred,
|
106
|
+
assert_query_route(@primary_preferred, :secondary)
|
107
|
+
assert_query_route(@secondary, :secondary)
|
108
|
+
assert_query_route(@secondary_preferred, :secondary)
|
112
109
|
|
113
110
|
# Restore set
|
114
111
|
@rs.restart
|
115
112
|
sleep(1)
|
116
113
|
@repl_cons.each { |con| con.refresh }
|
117
114
|
sleep(1)
|
118
|
-
@primary_direct = Connection.new(
|
119
|
-
@rs.config['host'],
|
120
|
-
@primary.read_pool.port
|
121
|
-
)
|
122
115
|
|
123
116
|
# Test that reads are going to the right members
|
124
|
-
assert_query_route(@primary,
|
125
|
-
assert_query_route(@primary_preferred,
|
126
|
-
assert_query_route(@secondary,
|
127
|
-
assert_query_route(@secondary_preferred,
|
117
|
+
assert_query_route(@primary, :primary)
|
118
|
+
assert_query_route(@primary_preferred, :primary)
|
119
|
+
assert_query_route(@secondary, :secondary)
|
120
|
+
assert_query_route(@secondary_preferred, :secondary)
|
128
121
|
end
|
129
122
|
|
130
123
|
def test_read_routing_with_secondary_down
|
131
124
|
prepare_routing_test
|
132
125
|
|
133
126
|
# Test that reads are going to the right members
|
134
|
-
assert_query_route(@primary,
|
135
|
-
assert_query_route(@primary_preferred,
|
136
|
-
assert_query_route(@secondary,
|
137
|
-
assert_query_route(@secondary_preferred,
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
127
|
+
assert_query_route(@primary, :primary)
|
128
|
+
assert_query_route(@primary_preferred, :primary)
|
129
|
+
assert_query_route(@secondary, :secondary)
|
130
|
+
assert_query_route(@secondary_preferred, :secondary)
|
131
|
+
|
132
|
+
secondaries = @rs.secondaries
|
133
|
+
secondaries[0].kill
|
134
|
+
assert_query_route(@secondary_preferred, :secondary)
|
135
|
+
|
136
|
+
secondaries[1].kill
|
137
|
+
sleep(2)
|
138
|
+
|
139
|
+
recovered = false
|
140
|
+
until recovered
|
141
|
+
begin
|
142
|
+
@secondary[TEST_DB]['test-sets'].find_one
|
143
|
+
recovered = true
|
144
|
+
rescue ConnectionFailure
|
145
|
+
end
|
147
146
|
end
|
148
|
-
|
147
|
+
|
148
|
+
assert_query_route(@secondary_preferred, :secondary)
|
149
|
+
assert_query_route(@secondary, :secondary)
|
150
|
+
assert_query_route(@primary_preferred, :secondary)
|
149
151
|
|
150
152
|
# Restore set
|
151
153
|
@rs.restart
|
152
154
|
sleep(1)
|
153
155
|
@repl_cons.each { |con| con.refresh }
|
154
156
|
sleep(1)
|
155
|
-
@secondary_direct = Connection.new(
|
156
|
-
@rs.config['host'],
|
157
|
-
@secondary.read_pool.port,
|
158
|
-
:slave_ok => true
|
159
|
-
)
|
160
157
|
|
161
158
|
# Test that reads are going to the right members
|
162
|
-
assert_query_route(@primary,
|
163
|
-
assert_query_route(@primary_preferred,
|
164
|
-
assert_query_route(@secondary,
|
165
|
-
assert_query_route(@secondary_preferred,
|
159
|
+
assert_query_route(@primary, :primary)
|
160
|
+
assert_query_route(@primary_preferred, :primary)
|
161
|
+
assert_query_route(@secondary, :secondary)
|
162
|
+
assert_query_route(@secondary_preferred, :secondary)
|
166
163
|
end
|
167
164
|
|
168
165
|
def test_write_lots_of_data
|
169
|
-
|
170
|
-
|
171
|
-
|
166
|
+
client = make_connection(:secondary_preferred)
|
167
|
+
db = client[TEST_DB]
|
168
|
+
coll = db.collection("test-sets", {:w => 2})
|
172
169
|
|
173
170
|
6000.times do |n|
|
174
|
-
|
171
|
+
coll.save({:a => n})
|
175
172
|
end
|
176
173
|
|
177
|
-
cursor =
|
174
|
+
cursor = coll.find()
|
178
175
|
cursor.next
|
179
176
|
cursor.close
|
180
177
|
end
|
@@ -189,15 +186,14 @@ class ReadPreferenceTest < Test::Unit::TestCase
|
|
189
186
|
@secondary_preferred = make_connection(:secondary_preferred)
|
190
187
|
@repl_cons = [@primary, @primary_preferred, @secondary, @secondary_preferred]
|
191
188
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
@secondary_direct = Connection.new(@rs.config['host'], @secondary.read_pool.port, :slave_ok => true)
|
196
|
-
authenticate_client(@secondary_direct)
|
189
|
+
@repl_cons.each do |client|
|
190
|
+
client.stubs(:pinned_pool).returns(nil)
|
191
|
+
end
|
197
192
|
end
|
198
193
|
|
199
194
|
def make_connection(mode = :primary, opts = {})
|
200
|
-
opts.merge!(
|
195
|
+
opts.merge!(:read => mode)
|
196
|
+
opts.merge!(:op_timeout => nil)
|
201
197
|
client = MongoReplicaSetClient.new(@rs.repl_set_seeds, opts)
|
202
198
|
authenticate_client(client)
|
203
199
|
end
|
@@ -206,15 +202,18 @@ class ReadPreferenceTest < Test::Unit::TestCase
|
|
206
202
|
connection['admin'].command({:serverStatus => 1})['opcounters']['query']
|
207
203
|
end
|
208
204
|
|
209
|
-
def assert_query_route(test_connection,
|
210
|
-
|
205
|
+
def assert_query_route(test_connection, type)
|
206
|
+
secondary = type == :secondary
|
211
207
|
authenticate_client(test_connection)
|
212
|
-
|
213
|
-
queries_before = query_count(expected_target)
|
208
|
+
cursor = test_connection[TEST_DB]['test-sets'].find
|
214
209
|
assert_nothing_raised do
|
215
|
-
|
210
|
+
cursor.next
|
216
211
|
end
|
217
|
-
|
218
|
-
assert_equal
|
212
|
+
pool = cursor.instance_variable_get("@pool")
|
213
|
+
assert_equal secondary, secondary?(MongoClient.new(pool.host, pool.port))
|
214
|
+
end
|
215
|
+
|
216
|
+
def secondary?(client)
|
217
|
+
client['admin'].command(:isMaster => 1)['secondary']
|
219
218
|
end
|
220
219
|
end
|
@@ -22,7 +22,8 @@ class ReplicaSetRefreshTest < Test::Unit::TestCase
|
|
22
22
|
|
23
23
|
def test_connect_and_manual_refresh_with_secondary_down
|
24
24
|
num_secondaries = @rs.secondaries.size
|
25
|
-
client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :refresh_mode => false
|
25
|
+
client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :refresh_mode => false,
|
26
|
+
:op_timeout => TEST_OP_TIMEOUT)
|
26
27
|
authenticate_client(client)
|
27
28
|
|
28
29
|
assert_equal num_secondaries, client.secondaries.size
|
@@ -57,7 +58,8 @@ class ReplicaSetRefreshTest < Test::Unit::TestCase
|
|
57
58
|
def test_automated_refresh_with_secondary_down
|
58
59
|
num_secondaries = @rs.secondaries.size
|
59
60
|
client = MongoReplicaSetClient.new(@rs.repl_set_seeds,
|
60
|
-
:refresh_interval => 1, :refresh_mode => :sync, :read => :secondary_preferred
|
61
|
+
:refresh_interval => 1, :refresh_mode => :sync, :read => :secondary_preferred,
|
62
|
+
:op_timeout => TEST_OP_TIMEOUT)
|
61
63
|
authenticate_client(client)
|
62
64
|
|
63
65
|
# Ensure secondaries are all recognized by client and client is connected
|
@@ -99,7 +101,8 @@ class ReplicaSetRefreshTest < Test::Unit::TestCase
|
|
99
101
|
factor = 5
|
100
102
|
nthreads = factor * 10
|
101
103
|
threads = []
|
102
|
-
client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :refresh_mode => :sync,
|
104
|
+
client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :refresh_mode => :sync,
|
105
|
+
:refresh_interval => 1, :op_timeout => TEST_OP_TIMEOUT)
|
103
106
|
authenticate_client(client)
|
104
107
|
|
105
108
|
nthreads.times do |i|
|
@@ -18,7 +18,7 @@ class ReplicaSetAckTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
def setup
|
20
20
|
ensure_cluster(:rs)
|
21
|
-
@client = MongoReplicaSetClient.from_uri(@uri)
|
21
|
+
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
|
22
22
|
|
23
23
|
@slave1 = MongoClient.new(
|
24
24
|
@client.secondary_pools.first.host,
|
@@ -33,7 +33,7 @@ class ReplicaSetAckTest < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def teardown
|
36
|
-
@client.close if @
|
36
|
+
@client.close if @client
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_safe_mode_with_w_failure
|
data/test/tools/mongo_config.rb
CHANGED
@@ -672,6 +672,7 @@ module Mongo
|
|
672
672
|
cmd_servers = replica_set? ? [ primary ] : routers
|
673
673
|
|
674
674
|
cmd_servers.each do |cmd_server|
|
675
|
+
next unless cmd_server
|
675
676
|
begin
|
676
677
|
client = Mongo::MongoClient.new(cmd_server.config[:host],
|
677
678
|
cmd_server.config[:port])
|
@@ -690,6 +691,7 @@ module Mongo
|
|
690
691
|
end
|
691
692
|
|
692
693
|
def stop
|
694
|
+
start
|
693
695
|
delete_users
|
694
696
|
servers.each{|server| server.stop}
|
695
697
|
self
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.0.
|
4
|
+
version: 1.12.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emily Stolfo
|
@@ -34,7 +34,7 @@ cert_chain:
|
|
34
34
|
JrZM8w8wGbIOeLtoQqa7HB/jOYbTahH7KMNh2LHAbOR93hNIJxVRa4iwxiMQ75tN
|
35
35
|
9WUIAJ4AEtjwRg1Bz0OwDo3aucPCBpx77+/FWhv7JYY=
|
36
36
|
-----END CERTIFICATE-----
|
37
|
-
date: 2014-
|
37
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: bson
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - '='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.12.0.
|
45
|
+
version: 1.12.0.rc1
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
50
|
- - '='
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 1.12.0.
|
52
|
+
version: 1.12.0.rc1
|
53
53
|
description: A Ruby driver for MongoDB. For more information about Mongo, see http://www.mongodb.org.
|
54
54
|
email: mongodb-dev@googlegroups.com
|
55
55
|
executables:
|
@@ -131,7 +131,6 @@ files:
|
|
131
131
|
- test/replica_set/authentication_test.rb
|
132
132
|
- test/replica_set/basic_test.rb
|
133
133
|
- test/replica_set/client_test.rb
|
134
|
-
- test/replica_set/complex_connect_test.rb
|
135
134
|
- test/replica_set/connection_test.rb
|
136
135
|
- test/replica_set/count_test.rb
|
137
136
|
- test/replica_set/cursor_test.rb
|
@@ -221,7 +220,6 @@ test_files:
|
|
221
220
|
- test/replica_set/authentication_test.rb
|
222
221
|
- test/replica_set/basic_test.rb
|
223
222
|
- test/replica_set/client_test.rb
|
224
|
-
- test/replica_set/complex_connect_test.rb
|
225
223
|
- test/replica_set/connection_test.rb
|
226
224
|
- test/replica_set/count_test.rb
|
227
225
|
- test/replica_set/cursor_test.rb
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# Copyright (C) 2009-2013 MongoDB, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'test_helper'
|
16
|
-
|
17
|
-
class ComplexConnectTest < Test::Unit::TestCase
|
18
|
-
|
19
|
-
def setup
|
20
|
-
ensure_cluster(:rs)
|
21
|
-
end
|
22
|
-
|
23
|
-
def teardown
|
24
|
-
@client.close if defined?(@conn) && @conn
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_complex_connect
|
28
|
-
host = @rs.servers.first.host
|
29
|
-
primary = MongoClient.new(host, @rs.primary.port)
|
30
|
-
authenticate_client(primary)
|
31
|
-
|
32
|
-
@client = MongoReplicaSetClient.new([
|
33
|
-
@rs.servers[2].host_port,
|
34
|
-
@rs.servers[1].host_port,
|
35
|
-
@rs.servers[0].host_port
|
36
|
-
])
|
37
|
-
|
38
|
-
authenticate_client(@client)
|
39
|
-
version = @client.server_version
|
40
|
-
|
41
|
-
@client[TEST_DB]['complext-connect-test'].insert({:a => 1})
|
42
|
-
assert @client[TEST_DB]['complext-connect-test'].find_one
|
43
|
-
|
44
|
-
config = primary['local']['system.replset'].find_one
|
45
|
-
old_config = config.dup
|
46
|
-
config['version'] += 1
|
47
|
-
|
48
|
-
# eliminate exception: can't find self in new replset config
|
49
|
-
port_to_delete = @rs.servers.collect(&:port).find{|port| port != primary.port}.to_s
|
50
|
-
|
51
|
-
config['members'].delete_if do |member|
|
52
|
-
member['host'].include?(port_to_delete)
|
53
|
-
end
|
54
|
-
|
55
|
-
assert_raise ConnectionFailure do
|
56
|
-
primary['admin'].command({:replSetReconfig => config})
|
57
|
-
end
|
58
|
-
@rs.start
|
59
|
-
|
60
|
-
assert_raise ConnectionFailure do
|
61
|
-
perform_step_down(primary)
|
62
|
-
end
|
63
|
-
|
64
|
-
# isMaster is currently broken in 2.1+ when called on removed nodes
|
65
|
-
puts version
|
66
|
-
if version < "2.1"
|
67
|
-
rescue_connection_failure do
|
68
|
-
assert @client[TEST_DB]['complext-connect-test'].find_one
|
69
|
-
end
|
70
|
-
|
71
|
-
assert @client[TEST_DB]['complext-connect-test'].find_one
|
72
|
-
end
|
73
|
-
|
74
|
-
primary = MongoClient.new(host, @rs.primary.port)
|
75
|
-
authenticate_client(primary)
|
76
|
-
assert_raise ConnectionFailure do
|
77
|
-
primary['admin'].command({:replSetReconfig => old_config})
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|