mongo 1.8.6 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Rakefile +13 -1
  5. data/VERSION +1 -1
  6. data/bin/mongo_console +15 -0
  7. data/lib/mongo.rb +14 -0
  8. data/lib/mongo/collection.rb +80 -42
  9. data/lib/mongo/cursor.rb +15 -1
  10. data/lib/mongo/db.rb +56 -19
  11. data/lib/mongo/exceptions.rb +14 -0
  12. data/lib/mongo/gridfs/grid.rb +16 -3
  13. data/lib/mongo/gridfs/grid_ext.rb +14 -0
  14. data/lib/mongo/gridfs/grid_file_system.rb +16 -3
  15. data/lib/mongo/gridfs/grid_io.rb +17 -3
  16. data/lib/mongo/legacy.rb +14 -0
  17. data/lib/mongo/mongo_client.rb +93 -40
  18. data/lib/mongo/mongo_replica_set_client.rb +21 -0
  19. data/lib/mongo/mongo_sharded_client.rb +15 -1
  20. data/lib/mongo/networking.rb +14 -0
  21. data/lib/mongo/util/conversions.rb +16 -2
  22. data/lib/mongo/util/core_ext.rb +14 -31
  23. data/lib/mongo/util/logging.rb +23 -7
  24. data/lib/mongo/util/node.rb +17 -2
  25. data/lib/mongo/util/pool.rb +17 -1
  26. data/lib/mongo/util/pool_manager.rb +15 -2
  27. data/lib/mongo/util/read_preference.rb +14 -0
  28. data/lib/mongo/util/server_version.rb +15 -0
  29. data/lib/mongo/util/sharding_pool_manager.rb +13 -0
  30. data/lib/mongo/util/socket_util.rb +14 -0
  31. data/lib/mongo/util/ssl_socket.rb +48 -7
  32. data/lib/mongo/util/support.rb +14 -0
  33. data/lib/mongo/util/tcp_socket.rb +18 -4
  34. data/lib/mongo/util/thread_local_variable_manager.rb +14 -0
  35. data/lib/mongo/util/unix_socket.rb +20 -6
  36. data/lib/mongo/util/uri_parser.rb +16 -8
  37. data/lib/mongo/util/write_concern.rb +16 -2
  38. data/test/functional/authentication_test.rb +26 -1
  39. data/test/functional/collection_test.rb +140 -41
  40. data/test/functional/connection_test.rb +19 -6
  41. data/test/functional/conversions_test.rb +14 -0
  42. data/test/functional/cursor_fail_test.rb +14 -0
  43. data/test/functional/cursor_message_test.rb +14 -0
  44. data/test/functional/cursor_test.rb +15 -1
  45. data/test/functional/db_api_test.rb +15 -1
  46. data/test/functional/db_connection_test.rb +14 -0
  47. data/test/functional/db_test.rb +14 -0
  48. data/test/functional/grid_file_system_test.rb +16 -4
  49. data/test/functional/grid_io_test.rb +14 -0
  50. data/test/functional/grid_test.rb +14 -0
  51. data/test/functional/pool_test.rb +22 -6
  52. data/test/functional/safe_test.rb +14 -0
  53. data/test/functional/ssl_test.rb +109 -0
  54. data/test/functional/support_test.rb +14 -0
  55. data/test/functional/threading_test.rb +22 -8
  56. data/test/functional/timeout_test.rb +20 -6
  57. data/test/functional/uri_test.rb +14 -14
  58. data/test/functional/write_concern_test.rb +14 -0
  59. data/test/replica_set/authentication_test.rb +28 -2
  60. data/test/replica_set/basic_test.rb +14 -0
  61. data/test/replica_set/client_test.rb +14 -0
  62. data/test/replica_set/complex_connect_test.rb +14 -0
  63. data/test/replica_set/connection_test.rb +14 -0
  64. data/test/replica_set/count_test.rb +14 -0
  65. data/test/replica_set/cursor_test.rb +14 -0
  66. data/test/replica_set/insert_test.rb +14 -0
  67. data/test/replica_set/max_values_test.rb +14 -0
  68. data/test/replica_set/pinning_test.rb +14 -0
  69. data/test/replica_set/query_test.rb +14 -0
  70. data/test/replica_set/read_preference_test.rb +14 -0
  71. data/test/replica_set/refresh_test.rb +14 -0
  72. data/test/replica_set/replication_ack_test.rb +14 -0
  73. data/test/replica_set/ssl_test.rb +114 -0
  74. data/test/sharded_cluster/basic_test.rb +14 -0
  75. data/test/shared/authentication.rb +55 -0
  76. data/test/test_helper.rb +15 -1
  77. data/test/threading/basic_test.rb +14 -0
  78. data/test/tools/mongo_config.rb +16 -1
  79. data/test/tools/mongo_config_test.rb +15 -1
  80. data/test/unit/client_test.rb +14 -0
  81. data/test/unit/collection_test.rb +14 -0
  82. data/test/unit/connection_test.rb +14 -0
  83. data/test/unit/cursor_test.rb +14 -0
  84. data/test/unit/db_test.rb +15 -1
  85. data/test/unit/grid_test.rb +14 -0
  86. data/test/unit/mongo_sharded_client_test.rb +14 -0
  87. data/test/unit/node_test.rb +15 -0
  88. data/test/unit/pool_manager_test.rb +15 -0
  89. data/test/unit/pool_test.rb +14 -0
  90. data/test/unit/read_pref_test.rb +14 -0
  91. data/test/unit/read_test.rb +14 -0
  92. data/test/unit/safe_test.rb +14 -0
  93. data/test/unit/sharding_pool_manager_test.rb +15 -0
  94. data/test/unit/util_test.rb +14 -0
  95. data/test/unit/write_concern_test.rb +15 -1
  96. metadata +8 -4
  97. metadata.gz.sig +0 -0
