mongo 1.8.3.rc1 → 1.8.3
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 +1 -3
- data/VERSION +1 -1
- data/lib/mongo/cursor.rb +1 -1
- data/test/functional/collection_test.rb +60 -0
- data/test/replica_set/cursor_test.rb +26 -0
- data/test/replica_set/refresh_test.rb +24 -47
- data/test/tools/mongo_config.rb +5 -1
- metadata +6 -7
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9292e4cac6a44329fb7c7940421fe07ff8e787bd
|
4
|
+
data.tar.gz: 14a5d525f6fd6cefe6694576e02d841d2882994b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b58e0adafd2a3b6522a74c87c8aaae7ea7ae2968fc8fa83b1fe0851accc74df459e683d3755a5d96d84509d19b6b3e11c55d35a6ed4024997b28d847dd587233
|
7
|
+
data.tar.gz: a910cea9b47023cd6bca4771557d00e435f2acc9234acafcfd43445e82ab947e941bca3db71afb2030aeedb1454e0956bf530b8e82b6b606b5a9d5b9fd404e1b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,3 +1 @@
|
|
1
|
-
|
2
|
-
��:��Ԍ{*Hm��}#]�9��Pu9)=4rQ���1�R��/��|�����J_Ş�6*
|
3
|
-
���%�H����b�mtgϳ�@ �����B.��.�@'s/�ó'���E��T��]ɘ)_��ݻxD�'��̰7��'����6�Q;����>�MP����L/�O�͈����_"c��2��Q���os�m��%8��Yp�?��2��`�w��Q�n�l��(CBs\�
|
1
|
+
(K��[���yܷ�Y��/���#rC�l�o���30ij�~a���E6Bc\X%YJQ�s�'M
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.8.3
|
1
|
+
1.8.3
|
data/lib/mongo/cursor.rb
CHANGED
@@ -552,7 +552,7 @@ module Mongo
|
|
552
552
|
message.put_int(@options)
|
553
553
|
BSON::BSON_RUBY.serialize_cstr(message, "#{@db.name}.#{@collection.name}")
|
554
554
|
message.put_int(@skip)
|
555
|
-
message.put_int(@limit)
|
555
|
+
@batch_size > 1 ? message.put_int(@batch_size) : message.put_int(@limit)
|
556
556
|
spec = query_contains_special_fields? ? construct_query_spec : @selector
|
557
557
|
message.put_binary(BSON::BSON_CODER.serialize(spec, false, false, @connection.max_bson_size).to_s)
|
558
558
|
message.put_binary(BSON::BSON_CODER.serialize(@fields, false, false, @connection.max_bson_size).to_s) if @fields
|
@@ -902,6 +902,66 @@ class TestCollection < Test::Unit::TestCase
|
|
902
902
|
# assert_equal :mike, @@test.find_one("foo" => "mike")["foo"]
|
903
903
|
end
|
904
904
|
|
905
|
+
def test_batch_size
|
906
|
+
n_docs = 6
|
907
|
+
batch_size = n_docs/2
|
908
|
+
n_docs.times do |i|
|
909
|
+
@@test.save(:foo => i)
|
910
|
+
end
|
911
|
+
|
912
|
+
doc_count = 0
|
913
|
+
cursor = @@test.find({}, :batch_size => batch_size)
|
914
|
+
cursor.next
|
915
|
+
assert_equal batch_size, cursor.instance_variable_get(:@returned)
|
916
|
+
doc_count += batch_size
|
917
|
+
batch_size.times { cursor.next }
|
918
|
+
assert_equal doc_count + batch_size, cursor.instance_variable_get(:@returned)
|
919
|
+
doc_count += batch_size
|
920
|
+
assert_equal n_docs, doc_count
|
921
|
+
end
|
922
|
+
|
923
|
+
def test_batch_size_with_smaller_limit
|
924
|
+
n_docs = 6
|
925
|
+
batch_size = n_docs/2
|
926
|
+
n_docs.times do |i|
|
927
|
+
@@test.insert(:foo => i)
|
928
|
+
end
|
929
|
+
|
930
|
+
cursor = @@test.find({}, :batch_size => batch_size, :limit => 2)
|
931
|
+
cursor.next
|
932
|
+
assert_equal 2, cursor.instance_variable_get(:@returned)
|
933
|
+
end
|
934
|
+
|
935
|
+
def test_batch_size_with_larger_limit
|
936
|
+
n_docs = 6
|
937
|
+
batch_size = n_docs/2
|
938
|
+
n_docs.times do |i|
|
939
|
+
@@test.insert(:foo => i)
|
940
|
+
end
|
941
|
+
|
942
|
+
doc_count = 0
|
943
|
+
cursor = @@test.find({}, :batch_size => batch_size, :limit => n_docs + 5)
|
944
|
+
cursor.next
|
945
|
+
assert_equal batch_size, cursor.instance_variable_get(:@returned)
|
946
|
+
doc_count += batch_size
|
947
|
+
batch_size.times { cursor.next }
|
948
|
+
assert_equal doc_count + batch_size, cursor.instance_variable_get(:@returned)
|
949
|
+
doc_count += batch_size
|
950
|
+
assert_equal n_docs, doc_count
|
951
|
+
end
|
952
|
+
|
953
|
+
def test_batch_size_with_negative_limit
|
954
|
+
n_docs = 6
|
955
|
+
batch_size = n_docs/2
|
956
|
+
n_docs.times do |i|
|
957
|
+
@@test.insert(:foo => i)
|
958
|
+
end
|
959
|
+
|
960
|
+
cursor = @@test.find({}, :batch_size => batch_size, :limit => -7)
|
961
|
+
cursor.next
|
962
|
+
assert_equal n_docs, cursor.instance_variable_get(:@returned)
|
963
|
+
end
|
964
|
+
|
905
965
|
def test_limit_and_skip
|
906
966
|
10.times do |i|
|
907
967
|
@@test.save(:foo => i)
|
@@ -41,6 +41,11 @@ class ReplicaSetCursorTest < Test::Unit::TestCase
|
|
41
41
|
assert_cursors_on_members(:secondary)
|
42
42
|
end
|
43
43
|
|
44
|
+
def test_intervening_query_secondary
|
45
|
+
setup_client(:primary)
|
46
|
+
refresh_while_iterating(:secondary)
|
47
|
+
end
|
48
|
+
|
44
49
|
private
|
45
50
|
|
46
51
|
def setup_client(read=:primary)
|
@@ -169,4 +174,25 @@ class ReplicaSetCursorTest < Test::Unit::TestCase
|
|
169
174
|
cursor_clone.next
|
170
175
|
end
|
171
176
|
end
|
177
|
+
|
178
|
+
def refresh_while_iterating(read)
|
179
|
+
set_read_client_and_tag(read)
|
180
|
+
|
181
|
+
read_opts = {:read => read}
|
182
|
+
read_opts[:tag_sets] = [{:node => @tag}]
|
183
|
+
read_opts[:batch_size] = 2
|
184
|
+
cursor = @coll.find({}, read_opts)
|
185
|
+
|
186
|
+
2.times { cursor.next }
|
187
|
+
port = cursor.instance_variable_get(:@pool).port
|
188
|
+
host = cursor.instance_variable_get(:@pool).host
|
189
|
+
# Refresh connection
|
190
|
+
@client.refresh
|
191
|
+
assert_nothing_raised do
|
192
|
+
cursor.next
|
193
|
+
end
|
194
|
+
|
195
|
+
assert_equal port, cursor.instance_variable_get(:@pool).port
|
196
|
+
assert_equal host, cursor.instance_variable_get(:@pool).host
|
197
|
+
end
|
172
198
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'benchmark'
|
3
2
|
|
4
3
|
class ReplicaSetRefreshTest < Test::Unit::TestCase
|
5
4
|
|
@@ -7,98 +6,76 @@ class ReplicaSetRefreshTest < Test::Unit::TestCase
|
|
7
6
|
ensure_cluster(:rs)
|
8
7
|
end
|
9
8
|
|
10
|
-
def
|
9
|
+
def test_connect_and_manual_refresh_with_secondary_down
|
11
10
|
num_secondaries = @rs.secondaries.size
|
12
11
|
client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :refresh_mode => false)
|
13
12
|
|
14
13
|
assert_equal num_secondaries, client.secondaries.size
|
15
14
|
assert client.connected?
|
16
15
|
assert_equal client.read_pool, client.primary_pool
|
16
|
+
old_refresh_version = client.refresh_version
|
17
17
|
|
18
|
-
@rs.
|
18
|
+
@rs.stop_secondary
|
19
19
|
|
20
20
|
client.refresh
|
21
|
-
|
21
|
+
assert_equal num_secondaries - 1, client.secondaries.size
|
22
22
|
assert client.connected?
|
23
23
|
assert_equal client.read_pool, client.primary_pool
|
24
|
+
assert client.refresh_version > old_refresh_version
|
25
|
+
old_refresh_version = client.refresh_version
|
24
26
|
|
25
27
|
# Test no changes after restart until manual refresh
|
26
28
|
@rs.restart
|
27
|
-
|
29
|
+
assert_equal num_secondaries - 1, client.secondaries.size
|
28
30
|
assert client.connected?
|
29
31
|
assert_equal client.read_pool, client.primary_pool
|
32
|
+
assert_equal client.refresh_version, old_refresh_version
|
30
33
|
|
31
34
|
# Refresh and ensure state
|
32
35
|
client.refresh
|
33
|
-
assert_equal client.read_pool, client.primary_pool
|
34
36
|
assert_equal num_secondaries, client.secondaries.size
|
37
|
+
assert client.connected?
|
38
|
+
assert_equal client.read_pool, client.primary_pool
|
39
|
+
assert client.refresh_version > old_refresh_version
|
35
40
|
end
|
36
41
|
|
37
|
-
def
|
42
|
+
def test_automated_refresh_with_secondary_down
|
38
43
|
num_secondaries = @rs.secondaries.size
|
39
44
|
client = MongoReplicaSetClient.new(@rs.repl_set_seeds,
|
40
45
|
:refresh_interval => 1, :refresh_mode => :sync, :read => :secondary_preferred)
|
41
46
|
|
42
|
-
# Ensure secondaries
|
47
|
+
# Ensure secondaries are all recognized by client and client is connected
|
43
48
|
assert_equal num_secondaries, client.secondaries.size
|
44
49
|
assert client.connected?
|
45
50
|
assert client.secondary_pools.include?(client.read_pool)
|
51
|
+
pool = client.read_pool
|
46
52
|
|
47
|
-
@rs.
|
53
|
+
@rs.member_by_name(pool.host_string).stop
|
48
54
|
sleep(2)
|
49
55
|
|
56
|
+
old_refresh_version = client.refresh_version
|
57
|
+
# Trigger synchronous refresh
|
50
58
|
client['foo']['bar'].find_one
|
51
59
|
|
52
|
-
assert client.secondaries.empty?
|
53
60
|
assert client.connected?
|
54
|
-
|
55
|
-
|
56
|
-
|
61
|
+
assert client.refresh_version > old_refresh_version
|
62
|
+
assert_equal num_secondaries - 1, client.secondaries.size
|
63
|
+
assert client.secondary_pools.include?(client.read_pool)
|
64
|
+
assert_not_equal pool, client.read_pool
|
57
65
|
|
58
66
|
# Restart nodes and ensure refresh interval has passed
|
59
67
|
@rs.restart
|
60
68
|
sleep(2)
|
61
69
|
|
62
|
-
|
63
|
-
"Refresh version has changed."
|
64
|
-
|
70
|
+
old_refresh_version = client.refresh_version
|
65
71
|
# Trigger synchronous refresh
|
66
72
|
client['foo']['bar'].find_one
|
67
73
|
|
74
|
+
assert client.connected?
|
68
75
|
assert client.refresh_version > old_refresh_version,
|
69
76
|
"Refresh version hasn't changed."
|
70
77
|
assert_equal num_secondaries, client.secondaries.size
|
71
78
|
"No secondaries have been added."
|
72
|
-
assert client.manager.read_pool != client.manager.primary,
|
73
|
-
"Read pool and primary pool are identical."
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_automated_refresh_when_secondary_goes_down
|
77
|
-
client = MongoReplicaSetClient.new(@rs.repl_set_seeds,
|
78
|
-
:refresh_interval => 1, :refresh_mode => :sync)
|
79
|
-
|
80
|
-
num_secondaries = client.secondary_pools.size
|
81
|
-
old_refresh_version = client.refresh_version
|
82
|
-
|
83
|
-
@rs.stop_secondary
|
84
|
-
sleep(2)
|
85
|
-
|
86
|
-
assert client.refresh_version == old_refresh_version,
|
87
|
-
"Refresh version has changed."
|
88
|
-
|
89
|
-
client['foo']['bar'].find_one
|
90
|
-
|
91
|
-
assert client.refresh_version > old_refresh_version,
|
92
|
-
"Refresh version hasn't changed."
|
93
|
-
assert_equal num_secondaries - 1, client.secondaries.size
|
94
|
-
assert_equal num_secondaries - 1, client.secondary_pools.size
|
95
|
-
|
96
|
-
@rs.restart
|
97
|
-
sleep(2)
|
98
|
-
|
99
|
-
client['foo']['bar'].find_one
|
100
|
-
|
101
|
-
assert_equal num_secondaries, client.secondaries.size
|
102
79
|
assert_equal num_secondaries, client.secondary_pools.size
|
103
80
|
end
|
104
81
|
=begin
|
@@ -150,4 +127,4 @@ class ReplicaSetRefreshTest < Test::Unit::TestCase
|
|
150
127
|
assert_equal 2, client.secondaries.length
|
151
128
|
end
|
152
129
|
=end
|
153
|
-
end
|
130
|
+
end
|
data/test/tools/mongo_config.rb
CHANGED
@@ -430,10 +430,14 @@ module Mongo
|
|
430
430
|
|
431
431
|
def members_by_name(names)
|
432
432
|
names.collect do |name|
|
433
|
-
|
433
|
+
member_by_name(name)
|
434
434
|
end.compact
|
435
435
|
end
|
436
436
|
|
437
|
+
def member_by_name(name)
|
438
|
+
servers.find{|server| server.host_port == name}
|
439
|
+
end
|
440
|
+
|
437
441
|
def primary
|
438
442
|
members_by_name([primary_name]).first
|
439
443
|
end
|
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.8.3
|
4
|
+
version: 1.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Brock
|
@@ -33,7 +33,7 @@ cert_chain:
|
|
33
33
|
8v7zLF2XliYbfurYIwkcXs8yPn8ggApBIy9bX6VJxRs/l2+UvqzaHIFaFy/F8/GP
|
34
34
|
RNTuXsVG5NDACo7Q
|
35
35
|
-----END CERTIFICATE-----
|
36
|
-
date: 2013-
|
36
|
+
date: 2013-03-04 00:00:00.000000000 Z
|
37
37
|
dependencies:
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: bson
|
@@ -41,14 +41,14 @@ dependencies:
|
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 1.8.3
|
44
|
+
version: 1.8.3
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
48
48
|
requirements:
|
49
49
|
- - ~>
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: 1.8.3
|
51
|
+
version: 1.8.3
|
52
52
|
description: A Ruby driver for MongoDB. For more information about Mongo, see http://www.mongodb.org.
|
53
53
|
email: mongodb-dev@googlegroups.com
|
54
54
|
executables:
|
@@ -173,9 +173,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
173
|
version: '0'
|
174
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
175
|
requirements:
|
176
|
-
- - '
|
176
|
+
- - '>='
|
177
177
|
- !ruby/object:Gem::Version
|
178
|
-
version:
|
178
|
+
version: '0'
|
179
179
|
requirements: []
|
180
180
|
rubyforge_project: mongo
|
181
181
|
rubygems_version: 2.0.0
|
@@ -249,4 +249,3 @@ test_files:
|
|
249
249
|
- test/unit/safe_test.rb
|
250
250
|
- test/unit/util_test.rb
|
251
251
|
- test/unit/write_concern_test.rb
|
252
|
-
has_rdoc: yard
|
metadata.gz.sig
CHANGED
Binary file
|