Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixing more test and doc references to safe mode

  • Loading branch information...
commit 6a96bc0ae5a486bf9d89e6d6ce08492c65c1ff73 1 parent 0e746be
@brandonblack brandonblack authored
View
0  HISTORY → HISTORY.md
File renamed without changes
View
6 README.md
@@ -172,7 +172,7 @@ timeout for waiting for old connections to be released to the pool.
To set up a pooled connection to a single MongoDB instance:
```ruby
- @client = Client.new("localhost", 27017, :safe => true, :pool_size => 5, :timeout => 5)
+ @client = Client.new("localhost", 27017, :pool_size => 5, :timeout => 5)
```
Though the pooling architecture will undoubtedly evolve, it currently owes much credit
@@ -225,7 +225,7 @@ You can tell the Ruby Mongo driver how to create primary keys by passing in
the :pk option to the Client#db method.
```ruby
-db = Mongo::Client.new('localhost', 27017, :safe => true).db('dbname', :pk => MyPKFactory.new)
+db = Mongo::Client.new('localhost', 27017).db('dbname', :pk => MyPKFactory.new)
```
A primary key factory object must respond to :create_pk, which should
@@ -281,7 +281,7 @@ To turn on strict mode, either pass in :strict => true when obtaining a DB
object or call the `:strict=` method:
```ruby
-db = Client.new('localhost', 27017, :safe => true).db('dbname', :strict => true)
+db = Client.new('localhost', 27017).db('dbname', :strict => true)
# I'm feeling lax
db.strict = false
# No, I'm not!
View
11 lib/mongo/util/pool.rb
@@ -21,8 +21,13 @@ class Pool
MAX_PING_TIME = 1_000_000
PRUNE_INTERVAL = 10_000
- attr_accessor :host, :port, :address,
- :size, :timeout, :safe, :checked_out, :client
+ attr_accessor :host,
+ :port,
+ :address,
+ :size,
+ :timeout,
+ :checked_out,
+ :client
# Create a new pool of connections.
def initialize(client, host, port, opts={})
@@ -64,7 +69,7 @@ def initialize(client, host, port, opts={})
# Close this pool.
#
- # @option opts [Boolean] :soft (false) If true,
+ # @option opts [Boolean]:soft (false) If true,
# close only those sockets that are not checked out.
def close(opts={})
@connection_mutex.synchronize do
View
2  tasks/benchmark/exp_series.rb
@@ -338,7 +338,7 @@ def insert(coll, doc)
def insert_safe(coll, doc)
clear_ids(doc)
- coll.insert(doc, :safe => true) # note that insert stores :_id in doc and subsequent inserts with :_id are updates
+ coll.insert(doc) # note that insert stores :_id in doc and subsequent inserts with :_id are updates
end
def find_one_setup(db, coll, doc, iterations)
View
8 test/functional/collection_test.rb
@@ -2,10 +2,10 @@
require 'test_helper'
class TestCollection < Test::Unit::TestCase
- @@connection ||= standard_connection(:op_timeout => 10)
- @@db = @@connection.db(MONGO_TEST_DB)
- @@test = @@db.collection("test")
- @@version = @@connection.server_version
+ @@client ||= standard_connection(:op_timeout => 10)
+ @@db = @@client.db(MONGO_TEST_DB)
+ @@test = @@db.collection("test")
+ @@version = @@client.server_version
def setup
@@test.remove
View
16 test/functional/threading_test.rb
@@ -4,9 +4,9 @@ class TestThreading < Test::Unit::TestCase
include Mongo
- @@con = standard_connection(:pool_size => 10, :pool_timeout => 30)
- @@db = @@con[MONGO_TEST_DB]
- @@coll = @@db.collection('thread-test-collection')
+ @@client = standard_connection(:pool_size => 10, :pool_timeout => 30)
+ @@db = @@client[MONGO_TEST_DB]
+ @@coll = @@db.collection('thread-test-collection')
def set_up_safe_data
@@db.drop_collection('duplicate')
@@ -31,12 +31,12 @@ def test_safe_update
if i % 2 == 0
assert_raise Mongo::OperationFailure do
t1 = Time.now
- @unique.update({"test" => "insert"}, {"$set" => {"test" => "update"}}, :safe => true)
+ @unique.update({"test" => "insert"}, {"$set" => {"test" => "update"}})
times << Time.now - t1
end
else
t1 = Time.now
- @duplicate.update({"test" => "insert"}, {"$set" => {"test" => "update"}}, :safe => true)
+ @duplicate.update({"test" => "insert"}, {"$set" => {"test" => "update"}})
times << Time.now - t1
end
end
@@ -55,10 +55,10 @@ def test_safe_insert
threads[i] = Thread.new do
if i % 2 == 0
assert_raise Mongo::OperationFailure do
- @unique.insert({"test" => "insert"}, :safe => true)
+ @unique.insert({"test" => "insert"})
end
else
- @duplicate.insert({"test" => "insert"}, :safe => true)
+ @duplicate.insert({"test" => "insert"})
end
end
end
@@ -73,7 +73,7 @@ def test_threading
@@coll = @@db.collection('thread-test-collection')
1000.times do |i|
- @@coll.insert({"x" => i}, :safe => true)
+ @@coll.insert({"x" => i})
end
threads = []
View
13 test/threading/threading_with_large_pool_test.rb
@@ -6,7 +6,8 @@ class TestThreadingLargePool < Test::Unit::TestCase
include Mongo
- @@db = standard_connection(:pool_size => 50, :pool_timeout => 60).db(MONGO_TEST_DB)
+ @@client = standard_connection(:pool_size => 50, :pool_timeout => 60)
+ @@db = @@client.db(MONGO_TEST_DB)
@@coll = @@db.collection('thread-test-collection')
def set_up_safe_data
@@ -29,10 +30,10 @@ def test_safe_update
threads[i] = Thread.new do
if i % 2 == 0
assert_raise Mongo::OperationFailure do
- @unique.update({"test" => "insert"}, {"$set" => {"test" => "update"}}, :safe => true)
+ @unique.update({"test" => "insert"}, {"$set" => {"test" => "update"}})
end
else
- @duplicate.update({"test" => "insert"}, {"$set" => {"test" => "update"}}, :safe => true)
+ @duplicate.update({"test" => "insert"}, {"$set" => {"test" => "update"}})
end
end
end
@@ -49,10 +50,10 @@ def test_safe_insert
threads[i] = Thread.new do
if i % 2 == 0
assert_raise Mongo::OperationFailure do
- @unique.insert({"test" => "insert"}, :safe => true)
+ @unique.insert({"test" => "insert"})
end
else
- @duplicate.insert({"test" => "insert"}, :safe => true)
+ @duplicate.insert({"test" => "insert"})
end
end
end
@@ -67,7 +68,7 @@ def test_threading
@@coll = @@db.collection('thread-test-collection')
1000.times do |i|
- @@coll.insert({ "x" => i }, :safe => true)
+ @@coll.insert({ "x" => i })
end
threads = []
View
15 test/unit/collection_test.rb
@@ -73,7 +73,7 @@ class CollectionTest < Test::Unit::TestCase
end
should "send safe update message with legacy" do
- @client = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
+ @client = Connection.new('localhost', 27017, :logger => @logger, :safe => true, :connect => false)
@db = @client['testing']
@coll = @db.collection('books')
@client.expects(:send_message_with_gle).with do |op, msg, db_name, log|
@@ -82,7 +82,7 @@ class CollectionTest < Test::Unit::TestCase
@coll.expects(:log_operation).with do |name, payload|
(name == :update) && payload[:document][:title].include?('Moby')
end
- @coll.update({}, {:title => 'Moby Dick'}, :safe => true)
+ @coll.update({}, {:title => 'Moby Dick'})
end
should "send safe insert message" do
@@ -96,17 +96,6 @@ class CollectionTest < Test::Unit::TestCase
@coll.update({}, {:title => 'Moby Dick'})
end
- should "send safe insert message with legacy" do
- @client = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
- @db = @client['testing']
- @coll = @db.collection('books')
- @client.expects(:send_message_with_gle).with do |op, msg, db_name, log|
- op == 2001
- end
- @coll.stubs(:log_operation)
- @coll.update({}, {:title => 'Moby Dick'}, :safe => true)
- end
-
should "not call insert for each ensure_index call" do
@client = Client.new('localhost', 27017, :logger => @logger, :connect => false)
@db = @client['testing']
Please sign in to comment.
Something went wrong with that request. Please try again.