jmongo 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/Gemfile +8 -0
  2. data/Gemfile.lock +43 -0
  3. data/Rakefile +72 -0
  4. data/jmongo.gemspec +84 -6
  5. data/lib/jmongo.rb +6 -14
  6. data/lib/jmongo/collection.rb +196 -114
  7. data/lib/jmongo/connection.rb +39 -13
  8. data/lib/jmongo/cursor.rb +161 -63
  9. data/lib/jmongo/db.rb +119 -30
  10. data/lib/jmongo/exceptions.rb +39 -0
  11. data/lib/jmongo/mongo-2.6.5.gb1.jar +0 -0
  12. data/lib/jmongo/mongo/bson.rb +130 -0
  13. data/lib/jmongo/mongo/collection.rb +185 -0
  14. data/lib/jmongo/mongo/connection.rb +45 -0
  15. data/lib/jmongo/mongo/db.rb +31 -0
  16. data/lib/jmongo/mongo/jmongo.rb +44 -0
  17. data/lib/jmongo/mongo/mongo.rb +98 -0
  18. data/lib/jmongo/mongo/ruby_ext.rb +38 -0
  19. data/lib/jmongo/mongo/utils.rb +136 -0
  20. data/lib/jmongo/version.rb +1 -1
  21. data/test-results.txt +98 -0
  22. data/test/auxillary/1.4_features.rb +166 -0
  23. data/test/auxillary/authentication_test.rb +68 -0
  24. data/test/auxillary/autoreconnect_test.rb +41 -0
  25. data/test/auxillary/fork_test.rb +30 -0
  26. data/test/auxillary/repl_set_auth_test.rb +58 -0
  27. data/test/auxillary/slave_connection_test.rb +36 -0
  28. data/test/auxillary/threaded_authentication_test.rb +101 -0
  29. data/test/bson/binary_test.rb +15 -0
  30. data/test/bson/bson_test.rb +657 -0
  31. data/test/bson/byte_buffer_test.rb +208 -0
  32. data/test/bson/hash_with_indifferent_access_test.rb +38 -0
  33. data/test/bson/json_test.rb +17 -0
  34. data/test/bson/object_id_test.rb +138 -0
  35. data/test/bson/ordered_hash_test.rb +245 -0
  36. data/test/bson/test_helper.rb +46 -0
  37. data/test/bson/timestamp_test.rb +46 -0
  38. data/test/collection_test.rb +933 -0
  39. data/test/connection_test.rb +325 -0
  40. data/test/conversions_test.rb +121 -0
  41. data/test/cursor_fail_test.rb +75 -0
  42. data/test/cursor_message_test.rb +43 -0
  43. data/test/cursor_test.rb +547 -0
  44. data/test/data/empty_data +0 -0
  45. data/test/data/sample_data +0 -0
  46. data/test/data/sample_file.pdf +0 -0
  47. data/test/data/small_data.txt +1 -0
  48. data/test/db_api_test.rb +739 -0
  49. data/test/db_connection_test.rb +15 -0
  50. data/test/db_test.rb +325 -0
  51. data/test/grid_file_system_test.rb +260 -0
  52. data/test/grid_io_test.rb +210 -0
  53. data/test/grid_test.rb +259 -0
  54. data/test/load/thin/config.ru +6 -0
  55. data/test/load/thin/config.yml.template +6 -0
  56. data/test/load/thin/load.rb +24 -0
  57. data/test/load/unicorn/config.ru +6 -0
  58. data/test/load/unicorn/load.rb +23 -0
  59. data/test/load/unicorn/unicorn.rb.template +29 -0
  60. data/test/replica_sets/connect_test.rb +111 -0
  61. data/test/replica_sets/connection_string_test.rb +29 -0
  62. data/test/replica_sets/count_test.rb +36 -0
  63. data/test/replica_sets/insert_test.rb +54 -0
  64. data/test/replica_sets/pooled_insert_test.rb +58 -0
  65. data/test/replica_sets/query_secondaries.rb +109 -0
  66. data/test/replica_sets/query_test.rb +52 -0
  67. data/test/replica_sets/read_preference_test.rb +43 -0
  68. data/test/replica_sets/refresh_test.rb +123 -0
  69. data/test/replica_sets/replication_ack_test.rb +71 -0
  70. data/test/replica_sets/rs_test_helper.rb +27 -0
  71. data/test/safe_test.rb +68 -0
  72. data/test/support/hash_with_indifferent_access.rb +186 -0
  73. data/test/support/keys.rb +45 -0
  74. data/test/support_test.rb +19 -0
  75. data/test/test_helper.rb +111 -0
  76. data/test/threading/threading_with_large_pool_test.rb +90 -0
  77. data/test/threading_test.rb +88 -0
  78. data/test/tools/auth_repl_set_manager.rb +14 -0
  79. data/test/tools/keyfile.txt +1 -0
  80. data/test/tools/repl_set_manager.rb +377 -0
  81. data/test/unit/collection_test.rb +128 -0
  82. data/test/unit/connection_test.rb +85 -0
  83. data/test/unit/cursor_test.rb +127 -0
  84. data/test/unit/db_test.rb +96 -0
  85. data/test/unit/grid_test.rb +51 -0
  86. data/test/unit/node_test.rb +73 -0
  87. data/test/unit/pool_manager_test.rb +47 -0
  88. data/test/unit/pool_test.rb +9 -0
  89. data/test/unit/read_test.rb +101 -0
  90. data/test/unit/safe_test.rb +125 -0
  91. data/test/uri_test.rb +92 -0
  92. metadata +170 -99
  93. data/lib/jmongo/ajrb.rb +0 -189
  94. data/lib/jmongo/jmongo_jext.rb +0 -302
  95. data/lib/jmongo/mongo-2.6.3.jar +0 -0
  96. data/lib/jmongo/utils.rb +0 -61
