Skip to content

Commit 2435597

Browse files
committed
Working replica set tests
1 parent e3c1b1e commit 2435597

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

test/replica_sets/insert_test.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
require 'test/unit'
44
require 'test/test_helper'
55

6-
# NOTE: this test should be run only if a replica pair is running.
7-
class ReplicaPairInsertTest < Test::Unit::TestCase
6+
# NOTE: This test expects a replica set of three nodes to be running
7+
# on the local host.
8+
class ReplicaSetInsertTest < Test::Unit::TestCase
89
include Mongo
910

1011
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")
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")
1516
end
1617

1718
def test_insert

test/replica_sets/pooled_insert_test.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
require 'test/unit'
44
require 'test/test_helper'
55

6-
# NOTE: this test should be run only if a replica pair is running.
7-
class ReplicaPairPooledInsertTest < Test::Unit::TestCase
6+
# NOTE: This test expects a replica set of three nodes to be running
7+
# on the local host.
8+
class ReplicaSetPooledInsertTest < Test::Unit::TestCase
89
include Mongo
910

1011
def setup
11-
@conn = Mongo::Connection.new({:left => ["localhost", 27017], :right => ["localhost", 27018]}, nil, :pool_size => 10, :timeout => 5)
12-
@db = @conn.db('mongo-ruby-test')
13-
@db.drop_collection("test-pairs")
14-
@coll = @db.collection("test-pairs")
12+
@conn = Mongo::Connection.multi([['localhost', 27017], ['localhost', 27018], ['localhost', 27019]],
13+
:pool_size => 10, :timeout => 5)
14+
@db = @conn.db(MONGO_TEST_DB)
15+
@db.drop_collection("test-sets")
16+
@coll = @db.collection("test-sets")
1517
end
1618

1719
def test_insert

test/replica_sets/query_test.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
require 'test/unit'
44
require 'test/test_helper'
55

6-
# NOTE: this test should be run only if a replica pair is running.
6+
# NOTE: This test expects a replica set of three nodes to be running
7+
# on the local host.
78
class ReplicaPairQueryTest < Test::Unit::TestCase
89
include Mongo
910

1011
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")
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")
1516
end
1617

1718
def test_query

0 commit comments

Comments
 (0)