mongo 1.5.0 → 1.5.1

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.
@@ -1,5 +1,12 @@
1
1
  # MongoDB Ruby Driver History
2
2
 
3
+ ### 1.5.1
4
+ 2011-11-29
5
+
6
+ Release due to corrupted gemspec. This was a bug having
7
+ to do with rubygems. Apparently, gems must still be
8
+ built with Ruby 1.8.
9
+
3
10
  ### 1.5.0
4
11
  2011-11-28
5
12
 
@@ -0,0 +1,42 @@
1
+ # encoding: UTF-8
2
+
3
+ # --
4
+ # Copyright (C) 2008-2011 10gen Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ # ++
18
+ module Mongo #:nodoc:
19
+ module TimeoutWrapper
20
+ extend self
21
+
22
+ def timeout_lib=(lib)
23
+ @@timeout_lib = lib
24
+ end
25
+
26
+ def timeout_lib
27
+ @@timeout_lib
28
+ end
29
+
30
+ def timeout(delay, &block)
31
+ if timeout_lib
32
+ begin
33
+ timeout_lib.timeout(delay, &block)
34
+ rescue ::Timeout::Error
35
+ raise Mongo::OperationTimeout
36
+ end
37
+ else
38
+ yield
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module Mongo
2
- VERSION = "1.5.0"
2
+ VERSION = "1.5.1"
3
3
  end
