test/functional/client_test.rb in mongo-1.11.1 vs test/functional/client_test.rb in mongo-1.12.0.rc0
- old
+ new
@@ -72,10 +72,31 @@
assert MongoClient.new
end
end
end
+ def test_unix_sock
+ # There's an issue with unix sockets on JRuby with 32-bit libc
+ # https://jira.codehaus.org/browse/JRUBY-7183
+ return if RUBY_PLATFORM =~ /java/
+ begin
+ assert MongoClient.new("/tmp/mongodb-#{TEST_PORT}.sock")
+ rescue Errno::EAFNOSUPPORT
+ # System doesn't support UNIX sockets
+ end
+ end
+
+ def test_initialize_with_auths
+ auth = { :username => TEST_USER,
+ :password => TEST_USER_PWD,
+ :db_name => TEST_DB,
+ :source => TEST_DB}
+
+ client = MongoClient.new(:auths => Set.new([auth]))
+ assert client['test']['test'].find.to_a
+ end
+
def test_connection_uri
con = MongoClient.from_uri("mongodb://#{host_port}")
assert_equal mongo_host, con.primary_pool.host
assert_equal mongo_port, con.primary_pool.port
end
@@ -426,9 +447,21 @@
conn.primary_pool.port = Mongo::MongoClient::DEFAULT_PORT
conn.primary_pool.instance_variable_set("@pids", {dropped_socket => Process.pid})
conn.primary_pool.instance_variable_set("@sockets", [dropped_socket])
assert !conn.active?
+ end
+
+ def test_operation_timeout_with_active
+ conn = standard_connection
+ assert conn.active?
+ assert_equal Mongo::MongoClient::DEFAULT_OP_TIMEOUT, conn.op_timeout
+
+ pool = conn.primary_pool
+ socket = pool.instance_variable_get(:@thread_ids_to_sockets)[Thread.current.object_id]
+
+ socket.stubs(:read).raises(Mongo::OperationTimeout)
+ assert_equal false, conn.active?
end
context "Saved authentications" do
setup do
@client = Mongo::MongoClient.new