|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -TEST_HOST = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' unless defined? TEST_HOST |
16 | | -TEST_DATA = File.join(File.dirname(__FILE__), 'fixtures/data') |
17 | | -TEST_BASE = Test::Unit::TestCase |
| 15 | +TEST_HOST = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' unless defined? TEST_HOST |
| 16 | +TEST_DATA = File.join(File.dirname(__FILE__), 'fixtures/data') |
| 17 | +TEST_OP_TIMEOUT = 40 |
| 18 | +TEST_BASE = Test::Unit::TestCase |
18 | 19 |
|
19 | 20 | unless defined? TEST_PORT |
20 | 21 | TEST_PORT = if ENV['MONGO_RUBY_DRIVER_PORT'] |
@@ -89,16 +90,17 @@ def rescue_connection_failure(max_retries=30) |
89 | 90 | # |
90 | 91 | # @return [MongoClient] The client instance. |
91 | 92 | def self.standard_connection(options={}, legacy=false) |
| 93 | + opts = options[:op_timeout] ? options : options.merge(:op_timeout => TEST_OP_TIMEOUT) |
92 | 94 | if legacy |
93 | 95 | silently do |
94 | 96 | # We have to create the Connection object directly here instead of using TEST_URI |
95 | 97 | # because Connection#from_uri ends up creating a MongoClient object. |
96 | | - conn = Connection.new(TEST_HOST, TEST_PORT, options) |
| 98 | + conn = Connection.new(TEST_HOST, TEST_PORT, opts) |
97 | 99 | conn[TEST_DB].authenticate(TEST_USER, TEST_USER_PWD) |
98 | 100 | conn |
99 | 101 | end |
100 | 102 | else |
101 | | - MongoClient.from_uri(TEST_URI, options) |
| 103 | + MongoClient.from_uri(TEST_URI, opts) |
102 | 104 | end |
103 | 105 | end |
104 | 106 |
|
@@ -420,7 +422,7 @@ def self.cleanup_users_and_dbs |
420 | 422 | not_cluster = TEST_BASE.class_eval { class_variables }.none? { |v| v =~ /@@cluster_/ } |
421 | 423 |
|
422 | 424 | if @@connected_single_mongod && not_cluster |
423 | | - client = Mongo::MongoClient.from_uri(TEST_URI) |
| 425 | + client = Mongo::MongoClient.from_uri(TEST_URI, :op_timeout => TEST_OP_TIMEOUT) |
424 | 426 | db = client[TEST_DB] |
425 | 427 | begin |
426 | 428 | begin |
|
0 commit comments