mongo 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +6 -0
- data/README.rdoc +1 -1
- data/Rakefile +5 -0
- data/lib/mongo.rb +1 -1
- data/lib/mongo/collection.rb +1 -1
- data/lib/mongo/connection.rb +8 -3
- data/lib/mongo/db.rb +33 -19
- data/mongo.gemspec +1 -1
- data/test/{slave_connection_test.rb → auxillary/slave_connection_test.rb} +5 -5
- data/test/collection_test.rb +6 -19
- data/test/connection_test.rb +1 -1
- data/test/cursor_test.rb +5 -5
- data/test/db_api_test.rb +1 -1
- data/test/db_test.rb +12 -24
- data/test/replica_sets/replication_ack_test.rb +71 -0
- data/test/test_helper.rb +2 -0
- metadata +6 -44
data/HISTORY
CHANGED
data/README.rdoc
CHANGED
@@ -165,7 +165,7 @@ or handle reconnecting when passenger forks a new process:
|
|
165
165
|
if defined?(PhusionPassenger)
|
166
166
|
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
167
167
|
if forked
|
168
|
-
# Call db.
|
168
|
+
# Call db.connect to reconnect here
|
169
169
|
end
|
170
170
|
end
|
171
171
|
end
|
data/Rakefile
CHANGED
@@ -98,6 +98,11 @@ namespace :test do
|
|
98
98
|
t.verbose = true
|
99
99
|
end
|
100
100
|
|
101
|
+
Rake::TestTask.new(:replica_set_ack) do |t|
|
102
|
+
t.test_files = FileList['test/replica_sets/replication_ack_test.rb']
|
103
|
+
t.verbose = true
|
104
|
+
end
|
105
|
+
|
101
106
|
Rake::TestTask.new(:auto_reconnect) do |t|
|
102
107
|
t.test_files = FileList['test/auxillary/autoreconnect_test.rb']
|
103
108
|
t.verbose = true
|
data/lib/mongo.rb
CHANGED
data/lib/mongo/collection.rb
CHANGED
@@ -260,7 +260,7 @@ module Mongo
|
|
260
260
|
# run the operation in safe mode, which run a getlasterror command on the
|
261
261
|
# database to report any assertion. In addition, a hash can be provided to
|
262
262
|
# run an fsync and/or wait for replication of the remove (>= 1.5.1). See the options
|
263
|
-
# for DB#
|
263
|
+
# for DB#get_last_error.
|
264
264
|
#
|
265
265
|
# @example remove all documents from the 'users' collection:
|
266
266
|
# users.remove
|
data/lib/mongo/connection.rb
CHANGED
@@ -119,7 +119,7 @@ module Mongo
|
|
119
119
|
@logger = options[:logger] || nil
|
120
120
|
@options = options
|
121
121
|
|
122
|
-
should_connect = options
|
122
|
+
should_connect = options.fetch(:connect, true)
|
123
123
|
connect if should_connect
|
124
124
|
end
|
125
125
|
|
@@ -376,7 +376,7 @@ module Mongo
|
|
376
376
|
# @param [BSON::ByteBuffer] message a message to send to the database.
|
377
377
|
# @param [String] log_message text version of +message+ for logging.
|
378
378
|
#
|
379
|
-
# @return [
|
379
|
+
# @return [Integer] number of bytes sent
|
380
380
|
def send_message(operation, message, log_message=nil)
|
381
381
|
@logger.debug(" MONGODB #{log_message || message}") if @logger
|
382
382
|
begin
|
@@ -398,7 +398,7 @@ module Mongo
|
|
398
398
|
# @param [Hash] last_error_params parameters to be sent to getLastError. See DB#error for
|
399
399
|
# available options.
|
400
400
|
#
|
401
|
-
# @see DB#
|
401
|
+
# @see DB#get_last_error for valid last error params.
|
402
402
|
#
|
403
403
|
# @return [Array]
|
404
404
|
# An array whose indexes include [0] documents returned, [1] number of document received,
|
@@ -812,12 +812,17 @@ module Mongo
|
|
812
812
|
|
813
813
|
# Low-level method for sending a message on a socket.
|
814
814
|
# Requires a packed message and an available socket,
|
815
|
+
#
|
816
|
+
# @return [Integer] number of bytes sent
|
815
817
|
def send_message_on_socket(packed_message, socket)
|
816
818
|
begin
|
819
|
+
total_bytes_sent = 0
|
817
820
|
while packed_message.size > 0
|
818
821
|
byte_sent = socket.send(packed_message, 0)
|
822
|
+
total_bytes_sent += byte_sent
|
819
823
|
packed_message.slice!(0, byte_sent)
|
820
824
|
end
|
825
|
+
total_bytes_sent
|
821
826
|
rescue => ex
|
822
827
|
close
|
823
828
|
raise ConnectionFailure, "Operation failed with the following exception: #{ex}"
|
data/lib/mongo/db.rb
CHANGED
@@ -122,7 +122,7 @@ module Mongo
|
|
122
122
|
}
|
123
123
|
)
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
# Removes stored Javascript function from the database. Returns
|
127
127
|
# false if the function does not exist
|
128
128
|
#
|
@@ -136,7 +136,7 @@ module Mongo
|
|
136
136
|
return false
|
137
137
|
end
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
# Adds a user to this database for use with authentication. If the user already
|
141
141
|
# exists in the system, the password will be updated.
|
142
142
|
#
|
@@ -276,6 +276,8 @@ module Mongo
|
|
276
276
|
ok?(command(:drop => name))
|
277
277
|
end
|
278
278
|
|
279
|
+
# @deprecated
|
280
|
+
#
|
279
281
|
# Get the error message from the most recently executed database
|
280
282
|
# operation for this connection.
|
281
283
|
#
|
@@ -286,19 +288,36 @@ module Mongo
|
|
286
288
|
# @return [String, Nil] either the text describing an error or nil if no
|
287
289
|
# error has occurred.
|
288
290
|
def error(opts={})
|
291
|
+
warn "DB#error is deprecated. Please use DB#get_last_error instead"
|
289
292
|
opts.assert_valid_keys(:w, :wtimeout, :fsync)
|
293
|
+
get_last_error(opts)['err']
|
294
|
+
end
|
295
|
+
|
296
|
+
# Run the getlasterror command with the specified replication options.
|
297
|
+
#
|
298
|
+
# @option opts [Boolean] :fsync (false)
|
299
|
+
# @option opts [Integer] :w (nil)
|
300
|
+
# @option opts [Integer] :wtimeout (nil)
|
301
|
+
#
|
302
|
+
# @return [Hash] the entire response to getlasterror.
|
303
|
+
#
|
304
|
+
# @raise [MongoDBError] if the operation fails.
|
305
|
+
def get_last_error(opts={})
|
290
306
|
cmd = BSON::OrderedHash.new
|
291
307
|
cmd[:getlasterror] = 1
|
292
|
-
cmd.merge!(opts)
|
308
|
+
cmd.merge!(opts)
|
293
309
|
doc = command(cmd, :check_response => false)
|
294
310
|
raise MongoDBError, "error retrieving last error: #{doc.inspect}" unless ok?(doc)
|
295
|
-
doc
|
311
|
+
doc
|
296
312
|
end
|
297
313
|
|
314
|
+
# @deprecated
|
315
|
+
#
|
298
316
|
# Get status information from the last operation on this connection.
|
299
317
|
#
|
300
318
|
# @return [Hash] a hash representing the status of the last db op.
|
301
319
|
def last_status
|
320
|
+
warn "DB#last_status is deprecated. Please use the equivalent DB#get_last_error instead"
|
302
321
|
command(:getlasterror => 1)
|
303
322
|
end
|
304
323
|
|
@@ -307,7 +326,7 @@ module Mongo
|
|
307
326
|
#
|
308
327
|
# @return [Boolean]
|
309
328
|
def error?
|
310
|
-
|
329
|
+
get_last_error['err'] != nil
|
311
330
|
end
|
312
331
|
|
313
332
|
# Get the most recent error to have occured on this database.
|
@@ -360,10 +379,9 @@ module Mongo
|
|
360
379
|
|
361
380
|
oh = BSON::OrderedHash.new
|
362
381
|
oh[:$eval] = code
|
363
|
-
oh[:args]
|
382
|
+
oh[:args] = args
|
364
383
|
doc = command(oh)
|
365
|
-
|
366
|
-
raise OperationFailure, "eval failed: #{doc['errmsg']}"
|
384
|
+
doc['retval']
|
367
385
|
end
|
368
386
|
|
369
387
|
# Rename a collection.
|
@@ -372,13 +390,13 @@ module Mongo
|
|
372
390
|
# @param [String] to new collection name.
|
373
391
|
#
|
374
392
|
# @return [True] returns +true+ on success.
|
375
|
-
#
|
393
|
+
#
|
376
394
|
# @raise MongoDBError if there's an error renaming the collection.
|
377
395
|
def rename_collection(from, to)
|
378
396
|
oh = BSON::OrderedHash.new
|
379
397
|
oh[:renameCollection] = "#{@name}.#{from}"
|
380
398
|
oh[:to] = "#{@name}.#{to}"
|
381
|
-
doc = DB.new('admin', @connection).command(oh)
|
399
|
+
doc = DB.new('admin', @connection).command(oh, :check_response => false)
|
382
400
|
ok?(doc) || raise(MongoDBError, "Error renaming collection: #{doc.inspect}")
|
383
401
|
end
|
384
402
|
|
@@ -415,7 +433,6 @@ module Mongo
|
|
415
433
|
info
|
416
434
|
end
|
417
435
|
|
418
|
-
|
419
436
|
# Return stats on this database. Uses MongoDB's dbstats command.
|
420
437
|
#
|
421
438
|
# @return [Hash]
|
@@ -445,9 +462,6 @@ module Mongo
|
|
445
462
|
# key, specifying the command to be performed. In Ruby 1.9, OrderedHash isn't necessary since
|
446
463
|
# hashes are ordered by default.
|
447
464
|
#
|
448
|
-
# @param [Boolean] admin If +true+, the command will be executed on the admin
|
449
|
-
# collection. DEPRECATED.
|
450
|
-
#
|
451
465
|
# @option opts [Boolean] :check_response (true) If +true+, raises an exception if the
|
452
466
|
# command fails.
|
453
467
|
# @option opts [Socket] :sock a socket to use for sending the command. This is mainly for internal use.
|
@@ -455,8 +469,8 @@ module Mongo
|
|
455
469
|
# @return [Hash]
|
456
470
|
#
|
457
471
|
# @core commands command_instance-method
|
458
|
-
def command(selector, opts={}
|
459
|
-
check_response = opts
|
472
|
+
def command(selector, opts={})
|
473
|
+
check_response = opts.fetch(:check_response, true)
|
460
474
|
sock = opts[:sock]
|
461
475
|
raise MongoArgumentError, "command must be given a selector" unless selector.is_a?(Hash) && !selector.empty?
|
462
476
|
if selector.keys.length > 1 && RUBY_VERSION < '1.9' && selector.class != BSON::OrderedHash
|
@@ -511,7 +525,7 @@ module Mongo
|
|
511
525
|
def profiling_level
|
512
526
|
oh = BSON::OrderedHash.new
|
513
527
|
oh[:profile] = -1
|
514
|
-
doc = command(oh)
|
528
|
+
doc = command(oh, :check_response => false)
|
515
529
|
raise "Error with profile command: #{doc.inspect}" unless ok?(doc) && doc['was'].kind_of?(Numeric)
|
516
530
|
case doc['was'].to_i
|
517
531
|
when 0
|
@@ -541,7 +555,7 @@ module Mongo
|
|
541
555
|
else
|
542
556
|
raise "Error: illegal profiling level value #{level}"
|
543
557
|
end
|
544
|
-
doc = command(oh)
|
558
|
+
doc = command(oh, :check_response => false)
|
545
559
|
ok?(doc) || raise(MongoDBError, "Error with profile command: #{doc.inspect}")
|
546
560
|
end
|
547
561
|
|
@@ -561,7 +575,7 @@ module Mongo
|
|
561
575
|
# @raise [MongoDBError] if the command fails or there's a problem with the validation
|
562
576
|
# data, or if the collection is invalid.
|
563
577
|
def validate_collection(name)
|
564
|
-
doc = command(:validate => name)
|
578
|
+
doc = command({:validate => name}, :check_response => false)
|
565
579
|
raise MongoDBError, "Error with validate command: #{doc.inspect}" unless ok?(doc)
|
566
580
|
result = doc['result']
|
567
581
|
raise MongoDBError, "Error with validation data: #{doc.inspect}" unless result.kind_of?(String)
|
data/mongo.gemspec
CHANGED
@@ -8,22 +8,22 @@ class SlaveConnectionTest < Test::Unit::TestCase
|
|
8
8
|
@@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
|
9
9
|
@@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT
|
10
10
|
conn = Connection.new(@@host, @@port, :slave_ok => true)
|
11
|
-
|
12
|
-
|
11
|
+
response = conn['admin'].command(:ismaster => 1)
|
12
|
+
Mongo::Support.ok?(response) && response['ismaster'] != 1
|
13
13
|
end
|
14
14
|
|
15
15
|
if self.connect_to_slave
|
16
16
|
puts "Connected to slave; running slave tests."
|
17
17
|
|
18
18
|
def test_connect_to_slave
|
19
|
-
assert_raise Mongo::
|
19
|
+
assert_raise Mongo::ConnectionFailure do
|
20
20
|
@db = Connection.new(@@host, @@port, :slave_ok => false).db('ruby-mongo-demo')
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_slave_ok_sent_to_queries
|
25
|
-
@
|
26
|
-
assert_equal true, @
|
25
|
+
@con = Connection.new(@@host, @@port, :slave_ok => true)
|
26
|
+
assert_equal true, @con.slave_ok?
|
27
27
|
end
|
28
28
|
else
|
29
29
|
puts "Not connected to slave; skipping slave connection tests."
|
data/test/collection_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'test/test_helper'
|
1
|
+
require './test/test_helper'
|
2
2
|
|
3
3
|
class TestCollection < Test::Unit::TestCase
|
4
4
|
@@connection ||= Connection.new(ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost', ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT)
|
@@ -139,24 +139,6 @@ class TestCollection < Test::Unit::TestCase
|
|
139
139
|
@@test.remove({:foo => 2}, :safe => {:w => 2, :wtime => 1, :fsync => true})
|
140
140
|
end
|
141
141
|
end
|
142
|
-
|
143
|
-
def test_safe_mode_with_w_failure
|
144
|
-
assert_raise_error OperationFailure, "timed out waiting for slaves" do
|
145
|
-
@@test.insert({:foo => 1}, :safe => {:w => 2, :wtimeout => 1, :fsync => true})
|
146
|
-
end
|
147
|
-
assert_raise_error OperationFailure, "timed out waiting for slaves" do
|
148
|
-
@@test.update({:foo => 1}, {:foo => 2}, :safe => {:w => 2, :wtimeout => 1, :fsync => true})
|
149
|
-
end
|
150
|
-
assert_raise_error OperationFailure, "timed out waiting for slaves" do
|
151
|
-
@@test.remove({:foo => 2}, :safe => {:w => 2, :wtimeout => 1, :fsync => true})
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_safe_mode_with_write_and_fsync
|
156
|
-
assert @@test.insert({:foo => 1}, :safe => {:w => 1, :wtimeout => 1, :fsync => true})
|
157
|
-
assert @@test.update({:foo => 1}, {:foo => 2}, :safe => {:w => 1, :wtimeout => 1, :fsync => true})
|
158
|
-
assert @@test.remove({:foo => 2}, :safe => {:w => 1, :wtimeout => 1, :fsync => true})
|
159
|
-
end
|
160
142
|
end
|
161
143
|
|
162
144
|
def test_update
|
@@ -259,6 +241,11 @@ class TestCollection < Test::Unit::TestCase
|
|
259
241
|
@test.drop
|
260
242
|
end
|
261
243
|
|
244
|
+
def test_remove_return_value
|
245
|
+
assert_equal 50, @@test.remove({})
|
246
|
+
assert_equal 57, @@test.remove({"x" => 1})
|
247
|
+
end
|
248
|
+
|
262
249
|
def test_count
|
263
250
|
@@test.drop
|
264
251
|
|
data/test/connection_test.rb
CHANGED
data/test/cursor_test.rb
CHANGED
@@ -399,18 +399,18 @@ class CursorTest < Test::Unit::TestCase
|
|
399
399
|
|
400
400
|
def test_cursor_invalid
|
401
401
|
@@coll.remove
|
402
|
-
|
402
|
+
10000.times do |n|
|
403
403
|
@@coll.insert({:a => n})
|
404
404
|
end
|
405
405
|
|
406
406
|
cursor = @@coll.find({})
|
407
|
-
cursor.next_document
|
408
|
-
cursor.close
|
409
407
|
|
410
|
-
assert_raise_error
|
411
|
-
|
408
|
+
assert_raise_error Mongo::OperationFailure, "CURSOR_NOT_FOUND" do
|
409
|
+
9999.times do
|
412
410
|
cursor.next_document
|
411
|
+
cursor.instance_variable_set(:@cursor_id, 1234567890)
|
413
412
|
end
|
414
413
|
end
|
415
414
|
end
|
415
|
+
|
416
416
|
end
|
data/test/db_api_test.rb
CHANGED
data/test/db_test.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
$:.unshift '.'
|
1
2
|
require 'test/test_helper'
|
2
3
|
require 'digest/md5'
|
3
4
|
require 'stringio'
|
@@ -163,52 +164,34 @@ class DBTest < Test::Unit::TestCase
|
|
163
164
|
|
164
165
|
def test_error
|
165
166
|
@@db.reset_error_history
|
166
|
-
assert_nil @@db.
|
167
|
+
assert_nil @@db.get_last_error['err']
|
167
168
|
assert !@@db.error?
|
168
169
|
assert_nil @@db.previous_error
|
169
170
|
|
170
171
|
@@db.command({:forceerror => 1}, :check_response => false)
|
171
172
|
assert @@db.error?
|
172
|
-
assert_not_nil @@db.
|
173
|
+
assert_not_nil @@db.get_last_error['err']
|
173
174
|
assert_not_nil @@db.previous_error
|
174
175
|
|
175
176
|
@@db.command({:forceerror => 1}, :check_response => false)
|
176
177
|
assert @@db.error?
|
177
|
-
assert @@db.
|
178
|
+
assert @@db.get_last_error['err']
|
178
179
|
prev_error = @@db.previous_error
|
179
180
|
assert_equal 1, prev_error['nPrev']
|
180
|
-
assert_equal prev_error["err"], @@db.
|
181
|
+
assert_equal prev_error["err"], @@db.get_last_error['err']
|
181
182
|
|
182
183
|
@@db.collection('test').find_one
|
183
|
-
assert_nil @@db.
|
184
|
+
assert_nil @@db.get_last_error['err']
|
184
185
|
assert !@@db.error?
|
185
186
|
assert @@db.previous_error
|
186
187
|
assert_equal 2, @@db.previous_error['nPrev']
|
187
188
|
|
188
189
|
@@db.reset_error_history
|
189
|
-
assert_nil @@db.
|
190
|
+
assert_nil @@db.get_last_error['err']
|
190
191
|
assert !@@db.error?
|
191
192
|
assert_nil @@db.previous_error
|
192
193
|
end
|
193
194
|
|
194
|
-
if @@version >= "1.5.1"
|
195
|
-
def test_failing_error_params
|
196
|
-
assert_raise_error Mongo::MongoDBError, "timed out waiting for slaves" do
|
197
|
-
@@db.error(:w => 2, :wtimeout => 10, :fsync => true)
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_passing_error_params
|
202
|
-
assert_nil @@db.error(:w => 1, :wtimeout => 10, :fsync => true)
|
203
|
-
end
|
204
|
-
|
205
|
-
def test_invalid_error_params
|
206
|
-
assert_raise_error ArgumentError, "Unknown key(s): z" do
|
207
|
-
@@db.error(:z => 1, :wtimeout => 10, :fsync => true)
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
195
|
def test_check_command_response
|
213
196
|
command = {:forceerror => 1}
|
214
197
|
assert_raise OperationFailure do
|
@@ -256,6 +239,11 @@ class DBTest < Test::Unit::TestCase
|
|
256
239
|
end
|
257
240
|
end
|
258
241
|
|
242
|
+
def test_eval
|
243
|
+
@@db.eval("db.system.save({_id:'hello', value: function() { print('hello'); } })")
|
244
|
+
assert_equal 'hello', @@db['system'].find_one['_id']
|
245
|
+
end
|
246
|
+
|
259
247
|
if @@version >= "1.3.5"
|
260
248
|
def test_db_stats
|
261
249
|
stats = @@db.stats
|
@@ -0,0 +1,71 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
require 'mongo'
|
3
|
+
require 'test/unit'
|
4
|
+
require 'test/test_helper'
|
5
|
+
|
6
|
+
# NOTE: This test expects a replica set of three nodes to be running on local host.
|
7
|
+
class ReplicaSetAckTest < Test::Unit::TestCase
|
8
|
+
include Mongo
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@conn = Mongo::Connection.multi([['localhost', 27017], ['localhost', 27018], ['localhost', 27019]])
|
12
|
+
|
13
|
+
master = [@conn.host, @conn.port]
|
14
|
+
@slaves = @conn.nodes - master
|
15
|
+
|
16
|
+
@slave1 = Mongo::Connection.new(@slaves[0][0], @slaves[0][1], :slave_ok => true)
|
17
|
+
@slave2 = Mongo::Connection.new(@slaves[1][0], @slaves[1][1], :slave_ok => true)
|
18
|
+
|
19
|
+
@db = @conn.db(MONGO_TEST_DB)
|
20
|
+
@db.drop_collection("test-sets")
|
21
|
+
@col = @db.collection("test-sets")
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_safe_mode_with_w_failure
|
25
|
+
assert_raise_error OperationFailure, "timed out waiting for slaves" do
|
26
|
+
@col.insert({:foo => 1}, :safe => {:w => 4, :wtimeout => 1, :fsync => true})
|
27
|
+
end
|
28
|
+
assert_raise_error OperationFailure, "timed out waiting for slaves" do
|
29
|
+
@col.update({:foo => 1}, {:foo => 2}, :safe => {:w => 4, :wtimeout => 1, :fsync => true})
|
30
|
+
end
|
31
|
+
assert_raise_error OperationFailure, "timed out waiting for slaves" do
|
32
|
+
@col.remove({:foo => 2}, :safe => {:w => 4, :wtimeout => 1, :fsync => true})
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_safe_mode_replication_ack
|
37
|
+
@col.insert({:baz => "bar"}, :safe => {:w => 3, :wtimeout => 1000})
|
38
|
+
|
39
|
+
assert @col.insert({:foo => "0" * 10000}, :safe => {:w => 3, :wtimeout => 1000})
|
40
|
+
assert_equal 2, @slave1[MONGO_TEST_DB]["test-sets"].count
|
41
|
+
assert_equal 2, @slave2[MONGO_TEST_DB]["test-sets"].count
|
42
|
+
|
43
|
+
|
44
|
+
assert @col.update({:baz => "bar"}, {:baz => "foo"}, :safe => {:w => 3, :wtimeout => 1000})
|
45
|
+
assert @slave1[MONGO_TEST_DB]["test-sets"].find_one({:baz => "foo"})
|
46
|
+
assert @slave2[MONGO_TEST_DB]["test-sets"].find_one({:baz => "foo"})
|
47
|
+
|
48
|
+
assert @col.remove({}, :safe => {:w => 3, :wtimeout => 1000})
|
49
|
+
assert_equal 0, @slave1[MONGO_TEST_DB]["test-sets"].count
|
50
|
+
assert_equal 0, @slave2[MONGO_TEST_DB]["test-sets"].count
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_last_error_responses
|
54
|
+
20.times { @col.insert({:baz => "bar"}) }
|
55
|
+
response = @db.get_last_error(:w => 3, :wtimeout => 10000)
|
56
|
+
assert response['ok'] == 1
|
57
|
+
assert response['lastOp']
|
58
|
+
|
59
|
+
@col.update({}, {:baz => "foo"}, :multi => true)
|
60
|
+
response = @db.get_last_error(:w => 3, :wtimeout => 1000)
|
61
|
+
assert response['ok'] == 1
|
62
|
+
assert response['lastOp']
|
63
|
+
|
64
|
+
@col.remove({})
|
65
|
+
response = @db.get_last_error(:w => 3, :wtimeout => 1000)
|
66
|
+
assert response['ok'] == 1
|
67
|
+
assert response['n'] == 20
|
68
|
+
assert response['lastOp']
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 27
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
8
|
+
- 7
|
9
|
+
version: 1.0.7
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Jim Menard
|
@@ -17,18 +16,16 @@ autorequire:
|
|
17
16
|
bindir: bin
|
18
17
|
cert_chain: []
|
19
18
|
|
20
|
-
date: 2010-
|
19
|
+
date: 2010-08-05 00:00:00 -04:00
|
21
20
|
default_executable:
|
22
21
|
dependencies:
|
23
22
|
- !ruby/object:Gem::Dependency
|
24
23
|
name: bson
|
25
24
|
prerelease: false
|
26
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
26
|
requirements:
|
29
27
|
- - ">="
|
30
28
|
- !ruby/object:Gem::Version
|
31
|
-
hash: 31
|
32
29
|
segments:
|
33
30
|
- 1
|
34
31
|
- 0
|
@@ -76,38 +73,6 @@ files:
|
|
76
73
|
- examples/types.rb
|
77
74
|
- bin/bson_benchmark.rb
|
78
75
|
- bin/fail_if_no_c.rb
|
79
|
-
- test/auxillary/1.4_features.rb
|
80
|
-
- test/auxillary/authentication_test.rb
|
81
|
-
- test/auxillary/autoreconnect_test.rb
|
82
|
-
- test/collection_test.rb
|
83
|
-
- test/connection_test.rb
|
84
|
-
- test/conversions_test.rb
|
85
|
-
- test/cursor_fail_test.rb
|
86
|
-
- test/cursor_message_test.rb
|
87
|
-
- test/cursor_test.rb
|
88
|
-
- test/db_api_test.rb
|
89
|
-
- test/db_connection_test.rb
|
90
|
-
- test/db_test.rb
|
91
|
-
- test/grid_file_system_test.rb
|
92
|
-
- test/grid_io_test.rb
|
93
|
-
- test/grid_test.rb
|
94
|
-
- test/replica_pairs/count_test.rb
|
95
|
-
- test/replica_pairs/insert_test.rb
|
96
|
-
- test/replica_pairs/pooled_insert_test.rb
|
97
|
-
- test/replica_pairs/query_test.rb
|
98
|
-
- test/replica_sets/count_test.rb
|
99
|
-
- test/replica_sets/insert_test.rb
|
100
|
-
- test/replica_sets/pooled_insert_test.rb
|
101
|
-
- test/replica_sets/query_test.rb
|
102
|
-
- test/slave_connection_test.rb
|
103
|
-
- test/support_test.rb
|
104
|
-
- test/test_helper.rb
|
105
|
-
- test/threading/test_threading_large_pool.rb
|
106
|
-
- test/threading_test.rb
|
107
|
-
- test/unit/collection_test.rb
|
108
|
-
- test/unit/connection_test.rb
|
109
|
-
- test/unit/cursor_test.rb
|
110
|
-
- test/unit/db_test.rb
|
111
76
|
has_rdoc: true
|
112
77
|
homepage: http://www.mongodb.org
|
113
78
|
licenses: []
|
@@ -120,27 +85,23 @@ rdoc_options:
|
|
120
85
|
require_paths:
|
121
86
|
- lib
|
122
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
-
none: false
|
124
88
|
requirements:
|
125
89
|
- - ">="
|
126
90
|
- !ruby/object:Gem::Version
|
127
|
-
hash: 3
|
128
91
|
segments:
|
129
92
|
- 0
|
130
93
|
version: "0"
|
131
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
-
none: false
|
133
95
|
requirements:
|
134
96
|
- - ">="
|
135
97
|
- !ruby/object:Gem::Version
|
136
|
-
hash: 3
|
137
98
|
segments:
|
138
99
|
- 0
|
139
100
|
version: "0"
|
140
101
|
requirements: []
|
141
102
|
|
142
103
|
rubyforge_project:
|
143
|
-
rubygems_version: 1.3.
|
104
|
+
rubygems_version: 1.3.6
|
144
105
|
signing_key:
|
145
106
|
specification_version: 3
|
146
107
|
summary: Ruby driver for the MongoDB
|
@@ -148,6 +109,7 @@ test_files:
|
|
148
109
|
- test/auxillary/1.4_features.rb
|
149
110
|
- test/auxillary/authentication_test.rb
|
150
111
|
- test/auxillary/autoreconnect_test.rb
|
112
|
+
- test/auxillary/slave_connection_test.rb
|
151
113
|
- test/collection_test.rb
|
152
114
|
- test/connection_test.rb
|
153
115
|
- test/conversions_test.rb
|
@@ -168,7 +130,7 @@ test_files:
|
|
168
130
|
- test/replica_sets/insert_test.rb
|
169
131
|
- test/replica_sets/pooled_insert_test.rb
|
170
132
|
- test/replica_sets/query_test.rb
|
171
|
-
- test/
|
133
|
+
- test/replica_sets/replication_ack_test.rb
|
172
134
|
- test/support_test.rb
|
173
135
|
- test/test_helper.rb
|
174
136
|
- test/threading/test_threading_large_pool.rb
|