mongo 1.9.2 → 1.10.0.rc0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/LICENSE +1 -1
  5. data/README.md +94 -334
  6. data/Rakefile +6 -4
  7. data/VERSION +1 -1
  8. data/bin/mongo_console +13 -6
  9. data/lib/mongo.rb +22 -27
  10. data/lib/mongo/bulk_write_collection_view.rb +352 -0
  11. data/lib/mongo/collection.rb +128 -188
  12. data/lib/mongo/collection_writer.rb +348 -0
  13. data/lib/mongo/connection.rb +19 -0
  14. data/lib/mongo/{util → connection}/node.rb +15 -1
  15. data/lib/mongo/{util → connection}/pool.rb +34 -19
  16. data/lib/mongo/{util → connection}/pool_manager.rb +8 -2
  17. data/lib/mongo/{util → connection}/sharding_pool_manager.rb +1 -1
  18. data/lib/mongo/connection/socket.rb +18 -0
  19. data/lib/mongo/{util → connection/socket}/socket_util.rb +5 -2
  20. data/lib/mongo/{util → connection/socket}/ssl_socket.rb +3 -4
  21. data/lib/mongo/{util → connection/socket}/tcp_socket.rb +25 -15
  22. data/lib/mongo/{util → connection/socket}/unix_socket.rb +6 -4
  23. data/lib/mongo/cursor.rb +113 -47
  24. data/lib/mongo/db.rb +203 -131
  25. data/lib/mongo/{exceptions.rb → exception.rb} +7 -1
  26. data/lib/mongo/functional.rb +19 -0
  27. data/lib/mongo/functional/authentication.rb +303 -0
  28. data/lib/mongo/{util → functional}/logging.rb +1 -1
  29. data/lib/mongo/{util → functional}/read_preference.rb +49 -1
  30. data/lib/mongo/{util → functional}/uri_parser.rb +81 -69
  31. data/lib/mongo/{util → functional}/write_concern.rb +2 -1
  32. data/{test/unit/pool_test.rb → lib/mongo/gridfs.rb} +5 -10
  33. data/lib/mongo/gridfs/grid.rb +1 -3
  34. data/lib/mongo/gridfs/grid_ext.rb +1 -1
  35. data/lib/mongo/gridfs/grid_file_system.rb +1 -1
  36. data/lib/mongo/gridfs/grid_io.rb +1 -1
  37. data/lib/mongo/legacy.rb +63 -8
  38. data/lib/mongo/mongo_client.rb +128 -154
  39. data/lib/mongo/mongo_replica_set_client.rb +17 -11
  40. data/lib/mongo/mongo_sharded_client.rb +2 -1
  41. data/lib/mongo/networking.rb +19 -10
  42. data/lib/mongo/utils.rb +19 -0
  43. data/lib/mongo/{util → utils}/conversions.rb +1 -1
  44. data/lib/mongo/{util → utils}/core_ext.rb +1 -1
  45. data/lib/mongo/{util → utils}/server_version.rb +1 -1
  46. data/lib/mongo/{util → utils}/support.rb +10 -57
  47. data/lib/mongo/{util → utils}/thread_local_variable_manager.rb +1 -1
  48. data/test/functional/authentication_test.rb +8 -21
  49. data/test/functional/bulk_write_collection_view_test.rb +782 -0
  50. data/test/functional/{connection_test.rb → client_test.rb} +153 -78
  51. data/test/functional/collection_test.rb +343 -97
  52. data/test/functional/collection_writer_test.rb +83 -0
  53. data/test/functional/conversions_test.rb +1 -3
  54. data/test/functional/cursor_fail_test.rb +3 -3
  55. data/test/functional/cursor_message_test.rb +3 -3
  56. data/test/functional/cursor_test.rb +38 -3
  57. data/test/functional/db_api_test.rb +5 -5
  58. data/test/functional/db_connection_test.rb +2 -2
  59. data/test/functional/db_test.rb +35 -11
  60. data/test/functional/grid_file_system_test.rb +2 -2
  61. data/test/functional/grid_io_test.rb +2 -2
  62. data/test/functional/grid_test.rb +2 -2
  63. data/test/functional/pool_test.rb +2 -3
  64. data/test/functional/safe_test.rb +5 -5
  65. data/test/functional/ssl_test.rb +22 -102
  66. data/test/functional/support_test.rb +1 -1
  67. data/test/functional/timeout_test.rb +6 -22
  68. data/test/functional/uri_test.rb +113 -12
  69. data/test/functional/write_concern_test.rb +6 -6
  70. data/test/helpers/general.rb +50 -0
  71. data/test/helpers/test_unit.rb +309 -0
  72. data/test/replica_set/authentication_test.rb +8 -23
  73. data/test/replica_set/basic_test.rb +41 -14
  74. data/test/replica_set/client_test.rb +179 -117
  75. data/test/replica_set/complex_connect_test.rb +6 -7
  76. data/test/replica_set/connection_test.rb +46 -38
  77. data/test/replica_set/count_test.rb +2 -2
  78. data/test/replica_set/cursor_test.rb +8 -8
  79. data/test/replica_set/insert_test.rb +64 -2
  80. data/test/replica_set/max_values_test.rb +59 -10
  81. data/test/replica_set/pinning_test.rb +2 -2
  82. data/test/replica_set/query_test.rb +2 -2
  83. data/test/replica_set/read_preference_test.rb +6 -6
  84. data/test/replica_set/refresh_test.rb +7 -7
  85. data/test/replica_set/replication_ack_test.rb +5 -5
  86. data/test/replica_set/ssl_test.rb +24 -106
  87. data/test/sharded_cluster/basic_test.rb +43 -15
  88. data/test/shared/authentication/basic_auth_shared.rb +215 -0
  89. data/test/shared/authentication/sasl_plain_shared.rb +96 -0
  90. data/test/shared/ssl_shared.rb +173 -0
  91. data/test/test_helper.rb +31 -199
  92. data/test/threading/basic_test.rb +29 -3
  93. data/test/tools/mongo_config.rb +45 -20
  94. data/test/tools/mongo_config_test.rb +1 -1
  95. data/test/unit/client_test.rb +136 -57
  96. data/test/unit/collection_test.rb +31 -55
  97. data/test/unit/connection_test.rb +135 -72
  98. data/test/unit/cursor_test.rb +2 -2
  99. data/test/unit/db_test.rb +19 -15
  100. data/test/unit/grid_test.rb +2 -2
  101. data/test/unit/mongo_sharded_client_test.rb +17 -15
  102. data/test/unit/node_test.rb +2 -2
  103. data/test/unit/pool_manager_test.rb +7 -5
  104. data/test/unit/read_pref_test.rb +82 -2
  105. data/test/unit/read_test.rb +14 -14
  106. data/test/unit/safe_test.rb +9 -9
  107. data/test/unit/sharding_pool_manager_test.rb +11 -5
  108. data/test/unit/write_concern_test.rb +9 -9
  109. metadata +71 -56
  110. metadata.gz.sig +0 -0
  111. data/test/functional/threading_test.rb +0 -109
  112. data/test/shared/authentication.rb +0 -121
  113. data/test/unit/util_test.rb +0 -69
