mongo 1.5.0.rc0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -7
- data/docs/HISTORY.md +19 -0
- data/lib/mongo/collection.rb +1 -0
- data/lib/mongo/networking.rb +1 -1
- data/lib/mongo/version.rb +1 -1
- data/test/collection_test.rb +12 -4
- data/test/unit/collection_test.rb +10 -0
- metadata +145 -160
- data/lib/mongo/util/timeout.rb +0 -42
- data/test/bson/bson_string_test.rb +0 -30
- data/test/pool_test.rb +0 -21
- data/test/replica_sets/threading_test.rb +0 -111
- data/test/timeout_test.rb +0 -14
data/README.md
CHANGED
@@ -208,14 +208,14 @@ keys. This is the PKFactory that comes with the MongoRecord code (an
|
|
208
208
|
ActiveRecord-like framework for non-Rails apps) and the AR Mongo adapter code
|
209
209
|
(for Rails):
|
210
210
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
211
|
+
class PKFactory
|
212
|
+
def create_pk(row)
|
213
|
+
return row if row[:_id]
|
214
|
+
row.delete(:_id) # in case it exists but the value is nil
|
215
|
+
row['_id'] ||= Mongo::ObjectID.new
|
216
|
+
row
|
217
|
+
end
|
217
218
|
end
|
218
|
-
end
|
219
219
|
|
220
220
|
A database's PK factory object may be set either when a DB object is created
|
221
221
|
or immediately after you obtain it, but only once. The only reason it is
|
data/docs/HISTORY.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# MongoDB Ruby Driver History
|
2
2
|
|
3
|
+
### 1.5.0
|
4
|
+
2011-11-28
|
5
|
+
|
6
|
+
This releases fixes bugs introduced in 1.4.0 and 1.4.1 that
|
7
|
+
were introduced as a result of adding replica set refresh modes.
|
8
|
+
|
9
|
+
* Removed :async refresh mode.
|
10
|
+
* Disabled auto refresh mode by default. If you want the driver
|
11
|
+
to automatically check the state of the replica set, you must
|
12
|
+
use :sync mode. Note that replica set refresh is designed only to
|
13
|
+
account for benign changes to the replica set (adding and removing
|
14
|
+
nodes that don't affect current connections).
|
15
|
+
* Fixed bug with commands being sent to secondary nodes. The next
|
16
|
+
release will allow you to specify where commands can be sent.
|
17
|
+
* Support :j safe mode option.
|
18
|
+
* Fix :max_scan and :show_disk_loc Cursor options.
|
19
|
+
|
20
|
+
You can see the remaining issues at https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=10005&version=10992
|
21
|
+
|
3
22
|
### 1.5.0.rc0
|
4
23
|
2011-11-18
|
5
24
|
|
data/lib/mongo/collection.rb
CHANGED
data/lib/mongo/networking.rb
CHANGED
@@ -225,7 +225,7 @@ module Mongo
|
|
225
225
|
cmd = BSON::OrderedHash.new
|
226
226
|
cmd[:getlasterror] = 1
|
227
227
|
if opts.is_a?(Hash)
|
228
|
-
opts.assert_valid_keys(:w, :wtimeout, :fsync)
|
228
|
+
opts.assert_valid_keys(:w, :wtimeout, :fsync, :j)
|
229
229
|
cmd.merge!(opts)
|
230
230
|
end
|
231
231
|
message.put_binary(BSON::BSON_CODER.serialize(cmd, false).to_s)
|
data/lib/mongo/version.rb
CHANGED
data/test/collection_test.rb
CHANGED
@@ -206,6 +206,14 @@ class TestCollection < Test::Unit::TestCase
|
|
206
206
|
end
|
207
207
|
end
|
208
208
|
|
209
|
+
if @@version >= "2.0.0"
|
210
|
+
def test_safe_mode_with_journal_commit_option
|
211
|
+
@@test.insert({:foo => 1}, :safe => {:j => true})
|
212
|
+
@@test.update({:foo => 1}, {:foo => 2}, :safe => {:j => true})
|
213
|
+
@@test.remove({:foo => 2}, :safe => {:j => true})
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
209
217
|
def test_update
|
210
218
|
id1 = @@test.save("x" => 5)
|
211
219
|
@@test.update({}, {"$inc" => {"x" => 1}})
|
@@ -661,13 +669,13 @@ class TestCollection < Test::Unit::TestCase
|
|
661
669
|
|
662
670
|
@@test.ensure_index([["x", Mongo::DESCENDING]], {})
|
663
671
|
assert_equal 2, @@test.index_information.keys.count
|
664
|
-
assert @@test.index_information.keys.include?
|
672
|
+
assert @@test.index_information.keys.include?("x_-1")
|
665
673
|
|
666
674
|
@@test.ensure_index([["x", Mongo::ASCENDING]])
|
667
|
-
assert @@test.index_information.keys.include?
|
675
|
+
assert @@test.index_information.keys.include?("x_1")
|
668
676
|
|
669
677
|
@@test.ensure_index([["type", 1], ["date", -1]])
|
670
|
-
assert @@test.index_information.keys.include?
|
678
|
+
assert @@test.index_information.keys.include?("type_1_date_-1")
|
671
679
|
|
672
680
|
@@test.drop_index("x_1")
|
673
681
|
assert_equal 3, @@test.index_information.keys.count
|
@@ -676,7 +684,7 @@ class TestCollection < Test::Unit::TestCase
|
|
676
684
|
|
677
685
|
@@test.ensure_index([["x", Mongo::DESCENDING]], {})
|
678
686
|
assert_equal 3, @@test.index_information.keys.count
|
679
|
-
assert @@test.index_information.keys.include?
|
687
|
+
assert @@test.index_information.keys.include?("x_-1")
|
680
688
|
|
681
689
|
# Make sure that drop_index expires cache properly
|
682
690
|
@@test.ensure_index([['a', 1]])
|
@@ -125,5 +125,15 @@ class CollectionTest < Test::Unit::TestCase
|
|
125
125
|
|
126
126
|
@coll.ensure_index [["x", Mongo::DESCENDING], ["y", Mongo::DESCENDING]]
|
127
127
|
end
|
128
|
+
|
129
|
+
should "use the connection's logger" do
|
130
|
+
@conn = Connection.new('localhost', 27017, :logger => @logger, :connect => false)
|
131
|
+
@db = @conn['testing']
|
132
|
+
@coll = @db.collection('books')
|
133
|
+
@logger.expects(:warn).with do |msg|
|
134
|
+
msg == "MONGODB [WARNING] test warning"
|
135
|
+
end
|
136
|
+
@coll.log(:warn, "test warning")
|
137
|
+
end
|
128
138
|
end
|
129
139
|
end
|
metadata
CHANGED
@@ -1,236 +1,221 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.5.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Jim Menard
|
9
9
|
- Mike Dirolf
|
10
10
|
- Kyle Banker
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
dependencies:
|
18
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
date: 2011-11-28 00:00:00.000000000Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
19
17
|
name: bson
|
20
|
-
|
21
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirement: &10966820 !ruby/object:Gem::Requirement
|
22
19
|
none: false
|
23
|
-
requirements:
|
24
|
-
- -
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.5.0
|
20
|
+
requirements:
|
21
|
+
- - =
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.5.0
|
27
24
|
type: :runtime
|
28
|
-
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *10966820
|
29
27
|
description: A Ruby driver for MongoDB. For more information about Mongo, see http://www.mongodb.org.
|
30
28
|
email: mongodb-dev@googlegroups.com
|
31
|
-
executables:
|
29
|
+
executables:
|
32
30
|
- mongo_console
|
33
31
|
extensions: []
|
34
|
-
|
35
|
-
extra_rdoc_files:
|
32
|
+
extra_rdoc_files:
|
36
33
|
- README.md
|
37
|
-
files:
|
34
|
+
files:
|
38
35
|
- README.md
|
39
36
|
- Rakefile
|
40
37
|
- mongo.gemspec
|
41
38
|
- LICENSE.txt
|
42
39
|
- lib/mongo.rb
|
43
40
|
- lib/mongo/collection.rb
|
44
|
-
- lib/mongo/
|
45
|
-
- lib/mongo/cursor.rb
|
46
|
-
- lib/mongo/db.rb
|
47
|
-
- lib/mongo/exceptions.rb
|
41
|
+
- lib/mongo/networking.rb
|
48
42
|
- lib/mongo/gridfs/grid.rb
|
49
43
|
- lib/mongo/gridfs/grid_ext.rb
|
50
44
|
- lib/mongo/gridfs/grid_file_system.rb
|
51
45
|
- lib/mongo/gridfs/grid_io.rb
|
52
46
|
- lib/mongo/gridfs/grid_io_fix.rb
|
53
|
-
- lib/mongo/
|
54
|
-
- lib/mongo/
|
47
|
+
- lib/mongo/version.rb
|
48
|
+
- lib/mongo/util/pool_manager.rb
|
55
49
|
- lib/mongo/util/conversions.rb
|
56
50
|
- lib/mongo/util/core_ext.rb
|
57
|
-
- lib/mongo/util/
|
58
|
-
- lib/mongo/util/node.rb
|
51
|
+
- lib/mongo/util/ssl_socket.rb
|
59
52
|
- lib/mongo/util/pool.rb
|
60
|
-
- lib/mongo/util/
|
53
|
+
- lib/mongo/util/node.rb
|
54
|
+
- lib/mongo/util/uri_parser.rb
|
61
55
|
- lib/mongo/util/server_version.rb
|
62
|
-
- lib/mongo/util/ssl_socket.rb
|
63
56
|
- lib/mongo/util/support.rb
|
64
|
-
- lib/mongo/util/
|
65
|
-
- lib/mongo/
|
66
|
-
- lib/mongo/
|
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
|
67
63
|
- docs/CREDITS.md
|
68
|
-
- docs/
|
64
|
+
- docs/WRITE_CONCERN.md
|
65
|
+
- docs/RELEASES.md
|
69
66
|
- docs/GridFS.md
|
70
67
|
- docs/HISTORY.md
|
71
|
-
- docs/
|
72
|
-
- docs/
|
68
|
+
- docs/FAQ.md
|
69
|
+
- docs/TUTORIAL.md
|
73
70
|
- docs/REPLICA_SETS.md
|
71
|
+
- docs/READ_PREFERENCE.md
|
74
72
|
- docs/TAILABLE_CURSORS.md
|
75
|
-
- docs/TUTORIAL.md
|
76
|
-
- docs/WRITE_CONCERN.md
|
77
73
|
- bin/mongo_console
|
78
|
-
- test/
|
79
|
-
- test/
|
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
|
80
97
|
- test/auxillary/autoreconnect_test.rb
|
98
|
+
- test/auxillary/threaded_authentication_test.rb
|
99
|
+
- test/auxillary/authentication_test.rb
|
100
|
+
- test/auxillary/1.4_features.rb
|
81
101
|
- test/auxillary/fork_test.rb
|
82
|
-
- test/auxillary/repl_set_auth_test.rb
|
83
102
|
- test/auxillary/slave_connection_test.rb
|
84
|
-
- test/
|
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
|
85
116
|
- test/bson/binary_test.rb
|
86
|
-
- test/bson/bson_string_test.rb
|
87
|
-
- test/bson/bson_test.rb
|
88
|
-
- test/bson/byte_buffer_test.rb
|
89
|
-
- test/bson/hash_with_indifferent_access_test.rb
|
90
117
|
- test/bson/json_test.rb
|
91
|
-
- test/bson/
|
118
|
+
- test/bson/byte_buffer_test.rb
|
92
119
|
- test/bson/ordered_hash_test.rb
|
120
|
+
- test/bson/object_id_test.rb
|
93
121
|
- test/bson/test_helper.rb
|
122
|
+
- test/bson/bson_test.rb
|
94
123
|
- test/bson/timestamp_test.rb
|
95
|
-
- test/
|
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
|
96
128
|
- test/connection_test.rb
|
97
|
-
- test/conversions_test.rb
|
98
|
-
- test/cursor_fail_test.rb
|
99
|
-
- test/cursor_message_test.rb
|
100
|
-
- test/cursor_test.rb
|
101
129
|
- test/db_api_test.rb
|
102
|
-
- test/db_connection_test.rb
|
103
|
-
- test/db_test.rb
|
104
130
|
- test/grid_file_system_test.rb
|
105
|
-
- test/grid_io_test.rb
|
106
|
-
- test/grid_test.rb
|
107
|
-
- test/load/thin/load.rb
|
108
|
-
- test/load/unicorn/load.rb
|
109
|
-
- test/pool_test.rb
|
110
|
-
- test/replica_sets/basic_test.rb
|
111
|
-
- test/replica_sets/connect_test.rb
|
112
|
-
- test/replica_sets/count_test.rb
|
113
|
-
- test/replica_sets/insert_test.rb
|
114
|
-
- test/replica_sets/query_test.rb
|
115
|
-
- test/replica_sets/read_preference_test.rb
|
116
|
-
- test/replica_sets/refresh_test.rb
|
117
|
-
- test/replica_sets/refresh_with_threads_test.rb
|
118
|
-
- test/replica_sets/replication_ack_test.rb
|
119
|
-
- test/replica_sets/rs_test_helper.rb
|
120
|
-
- test/replica_sets/threading_test.rb
|
121
131
|
- test/safe_test.rb
|
122
|
-
- test/
|
123
|
-
- test/
|
124
|
-
- test/support_test.rb
|
125
|
-
- test/test_helper.rb
|
126
|
-
- test/threading/threading_with_large_pool_test.rb
|
127
|
-
- test/threading_test.rb
|
128
|
-
- test/timeout_test.rb
|
129
|
-
- test/tools/auth_repl_set_manager.rb
|
130
|
-
- test/tools/repl_set_manager.rb
|
131
|
-
- test/unit/collection_test.rb
|
132
|
-
- test/unit/connection_test.rb
|
133
|
-
- test/unit/cursor_test.rb
|
134
|
-
- test/unit/db_test.rb
|
135
|
-
- test/unit/grid_test.rb
|
136
|
-
- test/unit/node_test.rb
|
137
|
-
- test/unit/pool_manager_test.rb
|
138
|
-
- test/unit/pool_test.rb
|
139
|
-
- test/unit/read_test.rb
|
140
|
-
- test/unit/safe_test.rb
|
141
|
-
- test/uri_test.rb
|
142
|
-
has_rdoc: true
|
132
|
+
- test/db_connection_test.rb
|
133
|
+
- test/grid_test.rb
|
143
134
|
homepage: http://www.mongodb.org
|
144
135
|
licenses: []
|
145
|
-
|
146
136
|
post_install_message:
|
147
|
-
rdoc_options:
|
137
|
+
rdoc_options:
|
148
138
|
- --main
|
149
139
|
- README.md
|
150
140
|
- --inline-source
|
151
|
-
require_paths:
|
141
|
+
require_paths:
|
152
142
|
- lib
|
153
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
144
|
none: false
|
155
|
-
requirements:
|
156
|
-
- -
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version:
|
159
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
150
|
none: false
|
161
|
-
requirements:
|
162
|
-
- -
|
163
|
-
- !ruby/object:Gem::Version
|
164
|
-
version:
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
165
155
|
requirements: []
|
166
|
-
|
167
156
|
rubyforge_project:
|
168
|
-
rubygems_version: 1.
|
157
|
+
rubygems_version: 1.8.10
|
169
158
|
signing_key:
|
170
159
|
specification_version: 3
|
171
160
|
summary: Ruby driver for the MongoDB
|
172
|
-
test_files:
|
173
|
-
- test/
|
174
|
-
- test/
|
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
|
175
185
|
- test/auxillary/autoreconnect_test.rb
|
186
|
+
- test/auxillary/threaded_authentication_test.rb
|
187
|
+
- test/auxillary/authentication_test.rb
|
188
|
+
- test/auxillary/1.4_features.rb
|
176
189
|
- test/auxillary/fork_test.rb
|
177
|
-
- test/auxillary/repl_set_auth_test.rb
|
178
190
|
- test/auxillary/slave_connection_test.rb
|
179
|
-
- test/
|
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
|
180
204
|
- test/bson/binary_test.rb
|
181
|
-
- test/bson/bson_string_test.rb
|
182
|
-
- test/bson/bson_test.rb
|
183
|
-
- test/bson/byte_buffer_test.rb
|
184
|
-
- test/bson/hash_with_indifferent_access_test.rb
|
185
205
|
- test/bson/json_test.rb
|
186
|
-
- test/bson/
|
206
|
+
- test/bson/byte_buffer_test.rb
|
187
207
|
- test/bson/ordered_hash_test.rb
|
208
|
+
- test/bson/object_id_test.rb
|
188
209
|
- test/bson/test_helper.rb
|
210
|
+
- test/bson/bson_test.rb
|
189
211
|
- test/bson/timestamp_test.rb
|
190
|
-
- test/
|
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
|
191
216
|
- test/connection_test.rb
|
192
|
-
- test/conversions_test.rb
|
193
|
-
- test/cursor_fail_test.rb
|
194
|
-
- test/cursor_message_test.rb
|
195
|
-
- test/cursor_test.rb
|
196
217
|
- test/db_api_test.rb
|
197
|
-
- test/db_connection_test.rb
|
198
|
-
- test/db_test.rb
|
199
218
|
- test/grid_file_system_test.rb
|
200
|
-
- test/grid_io_test.rb
|
201
|
-
- test/grid_test.rb
|
202
|
-
- test/load/thin/load.rb
|
203
|
-
- test/load/unicorn/load.rb
|
204
|
-
- test/pool_test.rb
|
205
|
-
- test/replica_sets/basic_test.rb
|
206
|
-
- test/replica_sets/connect_test.rb
|
207
|
-
- test/replica_sets/count_test.rb
|
208
|
-
- test/replica_sets/insert_test.rb
|
209
|
-
- test/replica_sets/query_test.rb
|
210
|
-
- test/replica_sets/read_preference_test.rb
|
211
|
-
- test/replica_sets/refresh_test.rb
|
212
|
-
- test/replica_sets/refresh_with_threads_test.rb
|
213
|
-
- test/replica_sets/replication_ack_test.rb
|
214
|
-
- test/replica_sets/rs_test_helper.rb
|
215
|
-
- test/replica_sets/threading_test.rb
|
216
219
|
- test/safe_test.rb
|
217
|
-
- test/
|
218
|
-
- test/
|
219
|
-
- test/support_test.rb
|
220
|
-
- test/test_helper.rb
|
221
|
-
- test/threading/threading_with_large_pool_test.rb
|
222
|
-
- test/threading_test.rb
|
223
|
-
- test/timeout_test.rb
|
224
|
-
- test/tools/auth_repl_set_manager.rb
|
225
|
-
- test/tools/repl_set_manager.rb
|
226
|
-
- test/unit/collection_test.rb
|
227
|
-
- test/unit/connection_test.rb
|
228
|
-
- test/unit/cursor_test.rb
|
229
|
-
- test/unit/db_test.rb
|
230
|
-
- test/unit/grid_test.rb
|
231
|
-
- test/unit/node_test.rb
|
232
|
-
- test/unit/pool_manager_test.rb
|
233
|
-
- test/unit/pool_test.rb
|
234
|
-
- test/unit/read_test.rb
|
235
|
-
- test/unit/safe_test.rb
|
236
|
-
- test/uri_test.rb
|
220
|
+
- test/db_connection_test.rb
|
221
|
+
- test/grid_test.rb
|
data/lib/mongo/util/timeout.rb
DELETED
@@ -1,42 +0,0 @@
|
|
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,30 +0,0 @@
|
|
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
|
data/test/pool_test.rb
DELETED
@@ -1,21 +0,0 @@
|
|
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
|
@@ -1,111 +0,0 @@
|
|
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
|
data/test/timeout_test.rb
DELETED
@@ -1,14 +0,0 @@
|
|
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
|