@@ -0,0 +1,30 @@
1
+ # encoding:utf-8
2
+ require './test/bson/test_helper'
3
+ require 'complex'
4
+ require 'bigdecimal'
5
+ require 'rational'
6
+
7
+ class BSONTest < Test::Unit::TestCase
8
+
9
+ include BSON
10
+
11
+ def setup
12
+ @encoder = BSON::BSON_CODER
13
+ end
14
+
15
+ def assert_doc_pass(doc, options={})
16
+ bson = @encoder.serialize(doc)
17
+ if options[:debug]
18
+ puts "DEBUGGING DOC:"
19
+ p bson.to_a
20
+ puts "DESERIALIZES TO:"
21
+ end
22
+ assert_equal @encoder.serialize(doc).to_a, bson.to_a
23
+ assert_equal doc, @encoder.deserialize(bson)
24
+ end
25
+
26
+ def test_string
27
+ assert_doc_pass({:a => "hello"})
28
+ end
29
+
30
+ end
@@ -0,0 +1,21 @@
1
+ require './test/test_helper'
2
+ require 'logger'
3
+ require 'stringio'
4
+ require 'thread'
5
+
6
+ class TestPool < Test::Unit::TestCase
7
+
8
+ include Mongo
9
+ include BSON
10
+
11
+ def setup
12
+ @conn = standard_connection
13
+ end
14
+
15
+ def teardown
16
+ @conn[MONGO_TEST_DB].get_last_error
17
+ end
18
+
19
+ def test_foo
20
+ end
21
+ end
@@ -0,0 +1,111 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require './test/replica_sets/rs_test_helper'
3
+
4
+ class ReplicaSetThreadingTest < Test::Unit::TestCase
5
+ include ReplicaSetTest
6
+
7
+ def setup_safe_data
8
+ @conn = ReplSetConnection.new([self.rs.host, self.rs.ports[0]],
9
+ :pool_size => 100)
10
+ @db = @conn[MONGO_TEST_DB]
11
+ @coll = @db.collection('thread-test-collection')
12
+ @db.drop_collection('duplicate')
13
+ @db.drop_collection('unique')
14
+ @duplicate = @db.collection('duplicate')
15
+ @unique = @db.collection('unique')
16
+
17
+ @duplicate.insert("test" => "insert")
18
+ @duplicate.insert("test" => "update")
19
+ @unique.insert("test" => "insert")
20
+ @unique.insert("test" => "update")
21
+ @unique.create_index("test", :unique => true)
22
+ end
23
+
24
+ def test_safe_update
25
+ setup_safe_data
26
+ times = []
27
+ threads = []
28
+ 100.times do |i|
29
+ threads[i] = Thread.new do
30
+ 10.times do
31
+ if i % 2 == 0
32
+ assert_raise Mongo::OperationFailure do
33
+ t1 = Time.now
34
+ @unique.update({"test" => "insert"},
35
+ {"$set" => {"test" => "update"}}, :safe => true)
36
+ times << Time.now - t1
37
+ end
38
+ else
39
+ t1 = Time.now
40
+ @duplicate.update({"test" => "insert"},
41
+ {"$set" => {"test" => "update"}}, :safe => true)
42
+ times << Time.now - t1
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ 100.times do |i|
49
+ threads[i].join
50
+ end
51
+ @conn.close
52
+ end
53
+
54
+ def test_safe_insert
55
+ setup_safe_data
56
+ threads = []
57
+ 100.times do |i|
58
+ threads[i] = Thread.new do
59
+ if i % 2 == 0
60
+ assert_raise Mongo::OperationFailure do
61
+ @unique.insert({"test" => "insert"}, :safe => true)
62
+ end
63
+ else
64
+ @duplicate.insert({"test" => "insert"}, :safe => true)
65
+ end
66
+ end
67
+ end
68
+
69
+ 100.times do |i|
70
+ threads[i].join
71
+ end
72
+ @conn.close
73
+ end
74
+
75
+ def setup_replica_set_connection
76
+ @conn = ReplSetConnection.new([self.rs.host, self.rs.ports[0]],
77
+ :pool_size => 100, :auto_refresh => :sync,
78
+ :refresh_interval => 2)
79
+ @db = @conn[MONGO_TEST_DB]
80
+ @coll = @db.collection('thread-test-collection')
81
+ end
82
+
83
+ def test_threading_with_queries
84
+ setup_replica_set_connection
85
+ @coll.drop
86
+ @coll = @db.collection('thread-test-collection')
87
+
88
+ 1000.times do |i|
89
+ @coll.insert("x" => i)
90
+ end
91
+
92
+ threads = []
93
+
94
+ 10.times do |i|
95
+ threads[i] = Thread.new do
96
+ 100.times do
97
+ sum = 0
98
+ @coll.find().each do |document|
99
+ sum += document["x"]
100
+ end
101
+ assert_equal 499500, sum
102
+ end
103
+ end
104
+ end
105
+
106
+ 10.times do |i|
107
+ threads[i].join
108
+ end
109
+ @conn.close
110
+ end
111
+ end
@@ -0,0 +1,14 @@
1
+ require './test/test_helper'
2
+
3
+ class TestTimeout < Test::Unit::TestCase
4
+
5
+ def test_timeout
6
+ @conn = standard_connection(:op_timeout => 2)
7
+ assert @conn[MONGO_TEST_DB]['test'].save({:a => 1})
8
+ assert @conn[MONGO_TEST_DB]['test'].find.next
9
+ assert_raise OperationTimeout do
10
+ @conn[MONGO_TEST_DB]['test'].find({'$where' => 'function() { while(true) { this.a == 1 } }'}).next
11
+ end
12
+ end
13
+
14
+ end
metadata CHANGED
@@ -1,221 +1,250 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mongo
3
- version: !ruby/object:Gem::Version
4
- version: 1.5.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 1
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 5
9
+ - 1
10
+ version: 1.5.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Jim Menard
9
14
  - Mike Dirolf
10
15
  - Kyle Banker
11
16
  autorequire:
12
17
  bindir: bin
13
18
  cert_chain: []
14
- date: 2011-11-28 00:00:00.000000000Z
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
19
+
20
+ date: 2011-11-29 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
17
23
  name: bson
18
- requirement: &10966820 !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
19
26
  none: false