@@ -1,3 +1,17 @@
1
+ # Copyright (C) 2013 10gen Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  require 'cgi'
2
16
 
3
17
  module Mongo
@@ -225,7 +239,7 @@ module Mongo
225
239
  end
226
240
 
227
241
  if @slaveok && !@readpreference
228
- if direct?
242
+ unless replicaset?
229
243
  opts[:slave_ok] = true
230
244
  else
231
245
  opts[:read] = :secondary_preferred
@@ -233,10 +247,7 @@ module Mongo
233
247
  end
234
248
 
235
249
  opts[:ssl] = @ssl
236
-
237
- if direct?
238
- opts[:auths] = auths
239
- end
250
+ opts[:auths] = auths
240
251
 
241
252
  if replicaset.is_a?(String)
242
253
  opts[:name] = replicaset
@@ -290,9 +301,6 @@ module Mongo
290
301
  raise MongoArgumentError, "MongoDB URI must include username, password, "
291
302
  "and db if username and password are specified."
292
303
  end
293
-
294
- # The auths are repeated for each host in a replica set
295
- @auths *= hosturis.length
296
304
  end
297
305
 
298
306
  # This method uses the lambdas defined in OPT_VALID and OPT_CONV to validate
@@ -1,3 +1,17 @@
1
+ # Copyright (C) 2013 10gen Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  module Mongo
2
16
  module WriteConcern
3
17
 
@@ -29,7 +43,7 @@ module Mongo
29
43
 
30
44
  # todo: throw exception for conflicting write concern options
31
45
  def get_write_concern(opts, parent=nil)