@@ -0,0 +1,6 @@
1
+ require "rubygems"
2
+ require "sinatra"
3
+
4
+ require File.join(File.dirname(__FILE__), 'load.rb')
5
+
6
+ run Load
@@ -0,0 +1,6 @@
1
+ require "rubygems"
2
+ require "sinatra"
3
+
4
+ require File.join(File.dirname(__FILE__), 'load.rb')
5
+
6
+ run Load
@@ -0,0 +1,24 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'mongo')
2
+ require 'logger'
3
+
4
+ $con = Mongo::Connection.new
5
+ $db = $con['foo']
6
+
7
+ class Load < Sinatra::Base
8
+
9
+ configure do
10
+ LOGGER = Logger.new("sinatra.log")
11
+ enable :logging, :dump_errors
12
+ set :raise_errors, true
13
+ end
14
+
15
+ get '/' do
16
+ 3.times do |n|
17
+ if (v=$db.eval("1 + #{n}")) != 1 + n
18
+ STDERR << "#{1 + n} expected but got #{v}"
19
+ raise StandardError, "#{1 + n} expected but got #{v}"
20
+ end
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,6 @@
1
+ require "rubygems"
2
+ require "sinatra"
3
+
4
+ require File.join(File.dirname(__FILE__), 'load.rb')
5
+
6
+ run Load
@@ -0,0 +1,23 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'mongo')
2
+
3
+ $con = Mongo::Connection.new
4
+ $db = $con['foo']
5
+
6
+ class Load < Sinatra::Base
7
+
8
+ configure do
9
+ LOGGER = Logger.new("sinatra.log")
10
+ enable :logging, :dump_errors
11
+ set :raise_errors, true
12
+ end
13
+
14
+ get '/' do
15
+ 3.times do |n|
16
+ if (v=$db.eval("1 + #{n}")) != 1 + n
17
+ STDERR << "#{1 + n} expected but got #{v}"
18
+ raise StandardError, "#{1 + n} expected but got #{v}"
19
+ end
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,29 @@
1
+ # set path to app that will be used to configure unicorn,
2
+ # # note the trailing slash in this example
3
+ @dir = "/home/kyle/work/10gen/ruby-driver/test/load/"
4
+
5
+ worker_processes 10
6
+ working_directory @dir
7
+
8
+ preload_app true
9
+
10
+ timeout 30
11
+
12
+ # Specify path to socket unicorn listens to,
13
+ # we will use this in our nginx.conf later
14
+ listen "#{@dir}tmp/sockets/unicorn.sock", :backlog => 64
15
+
16
+ # Set process id path
17
+ pid "#{@dir}tmp/pids/unicorn.pid"
18
+
19
+ # # Set log file paths
20
+ stderr_path "#{@dir}log/unicorn.stderr.log"
21
+ stdout_path "#{@dir}log/unicorn.stdout.log"
22
+
23
+ # NOTE: You need this when using forking web servers!
24
+ after_fork do |server, worker|
25
+ $con.close if $con
26
+ $con = Mongo::Connection.new
27
+ $db = $con['foo']
28
+ STDERR << "FORKED #{server} #{worker}"
29
+ end
@@ -0,0 +1,111 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require './test/replica_sets/rs_test_helper'
3
+
4
+ # NOTE: This test expects a replica set of three nodes to be running on RS.host,
5
+ # on ports TEST_PORT, RS.ports[1], and TEST + 2.
6
+ class ConnectTest < Test::Unit::TestCase
7
+ include Mongo
8
+
9
+ def teardown
10
+ RS.restart_killed_nodes
11
+ @conn.close if defined?(@conn) && @conn
12
+ end
13
+
14
+ def test_connect_with_deprecated_multi
15
+ @conn = Connection.multi([[RS.host, RS.ports[0]], [RS.host, RS.ports[1]]], :name => RS.name)
16
+ assert @conn.is_a?(ReplSetConnection)
17
+ assert @conn.connected?
18
+ end
19
+
20
+ def test_connect_bad_name
21
+ assert_raise_error(ReplicaSetConnectionError, "-wrong") do
22
+ @conn = ReplSetConnection.new([RS.host, RS.ports[0]], [RS.host, RS.ports[1]],
23
+ [RS.host, RS.ports[2]], :name => RS.name + "-wrong")
24
+ end
25
+ end
26
+
27
+ # def test_connect_timeout
28
+ # passed = false
29
+ # timeout = 3
30
+ # begin
31
+ # t0 = Time.now
32
+ # @conn = ReplSetConnection.new(['192.169.169.1', 27017], :connect_timeout => timeout)
33
+ # rescue OperationTimeout
34
+ # passed = true
35
+ # t1 = Time.now
36
+ # end
37
+
38
+ # assert passed
39
+ # assert t1 - t0 < timeout + 1
40
+ # end
41
+
42
+ def test_connect
43
+ @conn = ReplSetConnection.new([RS.host, RS.ports[1]], [RS.host, RS.ports[0]],
44
+ [RS.host, RS.ports[2]], :name => RS.name)
45
+ assert @conn.connected?
46
+
47
+ assert_equal RS.primary, @conn.primary
48
+ assert_equal RS.secondaries.sort, @conn.secondaries.sort
49
+ assert_equal RS.arbiters.sort, @conn.arbiters.sort
50
+
51
+ @conn = ReplSetConnection.new([RS.host, RS.ports[1]], [RS.host, RS.ports[0]],
52
+ :name => RS.name)
53
+ assert @conn.connected?
54
+ end
55
+
56
+ def test_host_port_accessors
57
+ @conn = ReplSetConnection.new([RS.host, RS.ports[0]], [RS.host, RS.ports[1]],
58
+ [RS.host, RS.ports[2]], :name => RS.name)
59
+
60
+ assert_equal @conn.host, RS.primary[0]
61
+ assert_equal @conn.port, RS.primary[1]
62
+ end
63
+
64
+ def test_connect_with_primary_node_killed
65
+ node = RS.kill_primary
66
+
67
+ # Becuase we're killing the primary and trying to connect right away,
68
+ # this is going to fail right away.
69
+ assert_raise_error(ConnectionFailure, "Failed to connect to primary node") do
70
+ @conn = ReplSetConnection.new([RS.host, RS.ports[0]], [RS.host, RS.ports[1]],
71
+ [RS.host, RS.ports[2]])
72
+ end
73
+
74
+ # This allows the secondary to come up as a primary
75
+ rescue_connection_failure do
76
+ @conn = ReplSetConnection.new([RS.host, RS.ports[0]], [RS.host, RS.ports[1]],
77
+ [RS.host, RS.ports[2]])
78
+ end
79
+ end
80
+
81
+ def test_connect_with_secondary_node_killed
82
+ node = RS.kill_secondary
83
+
84
+ rescue_connection_failure do
85
+ @conn = ReplSetConnection.new([RS.host, RS.ports[0]], [RS.host, RS.ports[1]],
86
+ [RS.host, RS.ports[2]])
87
+ end
88
+ assert @conn.connected?
89
+ end
90
+
91
+ def test_connect_with_third_node_killed
92
+ RS.kill(RS.get_node_from_port(RS.ports[2]))
93
+
94
+ rescue_connection_failure do
95
+ @conn = ReplSetConnection.new([RS.host, RS.ports[0]], [RS.host, RS.ports[1]],
96
+ [RS.host, RS.ports[2]])
97
+ end
98
+ assert @conn.connected?
99
+ end
100
+
101
+ def test_connect_with_primary_stepped_down
102
+ RS.step_down_primary
103
+
104
+ rescue_connection_failure do
105
+ @conn = ReplSetConnection.new([RS.host, RS.ports[0]], [RS.host, RS.ports[1]],
106
+ [RS.host, RS.ports[2]])
107
+ end
108
+ assert @conn.connected?
109
+ end
110
+
111
+ end
@@ -0,0 +1,29 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require './test/replica_sets/rs_test_helper'
3
+
4
+ # NOTE: This test expects a replica set of three nodes to be running on RS.host,
5
+ # on ports TEST_PORT, RS.ports[1], and TEST + 2.
6
+ class ConnectionStringTest < Test::Unit::TestCase
7
+ include Mongo
8
+
9
+ def teardown
10
+ RS.restart_killed_nodes
11
+ @conn.close if @conn
12
+ end
13
+
14
+ def test_connect_with_connection_string
15
+ @conn = Connection.from_uri("mongodb://#{RS.host}:#{RS.ports[0]},#{RS.host}:#{RS.ports[1]}?replicaset=#{RS.name}")
16
+ assert @conn.is_a?(ReplSetConnection)
17
+ assert @conn.connected?
18
+ end
19
+
20
+ def test_connect_with_full_connection_string
21
+ @conn = Connection.from_uri("mongodb://#{RS.host}:#{RS.ports[0]},#{RS.host}:#{RS.ports[1]}?replicaset=#{RS.name};safe=true;w=2;fsync=true;slaveok=true")
22
+ assert @conn.is_a?(ReplSetConnection)
23
+ assert @conn.connected?
24
+ assert_equal 2, @conn.safe[:w]
25
+ assert @conn.safe[:fsync]
26
+ assert @conn.read_pool
27
+ end
28
+
29
+ end
@@ -0,0 +1,36 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require './test/replica_sets/rs_test_helper'
3
+
4
+ # NOTE: This test expects a replica set of three nodes to be running
5
+ # on the local host.
6
+ class ReplicaSetCountTest < Test::Unit::TestCase
7
+ include Mongo
8
+
9
+ def setup
10
+ @conn = ReplSetConnection.new([RS.host, RS.ports[0]], [RS.host, RS.ports[1]], [RS.host, RS.ports[2]])
11
+ @db = @conn.db(MONGO_TEST_DB)
12
+ @db.drop_collection("test-sets")
13
+ @coll = @db.collection("test-sets")
14
+ end
15
+
16
+ def teardown
17
+ RS.restart_killed_nodes
18
+ @conn.close if @conn
19
+ end
20
+
21
+ def test_correct_count_after_insertion_reconnect
22
+ @coll.insert({:a => 20}, :safe => {:w => 2, :wtimeout => 10000})
23
+ assert_equal 1, @coll.count
24
+
25
+ # Kill the current master node
26
+ @node = RS.kill_primary
27
+
28
+ rescue_connection_failure do
29
+ @coll.insert({:a => 30}, :safe => true)
30
+ end
31
+
32
+ @coll.insert({:a => 40}, :safe => true)
33
+ assert_equal 3, @coll.count, "Second count failed"
34
+ end
35
+
36
+ end
@@ -0,0 +1,54 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require './test/replica_sets/rs_test_helper'
3
+
4
+ # NOTE: This test expects a replica set of three nodes to be running
5
+ # on the local host.
6
+ class ReplicaSetInsertTest < Test::Unit::TestCase
7
+ include Mongo
8
+
9
+ def setup
10
+ @conn = ReplSetConnection.new([TEST_HOST, RS.ports[0]], [TEST_HOST, RS.ports[1]], [TEST_HOST, RS.ports[2]])
11
+ @db = @conn.db(MONGO_TEST_DB)
12
+ @db.drop_collection("test-sets")
13
+ @coll = @db.collection("test-sets")
14
+ end
15
+
16
+ def teardown
17
+ RS.restart_killed_nodes
18
+ @conn.close if @conn
19
+ end
20
+
21
+ def test_insert
22
+ @coll.save({:a => 20}, :safe => true)
23
+
24
+ RS.kill_primary
25
+
26
+ rescue_connection_failure do
27
+ @coll.save({:a => 30}, :safe => true)
28
+ end
29
+
30
+ @coll.save({:a => 40}, :safe => true)
31
+ @coll.save({:a => 50}, :safe => true)
32
+ @coll.save({:a => 60}, :safe => true)
33
+ @coll.save({:a => 70}, :safe => true)
34
+
35
+ # Restart the old master and wait for sync
36
+ RS.restart_killed_nodes
37
+ sleep(1)
38
+ results = []
39
+
40
+ rescue_connection_failure do
41
+ @coll.find.each {|r| results << r}
42
+ [20, 30, 40, 50, 60, 70].each do |a|
43
+ assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
44
+ end
45
+ end
46
+
47
+ @coll.save({:a => 80}, :safe => true)
48
+ @coll.find.each {|r| results << r}
49
+ [20, 30, 40, 50, 60, 70, 80].each do |a|
50
+ assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a} on second find"
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,58 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require './test/replica_sets/rs_test_helper'
3
+
4
+ # NOTE: This test expects a replica set of three nodes to be running
5
+ # on the local host.
6
+ class ReplicaSetPooledInsertTest < Test::Unit::TestCase
7
+ include Mongo
8
+
9
+ def setup
10
+ @conn = ReplSetConnection.new([RS.host, RS.ports[0]], [RS.host, RS.ports[1]],
11
+ [RS.host, RS.ports[2]], :pool_size => 5, :timeout => 5)
12
+ @db = @conn.db(MONGO_TEST_DB)
13
+ @db.drop_collection("test-sets")
14
+ @coll = @db.collection("test-sets")
15
+ end
16
+
17
+ def teardown
18
+ RS.restart_killed_nodes
19
+ @conn.close if @conn
20
+ end
21
+
22
+ def test_insert
23
+ expected_results = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
24
+ @coll.save({:a => -1}, :safe => true)
25
+
26
+ RS.kill_primary
27
+
28
+ threads = []
29
+ 10.times do |i|
30
+ threads[i] = Thread.new do
31
+ rescue_connection_failure do
32
+ @coll.save({:a => i}, :safe => true)
33
+ end
34
+ end
35
+ end
36
+
37
+ threads.each {|t| t.join}
38
+
39
+ # Restart the old master and wait for sync
40
+ RS.restart_killed_nodes
41
+ sleep(1)
42
+ results = []
43
+
44
+ rescue_connection_failure do
45
+ @coll.find.each {|r| results << r}
46
+ expected_results.each do |a|
47
+ assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
48
+ end
49
+ end
50
+
51
+ @coll.save({:a => 10}, :safe => true)
52
+ @coll.find.each {|r| results << r}
53
+ (expected_results + [10]).each do |a|
54
+ assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a} on second find"
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,109 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require './test/replica_sets/rs_test_helper'
3
+
4
+ # NOTE: This test expects a replica set of three nodes to be running
5
+ # on the local host.
6
+ class ReplicaSetQuerySecondariesTest < Test::Unit::TestCase
7
+ include Mongo
8
+
9
+ def setup
10
+ @conn = ReplSetConnection.new([RS.host, RS.ports[0]], :read => :secondary)
11
+ @db = @conn.db(MONGO_TEST_DB)
12
+ @db.drop_collection("test-sets")
13
+ end
14
+
15
+ def teardown
16
+ RS.restart_killed_nodes
17
+ @conn.close if @conn
18
+ end
19
+
20
+ def test_read_primary
21
+ rescue_connection_failure do
22
+ assert !@conn.read_primary?
23
+ assert !@conn.primary?
24
+ end
25
+ end
26
+
27
+ def test_con
28
+ assert @conn.primary_pool, "No primary pool!"
29
+ assert @conn.read_pool, "No read pool!"
30
+ assert @conn.primary_pool.port != @conn.read_pool.port,
31
+ "Primary port and read port at the same!"
32
+ end
33
+
34
+ def test_query_secondaries
35
+ @coll = @db.collection("test-sets", :safe => {:w => 3, :wtimeout => 20000})
36
+ @coll.save({:a => 20})
37
+ @coll.save({:a => 30})
38
+ @coll.save({:a => 40})
39
+ results = []
40
+ @coll.find.each {|r| results << r["a"]}
41
+ assert results.include?(20)
42
+ assert results.include?(30)
43
+ assert results.include?(40)
44
+
45
+ RS.kill_primary
46
+
47
+ results = []
48
+ rescue_connection_failure do
49
+ @coll.find.each {|r| results << r}
50
+ [20, 30, 40].each do |a|
51
+ assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a}"
52
+ end
53
+ end
54
+ end
55
+
56
+ def test_kill_primary
57
+ @coll = @db.collection("test-sets", :safe => {:w => 3, :wtimeout => 10000})
58
+ @coll.save({:a => 20})
59
+ @coll.save({:a => 30})
60
+ assert_equal 2, @coll.find.to_a.length
61
+
62
+ # Should still be able to read immediately after killing master node
63
+ RS.kill_primary
64
+ assert_equal 2, @coll.find.to_a.length
65
+ rescue_connection_failure do
66
+ @coll.save({:a => 50}, :safe => {:w => 2, :wtimeout => 10000})
67
+ end
68
+ RS.restart_killed_nodes
69
+ @coll.save({:a => 50}, :safe => {:w => 2, :wtimeout => 10000})
70
+ assert_equal 4, @coll.find.to_a.length
71
+ end
72
+
73
+ def test_kill_secondary
74
+ @coll = @db.collection("test-sets", {:safe => {:w => 3, :wtimeout => 20000}})
75
+ @coll.save({:a => 20})
76
+ @coll.save({:a => 30})
77
+ assert_equal 2, @coll.find.to_a.length
78
+
79
+ read_node = RS.get_node_from_port(@conn.read_pool.port)
80
+ RS.kill(read_node)
81
+
82
+ # Should fail immediately on next read
83
+ old_read_pool_port = @conn.read_pool.port
84
+ assert_raise ConnectionFailure do
85
+ @coll.find.to_a.length
86
+ end
87
+
88
+ # Should eventually reconnect and be able to read
89
+ rescue_connection_failure do
90
+ length = @coll.find.to_a.length
91
+ assert_equal 2, length
92
+ end
93
+ new_read_pool_port = @conn.read_pool.port
94
+ assert old_read_pool_port != new_read_pool_port
95
+ end
96
+
97
+ def test_write_lots_of_data
98
+ @coll = @db.collection("test-sets", {:safe => {:w => 2}})
99
+
100
+ 6000.times do |n|
101
+ @coll.save({:a => n})
102
+ end
103
+
104
+ cursor = @coll.find()
105
+ cursor.next
106
+ cursor.close
107
+ end
108
+
109
+ end