20
- requirements:
21
- - - =
22
- - !ruby/object:Gem::Version
23
- version: 1.5.0
27
+ requirements:
28
+ - - "="
29
+ - !ruby/object:Gem::Version
30
+ hash: 1
31
+ segments:
32
+ - 1
33
+ - 5
34
+ - 1
35
+ version: 1.5.1
24
36
  type: :runtime
25
- prerelease: false
26
- version_requirements: *10966820
37
+ version_requirements: *id001
27
38
  description: A Ruby driver for MongoDB. For more information about Mongo, see http://www.mongodb.org.
28
39
  email: mongodb-dev@googlegroups.com
29
- executables:
40
+ executables:
30
41
  - mongo_console
31
42
  extensions: []
32
- extra_rdoc_files:
43
+
44
+ extra_rdoc_files:
33
45
  - README.md
34
- files:
46
+ files:
35
47
  - README.md
36
48
  - Rakefile
37
49
  - mongo.gemspec
38
50
  - LICENSE.txt
39
51
  - lib/mongo.rb
40
52
  - lib/mongo/collection.rb
41
- - lib/mongo/networking.rb
53
+ - lib/mongo/connection.rb
54
+ - lib/mongo/cursor.rb
55
+ - lib/mongo/db.rb
56
+ - lib/mongo/exceptions.rb
42
57
  - lib/mongo/gridfs/grid.rb
43
58
  - lib/mongo/gridfs/grid_ext.rb
44
59
  - lib/mongo/gridfs/grid_file_system.rb
45
60
  - lib/mongo/gridfs/grid_io.rb
46
61
  - lib/mongo/gridfs/grid_io_fix.rb
47
- - lib/mongo/version.rb
48
- - lib/mongo/util/pool_manager.rb
62
+ - lib/mongo/networking.rb
63
+ - lib/mongo/repl_set_connection.rb
49
64
  - lib/mongo/util/conversions.rb
50
65
  - lib/mongo/util/core_ext.rb
51
- - lib/mongo/util/ssl_socket.rb
52
- - lib/mongo/util/pool.rb
66
+ - lib/mongo/util/logging.rb
53
67
  - lib/mongo/util/node.rb
54
- - lib/mongo/util/uri_parser.rb
68
+ - lib/mongo/util/pool.rb
69
+ - lib/mongo/util/pool_manager.rb
55
70
  - lib/mongo/util/server_version.rb
71
+ - lib/mongo/util/ssl_socket.rb
56
72
  - lib/mongo/util/support.rb
57
- - lib/mongo/util/logging.rb
58
- - lib/mongo/connection.rb
59
- - lib/mongo/exceptions.rb
60
- - lib/mongo/repl_set_connection.rb
61
- - lib/mongo/db.rb
62
- - lib/mongo/cursor.rb
73
+ - lib/mongo/util/timeout.rb
74
+ - lib/mongo/util/uri_parser.rb
75
+ - lib/mongo/version.rb
63
76
  - docs/CREDITS.md
64
- - docs/WRITE_CONCERN.md
65
- - docs/RELEASES.md
77
+ - docs/FAQ.md
66
78
  - docs/GridFS.md
67
79
  - docs/HISTORY.md
68
- - docs/FAQ.md
69
- - docs/TUTORIAL.md
70
- - docs/REPLICA_SETS.md
71
80
  - docs/READ_PREFERENCE.md
81
+ - docs/RELEASES.md
82
+ - docs/REPLICA_SETS.md
72
83
  - docs/TAILABLE_CURSORS.md
84
+ - docs/TUTORIAL.md
85
+ - docs/WRITE_CONCERN.md
73
86
  - bin/mongo_console
