Fixes for 1.9.1 compatibility.
This commit is contained in:
parent
072b025cdc
commit
cdb60b378f
6
Rakefile
6
Rakefile
@ -19,6 +19,7 @@ desc "Test the MongoDB Ruby driver."
|
||||
task :test do
|
||||
Rake::Task['test:unit'].invoke
|
||||
Rake::Task['test:functional'].invoke
|
||||
Rake::Task['test:pooled_threading'].invoke
|
||||
end
|
||||
|
||||
namespace :test do
|
||||
@ -32,6 +33,11 @@ namespace :test do
|
||||
t.verbose = true
|
||||
end
|
||||
|
||||
Rake::TestTask.new(:pooled_threading) do |t|
|
||||
t.test_files = FileList['test/threading/*.rb']
|
||||
t.verbose = true
|
||||
end
|
||||
|
||||
Rake::TestTask.new(:pair_count) do |t|
|
||||
t.test_files = FileList['test/replica/count_test.rb']
|
||||
t.verbose = true
|
||||
|
@ -383,7 +383,7 @@ module Mongo
|
||||
next if @checked_out.size < @sockets.size
|
||||
|
||||
# Otherwise, wait.
|
||||
if @queue.wait(@timeout)
|
||||
if wait
|
||||
next
|
||||
else
|
||||
|
||||
@ -399,6 +399,20 @@ module Mongo
|
||||
end # synchronize
|
||||
end
|
||||
|
||||
if RUBY_VERSION >= '1.9'
|
||||
# Ruby 1.9's Condition Variables don't support timeouts yet;
|
||||
# until they do, we'll make do with this hack.
|
||||
def wait
|
||||
Timeout.timeout(@timeout) do
|
||||
@queue.wait
|
||||
end
|
||||
end
|
||||
else
|
||||
def wait
|
||||
@queue.wait(@timeout)
|
||||
end
|
||||
end
|
||||
|
||||
def receive(sock)
|
||||
receive_header(sock)
|
||||
number_received, cursor_id = receive_response_header(sock)
|
||||
|
@ -305,7 +305,7 @@ module Mongo
|
||||
sel = {:ns => full_collection_name(collection_name)}
|
||||
info = {}
|
||||
Cursor.new(Collection.new(self, SYSTEM_INDEX_COLLECTION), :selector => sel).each { |index|
|
||||
info[index['name']] = index['key'].map
|
||||
info[index['name']] = index['key'].map {|k| k}
|
||||
}
|
||||
info
|
||||
end
|
||||
|
@ -43,21 +43,21 @@ class TestThreadingLargePool < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_safe_insert
|
||||
set_up_safe_data
|
||||
threads = []
|
||||
100.times do |i|
|
||||
threads[i] = Thread.new do
|
||||
if i % 2 == 0
|
||||
assert_raise Mongo::OperationFailure do
|
||||
@unique.insert({"test" => "insert"}, :safe => true)
|
||||
end
|
||||
else
|
||||
@duplicate.insert({"test" => "insert"}, :safe => true)
|
||||
set_up_safe_data
|
||||
threads = []
|
||||
100.times do |i|
|
||||
threads[i] = Thread.new do
|
||||
if i % 2 == 0
|
||||
assert_raise Mongo::OperationFailure do
|
||||
@unique.insert({"test" => "insert"}, :safe => true)
|
||||
end
|
||||
else
|
||||
@duplicate.insert({"test" => "insert"}, :safe => true)
|
||||
end
|
||||
end
|
||||
|
||||
100.times do |i|
|
||||
end
|
||||
|
||||
100.times do |i|
|
||||
threads[i].join
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user