@@ -0,0 +1,83 @@
1
+ # Copyright (C) 2009-2013 MongoDB, 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
+
15
+ require 'test_helper'
16
+
17
+ module Mongo
18
+ class Collection
19
+ public :batch_write
20
+ end
21
+ class CollectionWriter
22
+ public :sort_by_first_sym, :ordered_group_by_first
23
+ end
24
+ end
25
+
26
+ class CollectionWriterTest < Test::Unit::TestCase
27
+
28
+ DATABASE_NAME = 'ruby_test_collection_writer'
29
+ COLLECTION_NAME = 'test'
30
+
31
+ def default_setup
32
+ @client = MongoClient.new
33
+ @db = @client[DATABASE_NAME]
34
+ @collection = @db[COLLECTION_NAME]
35
+ @collection.drop
36
+ end
37
+
38
+ context "Bulk API Execute" do
39
+ setup do
40
+ default_setup
41
+ end
42
+
43
+ should "sort_by_first_sym for grouping unordered ops" do
44
+ pairs = [
45
+ [:insert, {:n => 0}],
46
+ [:update, {:n => 1}], [:update, {:n => 2}],
47
+ [:delete, {:n => 3}],
48
+ [:insert, {:n => 5}], [:insert, {:n => 6}], [:insert, {:n => 7}],
49
+ [:update, {:n => 8}],
50
+ [:delete, {:n => 9}], [:delete, {:n => 10}]
51
+ ]
52
+ result = @collection.command_writer.sort_by_first_sym(pairs)
53
+ expected = [
54
+ :delete, :delete, :delete,
55
+ :insert, :insert, :insert, :insert,
56
+ :update, :update, :update
57
+ ]
58
+ assert_equal expected, result.collect{|first, rest| first}
59
+ end
60
+
61
+ should "calculate ordered_group_by_first" do
62
+ pairs = [
63
+ [:insert, {:n => 0}],
64
+ [:update, {:n => 1}], [:update, {:n => 2}],
65
+ [:delete, {:n => 3}],
66
+ [:insert, {:n => 5}], [:insert, {:n => 6}], [:insert, {:n => 7}],
67
+ [:update, {:n => 8}],
68
+ [:delete, {:n => 9}], [:delete, {:n => 10}]
69
+ ]
70
+ result = @collection.command_writer.ordered_group_by_first(pairs)
71
+ expected = [
72
+ [:insert, [{:n => 0}]],
73
+ [:update, [{:n => 1}, {:n => 2}]],
74
+ [:delete, [{:n => 3}]],
75
+ [:insert, [{:n => 5}, {:n => 6}, {:n => 7}]],
76
+ [:update, [{:n => 8}]],
77
+ [:delete, [{:n => 9}, {:n => 10}]]
78
+ ]
79
+ assert_equal expected, result
80
+ end
81
+
82
+ end
83
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -13,8 +13,6 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'test_helper'
16
- require 'mongo/exceptions'
17
- require 'mongo/util/conversions'
18
16
 
