mongo 1.1.5 → 1.3.0
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.
- data/README.md +15 -15
- data/Rakefile +38 -17
- data/docs/FAQ.md +4 -0
- data/docs/HISTORY.md +59 -0
- data/docs/RELEASES.md +33 -0
- data/docs/REPLICA_SETS.md +13 -16
- data/lib/mongo/collection.rb +157 -69
- data/lib/mongo/connection.rb +189 -65
- data/lib/mongo/cursor.rb +43 -29
- data/lib/mongo/db.rb +63 -43
- data/lib/mongo/exceptions.rb +4 -1
- data/lib/mongo/gridfs/grid.rb +1 -1
- data/lib/mongo/gridfs/grid_ext.rb +1 -1
- data/lib/mongo/gridfs/grid_file_system.rb +1 -1
- data/lib/mongo/gridfs/grid_io.rb +89 -8
- data/lib/mongo/gridfs/grid_io_fix.rb +1 -1
- data/lib/mongo/repl_set_connection.rb +72 -20
- data/lib/mongo/test.rb +20 -0
- data/lib/mongo/util/conversions.rb +1 -1
- data/lib/mongo/util/core_ext.rb +11 -1
- data/lib/mongo/util/pool.rb +67 -15
- data/lib/mongo/util/server_version.rb +1 -1
- data/lib/mongo/util/support.rb +1 -1
- data/lib/mongo/util/uri_parser.rb +127 -13
- data/lib/mongo.rb +38 -2
- data/test/async/collection_test.rb +224 -0
- data/test/async/connection_test.rb +24 -0
- data/test/async/cursor_test.rb +162 -0
- data/test/async/worker_pool_test.rb +99 -0
- data/test/auxillary/fork_test.rb +30 -0
- data/test/auxillary/repl_set_auth_test.rb +58 -0
- data/test/auxillary/threaded_authentication_test.rb +101 -0
- data/test/bson/bson_test.rb +140 -28
- data/test/bson/byte_buffer_test.rb +18 -0
- data/test/bson/object_id_test.rb +14 -1
- data/test/bson/ordered_hash_test.rb +7 -0
- data/test/bson/timestamp_test.rb +24 -0
- data/test/collection_test.rb +104 -15
- data/test/connection_test.rb +78 -2
- data/test/conversions_test.rb +10 -11
- data/test/cursor_fail_test.rb +1 -1
- data/test/cursor_message_test.rb +1 -1
- data/test/cursor_test.rb +33 -4
- data/test/db_api_test.rb +30 -52
- data/test/db_test.rb +3 -3
- data/test/grid_file_system_test.rb +0 -1
- data/test/grid_io_test.rb +72 -1
- data/test/grid_test.rb +16 -16
- data/test/load/resque/load.rb +21 -0
- data/test/load/resque/processor.rb +26 -0
- data/test/load/thin/load.rb +24 -0
- data/test/load/unicorn/load.rb +23 -0
- data/test/load/unicorn/unicorn.rb +29 -0
- data/test/replica_sets/connect_test.rb +11 -1
- data/test/replica_sets/connection_string_test.rb +32 -0
- data/test/replica_sets/query_secondaries.rb +16 -0
- data/test/replica_sets/query_test.rb +10 -0
- data/test/replica_sets/replication_ack_test.rb +2 -0
- data/test/replica_sets/rs_test_helper.rb +9 -11
- data/test/support/hash_with_indifferent_access.rb +0 -13
- data/test/support_test.rb +0 -1
- data/test/test_helper.rb +27 -8
- data/test/tools/auth_repl_set_manager.rb +14 -0
- data/test/tools/load.rb +58 -0
- data/test/tools/repl_set_manager.rb +34 -9
- data/test/tools/sharding_manager.rb +202 -0
- data/test/tools/test.rb +3 -12
- data/test/unit/collection_test.rb +20 -24
- data/test/unit/connection_test.rb +4 -18
- data/test/unit/cursor_test.rb +16 -6
- data/test/unit/db_test.rb +10 -11
- data/test/unit/repl_set_connection_test.rb +0 -23
- data/test/unit/safe_test.rb +3 -3
- data/test/uri_test.rb +91 -0
- metadata +49 -12
- data/docs/1.0_UPGRADE.md +0 -21
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
require
|
|
1
|
+
require './test/test_helper'
|
|
2
2
|
|
|
3
3
|
class CollectionTest < Test::Unit::TestCase
|
|
4
4
|
|
|
5
5
|
context "Basic operations: " do
|
|
6
6
|
setup do
|
|
7
7
|
@logger = mock()
|
|
8
|
+
@logger.expects(:debug)
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
should "send update message" do
|
|
@@ -14,7 +15,7 @@ class CollectionTest < Test::Unit::TestCase
|
|
|
14
15
|
@conn.expects(:send_message).with do |op, msg, log|
|
|
15
16
|
op == 2001
|
|
16
17
|
end
|
|
17
|
-
@
|
|
18
|
+
@conn.stubs(:log_operation)
|
|
18
19
|
@coll.update({}, {:title => 'Moby Dick'})
|
|
19
20
|
end
|
|
20
21
|
|
|
@@ -25,8 +26,8 @@ class CollectionTest < Test::Unit::TestCase
|
|
|
25
26
|
@conn.expects(:send_message).with do |op, msg, log|
|
|
26
27
|
op == 2002
|
|
27
28
|
end
|
|
28
|
-
@
|
|
29
|
-
|
|
29
|
+
@conn.expects(:log_operation).with do |name, payload|
|
|
30
|
+
(name == :insert) && payload[:documents][0][:title].include?('Moby')
|
|
30
31
|
end
|
|
31
32
|
@coll.insert({:title => 'Moby Dick'})
|
|
32
33
|
end
|
|
@@ -38,8 +39,8 @@ class CollectionTest < Test::Unit::TestCase
|
|
|
38
39
|
@conn.expects(:receive_message).with do |op, msg, log, sock|
|
|
39
40
|
op == 2004
|
|
40
41
|
end.returns([[], 0, 0])
|
|
41
|
-
@
|
|
42
|
-
|
|
42
|
+
@conn.expects(:log_operation).with do |name, payload|
|
|
43
|
+
(name == :find) && payload[:selector][:title].include?('Moby')
|
|
43
44
|
end
|
|
44
45
|
@coll.find({:title => 'Moby Dick'}).sort([['title', 1], ['author', 1]]).next_document
|
|
45
46
|
end
|
|
@@ -52,8 +53,8 @@ class CollectionTest < Test::Unit::TestCase
|
|
|
52
53
|
@conn.expects(:send_message).with do |op, msg, log|
|
|
53
54
|
op == 2002
|
|
54
55
|
end
|
|
55
|
-
@
|
|
56
|
-
|
|
56
|
+
@conn.expects(:log_operation).with do |name, payload|
|
|
57
|
+
(name == :insert) && payload[:documents][0][:data].inspect.include?('Binary')
|
|
57
58
|
end
|
|
58
59
|
@coll.insert({:data => data})
|
|
59
60
|
end
|
|
@@ -65,8 +66,8 @@ class CollectionTest < Test::Unit::TestCase
|
|
|
65
66
|
@conn.expects(:send_message_with_safe_check).with do |op, msg, db_name, log|
|
|
66
67
|
op == 2001
|
|
67
68
|
end
|
|
68
|
-
@
|
|
69
|
-
|
|
69
|
+
@conn.expects(:log_operation).with do |name, payload|
|
|
70
|
+
(name == :update) && payload[:document][:title].include?('Moby')
|
|
70
71
|
end
|
|
71
72
|
@coll.update({}, {:title => 'Moby Dick'}, :safe => true)
|
|
72
73
|
end
|
|
@@ -78,44 +79,42 @@ class CollectionTest < Test::Unit::TestCase
|
|
|
78
79
|
@conn.expects(:send_message_with_safe_check).with do |op, msg, db_name, log|
|
|
79
80
|
op == 2001
|
|
80
81
|
end
|
|
81
|
-
@
|
|
82
|
+
@conn.stubs(:log_operation)
|
|
82
83
|
@coll.update({}, {:title => 'Moby Dick'}, :safe => true)
|
|
83
84
|
end
|
|
84
|
-
|
|
85
|
+
|
|
85
86
|
should "not call insert for each ensure_index call" do
|
|
86
87
|
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
|
|
87
88
|
@db = @conn['testing']
|
|
88
89
|
@coll = @db.collection('books')
|
|
89
90
|
@coll.expects(:generate_indexes).once
|
|
90
|
-
|
|
91
|
+
|
|
91
92
|
@coll.ensure_index [["x", Mongo::DESCENDING]]
|
|
92
93
|
@coll.ensure_index [["x", Mongo::DESCENDING]]
|
|
93
|
-
|
|
94
94
|
end
|
|
95
|
+
|
|
95
96
|
should "call generate_indexes for a new direction on the same field for ensure_index" do
|
|
96
97
|
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
|
|
97
98
|
@db = @conn['testing']
|
|
98
99
|
@coll = @db.collection('books')
|
|
99
100
|
@coll.expects(:generate_indexes).twice
|
|
100
|
-
|
|
101
|
+
|
|
101
102
|
@coll.ensure_index [["x", Mongo::DESCENDING]]
|
|
102
103
|
@coll.ensure_index [["x", Mongo::ASCENDING]]
|
|
103
|
-
|
|
104
|
+
|
|
104
105
|
end
|
|
105
|
-
|
|
106
|
+
|
|
106
107
|
should "call generate_indexes twice because the cache time is 0 seconds" do
|
|
107
108
|
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
|
|
108
109
|
@db = @conn['testing']
|
|
109
110
|
@db.cache_time = 0
|
|
110
111
|
@coll = @db.collection('books')
|
|
111
112
|
@coll.expects(:generate_indexes).twice
|
|
112
|
-
|
|
113
113
|
|
|
114
114
|
@coll.ensure_index [["x", Mongo::DESCENDING]]
|
|
115
115
|
@coll.ensure_index [["x", Mongo::DESCENDING]]
|
|
116
|
-
|
|
117
116
|
end
|
|
118
|
-
|
|
117
|
+
|
|
119
118
|
should "call generate_indexes for each key when calling ensure_indexes" do
|
|
120
119
|
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
|
|
121
120
|
@db = @conn['testing']
|
|
@@ -124,11 +123,8 @@ class CollectionTest < Test::Unit::TestCase
|
|
|
124
123
|
@coll.expects(:generate_indexes).once.with do |a, b, c|
|
|
125
124
|
a == {"x"=>-1, "y"=>-1}
|
|
126
125
|
end
|
|
127
|
-
|
|
126
|
+
|
|
128
127
|
@coll.ensure_index [["x", Mongo::DESCENDING], ["y", Mongo::DESCENDING]]
|
|
129
128
|
end
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
129
|
end
|
|
134
130
|
end
|
|
@@ -3,27 +3,14 @@ include Mongo
|
|
|
3
3
|
|
|
4
4
|
class ConnectionTest < Test::Unit::TestCase
|
|
5
5
|
context "Initialization: " do
|
|
6
|
-
setup do
|
|
7
|
-
def new_mock_socket(host='localhost', port=27017)
|
|
8
|
-
socket = Object.new
|
|
9
|
-
socket.stubs(:setsockopt).with(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
|
10
|
-
socket.stubs(:close)
|
|
11
|
-
socket
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def new_mock_db
|
|
15
|
-
db = Object.new
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
6
|
context "given a single node" do
|
|
20
7
|
setup do
|
|
21
8
|
@conn = Connection.new('localhost', 27017, :connect => false)
|
|
22
9
|
TCPSocket.stubs(:new).returns(new_mock_socket)
|
|
23
10
|
|
|
24
11
|
admin_db = new_mock_db
|
|
25
|
-
admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1})
|
|
26
|
-
@conn.expects(:[]).with('admin').returns(admin_db)
|
|
12
|
+
admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1}).twice
|
|
13
|
+
@conn.expects(:[]).with('admin').returns(admin_db).twice
|
|
27
14
|
@conn.connect
|
|
28
15
|
end
|
|
29
16
|
|
|
@@ -65,9 +52,8 @@ class ConnectionTest < Test::Unit::TestCase
|
|
|
65
52
|
@conn = Connection.from_uri("mongodb://localhost", :connect => false)
|
|
66
53
|
|
|
67
54
|
admin_db = new_mock_db
|
|
68
|
-
admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1})
|
|
69
|
-
@conn.expects(:[]).with('admin').returns(admin_db)
|
|
70
|
-
@conn.expects(:apply_saved_authentication)
|
|
55
|
+
admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1}).twice
|
|
56
|
+
@conn.expects(:[]).with('admin').returns(admin_db).twice
|
|
71
57
|
@conn.connect
|
|
72
58
|
end
|
|
73
59
|
|
data/test/unit/cursor_test.rb
CHANGED
|
@@ -12,28 +12,32 @@ class CursorTest < Test::Unit::TestCase
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
should "set timeout" do
|
|
15
|
-
|
|
15
|
+
assert @cursor.timeout
|
|
16
|
+
assert @cursor.query_options_hash[:timeout]
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
should "set selector" do
|
|
19
|
-
|
|
20
|
+
assert_equal({}, @cursor.selector)
|
|
20
21
|
|
|
21
22
|
@cursor = Cursor.new(@collection, :selector => {:name => "Jones"})
|
|
22
|
-
|
|
23
|
+
assert_equal({:name => "Jones"}, @cursor.selector)
|
|
24
|
+
assert_equal({:name => "Jones"}, @cursor.query_options_hash[:selector])
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
should "set fields" do
|
|
26
28
|
assert_nil @cursor.fields
|
|
27
29
|
|
|
28
30
|
@cursor = Cursor.new(@collection, :fields => [:name, :date])
|
|
29
|
-
|
|
31
|
+
assert_equal({:name => 1, :date => 1}, @cursor.fields)
|
|
32
|
+
assert_equal({:name => 1, :date => 1}, @cursor.query_options_hash[:fields])
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
should "set mix fields 0 and 1" do
|
|
33
36
|
assert_nil @cursor.fields
|
|
34
37
|
|
|
35
38
|
@cursor = Cursor.new(@collection, :fields => {:name => 1, :date => 0})
|
|
36
|
-
|
|
39
|
+
assert_equal({:name => 1, :date => 0}, @cursor.fields)
|
|
40
|
+
assert_equal({:name => 1, :date => 0}, @cursor.query_options_hash[:fields])
|
|
37
41
|
end
|
|
38
42
|
|
|
39
43
|
should "set limit" do
|
|
@@ -41,6 +45,7 @@ class CursorTest < Test::Unit::TestCase
|
|
|
41
45
|
|
|
42
46
|
@cursor = Cursor.new(@collection, :limit => 10)
|
|
43
47
|
assert_equal 10, @cursor.limit
|
|
48
|
+
assert_equal 10, @cursor.query_options_hash[:limit]
|
|
44
49
|
end
|
|
45
50
|
|
|
46
51
|
|
|
@@ -49,6 +54,7 @@ class CursorTest < Test::Unit::TestCase
|
|
|
49
54
|
|
|
50
55
|
@cursor = Cursor.new(@collection, :skip => 5)
|
|
51
56
|
assert_equal 5, @cursor.skip
|
|
57
|
+
assert_equal 5, @cursor.query_options_hash[:skip]
|
|
52
58
|
end
|
|
53
59
|
|
|
54
60
|
should "set sort order" do
|
|
@@ -56,6 +62,7 @@ class CursorTest < Test::Unit::TestCase
|
|
|
56
62
|
|
|
57
63
|
@cursor = Cursor.new(@collection, :order => "last_name")
|
|
58
64
|
assert_equal "last_name", @cursor.order
|
|
65
|
+
assert_equal "last_name", @cursor.query_options_hash[:order]
|
|
59
66
|
end
|
|
60
67
|
|
|
61
68
|
should "set hint" do
|
|
@@ -63,6 +70,7 @@ class CursorTest < Test::Unit::TestCase
|
|
|
63
70
|
|
|
64
71
|
@cursor = Cursor.new(@collection, :hint => "name")
|
|
65
72
|
assert_equal "name", @cursor.hint
|
|
73
|
+
assert_equal "name", @cursor.query_options_hash[:hint]
|
|
66
74
|
end
|
|
67
75
|
|
|
68
76
|
should "cache full collection name" do
|
|
@@ -72,7 +80,9 @@ class CursorTest < Test::Unit::TestCase
|
|
|
72
80
|
|
|
73
81
|
context "Query fields" do
|
|
74
82
|
setup do
|
|
75
|
-
@
|
|
83
|
+
@logger = mock()
|
|
84
|
+
@logger.stubs(:debug)
|
|
85
|
+
@connection = stub(:class => Connection, :logger => @logger)
|
|
76
86
|
@db = stub(:slave_ok? => true, :name => "testing", :connection => @connection)
|
|
77
87
|
@collection = stub(:db => @db, :name => "items")
|
|
78
88
|
end
|
data/test/unit/db_test.rb
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
require './test/test_helper'
|
|
2
2
|
|
|
3
|
+
def insert_message(db, documents)
|
|
4
|
+
documents = [documents] unless documents.is_a?(Array)
|
|
5
|
+
message = ByteBuffer.new
|
|
6
|
+
message.put_int(0)
|
|
7
|
+
Mongo::BSON_CODER.serialize_cstr(message, "#{db.name}.test")
|
|
8
|
+
documents.each { |doc| message.put_array(Mongo::BSON_CODER.new.serialize(doc, true).to_a) }
|
|
9
|
+
message = db.add_message_headers(Mongo::Constants::OP_INSERT, message)
|
|
10
|
+
end
|
|
11
|
+
|
|
3
12
|
class DBTest < Test::Unit::TestCase
|
|
4
13
|
context "DBTest: " do
|
|
5
|
-
setup do
|
|
6
|
-
def insert_message(db, documents)
|
|
7
|
-
documents = [documents] unless documents.is_a?(Array)
|
|
8
|
-
message = ByteBuffer.new
|
|
9
|
-
message.put_int(0)
|
|
10
|
-
Mongo::BSON_CODER..serialize_cstr(message, "#{db.name}.test")
|
|
11
|
-
documents.each { |doc| message.put_array(Mongo::BSON_CODER.new.serialize(doc, true).to_a) }
|
|
12
|
-
message = db.add_message_headers(Mongo::Constants::OP_INSERT, message)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
14
|
context "DB commands" do
|
|
17
15
|
setup do
|
|
18
16
|
@conn = stub()
|
|
@@ -57,6 +55,7 @@ class DBTest < Test::Unit::TestCase
|
|
|
57
55
|
|
|
58
56
|
should "raise an error if logging out fails" do
|
|
59
57
|
@db.expects(:command).returns({})
|
|
58
|
+
@conn.expects(:pool_size).returns(1)
|
|
60
59
|
assert_raise Mongo::MongoDBError do
|
|
61
60
|
@db.logout
|
|
62
61
|
end
|
|
@@ -3,19 +3,6 @@ include Mongo
|
|
|
3
3
|
|
|
4
4
|
class ReplSetConnectionTest < Test::Unit::TestCase
|
|
5
5
|
context "Initialization: " do
|
|
6
|
-
setup do
|
|
7
|
-
def new_mock_socket(host='localhost', port=27017)
|
|
8
|
-
socket = Object.new
|
|
9
|
-
socket.stubs(:setsockopt).with(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
|
10
|
-
socket.stubs(:close)
|
|
11
|
-
socket
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def new_mock_db
|
|
15
|
-
db = Object.new
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
6
|
context "connecting to a replica set" do
|
|
20
7
|
setup do
|
|
21
8
|
TCPSocket.stubs(:new).returns(new_mock_socket('localhost', 27017))
|
|
@@ -67,16 +54,6 @@ class ReplSetConnectionTest < Test::Unit::TestCase
|
|
|
67
54
|
assert_equal ['localhost', 27017], @conn.nodes[0]
|
|
68
55
|
assert_equal ['mydb.com', 27018], @conn.nodes[1]
|
|
69
56
|
end
|
|
70
|
-
|
|
71
|
-
should "parse a uri specifying multiple nodes with auth" do
|
|
72
|
-
@conn = Connection.from_uri("mongodb://kyle:s3cr3t@localhost:27017/app,mickey:m0u5e@mydb.com:27018/dsny", :connect => false)
|
|
73
|
-
assert_equal ['localhost', 27017], @conn.nodes[0]
|
|
74
|
-
assert_equal ['mydb.com', 27018], @conn.nodes[1]
|
|
75
|
-
auth_hash = {'username' => 'kyle', 'password' => 's3cr3t', 'db_name' => 'app'}
|
|
76
|
-
assert_equal auth_hash, @conn.auths[0]
|
|
77
|
-
auth_hash = {'username' => 'mickey', 'password' => 'm0u5e', 'db_name' => 'dsny'}
|
|
78
|
-
assert_equal auth_hash, @conn.auths[1]
|
|
79
|
-
end
|
|
80
57
|
end
|
|
81
58
|
end
|
|
82
59
|
end
|
data/test/unit/safe_test.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require './test/test_helper'
|
|
2
2
|
|
|
3
3
|
class SafeTest < Test::Unit::TestCase
|
|
4
4
|
|
|
@@ -40,7 +40,7 @@ class SafeTest < Test::Unit::TestCase
|
|
|
40
40
|
col = @db['bar']
|
|
41
41
|
assert_equal @safe_value, col.safe
|
|
42
42
|
|
|
43
|
-
col = Collection.new(
|
|
43
|
+
col = Collection.new('bar', @db)
|
|
44
44
|
assert_equal @safe_value, col.safe
|
|
45
45
|
end
|
|
46
46
|
|
|
@@ -48,7 +48,7 @@ class SafeTest < Test::Unit::TestCase
|
|
|
48
48
|
col = @db.collection('bar', :safe => false)
|
|
49
49
|
assert_equal false, col.safe
|
|
50
50
|
|
|
51
|
-
col = Collection.new(
|
|
51
|
+
col = Collection.new('bar', @db, :safe => false)
|
|
52
52
|
assert_equal false, col.safe
|
|
53
53
|
end
|
|
54
54
|
end
|
data/test/uri_test.rb
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require './test/test_helper'
|
|
2
|
+
|
|
3
|
+
class TestThreading < Test::Unit::TestCase
|
|
4
|
+
include Mongo
|
|
5
|
+
|
|
6
|
+
def test_uri_without_port
|
|
7
|
+
parser = Mongo::URIParser.new('mongodb://localhost')
|
|
8
|
+
assert_equal 1, parser.nodes.length
|
|
9
|
+
assert_equal 'localhost', parser.nodes[0][0]
|
|
10
|
+
assert_equal 27017, parser.nodes[0][1]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_basic_uri
|
|
14
|
+
parser = Mongo::URIParser.new('mongodb://localhost:27018')
|
|
15
|
+
assert_equal 1, parser.nodes.length
|
|
16
|
+
assert_equal 'localhost', parser.nodes[0][0]
|
|
17
|
+
assert_equal 27018, parser.nodes[0][1]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_multiple_uris
|
|
21
|
+
parser = Mongo::URIParser.new('mongodb://a.example.com:27018,b.example.com')
|
|
22
|
+
assert_equal 2, parser.nodes.length
|
|
23
|
+
assert_equal 'a.example.com', parser.nodes[0][0]
|
|
24
|
+
assert_equal 27018, parser.nodes[0][1]
|
|
25
|
+
assert_equal 'b.example.com', parser.nodes[1][0]
|
|
26
|
+
assert_equal 27017, parser.nodes[1][1]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_complex_passwords
|
|
30
|
+
parser = Mongo::URIParser.new('mongodb://bob:secret.word@a.example.com:27018/test')
|
|
31
|
+
assert_equal "bob", parser.auths[0]["username"]
|
|
32
|
+
assert_equal "secret.word", parser.auths[0]["password"]
|
|
33
|
+
|
|
34
|
+
parser = Mongo::URIParser.new('mongodb://bob:s-_3#%R.t@a.example.com:27018/test')
|
|
35
|
+
assert_equal "bob", parser.auths[0]["username"]
|
|
36
|
+
assert_equal "s-_3#%R.t", parser.auths[0]["password"]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_passwords_contain_no_commas
|
|
40
|
+
assert_raise MongoArgumentError do
|
|
41
|
+
Mongo::URIParser.new('mongodb://bob:a,b@a.example.com:27018/test')
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_multiple_uris_with_auths
|
|
46
|
+
parser = Mongo::URIParser.new('mongodb://bob:secret@a.example.com:27018/test,joe:secret2@b.example.com/test2')
|
|
47
|
+
assert_equal 2, parser.nodes.length
|
|
48
|
+
assert_equal 'a.example.com', parser.nodes[0][0]
|
|
49
|
+
assert_equal 27018, parser.nodes[0][1]
|
|
50
|
+
assert_equal 'b.example.com', parser.nodes[1][0]
|
|
51
|
+
assert_equal 27017, parser.nodes[1][1]
|
|
52
|
+
assert_equal 2, parser.auths.length
|
|
53
|
+
assert_equal "bob", parser.auths[0]["username"]
|
|
54
|
+
assert_equal "secret", parser.auths[0]["password"]
|
|
55
|
+
assert_equal "test", parser.auths[0]["db_name"]
|
|
56
|
+
assert_equal "joe", parser.auths[1]["username"]
|
|
57
|
+
assert_equal "secret2", parser.auths[1]["password"]
|
|
58
|
+
assert_equal "test2", parser.auths[1]["db_name"]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_opts_basic
|
|
62
|
+
parser = Mongo::URIParser.new('mongodb://localhost:27018?connect=direct;slaveok=true;safe=true')
|
|
63
|
+
assert_equal 'direct', parser.connect
|
|
64
|
+
assert parser.slaveok
|
|
65
|
+
assert parser.safe
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_opts_with_amp_separator
|
|
69
|
+
parser = Mongo::URIParser.new('mongodb://localhost:27018?connect=direct&slaveok=true&safe=true')
|
|
70
|
+
assert_equal 'direct', parser.connect
|
|
71
|
+
assert parser.slaveok
|
|
72
|
+
assert parser.safe
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_opts_safe
|
|
76
|
+
parser = Mongo::URIParser.new('mongodb://localhost:27018?safe=true;w=2;wtimeout=200;fsync=true')
|
|
77
|
+
assert parser.safe
|
|
78
|
+
assert_equal 2, parser.w
|
|
79
|
+
assert_equal 200, parser.wtimeout
|
|
80
|
+
assert parser.fsync
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_opts_replica_set
|
|
84
|
+
assert_raise_error MongoArgumentError, "specify that connect=replicaset" do
|
|
85
|
+
Mongo::URIParser.new('mongodb://localhost:27018?replicaset=foo')
|
|
86
|
+
end
|
|
87
|
+
parser = Mongo::URIParser.new('mongodb://localhost:27018?connect=replicaset;replicaset=foo')
|
|
88
|
+
assert_equal 'foo', parser.replicaset
|
|
89
|
+
assert_equal 'replicaset', parser.connect
|
|
90
|
+
end
|
|
91
|
+
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mongo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
5
|
-
prerelease:
|
|
4
|
+
hash: 27
|
|
5
|
+
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
version: 1.
|
|
8
|
+
- 3
|
|
9
|
+
- 0
|
|
10
|
+
version: 1.3.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Jim Menard
|
|
@@ -17,7 +17,7 @@ autorequire:
|
|
|
17
17
|
bindir: bin
|
|
18
18
|
cert_chain: []
|
|
19
19
|
|
|
20
|
-
date:
|
|
20
|
+
date: 2011-04-04 00:00:00 -04:00
|
|
21
21
|
default_executable:
|
|
22
22
|
dependencies:
|
|
23
23
|
- !ruby/object:Gem::Dependency
|
|
@@ -28,12 +28,12 @@ dependencies:
|
|
|
28
28
|
requirements:
|
|
29
29
|
- - ">="
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
|
-
hash:
|
|
31
|
+
hash: 27
|
|
32
32
|
segments:
|
|
33
33
|
- 1
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
version: 1.
|
|
34
|
+
- 3
|
|
35
|
+
- 0
|
|
36
|
+
version: 1.3.0
|
|
37
37
|
type: :runtime
|
|
38
38
|
version_requirements: *id001
|
|
39
39
|
description: A Ruby driver for MongoDB. For more information about Mongo, see http://www.mongodb.org.
|
|
@@ -55,6 +55,7 @@ files:
|
|
|
55
55
|
- lib/mongo/exceptions.rb
|
|
56
56
|
- lib/mongo/connection.rb
|
|
57
57
|
- lib/mongo/repl_set_connection.rb
|
|
58
|
+
- lib/mongo/test.rb
|
|
58
59
|
- lib/mongo/gridfs/grid_io.rb
|
|
59
60
|
- lib/mongo/gridfs/grid_file_system.rb
|
|
60
61
|
- lib/mongo/gridfs/grid.rb
|
|
@@ -72,7 +73,7 @@ files:
|
|
|
72
73
|
- docs/CREDITS.md
|
|
73
74
|
- docs/FAQ.md
|
|
74
75
|
- docs/REPLICA_SETS.md
|
|
75
|
-
- docs/
|
|
76
|
+
- docs/RELEASES.md
|
|
76
77
|
- docs/GridFS.md
|
|
77
78
|
- docs/WRITE_CONCERN.md
|
|
78
79
|
- bin/mongo_console
|
|
@@ -87,18 +88,34 @@ files:
|
|
|
87
88
|
- test/unit/safe_test.rb
|
|
88
89
|
- test/db_test.rb
|
|
89
90
|
- test/collection_test.rb
|
|
91
|
+
- test/async/collection_test.rb
|
|
92
|
+
- test/async/cursor_test.rb
|
|
93
|
+
- test/async/connection_test.rb
|
|
94
|
+
- test/async/worker_pool_test.rb
|
|
90
95
|
- test/cursor_test.rb
|
|
96
|
+
- test/load/unicorn/unicorn.rb
|
|
97
|
+
- test/load/unicorn/load.rb
|
|
98
|
+
- test/load/resque/processor.rb
|
|
99
|
+
- test/load/resque/load.rb
|
|
100
|
+
- test/load/thin/load.rb
|
|
91
101
|
- test/grid_test.rb
|
|
92
102
|
- test/db_api_test.rb
|
|
93
103
|
- test/auxillary/slave_connection_test.rb
|
|
104
|
+
- test/auxillary/threaded_authentication_test.rb
|
|
94
105
|
- test/auxillary/authentication_test.rb
|
|
106
|
+
- test/auxillary/fork_test.rb
|
|
95
107
|
- test/auxillary/autoreconnect_test.rb
|
|
108
|
+
- test/auxillary/repl_set_auth_test.rb
|
|
96
109
|
- test/auxillary/1.4_features.rb
|
|
97
110
|
- test/conversions_test.rb
|
|
98
111
|
- test/connection_test.rb
|
|
112
|
+
- test/uri_test.rb
|
|
99
113
|
- test/cursor_message_test.rb
|
|
100
114
|
- test/tools/test.rb
|
|
101
115
|
- test/tools/repl_set_manager.rb
|
|
116
|
+
- test/tools/auth_repl_set_manager.rb
|
|
117
|
+
- test/tools/load.rb
|
|
118
|
+
- test/tools/sharding_manager.rb
|
|
102
119
|
- test/cursor_fail_test.rb
|
|
103
120
|
- test/threading/threading_with_large_pool_test.rb
|
|
104
121
|
- test/test_helper.rb
|
|
@@ -107,6 +124,7 @@ files:
|
|
|
107
124
|
- test/bson/binary_test.rb
|
|
108
125
|
- test/bson/object_id_test.rb
|
|
109
126
|
- test/bson/json_test.rb
|
|
127
|
+
- test/bson/timestamp_test.rb
|
|
110
128
|
- test/bson/bson_test.rb
|
|
111
129
|
- test/bson/ordered_hash_test.rb
|
|
112
130
|
- test/bson/hash_with_indifferent_access_test.rb
|
|
@@ -119,6 +137,7 @@ files:
|
|
|
119
137
|
- test/replica_sets/replication_ack_test.rb
|
|
120
138
|
- test/replica_sets/query_secondaries.rb
|
|
121
139
|
- test/replica_sets/query_test.rb
|
|
140
|
+
- test/replica_sets/connection_string_test.rb
|
|
122
141
|
- test/replica_sets/insert_test.rb
|
|
123
142
|
- test/replica_sets/connect_test.rb
|
|
124
143
|
- test/safe_test.rb
|
|
@@ -156,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
156
175
|
requirements: []
|
|
157
176
|
|
|
158
177
|
rubyforge_project:
|
|
159
|
-
rubygems_version: 1.
|
|
178
|
+
rubygems_version: 1.4.1
|
|
160
179
|
signing_key:
|
|
161
180
|
specification_version: 3
|
|
162
181
|
summary: Ruby driver for the MongoDB
|
|
@@ -172,18 +191,34 @@ test_files:
|
|
|
172
191
|
- test/unit/safe_test.rb
|
|
173
192
|
- test/db_test.rb
|
|
174
193
|
- test/collection_test.rb
|
|
194
|
+
- test/async/collection_test.rb
|
|
195
|
+
- test/async/cursor_test.rb
|
|
196
|
+
- test/async/connection_test.rb
|
|
197
|
+
- test/async/worker_pool_test.rb
|
|
175
198
|
- test/cursor_test.rb
|
|
199
|
+
- test/load/unicorn/unicorn.rb
|
|
200
|
+
- test/load/unicorn/load.rb
|
|
201
|
+
- test/load/resque/processor.rb
|
|
202
|
+
- test/load/resque/load.rb
|
|
203
|
+
- test/load/thin/load.rb
|
|
176
204
|
- test/grid_test.rb
|
|
177
205
|
- test/db_api_test.rb
|
|
178
206
|
- test/auxillary/slave_connection_test.rb
|
|
207
|
+
- test/auxillary/threaded_authentication_test.rb
|
|
179
208
|
- test/auxillary/authentication_test.rb
|
|
209
|
+
- test/auxillary/fork_test.rb
|
|
180
210
|
- test/auxillary/autoreconnect_test.rb
|
|
211
|
+
- test/auxillary/repl_set_auth_test.rb
|
|
181
212
|
- test/auxillary/1.4_features.rb
|
|
182
213
|
- test/conversions_test.rb
|
|
183
214
|
- test/connection_test.rb
|
|
215
|
+
- test/uri_test.rb
|
|
184
216
|
- test/cursor_message_test.rb
|
|
185
217
|
- test/tools/test.rb
|
|
186
218
|
- test/tools/repl_set_manager.rb
|
|
219
|
+
- test/tools/auth_repl_set_manager.rb
|
|
220
|
+
- test/tools/load.rb
|
|
221
|
+
- test/tools/sharding_manager.rb
|
|
187
222
|
- test/cursor_fail_test.rb
|
|
188
223
|
- test/threading/threading_with_large_pool_test.rb
|
|
189
224
|
- test/test_helper.rb
|
|
@@ -192,6 +227,7 @@ test_files:
|
|
|
192
227
|
- test/bson/binary_test.rb
|
|
193
228
|
- test/bson/object_id_test.rb
|
|
194
229
|
- test/bson/json_test.rb
|
|
230
|
+
- test/bson/timestamp_test.rb
|
|
195
231
|
- test/bson/bson_test.rb
|
|
196
232
|
- test/bson/ordered_hash_test.rb
|
|
197
233
|
- test/bson/hash_with_indifferent_access_test.rb
|
|
@@ -204,6 +240,7 @@ test_files:
|
|
|
204
240
|
- test/replica_sets/replication_ack_test.rb
|
|
205
241
|
- test/replica_sets/query_secondaries.rb
|
|
206
242
|
- test/replica_sets/query_test.rb
|
|
243
|
+
- test/replica_sets/connection_string_test.rb
|
|
207
244
|
- test/replica_sets/insert_test.rb
|
|
208
245
|
- test/replica_sets/connect_test.rb
|
|
209
246
|
- test/safe_test.rb
|
data/docs/1.0_UPGRADE.md
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
You can upgrade freely from v0.20 to v1.0.
|
|
2
|
-
|
|
3
|
-
However, if you're running a version < 0.20, upgrade to 0.20
|
|
4
|
-
before upgrading to 1.0.
|
|
5
|
-
|
|
6
|
-
The upgrade to 0.20 requires some minor code upgrades.
|
|
7
|
-
|
|
8
|
-
1. Note the exception changes in HISTORY. Certain exceptions are now scoped under the BSON
|
|
9
|
-
module; if you're catching these, you will need to modify your code.
|
|
10
|
-
|
|
11
|
-
2. The BSON types are now scoped under the BSON module.
|
|
12
|
-
|
|
13
|
-
3. Note that mongo_ext no longer exists. The new gems are bson and bson_ext.
|
|
14
|
-
|
|
15
|
-
4. Indexes on GridFS chunks collections should be unique. If you have existing GridFS
|
|
16
|
-
collections, you should drop the current index and replace with a unique one. Before you do this,
|
|
17
|
-
make sure that index doesn't exist; no need to go through process unnecessarily.
|
|
18
|
-
If you do need to create the index, once you have the chunks collection, here are the commands you can run:
|
|
19
|
-
|
|
20
|
-
@chunks.drop_index('files_id_1_n_1')
|
|
21
|
-
@chunks.create_index([['files_id', Mongo::ASCENDING], ['n', Mongo::ASCENDING]], :unique => true)
|