Skip to content
5 changes: 1 addition & 4 deletions tasks/testing.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ TEST_SUITES = {
:threading => { :pattern => 'test/threading/**/*_test.rb' },
:replica_set => {
:pattern => 'test/replica_set/**/*_test.rb',
:exclude => ['test/replica_set/complex_connect_test.rb',
'test/replica_set/count_test.rb',
'test/replica_set/read_preference_test.rb',
'test/replica_set/ssl_test.rb']
:exclude => ['test/replica_set/ssl_test.rb']
},
:sharded_cluster => { :pattern => 'test/sharded_cluster/**/*_test.rb' },
:tools => {
Expand Down
3 changes: 2 additions & 1 deletion test/functional/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ def test_connection_activity
end

def test_operation_timeout_with_active
conn = standard_connection
conn = MongoClient.new
authenticate_client(conn)
assert conn.active?
assert_equal Mongo::MongoClient::DEFAULT_OP_TIMEOUT, conn.op_timeout

Expand Down
14 changes: 8 additions & 6 deletions test/helpers/test_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

TEST_HOST = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' unless defined? TEST_HOST
TEST_DATA = File.join(File.dirname(__FILE__), 'fixtures/data')
TEST_BASE = Test::Unit::TestCase
TEST_HOST = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' unless defined? TEST_HOST
TEST_DATA = File.join(File.dirname(__FILE__), 'fixtures/data')
TEST_OP_TIMEOUT = 40
TEST_BASE = Test::Unit::TestCase

unless defined? TEST_PORT
TEST_PORT = if ENV['MONGO_RUBY_DRIVER_PORT']
Expand Down Expand Up @@ -89,16 +90,17 @@ def rescue_connection_failure(max_retries=30)
#
# @return [MongoClient] The client instance.
def self.standard_connection(options={}, legacy=false)
opts = options[:op_timeout] ? options : options.merge(:op_timeout => TEST_OP_TIMEOUT)
if legacy
silently do
# We have to create the Connection object directly here instead of using TEST_URI
# because Connection#from_uri ends up creating a MongoClient object.
conn = Connection.new(TEST_HOST, TEST_PORT, options)
conn = Connection.new(TEST_HOST, TEST_PORT, opts)
conn[TEST_DB].authenticate(TEST_USER, TEST_USER_PWD)
conn
end
else
MongoClient.from_uri(TEST_URI, options)
MongoClient.from_uri(TEST_URI, opts)
end
end

Expand Down Expand Up @@ -420,7 +422,7 @@ def self.cleanup_users_and_dbs
not_cluster = TEST_BASE.class_eval { class_variables }.none? { |v| v =~ /@@cluster_/ }

if @@connected_single_mongod && not_cluster
client = Mongo::MongoClient.from_uri(TEST_URI)
client = Mongo::MongoClient.from_uri(TEST_URI, :op_timeout => TEST_OP_TIMEOUT)
db = client[TEST_DB]
begin
begin
Expand Down
2 changes: 1 addition & 1 deletion test/replica_set/authentication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ReplicaSetAuthenticationTest < Test::Unit::TestCase

def setup
ensure_cluster(:rs)
@client = MongoReplicaSetClient.from_uri(@uri)
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
@admin = @client['admin']
@version = @client.server_version
@db = @client['ruby-test']
Expand Down
2 changes: 1 addition & 1 deletion test/replica_set/basic_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setup
end

def test_connect
client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :name => @rs.repl_set_name)
client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :name => @rs.repl_set_name, :op_timeout => TEST_OP_TIMEOUT)
assert client.connected?
assert_equal @rs.primary_name, client.primary.join(':')
assert_equal @rs.secondary_names.sort, client.secondaries.collect{|s| s.join(':')}.sort
Expand Down
2 changes: 1 addition & 1 deletion test/replica_set/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def teardown
end

def test_reconnection
@client = MongoReplicaSetClient.from_uri(@uri)
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
assert @client.connected?

manager = @client.local_manager
Expand Down
80 changes: 0 additions & 80 deletions test/replica_set/complex_connect_test.rb

This file was deleted.

2 changes: 1 addition & 1 deletion test/replica_set/count_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ReplicaSetCountTest < Test::Unit::TestCase

def setup
ensure_cluster(:rs)
@client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :read => :primary_preferred)
@client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :read => :primary_preferred, :op_timeout => TEST_OP_TIMEOUT)
authenticate_client(@client)
assert @client.primary_pool
@primary = MongoClient.new(@client.primary_pool.host, @client.primary_pool.port)
Expand Down
2 changes: 1 addition & 1 deletion test/replica_set/cursor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_intervening_query_secondary
def setup_client(read=:primary)
route_read ||= read
# Setup ReplicaSet Connection
@client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :read => read)
@client = MongoReplicaSetClient.new(@rs.repl_set_seeds, :read => read, :op_timeout => TEST_OP_TIMEOUT)
authenticate_client(@client)

@db = @client.db(TEST_DB)
Expand Down
2 changes: 1 addition & 1 deletion test/replica_set/insert_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ReplicaSetInsertTest < Test::Unit::TestCase

def setup
ensure_cluster(:rs)
@client = MongoReplicaSetClient.from_uri(@uri)
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
@version = @client.server_version
@db = @client.db(TEST_DB)
@db.drop_collection("test-sets")
Expand Down
2 changes: 1 addition & 1 deletion test/replica_set/max_values_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MaxValuesTest < Test::Unit::TestCase

def setup
ensure_cluster(:rs)
@client = MongoReplicaSetClient.from_uri(@uri)
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
@db = new_mock_db
@client.stubs(:[]).returns(@db)
@ismaster = {
Expand Down
2 changes: 1 addition & 1 deletion test/replica_set/pinning_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class ReplicaSetPinningTest < Test::Unit::TestCase
def setup
ensure_cluster(:rs)
@client = MongoReplicaSetClient.from_uri(@uri)
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
@db = @client.db(TEST_DB)
@coll = @db.collection("test-sets")
@coll.insert({:a => 1})
Expand Down
2 changes: 1 addition & 1 deletion test/replica_set/query_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ReplicaSetQueryTest < Test::Unit::TestCase

def setup
ensure_cluster(:rs)
@client = MongoReplicaSetClient.from_uri(@uri)
@client = MongoReplicaSetClient.from_uri(@uri, :op_timeout => TEST_OP_TIMEOUT)
@db = @client.db(TEST_DB)
@db.drop_collection("test-sets")
@coll = @db.collection("test-sets")
Expand Down
Loading