19
17
  class ConversionsTest < Test::Unit::TestCase
20
18
  include Mongo::Conversions
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -20,14 +20,14 @@ class CursorFailTest < Test::Unit::TestCase
20
20
  include Mongo
21
21
 
22
22
  @@connection = standard_connection
23
- @@db = @@connection.db(MONGO_TEST_DB)
23
+ @@db = @@connection.db(TEST_DB)
24
24
  @@coll = @@db.collection('test')
25
25
  @@version = @@connection.server_version
26
26
 
27
27
  def setup
28
28
  @@coll.remove({})
29
29
  @@coll.insert({'a' => 1}) # collection not created until it's used
30
- @@coll_full_name = "#{MONGO_TEST_DB}.test"
30
+ @@coll_full_name = "#{TEST_DB}.test"
31
31
  end
32
32
 
33
33
  def test_refill_via_get_more_alt_coll
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -20,14 +20,14 @@ class CursorMessageTest < Test::Unit::TestCase
20
20
  include Mongo
21
21
 
22
22
  @@connection = standard_connection
23
- @@db = @@connection.db(MONGO_TEST_DB)
23
+ @@db = @@connection.db(TEST_DB)
24
24
  @@coll = @@db.collection('test')
25
25
  @@version = @@connection.server_version
26
26
 
27
27
  def setup
28
28
  @@coll.remove
29
29
  @@coll.insert('a' => 1) # collection not created until it's used
30
- @@coll_full_name = "#{MONGO_TEST_DB}.test"
30
+ @@coll_full_name = "#{TEST_DB}.test"
31
31
  end
32
32
 
33
33
  def test_valid_batch_sizes
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -20,14 +20,14 @@ class CursorTest < Test::Unit::TestCase
20
20
  include Mongo::Constants
21
21
 
22
22
  @@connection = standard_connection
23
- @@db = @@connection.db(MONGO_TEST_DB)
23
+ @@db = @@connection.db(TEST_DB)
24
24
  @@coll = @@db.collection('test')
25
25
  @@version = @@connection.server_version
26
26
 
27
27
  def setup
28
28
  @@coll.remove
