mongo 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +50 -69
- data/docs/CREDITS.md +4 -0
- data/docs/HISTORY.md +9 -0
- data/docs/REPLICA_SETS.md +8 -10
- data/lib/mongo.rb +3 -1
- data/lib/mongo/collection.rb +2 -1
- data/lib/mongo/connection.rb +146 -314
- data/lib/mongo/db.rb +6 -2
- data/lib/mongo/gridfs/grid.rb +1 -1
- data/lib/mongo/gridfs/grid_io.rb +29 -5
- data/lib/mongo/repl_set_connection.rb +290 -0
- data/lib/mongo/util/pool.rb +6 -8
- data/lib/mongo/util/uri_parser.rb +71 -0
- data/mongo.gemspec +1 -2
- data/test/collection_test.rb +9 -7
- data/test/connection_test.rb +0 -6
- data/test/grid_file_system_test.rb +2 -2
- data/test/grid_io_test.rb +33 -1
- data/test/grid_test.rb +36 -6
- data/test/replica_sets/connect_test.rb +59 -21
- data/test/replica_sets/count_test.rb +9 -7
- data/test/replica_sets/insert_test.rb +11 -9
- data/test/replica_sets/pooled_insert_test.rb +12 -13
- data/test/replica_sets/query_secondaries.rb +48 -8
- data/test/replica_sets/query_test.rb +10 -9
- data/test/replica_sets/replication_ack_test.rb +15 -22
- data/test/replica_sets/rs_test_helper.rb +29 -0
- data/test/test_helper.rb +13 -20
- data/test/threading/{test_threading_large_pool.rb → threading_with_large_pool_test.rb} +1 -1
- data/test/tools/repl_set_manager.rb +241 -0
- data/test/tools/test.rb +13 -0
- data/test/unit/connection_test.rb +3 -85
- data/test/unit/repl_set_connection_test.rb +82 -0
- metadata +19 -21
- data/test/replica_pairs/count_test.rb +0 -34
- data/test/replica_pairs/insert_test.rb +0 -50
- data/test/replica_pairs/pooled_insert_test.rb +0 -54
- data/test/replica_pairs/query_test.rb +0 -39
- data/test/replica_sets/node_type_test.rb +0 -42
- data/test/rs.rb +0 -24
@@ -1,39 +0,0 @@
|
|
1
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
require 'mongo'
|
3
|
-
require 'test/unit'
|
4
|
-
require './test/test_helper'
|
5
|
-
|
6
|
-
# NOTE: this test should be run only if a replica pair is running.
|
7
|
-
class ReplicaPairQueryTest < Test::Unit::TestCase
|
8
|
-
include Mongo
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@conn = Mongo::Connection.new({:left => ["localhost", 27017], :right => ["localhost", 27018]}, nil)
|
12
|
-
@db = @conn.db('mongo-ruby-test')
|
13
|
-
@db.drop_collection("test-pairs")
|
14
|
-
@coll = @db.collection("test-pairs")
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_query
|
18
|
-
@coll.save({:a => 20})
|
19
|
-
@coll.save({:a => 30})
|
20
|
-
@coll.save({:a => 40})
|
21
|
-
results = []
|
22
|
-
@coll.find.each {|r| results << r}
|
23
|
-
[20, 30, 40].each do |a|
|
24
|
-
assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
|
25
|
-
end
|
26
|
-
|
27
|
-
puts "Please disconnect the current master."
|
28
|
-
gets
|
29
|
-
|
30
|
-
results = []
|
31
|
-
rescue_connection_failure do
|
32
|
-
@coll.find.each {|r| results << r}
|
33
|
-
[20, 30, 40].each do |a|
|
34
|
-
assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
require 'mongo'
|
3
|
-
require 'test/unit'
|
4
|
-
require './test/test_helper'
|
5
|
-
|
6
|
-
# NOTE: This test expects a replica set of three nodes, one of which is an arbiter, to be running
|
7
|
-
# on the local host.
|
8
|
-
class ReplicaSetNodeTypeTest < Test::Unit::TestCase
|
9
|
-
include Mongo
|
10
|
-
|
11
|
-
def setup
|
12
|
-
@conn = Mongo::Connection.multi([['localhost', 27017], ['localhost', 27018], ['localhost', 27019]])
|
13
|
-
@db = @conn.db(MONGO_TEST_DB)
|
14
|
-
@db.drop_collection("test-sets")
|
15
|
-
@coll = @db.collection("test-sets")
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_correct_node_types
|
19
|
-
p @conn.primary
|
20
|
-
p @conn.secondaries
|
21
|
-
p @conn.arbiters
|
22
|
-
assert_equal 1, @conn.secondaries.length
|
23
|
-
assert_equal 1, @conn.arbiters.length
|
24
|
-
|
25
|
-
old_secondary = @conn.secondaries.first
|
26
|
-
old_primary = @conn.primary
|
27
|
-
|
28
|
-
puts "Please disconnect the current primary and reconnect so that it becomes secondary."
|
29
|
-
gets
|
30
|
-
|
31
|
-
# Insert something to rescue the connection failure.
|
32
|
-
rescue_connection_failure do
|
33
|
-
@coll.insert({:a => 30}, :safe => true)
|
34
|
-
end
|
35
|
-
|
36
|
-
assert_equal 1, @conn.secondaries.length
|
37
|
-
assert_equal 1, @conn.arbiters.length
|
38
|
-
assert_equal old_primary, @conn.secondaries.first
|
39
|
-
assert_equal old_secondary, @conn.primary
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
data/test/rs.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'mongo'
|
5
|
-
|
6
|
-
START_PORT = 27017
|
7
|
-
N = 4
|
8
|
-
|
9
|
-
N.times do |n|
|
10
|
-
system("sudo rm -rf /data/rs#{n}")
|
11
|
-
system("sudo mkdir -p /data/rs#{n}")
|
12
|
-
system("sudo chown kyle:kyle /data/rs#{n}")
|
13
|
-
system("mongod --replSet replica-set-foo --logpath '#{n}.log' --dbpath /data/rs#{n} --port #{START_PORT + n} --fork")
|
14
|
-
end
|
15
|
-
|
16
|
-
con =<<DOC
|
17
|
-
config = {_id: 'replica-set-foo',
|
18
|
-
members: [{_id: 0, host:'localhost:27017'},
|
19
|
-
{_id:1, host:'localhost:27018'},
|
20
|
-
{_id: 2, host: 'localhost:27019', arbiterOnly: true},
|
21
|
-
{_id: 3, host: 'localhost:27020'}]}"
|
22
|
-
DOC
|
23
|
-
|
24
|
-
puts con
|