74
- - test/tools/repl_set_manager.rb
75
- - test/tools/auth_repl_set_manager.rb
76
- - test/uri_test.rb
77
- - test/conversions_test.rb
78
- - test/grid_io_test.rb
79
- - test/cursor_fail_test.rb
80
- - test/unit/cursor_test.rb
81
- - test/unit/pool_test.rb
82
- - test/unit/pool_manager_test.rb
83
- - test/unit/collection_test.rb
84
- - test/unit/node_test.rb
85
- - test/unit/db_test.rb
86
- - test/unit/connection_test.rb
87
- - test/unit/read_test.rb
88
- - test/unit/safe_test.rb
89
- - test/unit/grid_test.rb
90
- - test/support_test.rb
91
- - test/cursor_test.rb
92
- - test/support/keys.rb
93
- - test/support/hash_with_indifferent_access.rb
94
- - test/test_helper.rb
95
- - test/threading_test.rb
96
- - test/auxillary/repl_set_auth_test.rb
97
- - test/auxillary/autoreconnect_test.rb
98
- - test/auxillary/threaded_authentication_test.rb
99
- - test/auxillary/authentication_test.rb
100
87
  - test/auxillary/1.4_features.rb
88
+ - test/auxillary/authentication_test.rb
89
+ - test/auxillary/autoreconnect_test.rb
101
90
  - test/auxillary/fork_test.rb
91
+ - test/auxillary/repl_set_auth_test.rb
102
92
  - test/auxillary/slave_connection_test.rb
103
- - test/threading/threading_with_large_pool_test.rb
104
- - test/replica_sets/insert_test.rb
105
- - test/replica_sets/read_preference_test.rb
106
- - test/replica_sets/connect_test.rb
107
- - test/replica_sets/basic_test.rb
108
- - test/replica_sets/count_test.rb
109
- - test/replica_sets/refresh_test.rb
110
- - test/replica_sets/replication_ack_test.rb
111
- - test/replica_sets/query_test.rb
112
- - test/replica_sets/refresh_with_threads_test.rb
113
- - test/replica_sets/rs_test_helper.rb
114
- - test/collection_test.rb
115
- - test/cursor_message_test.rb
93
+ - test/auxillary/threaded_authentication_test.rb
116
94
  - test/bson/binary_test.rb
117
- - test/bson/json_test.rb
95
+ - test/bson/bson_string_test.rb
96
+ - test/bson/bson_test.rb
118
97
  - test/bson/byte_buffer_test.rb
119
- - test/bson/ordered_hash_test.rb
98
+ - test/bson/hash_with_indifferent_access_test.rb
99
+ - test/bson/json_test.rb
120
100
  - test/bson/object_id_test.rb
101
+ - test/bson/ordered_hash_test.rb
121
102
  - test/bson/test_helper.rb
122
- - test/bson/bson_test.rb
123
103
  - test/bson/timestamp_test.rb
124
- - test/bson/hash_with_indifferent_access_test.rb
125
- - test/load/unicorn/load.rb
126
- - test/load/thin/load.rb
127
- - test/db_test.rb
104
+ - test/collection_test.rb
128
105
  - test/connection_test.rb
106
+ - test/conversions_test.rb
107
+ - test/cursor_fail_test.rb
108
+ - test/cursor_message_test.rb
109
+ - test/cursor_test.rb
129
110
  - test/db_api_test.rb
130
- - test/grid_file_system_test.rb
131
- - test/safe_test.rb
132
111
  - test/db_connection_test.rb
112
+ - test/db_test.rb
113
+ - test/grid_file_system_test.rb
114
+ - test/grid_io_test.rb
133
115
  - test/grid_test.rb