29
29
  @@coll.insert('a' => 1) # collection not created until it's used
30
- @@coll_full_name = "#{MONGO_TEST_DB}.test"
30
+ @@coll_full_name = "#{TEST_DB}.test"
31
31
  end
32
32
 
33
33
  def test_alive
@@ -91,6 +91,41 @@ class CursorTest < Test::Unit::TestCase
91
91
  end
92
92
  end
93
93
 
94
+ def test_compile_regex_get_more
95
+ return unless defined?(BSON::BSON_RUBY) && BSON::BSON_CODER == BSON::BSON_RUBY
96
+ @@coll.remove
97
+ n_docs = 3
98
+ n_docs.times { |n| @@coll.insert({ 'n' => /.*/ }) }
99
+ cursor = @@coll.find({}, :batch_size => (n_docs-1), :compile_regex => false)
100
+ cursor.expects(:send_get_more)
101
+ cursor.to_a.each do |doc|
102
+ assert_kind_of BSON::Regex, doc['n']
103
+ end
104
+ end
105
+
106
+ def test_server_op_timeout_error
107
+ cursor = @@coll.find
108
+ cursor.stubs(:send_initial_query).returns(true)
109
+
110
+ cursor.instance_variable_set(:@cache, [{
111
+ '$err' => 'operation exceeded time limit',
112
+ 'code' => 50
113
+ }])
114
+
115
+ assert_raise ExecutionTimeout do
116
+ cursor.to_a
117
+ end
118
+ end
119
+
120
+ def test_server_op_timeout
121
+ with_forced_timeout(@@connection) do
122
+ assert_raise ExecutionTimeout do
123
+ cursor = @@coll.find.server_op_timeout(100)
124
+ cursor.to_a
125
+ end
126
+ end
127
+ end
128
+
94
129
  def test_exhaust_after_limit_error
95
130
  c = Cursor.new(@@coll, :limit => 17)
96
131
  assert_raise MongoArgumentError do
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ class DBAPITest < Test::Unit::TestCase
19
19
  include BSON
20
20
 
21
21
  @@client = standard_connection
22
- @@db = @@client.db(MONGO_TEST_DB)
22
+ @@db = @@client.db(TEST_DB)
23
23
  @@coll = @@db.collection('test')
24
24
  @@version = @@client.server_version
25
25
 
@@ -27,7 +27,7 @@ class DBAPITest < Test::Unit::TestCase
27
27
  @@coll.remove
28
28
  @r1 = {'a' => 1}
29
29
  @@coll.insert(@r1) # collection not created until it's used
30
- @@coll_full_name = "#{MONGO_TEST_DB}.test"
30
+ @@coll_full_name = "#{TEST_DB}.test"
31
31
  end
32
32
 
33
33
  def teardown
@@ -327,12 +327,12 @@ class DBAPITest < Test::Unit::TestCase
327
327
  begin
328
328
  coll = @@db.create_collection('foobar', :capped => true, :size => 1024)
329
329
  options = coll.options
330
- assert_equal 'foobar', options['create']
330
+ assert_equal 'foobar', options['create'] if @@client.server_version < '2.5.5'
331
331
  assert_equal true, options['capped']
332
332
  assert_equal 1024, options['size']
333
333
  rescue => ex
334
334
  @@db.drop_collection('foobar')
335
- fail "did not expect exception \"#{ex}\""
335
+ fail "did not expect exception \"#{ex.inspect}\""
336
336
  ensure
337
337
  @@db.strict = false
338
338
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ class DBConnectionTest < Test::Unit::TestCase
19
19
  def test_no_exceptions
20
20
  host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
21
21
  port = ENV['MONGO_RUBY_DRIVER_PORT'] || MongoClient::DEFAULT_PORT
22
- db = MongoClient.new(host, port).db(MONGO_TEST_DB)
22
+ db = MongoClient.new(host, port).db(TEST_DB)
23
23
  coll = db.collection('test')
24
24
  coll.remove
25
25
  db.get_last_error
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -29,8 +29,7 @@ class DBTest < Test::Unit::TestCase
29
29
  include Mongo
30
30
 
31
31
  @@client = standard_connection