32
- write_concern_from_legacy(opts) if opts.key?(:safe) || @legacy_write_concern
46
+ write_concern_from_legacy(opts) if opts.key?(:safe) || legacy_write_concern
33
47
  write_concern = {
34
48
  :w => 1,
35
49
  :j => false,
@@ -51,4 +65,4 @@ module Mongo
51
65
  end
52
66
 
53
67
  end
54
- end
68
+ end
@@ -1,3 +1,17 @@
1
+ # Copyright (C) 2013 10gen Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  require 'test_helper'
2
16
  require 'shared/authentication'
3
17
 
@@ -13,6 +27,17 @@ class AuthenticationTest < Test::Unit::TestCase
13
27
 
14
28
  def test_authenticate_with_connection_uri
15
29
  @db.add_user('eunice', 'uritest')
16
- assert MongoClient.from_uri("mongodb://eunice:uritest@#{host_port}/#{@db.name}")
30
+
31
+ client =
32
+ MongoClient.from_uri("mongodb://eunice:uritest@#{host_port}/#{@db.name}")
33
+
34
+ assert client
35
+ assert_equal client.auths.size, 1
36
+ assert client[MONGO_TEST_DB]['auth_test'].count
37
+
38
+ auth = client.auths.first
39
+ assert_equal @db.name, auth[:db_name]
40
+ assert_equal 'eunice', auth[:username]
41
+ assert_equal 'uritest', auth[:password]
17
42
  end
18
43
  end
@@ -1,3 +1,17 @@
1
+ # Copyright (C) 2013 10gen Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  require 'rbconfig'
2
16
  require 'test_helper'
3
17
 
@@ -244,6 +258,26 @@ class TestCollection < Test::Unit::TestCase
244
258
  assert_equal error_docs, invalid_docs
245
259
  end
246
260
 
261
+ def test_insert_one_error_doc_with_collect_on_error
262
+ invalid_doc = {'$invalid-key' => 1}
263
+ invalid_docs = [invalid_doc]
264
+ doc_ids, error_docs = @@test.insert(invalid_docs, :collect_on_error => true)
265
+ assert_equal [], doc_ids
266
+ assert_equal [invalid_doc], error_docs
267
+ end
268
+
269
+ def test_insert_empty_docs_raises_exception
270
+ assert_raise OperationFailure do
271
+ @@test.insert([])
272
+ end
273
+ end
274
+
275
+ def test_insert_empty_docs_with_collect_on_error_raises_exception
276
+ assert_raise OperationFailure do
277
+ @@test.insert([], :collect_on_error => true)
278
+ end
279
+ end
280
+
247
281
  def limited_collection
248
282
  conn = standard_connection(:connect => false)
249
283
  admin_db = Object.new
@@ -258,28 +292,93 @@ class TestCollection < Test::Unit::TestCase
258
292
  return conn.db(MONGO_TEST_DB)["test"]
259
293
  end
260
294
 
261
- def test_maximum_insert_size
295
+ def test_chunking_batch_insert
296
+ docs = []
297
+ 10.times do
298
+ docs << {'foo' => 'a' * 950}
299
+ end
300
+ limited_collection.insert(docs)
301
+ assert_equal 10, limited_collection.count
302
+ end
303
+
304
+ def test_chunking_batch_insert_without_collect_on_error
262
305
  docs = []
263
- 3.times do
306
+ 4.times do
264
307
  docs << {'foo' => 'a' * 950}
265
308
  end
266
- assert_equal limited_collection.insert(docs).length, 3
309
+ invalid_docs = []
310
+ invalid_docs << {'$invalid-key' => 1} # non utf8 encoding
311
+ docs += invalid_docs
312
+ 4.times do
313
+ docs << {'foo' => 'a' * 950}
314
+ end
315
+ assert_raise BSON::InvalidKeyName do
316
+ limited_collection.insert(docs, :collect_on_error => false)
317
+ end
267
318
  end
268
319
 
269
- def test_maximum_document_size
270
- assert_raise InvalidDocument do
271
- limited_collection.insert({'foo' => 'a' * 1024})
320
+ def test_chunking_batch_insert_with_collect_on_error
321
+ # Broken for current JRuby
322
+ if RUBY_PLATFORM == 'java' then return end
323
+ docs = []
324
+ 4.times do
325
+ docs << {'foo' => 'a' * 950}
326
+ end
327
+ invalid_docs = []
328
+ invalid_docs << {'$invalid-key' => 1} # non utf8 encoding
329
+ docs += invalid_docs
330
+ 4.times do
331
+ docs << {'foo' => 'a' * 950}
332
+ end
333
+ doc_ids, error_docs = limited_collection.insert(docs, :collect_on_error => true)
334
+ assert_equal 8, doc_ids.count
335
+ assert_equal doc_ids.count, limited_collection.count
336
+ assert_equal error_docs, invalid_docs
337
+ end
338
+
339
+ def test_chunking_batch_insert_with_continue_on_error
340
+ docs = []
341
+ 4.times do
342
+ docs << {'foo' => 'a' * 950}
343
+ end
344
+ docs << {'_id' => 'b', 'foo' => 'a'}
345
+ docs << {'_id' => 'b', 'foo' => 'c'}
346
+ 4.times do
347
+ docs << {'foo' => 'a' * 950}
272
348
  end
349
+ assert_raise OperationFailure do
350
+ limited_collection.insert(docs, :continue_on_error => true)
351
+ end
352
+ assert_equal 9, limited_collection.count
273
353
  end
274
354
 
275
- def test_maximum_message_size
355
+ def test_chunking_batch_insert_without_continue_on_error
276
356
  docs = []
277
357
  4.times do
278
358
  docs << {'foo' => 'a' * 950}
279
359
  end
360
+ docs << {'_id' => 'b', 'foo' => 'a'}
361
+ docs << {'_id' => 'b', 'foo' => 'c'}
362
+ 4.times do
363
+ docs << {'foo' => 'a' * 950}
364
+ end
365
+ assert_raise OperationFailure do
366
+ limited_collection.insert(docs, :continue_on_error => false)
367
+ end
368
+ assert_equal 5, limited_collection.count
369
+ end
370
+
371
+ def test_maximum_insert_size
372
+ docs = []
373
+ 3.times do
374
+ docs << {'foo' => 'a' * 950}
375
+ end
376
+ assert_equal limited_collection.insert(docs).length, 3
377
+ end
280
378
 
281
- assert_raise InvalidOperation do
282
- limited_collection.insert(docs)
379
+ def test_maximum_document_size
380
+ assert_raise InvalidDocument do
381
+ limited_collection.insert({'foo' => 'a' * 1024})
283
382
  end
284
383
  end
285
384
 
@@ -629,42 +728,42 @@ class TestCollection < Test::Unit::TestCase
629
728
  # save some data
630
729
  @@test.save( {
631
730
  "_id" => 1,
632
- "title" => "this is my title",
633
- "author" => "bob",
731
+ "title" => "this is my title",
732
+ "author" => "bob",
634
733
  "posted" => Time.utc(2000),
635
- "pageViews" => 5 ,
734
+ "pageViews" => 5 ,
636
735
  "tags" => [ "fun" , "good" , "fun" ],
637
- "comments" => [
638
- { "author" => "joe", "text" => "this is cool" },
639
- { "author" => "sam", "text" => "this is bad" }
736
+ "comments" => [
737
+ { "author" => "joe", "text" => "this is cool" },
738
+ { "author" => "sam", "text" => "this is bad" }
640
739
  ],
641
740
  "other" => { "foo" => 5 }
642
741
  } )
643
742
 
644
743
  @@test.save( {
645
744
  "_id" => 2,
646
- "title" => "this is your title",
647
- "author" => "dave",
745
+ "title" => "this is your title",
746
+ "author" => "dave",
648
747
  "posted" => Time.utc(2001),
649
- "pageViews" => 7,
748
+ "pageViews" => 7,
650
749
  "tags" => [ "fun" , "nasty" ],
651
- "comments" => [
652
- { "author" => "barbara" , "text" => "this is interesting" },
653
- { "author" => "jenny", "text" => "i like to play pinball", "votes" => 10 }
750
+ "comments" => [
751
+ { "author" => "barbara" , "text" => "this is interesting" },
752
+ { "author" => "jenny", "text" => "i like to play pinball", "votes" => 10 }
654
753
  ],
655
754
  "other" => { "bar" => 14 }
656
755
  })
657
756
 
658
757
  @@test.save( {
659
758
  "_id" => 3,
660
- "title" => "this is some other title",
661
- "author" => "jane",
759
+ "title" => "this is some other title",
760
+ "author" => "jane",
662
761
  "posted" => Time.utc(2002),
663
- "pageViews" => 6 ,
762
+ "pageViews" => 6 ,
664
763
  "tags" => [ "nasty", "filthy" ],
665
- "comments" => [
666
- { "author" => "will" , "text" => "i don't like the color" } ,
667
- { "author" => "jenny" , "text" => "can i get that in green?" }
764
+ "comments" => [
765
+ { "author" => "will" , "text" => "i don't like the color" } ,
766
+ { "author" => "jenny" , "text" => "can i get that in green?" }
668
767
  ],
669
768
  "other" => { "bar" => 14 }
670
769
  })
@@ -696,8 +795,8 @@ class TestCollection < Test::Unit::TestCase
696
795
 
697
796
  def test_aggregate_pipeline_operators_using_strings
698
797
  setup_aggregate_data
699
- desired_results = [ {"_id"=>1, "pageViews"=>5, "tags"=>["fun", "good", "fun"]},
700
- {"_id"=>2, "pageViews"=>7, "tags"=>["fun", "nasty"]},
798
+ desired_results = [ {"_id"=>1, "pageViews"=>5, "tags"=>["fun", "good", "fun"]},
799
+ {"_id"=>2, "pageViews"=>7, "tags"=>["fun", "nasty"]},
701
800
  {"_id"=>3, "pageViews"=>6, "tags"=>["nasty", "filthy"]} ]
702
801
  results = @@test.aggregate([{"$project" => {"tags" => 1, "pageViews" => 1}}])
703
802
  assert_equal desired_results, results
@@ -705,8 +804,8 @@ class TestCollection < Test::Unit::TestCase
705
804
 
706
805
  def test_aggregate_pipeline_operators_using_symbols
707
806
  setup_aggregate_data
708
- desired_results = [ {"_id"=>1, "pageViews"=>5, "tags"=>["fun", "good", "fun"]},
709
- {"_id"=>2, "pageViews"=>7, "tags"=>["fun", "nasty"]},
807
+ desired_results = [ {"_id"=>1, "pageViews"=>5, "tags"=>["fun", "good", "fun"]},
808
+ {"_id"=>2, "pageViews"=>7, "tags"=>["fun", "nasty"]},
710
809
  {"_id"=>3, "pageViews"=>6, "tags"=>["nasty", "filthy"]} ]
711
810
  results = @@test.aggregate([{"$project" => {:tags => 1, :pageViews => 1}}])
712
811
  assert_equal desired_results, results
@@ -721,25 +820,25 @@ class TestCollection < Test::Unit::TestCase
721
820
  def test_aggregate_pipeline_unwind
722
821
  setup_aggregate_data
723
822
  desired_results = [ {"_id"=>1, "title"=>"this is my title", "author"=>"bob", "posted"=>Time.utc(2000),
724
- "pageViews"=>5, "tags"=>"fun", "comments"=>[{"author"=>"joe", "text"=>"this is cool"},
823
+ "pageViews"=>5, "tags"=>"fun", "comments"=>[{"author"=>"joe", "text"=>"this is cool"},
725
824
  {"author"=>"sam", "text"=>"this is bad"}], "other"=>{"foo"=>5 } },
726
825
  {"_id"=>1, "title"=>"this is my title", "author"=>"bob", "posted"=>Time.utc(2000),
727
- "pageViews"=>5, "tags"=>"good", "comments"=>[{"author"=>"joe", "text"=>"this is cool"},
826
+ "pageViews"=>5, "tags"=>"good", "comments"=>[{"author"=>"joe", "text"=>"this is cool"},
728
827
  {"author"=>"sam", "text"=>"this is bad"}], "other"=>{"foo"=>5 } },
729
828
  {"_id"=>1, "title"=>"this is my title", "author"=>"bob", "posted"=>Time.utc(2000),
730
- "pageViews"=>5, "tags"=>"fun", "comments"=>[{"author"=>"joe", "text"=>"this is cool"},
829
+ "pageViews"=>5, "tags"=>"fun", "comments"=>[{"author"=>"joe", "text"=>"this is cool"},
731
830
  {"author"=>"sam", "text"=>"this is bad"}], "other"=>{"foo"=>5 } },
732
831
  {"_id"=>2, "title"=>"this is your title", "author"=>"dave", "posted"=>Time.utc(2001),
733
- "pageViews"=>7, "tags"=>"fun", "comments"=>[{"author"=>"barbara", "text"=>"this is interesting"},
832
+ "pageViews"=>7, "tags"=>"fun", "comments"=>[{"author"=>"barbara", "text"=>"this is interesting"},
734
833
  {"author"=>"jenny", "text"=>"i like to play pinball", "votes"=>10 }], "other"=>{"bar"=>14 } },
735
834
  {"_id"=>2, "title"=>"this is your title", "author"=>"dave", "posted"=>Time.utc(2001),
736
- "pageViews"=>7, "tags"=>"nasty", "comments"=>[{"author"=>"barbara", "text"=>"this is interesting"},
835
+ "pageViews"=>7, "tags"=>"nasty", "comments"=>[{"author"=>"barbara", "text"=>"this is interesting"},
737
836
  {"author"=>"jenny", "text"=>"i like to play pinball", "votes"=>10 }], "other"=>{"bar"=>14 } },
738
837
  {"_id"=>3, "title"=>"this is some other title", "author"=>"jane", "posted"=>Time.utc(2002),
739
- "pageViews"=>6, "tags"=>"nasty", "comments"=>[{"author"=>"will", "text"=>"i don't like the color"},
838
+ "pageViews"=>6, "tags"=>"nasty", "comments"=>[{"author"=>"will", "text"=>"i don't like the color"},
740
839
  {"author"=>"jenny", "text"=>"can i get that in green?"}], "other"=>{"bar"=>14 } },
741
840
  {"_id"=>3, "title"=>"this is some other title", "author"=>"jane", "posted"=>Time.utc(2002),
742
- "pageViews"=>6, "tags"=>"filthy", "comments"=>[{"author"=>"will", "text"=>"i don't like the color"},
841
+ "pageViews"=>6, "tags"=>"filthy", "comments"=>[{"author"=>"will", "text"=>"i don't like the color"},
743
842
  {"author"=>"jenny", "text"=>"can i get that in green?"}], "other"=>{"bar"=>14 } }
744
843
  ]
745
844
  results = @@test.aggregate([{"$unwind"=> "$tags"}])
@@ -1059,7 +1158,7 @@ end
1059
1158
  end
1060
1159
 
1061
1160
  def test_ensure_index_timeout
1062
- @@db.cache_time = 2
1161
+ @@db.cache_time = 1
1063
1162
  coll = @@db['ensure_test']
1064
1163
  coll.expects(:generate_indexes).twice
1065
1164
  coll.ensure_index([['a', 1]])
@@ -1070,7 +1169,7 @@ end
1070
1169
  coll.ensure_index([['a', 1]])
1071
1170
  coll.ensure_index([['a', 1]])
1072
1171
 
1073
- sleep(3)
1172
+ sleep(1)
1074
1173
  # This won't be, so generate_indexes will be called twice
1075
1174
  coll.ensure_index([['a', 1]])
1076
1175
  end
@@ -1143,7 +1242,7 @@ end
1143
1242
  end
1144
1243
 
1145
1244
  context "Grouping with a key function" do
1146
- setup do
1245
+ setup do
1147
1246
  @@test.remove
1148
1247
  @@test.save("a" => 1)
1149
1248
  @@test.save("a" => 2)
@@ -1,3 +1,17 @@
1
+ # Copyright (C) 2013 10gen Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
1
15
  require 'test_helper'
2
16
  require 'logger'
3
17
  require 'stringio'
@@ -243,12 +257,11 @@ class TestConnection < Test::Unit::TestCase
243
257
  assert_match(/unlock/, @client.unlock!['info'])
244
258
  unlocked = false
245
259
  counter = 0
246
- while counter < 5
260
+ while counter < 100
247
261
  if @client['admin']['$cmd.sys.inprog'].find_one['fsyncLock'].nil?
248
262
  unlocked = true
249
263
  break
250
264
  else
251
- sleep(1)
252
265
  counter += 1
253
266
  end
254
267
  end
@@ -336,8 +349,8 @@ class TestConnection < Test::Unit::TestCase
336
349
  context "Saved authentications" do
337
350
  setup do
338
351
  @client = standard_connection
339
- @auth = {:db_name => 'test', :username => 'bob', :password => 'secret'}
340
- @client.add_auth(@auth[:db_name], @auth[:username], @auth[:password])
352
+ @auth = {:db_name => 'test', :username => 'bob', :password => 'secret', :source => nil}
353
+ @client.add_auth(@auth[:db_name], @auth[:username], @auth[:password], @auth[:source])
341
354
  end
342
355
 
343
356
  teardown do
@@ -349,9 +362,9 @@ class TestConnection < Test::Unit::TestCase
349
362
  end
350
363
 
351
364
  should "not allow multiple authentications for the same db" do
352
- auth = {:db_name => 'test', :username => 'mickey', :password => 'm0u53'}
365
+ auth = {:db_name => 'test', :username => 'mickey', :password => 'm0u53', :source => nil}
353
366
  assert_raise Mongo::MongoArgumentError do
354
- @client.add_auth(auth[:db_name], auth[:username], auth[:password])
367
+ @client.add_auth(auth[:db_name], auth[:username], auth[:password], auth[:source])
355
368
  end
356
369
  end
357
370