116
+ - test/load/thin/load.rb
117
+ - test/load/unicorn/load.rb
118
+ - test/pool_test.rb
119
+ - test/replica_sets/basic_test.rb
120
+ - test/replica_sets/connect_test.rb
121
+ - test/replica_sets/count_test.rb
122
+ - test/replica_sets/insert_test.rb
123
+ - test/replica_sets/query_test.rb
124
+ - test/replica_sets/read_preference_test.rb
125
+ - test/replica_sets/refresh_test.rb
126
+ - test/replica_sets/refresh_with_threads_test.rb
127
+ - test/replica_sets/replication_ack_test.rb
128
+ - test/replica_sets/rs_test_helper.rb
129
+ - test/replica_sets/threading_test.rb
130
+ - test/safe_test.rb
131
+ - test/support/hash_with_indifferent_access.rb
132
+ - test/support/keys.rb
133
+ - test/support_test.rb
134
+ - test/test_helper.rb
135
+ - test/threading/threading_with_large_pool_test.rb
136
+ - test/threading_test.rb
137
+ - test/timeout_test.rb
138
+ - test/tools/auth_repl_set_manager.rb
139
+ - test/tools/repl_set_manager.rb
140
+ - test/unit/collection_test.rb
141
+ - test/unit/connection_test.rb
142
+ - test/unit/cursor_test.rb
143
+ - test/unit/db_test.rb
144
+ - test/unit/grid_test.rb
145
+ - test/unit/node_test.rb
146
+ - test/unit/pool_manager_test.rb
147
+ - test/unit/pool_test.rb
148
+ - test/unit/read_test.rb
149
+ - test/unit/safe_test.rb
150
+ - test/uri_test.rb
134
151
  homepage: http://www.mongodb.org
135
152
  licenses: []
153
+
136
154
  post_install_message:
137
- rdoc_options:
155
+ rdoc_options:
138
156
  - --main
139
157
  - README.md
140
158
  - --inline-source
141
- require_paths:
159
+ require_paths:
142
160
  - lib
143
- required_ruby_version: !ruby/object:Gem::Requirement
161
+ required_ruby_version: !ruby/object:Gem::Requirement
144
162
  none: false
145
- requirements:
146
- - - ! '>='
147
- - !ruby/object:Gem::Version
148
- version: '0'
149
- required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ hash: 3
167
+ segments:
168
+ - 0
169
+ version: "0"
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
171
  none: false
151
- requirements:
152
- - - ! '>='
153
- - !ruby/object:Gem::Version
154
- version: '0'
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ hash: 3
176
+ segments:
177
+ - 0
178
+ version: "0"
155
179
  requirements: []
180
+
156
181
  rubyforge_project:
157
- rubygems_version: 1.8.10
182
+ rubygems_version: 1.8.11
158
183
  signing_key:
159
184
  specification_version: 3
160
185
  summary: Ruby driver for the MongoDB
161
- test_files:
162
- - test/tools/repl_set_manager.rb
163
- - test/tools/auth_repl_set_manager.rb
164
- - test/uri_test.rb
165
- - test/conversions_test.rb
166
- - test/grid_io_test.rb
167
- - test/cursor_fail_test.rb
168
- - test/unit/cursor_test.rb
169
- - test/unit/pool_test.rb
170
- - test/unit/pool_manager_test.rb
171
- - test/unit/collection_test.rb
172
- - test/unit/node_test.rb
173
- - test/unit/db_test.rb
174
- - test/unit/connection_test.rb
175
- - test/unit/read_test.rb
176
- - test/unit/safe_test.rb
177
- - test/unit/grid_test.rb
178
- - test/support_test.rb
179
- - test/cursor_test.rb
180
- - test/support/keys.rb
181
- - test/support/hash_with_indifferent_access.rb
182
- - test/test_helper.rb
183
- - test/threading_test.rb
184
- - test/auxillary/repl_set_auth_test.rb
185
- - test/auxillary/autoreconnect_test.rb
186
- - test/auxillary/threaded_authentication_test.rb
187
- - test/auxillary/authentication_test.rb
186
+ test_files:
188
187
  - test/auxillary/1.4_features.rb
188
+ - test/auxillary/authentication_test.rb
189
+ - test/auxillary/autoreconnect_test.rb
189
190
  - test/auxillary/fork_test.rb
191
+ - test/auxillary/repl_set_auth_test.rb
190
192
  - test/auxillary/slave_connection_test.rb