32
- @@db = @@client.db(MONGO_TEST_DB)
33
- @@users = @@db.collection('system.users')
32
+ @@db = @@client.db(TEST_DB)
34
33
  @@version = @@client.server_version
35
34
 
36
35
  def test_close
@@ -42,8 +41,7 @@ class DBTest < Test::Unit::TestCase
42
41
  rescue => ex
43
42
  assert_match(/NilClass/, ex.to_s)
44
43
  ensure
45
- @@db = standard_connection.db(MONGO_TEST_DB)
46
- @@users = @@db.collection('system.users')
44
+ @@db = standard_connection.db(TEST_DB)
47
45
  end
48
46
  end
49
47
 
@@ -58,7 +56,7 @@ class DBTest < Test::Unit::TestCase
58
56
  end
59
57
 
60
58
  def test_get_and_drop_collection
61
- db = @@client.db(MONGO_TEST_DB, :strict => true)
59
+ db = @@client.db(TEST_DB, :strict => true)
62
60
  db.create_collection('foo')
63
61
  assert db.collection('foo')
64
62
  assert db.drop_collection('foo')
@@ -81,7 +79,7 @@ class DBTest < Test::Unit::TestCase
81
79
 
82
80
  def test_full_coll_name
83
81
  coll = @@db.collection('test')
84
- assert_equal "#{MONGO_TEST_DB}.test", @@db.full_collection_name(coll.name)
82
+ assert_equal "#{TEST_DB}.test", @@db.full_collection_name(coll.name)
85
83
  end
86
84
 
87
85
  def test_collection_names
@@ -109,7 +107,7 @@ class DBTest < Test::Unit::TestCase
109
107
  end
110
108
 
111
109
  def test_pk_factory
112
- db = standard_connection.db(MONGO_TEST_DB, :pk => TestPKFactory.new)
110
+ db = standard_connection.db(TEST_DB, :pk => TestPKFactory.new)
113
111
  coll = db.collection('test')
114
112
  coll.remove
115
113
 
@@ -133,7 +131,7 @@ class DBTest < Test::Unit::TestCase
133
131
 
134
132
  def test_pk_factory_reset
135
133
  conn = standard_connection
136
- db = conn.db(MONGO_TEST_DB)
134
+ db = conn.db(TEST_DB)
137
135
  db.pk_factory = Object.new # first time
138
136
  begin
139
137
  db.pk_factory = Object.new
@@ -205,6 +203,24 @@ class DBTest < Test::Unit::TestCase
205
203
  end
206
204
  end
207
205
 
206
+ def test_arbitrary_command_opts
207
+ with_forced_timeout(@@client) do
208
+ assert_raise ExecutionTimeout do
209
+ cmd = OrderedHash.new
210
+ cmd[:ping] = 1
211
+ cmd[:maxTimeMS] = 100
212
+ @@db.command(cmd)
213
+ end
214
+ end
215
+ end
216
+
217
+ def test_command_with_bson
218
+ normal_response = @@db.command({:buildInfo => 1})
219
+ bson = BSON::BSON_CODER.serialize({:buildInfo => 1}, false, false)
220
+ bson_response = @@db.command({:bson => bson})
221
+ assert_equal normal_response, bson_response
222
+ end
223
+
208
224
  def test_last_status
209
225
  @@db['test'].remove
210
226
  @@db['test'].save("i" => 1)
@@ -218,7 +234,7 @@ class DBTest < Test::Unit::TestCase
218
234
 
219
235
  def test_text_port_number_raises_no_errors
220
236
  client = standard_connection
221
- db = client[MONGO_TEST_DB]
237
+ db = client[TEST_DB]
222
238
  db.collection('users').remove
223
239
  end
224
240
 
@@ -236,6 +252,14 @@ class DBTest < Test::Unit::TestCase
236
252
  assert_equal 'hello', @@db['system'].find_one['_id']
237
253
  end
238
254
 
