From 6944794fb23491c364cc2cadc5435e77e599eea0 Mon Sep 17 00:00:00 2001 From: Tyler Brock Date: Fri, 16 Mar 2012 16:17:33 -0400 Subject: [PATCH] RUBY-422 Cleanup testing output --- lib/bson/bson_ruby.rb | 4 +- lib/bson/byte_buffer.rb | 2 +- lib/bson/types/object_id.rb | 52 ++++++++++--------- lib/mongo/collection.rb | 2 +- lib/mongo/connection.rb | 2 +- lib/mongo/gridfs/grid_file_system.rb | 2 +- lib/mongo/networking.rb | 10 +++- lib/mongo/util/node.rb | 2 +- lib/mongo/util/pool.rb | 2 +- test/bson/bson_test.rb | 33 ++++++------ .../bson/hash_with_indifferent_access_test.rb | 1 - test/bson/json_test.rb | 2 +- test/collection_test.rb | 9 +++- test/connection_test.rb | 19 ++++--- test/cursor_test.rb | 8 +-- test/grid_file_system_test.rb | 4 +- test/grid_io_test.rb | 4 +- test/grid_test.rb | 17 ++++-- test/replica_sets/connect_test.rb | 4 +- test/replica_sets/pooled_insert_test.rb | 2 +- test/replica_sets/rs_test_helper.rb | 2 +- test/test_helper.rb | 10 ++-- .../threading_with_large_pool_test.rb | 2 +- test/threading_test.rb | 2 +- test/unit/connection_test.rb | 7 --- test/uri_test.rb | 3 +- 26 files changed, 114 insertions(+), 93 deletions(-) diff --git a/lib/bson/bson_ruby.rb b/lib/bson/bson_ruby.rb index 223bda5..9632432 100644 --- a/lib/bson/bson_ruby.rb +++ b/lib/bson/bson_ruby.rb @@ -59,7 +59,7 @@ module BSON def self.to_utf8_binary(str) begin str.unpack("U*") - rescue => ex + rescue raise InvalidStringEncoding, "String not valid utf-8: #{str.inspect}" end str.encode(UTF8_ENCODING).force_encoding(BINARY_ENCODING) @@ -70,7 +70,7 @@ module BSON def self.to_utf8_binary(str) begin str.unpack("U*") - rescue => ex + rescue raise InvalidStringEncoding, "String not valid utf-8: #{str.inspect}" end str diff --git a/lib/bson/byte_buffer.rb b/lib/bson/byte_buffer.rb index 2ec4b40..297e483 100644 --- a/lib/bson/byte_buffer.rb +++ b/lib/bson/byte_buffer.rb @@ -57,7 +57,7 @@ module BSON def self.to_utf8_binary(str) begin str.unpack("U*") - rescue => ex + rescue raise InvalidStringEncoding, "String not valid utf-8: #{str.inspect}" end str diff --git a/lib/bson/types/object_id.rb b/lib/bson/types/object_id.rb index 54e41ed..6bfb7dc 100644 --- a/lib/bson/types/object_id.rb +++ b/lib/bson/types/object_id.rb @@ -192,33 +192,37 @@ module BSON @@index = 0 @@machine_id = Digest::MD5.digest(Socket.gethostname)[0, 3] - # This gets overwritten by the C extension if it loads. - def generate(oid_time=nil) - oid = '' + # We need to check whether BSON_CODER is defined because it's required by + # the BSON C extensions. + if defined?(BSON::BSON_CODER) && BSON::BSON_CODER == BSON::BSON_RUBY + # This gets overwritten by the C extension if it loads. + def generate(oid_time=nil) + oid = '' - # 4 bytes current time - if oid_time - t = oid_time.to_i - else - t = Time.new.to_i + # 4 bytes current time + if oid_time + t = oid_time.to_i + else + t = Time.new.to_i + end + oid += [t].pack("N") + + # 3 bytes machine + oid += @@machine_id + + # 2 bytes pid + oid += [Process.pid % 0xFFFF].pack("n") + + # 3 bytes inc + oid += [get_inc].pack("N")[1, 3] + + oid.unpack("C12") end - oid += [t].pack("N") - # 3 bytes machine - oid += @@machine_id - - # 2 bytes pid - oid += [Process.pid % 0xFFFF].pack("n") - - # 3 bytes inc - oid += [get_inc].pack("N")[1, 3] - - oid.unpack("C12") - end - - def get_inc - @@lock.synchronize do - @@index = (@@index + 1) % 0xFFFFFF + def get_inc + @@lock.synchronize do + @@index = (@@index + 1) % 0xFFFFFF + end end end end diff --git a/lib/mongo/collection.rb b/lib/mongo/collection.rb index 5ac7f1b..1ad1bc7 100644 --- a/lib/mongo/collection.rb +++ b/lib/mongo/collection.rb @@ -961,7 +961,7 @@ module Mongo begin message.put_binary(BSON::BSON_CODER.serialize(doc, check_keys, true, @connection.max_bson_size).to_s) true - rescue StandardError => e # StandardError will be replaced with BSONError + rescue StandardError # StandardError will be replaced with BSONError doc.delete(:_id) error_docs << doc false diff --git a/lib/mongo/connection.rb b/lib/mongo/connection.rb index 3fe8089..618e938 100644 --- a/lib/mongo/connection.rb +++ b/lib/mongo/connection.rb @@ -639,7 +639,7 @@ module Mongo else config = self['admin'].command({:ismaster => 1}, :socket => socket) end - rescue OperationFailure, SocketError, SystemCallError, IOError => ex + rescue OperationFailure, SocketError, SystemCallError, IOError close ensure socket.close if socket diff --git a/lib/mongo/gridfs/grid_file_system.rb b/lib/mongo/gridfs/grid_file_system.rb index c15c1fe..437e75e 100644 --- a/lib/mongo/gridfs/grid_file_system.rb +++ b/lib/mongo/gridfs/grid_file_system.rb @@ -115,7 +115,7 @@ module Mongo id = file.close if versions self.delete do - @files.find({'filename' => filename, '_id' => {'$ne' => id}}, :fields => ['_id'], :sort => ['uploadDate', -1], :skip => (versions -1)) + @files.find({'filename' => filename, '_id' => {'$ne' => id}}, :fields => ['_id'], :sort => ['uploadDate', -1], :skip => (versions - 1)) end end end diff --git a/lib/mongo/networking.rb b/lib/mongo/networking.rb index 001e7a4..ef8b3d0 100644 --- a/lib/mongo/networking.rb +++ b/lib/mongo/networking.rb @@ -186,7 +186,10 @@ module Mongo def receive_header(sock, expected_response, exhaust=false) header = receive_message_on_socket(16, sock) - size, request_id, response_to = header.unpack('VVV') + + # unpacks to size, request_id, response_to + response_to = header.unpack('VVV')[2] + if !exhaust && expected_response != response_to raise Mongo::ConnectionFailure, "Expected response #{expected_response} but got #{response_to}" end @@ -204,7 +207,10 @@ module Mongo raise "Short read for DB response header; " + "expected #{RESPONSE_HEADER_SIZE} bytes, saw #{header_buf.length}" end - flags, cursor_id_a, cursor_id_b, starting_from, number_remaining = header_buf.unpack('VVVVV') + + # unpacks to flags, cursor_id_a, cursor_id_b, starting_from, number_remaining + flags, cursor_id_a, cursor_id_b, _, number_remaining = header_buf.unpack('VVVVV') + check_response_flags(flags) cursor_id = (cursor_id_b << 32) + cursor_id_a [number_remaining, cursor_id] diff --git a/lib/mongo/util/node.rb b/lib/mongo/util/node.rb index a8d8108..9d6a49e 100644 --- a/lib/mongo/util/node.rb +++ b/lib/mongo/util/node.rb @@ -74,7 +74,7 @@ module Mongo begin result = @connection['admin'].command({:ping => 1}, :socket => @socket) return result['ok'] == 1 - rescue OperationFailure, SocketError, SystemCallError, IOError => ex + rescue OperationFailure, SocketError, SystemCallError, IOError return nil end end diff --git a/lib/mongo/util/pool.rb b/lib/mongo/util/pool.rb index 87f7c8b..a6e721a 100644 --- a/lib/mongo/util/pool.rb +++ b/lib/mongo/util/pool.rb @@ -133,7 +133,7 @@ module Mongo def ping begin return self.connection['admin'].command({:ping => 1}, :socket => @node.socket) - rescue OperationFailure, SocketError, SystemCallError, IOError => ex + rescue OperationFailure, SocketError, SystemCallError, IOError return false end end diff --git a/test/bson/bson_test.rb b/test/bson/bson_test.rb index ff00f83..d8bb757 100644 --- a/test/bson/bson_test.rb +++ b/test/bson/bson_test.rb @@ -74,23 +74,21 @@ class BSONTest < Test::Unit::TestCase end def test_limit_max_bson_size - doc = {'name' => 'a' * BSON_CODER.max_bson_size} + doc = {'name' => 'a' * BSON::DEFAULT_MAX_BSON_SIZE} assert_raise InvalidDocument do assert @encoder.serialize(doc) end end - def test_max_bson_size - assert BSON_CODER.max_bson_size >= BSON::DEFAULT_MAX_BSON_SIZE - end - def test_update_max_bson_size require 'ostruct' mock_conn = OpenStruct.new size = 7 * 1024 * 1024 mock_conn.max_bson_size = size - assert_equal size, BSON_CODER.update_max_bson_size(mock_conn) - assert_equal size, BSON_CODER.max_bson_size + silently do + assert_equal size, BSON_CODER.update_max_bson_size(mock_conn) + assert_equal size, BSON_CODER.max_bson_size + end end def test_round_trip @@ -217,10 +215,10 @@ class BSONTest < Test::Unit::TestCase doc = {'doc' => {'age' => 42, 'date' => Time.now.utc, 'shoe_size' => 9.5}} bson = @encoder.serialize(doc) doc2 = @encoder.deserialize(bson) - assert doc['doc'] - assert_equal 42, doc['doc']['age'] - assert_equal 9.5, doc['doc']['shoe_size'] - assert_in_delta Time.now, doc['doc']['date'], 1 + assert doc2['doc'] + assert_equal 42, doc2['doc']['age'] + assert_equal 9.5, doc2['doc']['shoe_size'] + assert_in_delta Time.now, doc2['doc']['date'], 1 end def test_oid @@ -269,6 +267,7 @@ class BSONTest < Test::Unit::TestCase doc = {'date' => [Time.now.utc]} bson = @encoder.serialize(doc) doc2 = @encoder.deserialize(bson) + assert doc2 end def test_date_returns_as_utc @@ -297,7 +296,7 @@ class BSONTest < Test::Unit::TestCase [DateTime.now, Date.today, Zone].each do |invalid_date| doc = {:date => invalid_date} begin - bson = BSON::BSON_CODER.serialize(doc) + BSON::BSON_CODER.serialize(doc) rescue => e ensure if !invalid_date.is_a? Time @@ -431,7 +430,7 @@ class BSONTest < Test::Unit::TestCase if !(RUBY_PLATFORM =~ /java/) def test_timestamp - val = {"test" => [4, 20]} + # val = {"test" => [4, 20]} result = @encoder.deserialize([0x13, 0x00, 0x00, 0x00, 0x11, 0x74, 0x65, 0x73, 0x74, 0x00, 0x04, 0x00, @@ -455,7 +454,7 @@ class BSONTest < Test::Unit::TestCase def test_overflow doc = {"x" => 2**75} assert_raise RangeError do - bson = @encoder.serialize(doc) + @encoder.serialize(doc) end doc = {"x" => 9223372036854775} @@ -466,7 +465,7 @@ class BSONTest < Test::Unit::TestCase doc["x"] = doc["x"] + 1 assert_raise RangeError do - bson = @encoder.serialize(doc) + @encoder.serialize(doc) end doc = {"x" => -9223372036854775} @@ -477,7 +476,7 @@ class BSONTest < Test::Unit::TestCase doc["x"] = doc["x"] - 1 assert_raise RangeError do - bson = BSON::BSON_CODER.serialize(doc) + BSON::BSON_CODER.serialize(doc) end end @@ -529,7 +528,7 @@ class BSONTest < Test::Unit::TestCase #one = {"_foo" => "foo"} #assert_equal @encoder.serialize(one).to_a, @encoder.serialize(dup).to_a - warn "Pending test for duplicate keys" + #warn "Pending test for duplicate keys" end def test_no_duplicate_id_when_moving_id diff --git a/test/bson/hash_with_indifferent_access_test.rb b/test/bson/hash_with_indifferent_access_test.rb index 0574ebb..67f1486 100644 --- a/test/bson/hash_with_indifferent_access_test.rb +++ b/test/bson/hash_with_indifferent_access_test.rb @@ -1,6 +1,5 @@ # encoding:utf-8 require './test/bson/test_helper' -require './test/support/hash_with_indifferent_access' class HashWithIndifferentAccessTest < Test::Unit::TestCase include BSON diff --git a/test/bson/json_test.rb b/test/bson/json_test.rb index 05d2765..a29adbb 100644 --- a/test/bson/json_test.rb +++ b/test/bson/json_test.rb @@ -7,7 +7,7 @@ class JSONTest < Test::Unit::TestCase # This test passes when run by itself but fails # when run as part of the whole test suite. def test_object_id_as_json - warn "Pending test object id as json" + #warn "Pending test object id as json" #id = BSON::ObjectId.new #obj = {'_id' => id} diff --git a/test/collection_test.rb b/test/collection_test.rb index a2d211e..87aeda0 100644 --- a/test/collection_test.rb +++ b/test/collection_test.rb @@ -42,8 +42,10 @@ class TestCollection < Test::Unit::TestCase end def test_pk_factory_on_collection - @coll = Collection.new('foo', @@db, TestPK) - assert_equal TestPK, @coll.pk_factory + silently do + @coll = Collection.new('foo', @@db, TestPK) + assert_equal TestPK, @coll.pk_factory + end @coll2 = Collection.new('foo', @@db, :pk => TestPK) @@ -197,6 +199,7 @@ class TestCollection < Test::Unit::TestCase docs << {:bar => 1} doc_ids, error_docs = @@test.insert(docs, :collect_on_error => true) assert_equal 2, @@test.count + assert_equal 2, doc_ids.count assert_equal error_docs, [] end @@ -215,6 +218,7 @@ class TestCollection < Test::Unit::TestCase doc_ids, error_docs = @@test.insert(docs, :collect_on_error => true) assert_equal 2, @@test.count + assert_equal 2, doc_ids.count assert_equal error_docs, invalid_docs end @@ -232,6 +236,7 @@ class TestCollection < Test::Unit::TestCase doc_ids, error_docs = @@test.insert(docs, :collect_on_error => true) assert_equal 2, @@test.count + assert_equal 2, doc_ids.count assert_equal error_docs, invalid_docs end diff --git a/test/connection_test.rb b/test/connection_test.rb index 3e4d932..782a96c 100644 --- a/test/connection_test.rb +++ b/test/connection_test.rb @@ -133,7 +133,7 @@ class TestConnection < Test::Unit::TestCase output = StringIO.new logger = Logger.new(output) logger.level = Logger::DEBUG - connection = standard_connection(:logger => logger).db(MONGO_TEST_DB) + standard_connection(:logger => logger).db(MONGO_TEST_DB) assert output.string.include?("admin['$cmd'].find") end @@ -141,8 +141,8 @@ class TestConnection < Test::Unit::TestCase output = StringIO.new logger = Logger.new(output) logger.level = Logger::DEBUG - connection = standard_connection(:logger => logger).db(MONGO_TEST_DB) - assert_match /\(\d+ms\)/, output.string + standard_connection(:logger => logger).db(MONGO_TEST_DB) + assert_match(/\(\d+ms\)/, output.string) assert output.string.include?("admin['$cmd'].find") end @@ -170,8 +170,10 @@ class TestConnection < Test::Unit::TestCase end def test_nodes - conn = Connection.multi([['foo', 27017], ['bar', 27018]], :connect => false) - nodes = conn.nodes + silently do + @conn = Connection.multi([['foo', 27017], ['bar', 27018]], :connect => false) + end + nodes = @conn.seeds assert_equal 2, nodes.length assert_equal ['foo', 27017], nodes[0] assert_equal ['bar', 27018], nodes[1] @@ -227,7 +229,7 @@ class TestConnection < Test::Unit::TestCase conn.expects(:[]).with('admin').returns(admin_db) conn.connect - assert_equal Mongo::DEFAULT_MAX_BSON_SIZE, BSON::BSON_CODER.max_bson_size + assert_equal Mongo::DEFAULT_MAX_BSON_SIZE, conn.max_bson_size end def test_connection_activity @@ -290,7 +292,7 @@ class TestConnection < Test::Unit::TestCase context "Socket pools" do context "checking out writers" do setup do - @con = standard_connection(:pool_size => 10, :timeout => 10) + @con = standard_connection(:pool_size => 10, :pool_timeout => 10) @coll = @con[MONGO_TEST_DB]['test-connection-exceptions'] end @@ -325,7 +327,7 @@ class TestConnection < Test::Unit::TestCase context "Connection exceptions" do setup do - @con = standard_connection(:pool_size => 10, :timeout => 10) + @con = standard_connection(:pool_size => 10, :pool_timeout => 10) @coll = @con[MONGO_TEST_DB]['test-connection-exceptions'] end @@ -363,6 +365,7 @@ class TestConnection < Test::Unit::TestCase TCPSocket.stubs(:new).returns(fake_socket) @con.primary_pool.checkout_new_socket + @con.primary_pool.expects(:warn) assert @con.primary_pool.close end end diff --git a/test/cursor_test.rb b/test/cursor_test.rb index c64c04b..ed35cd0 100644 --- a/test/cursor_test.rb +++ b/test/cursor_test.rb @@ -238,17 +238,17 @@ class CursorTest < Test::Unit::TestCase end def test_timeout - opts = Cursor.new(@@coll).query_opts + opts = Cursor.new(@@coll).options assert_equal 0, opts & Mongo::Constants::OP_QUERY_NO_CURSOR_TIMEOUT - opts = Cursor.new(@@coll, :timeout => false).query_opts + opts = Cursor.new(@@coll, :timeout => false).options assert_equal Mongo::Constants::OP_QUERY_NO_CURSOR_TIMEOUT, opts & Mongo::Constants::OP_QUERY_NO_CURSOR_TIMEOUT end def test_limit_exceptions cursor = @@coll.find() - firstResult = cursor.next_document + cursor.next_document assert_raise InvalidOperation, "Cannot modify the query once it has been run or closed." do cursor.limit(1) end @@ -278,7 +278,7 @@ class CursorTest < Test::Unit::TestCase def test_skip_exceptions cursor = @@coll.find() - firstResult = cursor.next_document + cursor.next_document assert_raise InvalidOperation, "Cannot modify the query once it has been run or closed." do cursor.skip(1) end diff --git a/test/grid_file_system_test.rb b/test/grid_file_system_test.rb index 0cae6b0..a4d19c0 100644 --- a/test/grid_file_system_test.rb +++ b/test/grid_file_system_test.rb @@ -263,7 +263,9 @@ class GridFileSystemTest < Test::Unit::TestCase should "seek only in read mode" do assert_raise GridError do - @grid.open('hello', 'w') {|f| f.seek(0) } + silently do + @grid.open('hello', 'w') { |f| f.seek(0) } + end end end end diff --git a/test/grid_io_test.rb b/test/grid_io_test.rb index f29547b..45ae590 100644 --- a/test/grid_io_test.rb +++ b/test/grid_io_test.rb @@ -45,7 +45,7 @@ class GridIOTest < Test::Unit::TestCase should "read data character by character using" do bytes = 0 file = GridIO.new(@files, @chunks, nil, "r", :query => {:_id => @file.files_id}) - while char = file.getc + while file.getc bytes += 1 end assert_equal bytes, 1_000_000 @@ -111,7 +111,7 @@ class GridIOTest < Test::Unit::TestCase should "tell position, eof, and rewind" do file = GridIO.new(@files, @chunks, nil, "r", :query => {:_id => @file.files_id}) - string = file.read(1000) + file.read(1000) assert_equal 1000, file.pos assert !file.eof? file.read diff --git a/test/grid_test.rb b/test/grid_test.rb index d1962fa..ee4b77a 100644 --- a/test/grid_test.rb +++ b/test/grid_test.rb @@ -142,7 +142,9 @@ class GridTest < Test::Unit::TestCase end should "ignore special keys" do - id = @grid.put(@data, :file_length => 100, :phrase => "blimey") + id = silently do + @grid.put(@data, :file_length => 100, :phrase => "blimey") + end file = @grid.get(id) assert_equal "blimey", file['phrase'] @@ -153,8 +155,9 @@ class GridTest < Test::Unit::TestCase context "Storing data with a length of zero" do setup do @grid = Grid.new(@db, 'test-fs') - @id = @grid.put('', :filename => 'sample', - :metadata => {'app' => 'photos'}) + @id = silently do + @grid.put('', :filename => 'sample', :metadata => {'app' => 'photos'}) + end end should "return the zero length" do @@ -201,7 +204,9 @@ class GridTest < Test::Unit::TestCase @grid = Grid.new(@db, 'test-fs') filename = 'empty_data' @io = File.open(File.join(File.dirname(__FILE__), 'data', filename), 'r') - id = @grid.put(@io, :filename => filename) + id = silently do + @grid.put(@io, :filename => filename) + end @file = @grid.get(id) @io.rewind @data = @io.read @@ -239,7 +244,9 @@ class GridTest < Test::Unit::TestCase end should "put and get an empty io object" do - read_and_write_stream('empty_data', 1) + silently do + read_and_write_stream('empty_data', 1) + end end should "put and get a small io object" do diff --git a/test/replica_sets/connect_test.rb b/test/replica_sets/connect_test.rb index efdf6c4..ed54aa6 100644 --- a/test/replica_sets/connect_test.rb +++ b/test/replica_sets/connect_test.rb @@ -14,7 +14,9 @@ class ConnectTest < Test::Unit::TestCase # TODO: test connect timeout. def test_connect_with_deprecated_multi - @conn = Connection.multi([[@rs.host, @rs.ports[0]], [@rs.host, @rs.ports[1]]], :name => @rs.name) + silently do + @conn = Connection.multi([[@rs.host, @rs.ports[0]], [@rs.host, @rs.ports[1]]], :name => @rs.name) + end assert @conn.is_a?(ReplSetConnection) assert @conn.connected? end diff --git a/test/replica_sets/pooled_insert_test.rb b/test/replica_sets/pooled_insert_test.rb index 965fc76..5945dd6 100644 --- a/test/replica_sets/pooled_insert_test.rb +++ b/test/replica_sets/pooled_insert_test.rb @@ -7,7 +7,7 @@ class ReplicaSetPooledInsertTest < Test::Unit::TestCase def setup ensure_rs - @conn = ReplSetConnection.new(build_seeds(3), :pool_size => 10, :timeout => 5, :refresh_mode => false) + @conn = ReplSetConnection.new(build_seeds(3), :pool_size => 10, :pool_timeout => 5, :refresh_mode => false) @db = @conn.db(MONGO_TEST_DB) @db.drop_collection("test-sets") @coll = @db.collection("test-sets") diff --git a/test/replica_sets/rs_test_helper.rb b/test/replica_sets/rs_test_helper.rb index 219c47c..c1ec2ac 100644 --- a/test/replica_sets/rs_test_helper.rb +++ b/test/replica_sets/rs_test_helper.rb @@ -21,7 +21,7 @@ class Test::Unit::TestCase begin yield rescue Mongo::ConnectionFailure => ex - puts "Rescue attempt #{retries}: from #{ex}" + #puts "Rescue attempt #{retries}: from #{ex}" retries += 1 raise ex if retries > max_retries sleep(2) diff --git a/test/test_helper.rb b/test/test_helper.rb index bfd0acb..ec58092 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,8 +7,11 @@ require 'test/unit' def silently warn_level = $VERBOSE $VERBOSE = nil - result = yield - $VERBOSE = warn_level + begin + result = yield + ensure + $VERBOSE = warn_level + end result end @@ -25,7 +28,6 @@ You can install them as follows: gem install mocha MSG - exit end @@ -88,7 +90,7 @@ class Test::Unit::TestCase end def new_mock_db - db = Object.new + Object.new end def assert_raise_error(klass, message) diff --git a/test/threading/threading_with_large_pool_test.rb b/test/threading/threading_with_large_pool_test.rb index 5df349a..256083c 100644 --- a/test/threading/threading_with_large_pool_test.rb +++ b/test/threading/threading_with_large_pool_test.rb @@ -6,7 +6,7 @@ class TestThreadingLargePool < Test::Unit::TestCase include Mongo - @@db = standard_connection(:pool_size => 50, :timeout => 60).db(MONGO_TEST_DB) + @@db = standard_connection(:pool_size => 50, :pool_timeout => 60).db(MONGO_TEST_DB) @@coll = @@db.collection('thread-test-collection') def set_up_safe_data diff --git a/test/threading_test.rb b/test/threading_test.rb index 357432b..c43e8b1 100644 --- a/test/threading_test.rb +++ b/test/threading_test.rb @@ -4,7 +4,7 @@ class TestThreading < Test::Unit::TestCase include Mongo - @@con = standard_connection(:pool_size => 10, :timeout => 30) + @@con = standard_connection(:pool_size => 10, :pool_timeout => 30) @@db = @@con[MONGO_TEST_DB] @@coll = @@db.collection('thread-test-collection') diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index d3bdc2c..2db2e26 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -81,13 +81,6 @@ class ConnectionTest < Test::Unit::TestCase assert_equal({:w => 2, :wtimeout => 1000, :fsync => true, :j => true}, @conn.safe) end - should "have wtimeoutMS take precidence over the depricated wtimeout" do - host_name = "localhost" - opts = "safe=true&wtimeout=100&wtimeoutMS=500" - @conn = Connection.from_uri("mongodb://#{host_name}/foo?#{opts}", :connect => false) - assert_equal({:wtimeout => 500}, @conn.safe) - end - should "set timeout options on connection" do host_name = "localhost" opts = "connectTimeoutMS=1000&socketTimeoutMS=5000" diff --git a/test/uri_test.rb b/test/uri_test.rb index 87c112a..fc2008d 100644 --- a/test/uri_test.rb +++ b/test/uri_test.rb @@ -78,10 +78,9 @@ class URITest < Test::Unit::TestCase end def test_opts_safe - parser = Mongo::URIParser.new('mongodb://localhost:27018?safe=true;w=2;journal=true;wtimeout=200;fsync=true;wtimeoutMS=200') + parser = Mongo::URIParser.new('mongodb://localhost:27018?safe=true;w=2;journal=true;fsync=true;wtimeoutMS=200') assert parser.safe assert_equal 2, parser.w - assert_equal 200, parser.wtimeout assert parser.fsync assert parser.journal assert_equal 200, parser.wtimeoutms