191
- - test/threading/threading_with_large_pool_test.rb
192
- - test/replica_sets/insert_test.rb
193
- - test/replica_sets/read_preference_test.rb
194
- - test/replica_sets/connect_test.rb
195
- - test/replica_sets/basic_test.rb
196
- - test/replica_sets/count_test.rb
197
- - test/replica_sets/refresh_test.rb
198
- - test/replica_sets/replication_ack_test.rb
199
- - test/replica_sets/query_test.rb
200
- - test/replica_sets/refresh_with_threads_test.rb
201
- - test/replica_sets/rs_test_helper.rb
202
- - test/collection_test.rb
203
- - test/cursor_message_test.rb
193
+ - test/auxillary/threaded_authentication_test.rb
204
194
  - test/bson/binary_test.rb
205
- - test/bson/json_test.rb
195
+ - test/bson/bson_string_test.rb
196
+ - test/bson/bson_test.rb
206
197
  - test/bson/byte_buffer_test.rb
207
- - test/bson/ordered_hash_test.rb
198
+ - test/bson/hash_with_indifferent_access_test.rb
199
+ - test/bson/json_test.rb
208
200
  - test/bson/object_id_test.rb
201
+ - test/bson/ordered_hash_test.rb
209
202
  - test/bson/test_helper.rb
210
- - test/bson/bson_test.rb
211
203
  - test/bson/timestamp_test.rb
212
- - test/bson/hash_with_indifferent_access_test.rb
213
- - test/load/unicorn/load.rb
214
- - test/load/thin/load.rb
215
- - test/db_test.rb
204
+ - test/collection_test.rb
216
205
  - test/connection_test.rb
206
+ - test/conversions_test.rb
207
+ - test/cursor_fail_test.rb
208
+ - test/cursor_message_test.rb
209
+ - test/cursor_test.rb
217
210
  - test/db_api_test.rb
218
- - test/grid_file_system_test.rb
219
- - test/safe_test.rb
220
211
  - test/db_connection_test.rb
212
+ - test/db_test.rb
213
+ - test/grid_file_system_test.rb
214
+ - test/grid_io_test.rb
221
215
  - test/grid_test.rb
216
+ - test/load/thin/load.rb
217
+ - test/load/unicorn/load.rb
218
+ - test/pool_test.rb
219
+ - test/replica_sets/basic_test.rb
220
+ - test/replica_sets/connect_test.rb
221
+ - test/replica_sets/count_test.rb
222
+ - test/replica_sets/insert_test.rb
223
+ - test/replica_sets/query_test.rb
224
+ - test/replica_sets/read_preference_test.rb
225
+ - test/replica_sets/refresh_test.rb
226
+ - test/replica_sets/refresh_with_threads_test.rb
227
+ - test/replica_sets/replication_ack_test.rb
228
+ - test/replica_sets/rs_test_helper.rb
229
+ - test/replica_sets/threading_test.rb
230
+ - test/safe_test.rb
231
+ - test/support/hash_with_indifferent_access.rb
232
+ - test/support/keys.rb
233
+ - test/support_test.rb
234
+ - test/test_helper.rb
235
+ - test/threading/threading_with_large_pool_test.rb
236
+ - test/threading_test.rb
237
+ - test/timeout_test.rb
238
+ - test/tools/auth_repl_set_manager.rb
239
+ - test/tools/repl_set_manager.rb
240
+ - test/unit/collection_test.rb
241
+ - test/unit/connection_test.rb
242
+ - test/unit/cursor_test.rb
243
+ - test/unit/db_test.rb
244
+ - test/unit/grid_test.rb
245
+ - test/unit/node_test.rb
246
+ - test/unit/pool_manager_test.rb
247
+ - test/unit/pool_test.rb
248
+ - test/unit/read_test.rb
249
+ - test/unit/safe_test.rb
250
+ - test/uri_test.rb