255
+ def test_eval_nolock
256
+ function = "db.system.save({_id:'hello', value: function(string) { print(string); } })"
257
+ @@db.expects(:command).with do |selector, opts|
258
+ selector[:nolock] == true
259
+ end.returns({ 'ok' => 1, 'retval' => 1 })
260
+ @@db.eval(function, 'hello', :nolock => true)
261
+ end
262
+
239
263
  if @@version >= "1.3.5"
240
264
  def test_db_stats
241
265
  stats = @@db.stats
@@ -246,7 +270,7 @@ class DBTest < Test::Unit::TestCase
246
270
 
247
271
  context "database profiling" do
248
272
  setup do
249
- @db = @@client[MONGO_TEST_DB]
273
+ @db = @@client[TEST_DB]
250
274
  @coll = @db['test']
251
275
  @coll.remove
252
276
  @r1 = @coll.insert('a' => 1) # collection not created until it's used
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ class GridFileSystemTest < Test::Unit::TestCase
18
18
  context "GridFileSystem:" do
19
19
  setup do
20
20
  @con = standard_connection
21
- @db = @con.db(MONGO_TEST_DB)
21
+ @db = @con.db(TEST_DB)
22
22
  end
23
23
 
24
24
  teardown do
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ class GridIOTest < Test::Unit::TestCase
18
18
 
19
19
  context "GridIO" do
20
20
  setup do
21
- @db = standard_connection.db(MONGO_TEST_DB)
21
+ @db = standard_connection.db(TEST_DB)
22
22
  @files = @db.collection('fs.files')
23
23
  @chunks = @db.collection('fs.chunks')
24
24
  @chunks.create_index([['files_id', Mongo::ASCENDING], ['n', Mongo::ASCENDING]])
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ end
35
35
  class GridTest < Test::Unit::TestCase
36
36
  context "Tests:" do
37
37
  setup do
38
- @db = standard_connection.db(MONGO_TEST_DB)
38
+ @db = standard_connection.db(TEST_DB)
39
39
  @files = @db.collection('test-fs.files')
40
40
  @chunks = @db.collection('test-fs.chunks')
41
41
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -13,14 +13,13 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'test_helper'
16
- require 'thread'
17
16
 
18
17
  class PoolTest < Test::Unit::TestCase
19
18
  include Mongo
20
19
 
21
20
  def setup
22
21
  @client ||= standard_connection({:pool_size => 15, :pool_timeout => 5})
23
- @db = @client.db(MONGO_TEST_DB)
22
+ @db = @client.db(TEST_DB)
24
23
  @collection = @db.collection("pool_test")
25
24
  end
26
25
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013 10gen Inc.
1
+ # Copyright (C) 2009-2013 MongoDB, Inc.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ class SafeTest < Test::Unit::TestCase
19
19
  context "Safe mode propogation: " do
20
20
  setup do
21
21
  @connection = standard_connection({:safe => true}, true) # Legacy
22
- @db = @connection[MONGO_TEST_DB]
22
+ @db = @connection[TEST_DB]
23
23
  @collection = @db['test-safe']
24
24
  @collection.create_index([[:a, 1]], :unique => true)
25
25
  @collection.remove
@@ -73,7 +73,7 @@ class SafeTest < Test::Unit::TestCase
73
73
  context "Safe error objects" do
74
74
  setup do
75
75
  @connection = standard_connection({:safe => true}, true) # Legacy
76
- @db = @connection[MONGO_TEST_DB]
76
+ @db = @connection[TEST_DB]
77
77
  @collection = @db['test']
78
78
  @collection.remove
79
79
  @collection.insert({:a => 1})
@@ -85,8 +85,8 @@ class SafeTest < Test::Unit::TestCase
85
85
  response = @collection.update({:a => 1}, {"$set" => {:a => 2}},
86
86
  :multi => true)
87
87
 
88
- assert response['updatedExisting']
89
- assert_equal 3, response['n']
88
+ assert(response['updatedExisting'] || @db.connection.wire_version_feature?(Mongo::MongoClient::BATCH_COMMANDS)) # TODO - review new write command return values
89
+ assert(response['n'] == 3 || @db.connection.wire_version_feature?(Mongo::MongoClient::BATCH_COMMANDS)) # TODO - update command top pending
90
90
  end
91
91
 
92
92
  should "return object on remove" do