Skip to content

Commit

Permalink
minor: insert test should use w = 2
Browse files Browse the repository at this point in the history
  • Loading branch information
banker committed Feb 15, 2012
1 parent b299986 commit 02d39a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions test/replica_sets/insert_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ def teardown
end

def test_insert
@coll.save({:a => 20}, :safe => true)
@coll.save({:a => 20}, :safe => {:w => 2})

@rs.kill_primary

rescue_connection_failure do
@coll.save({:a => 30}, :safe => true)
@coll.save({:a => 30}, :safe => {:w => 2})
end

@coll.save({:a => 40}, :safe => true)
@coll.save({:a => 50}, :safe => true)
@coll.save({:a => 60}, :safe => true)
@coll.save({:a => 70}, :safe => true)
@coll.save({:a => 40}, :safe => {:w => 2})
@coll.save({:a => 50}, :safe => {:w => 2})
@coll.save({:a => 60}, :safe => {:w => 2})
@coll.save({:a => 70}, :safe => {:w => 2})

# Restart the old master and wait for sync
@rs.restart_killed_nodes
sleep(1)
sleep(5)
results = []

rescue_connection_failure do
Expand All @@ -43,7 +43,7 @@ def test_insert
end
end

@coll.save({:a => 80}, :safe => true)
@coll.save({:a => 80}, :safe => {:w => 2})
@coll.find.each {|r| results << r}
[20, 30, 40, 50, 60, 70, 80].each do |a|
assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a} on second find"
Expand Down
6 changes: 3 additions & 3 deletions test/replica_sets/pooled_insert_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ def teardown

def test_insert
expected_results = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
@coll.save({:a => -1}, :safe => true)
@coll.save({:a => -1}, :safe => {:w => 2})

@rs.kill_primary

threads = []
10.times do |i|
threads[i] = Thread.new do
rescue_connection_failure do
@coll.save({:a => i}, :safe => true)
@coll.save({:a => i}, :safe => {:w => 2})
end
end
end
Expand All @@ -48,7 +48,7 @@ def test_insert
end
end

@coll.save({:a => 10}, :safe => true)
@coll.save({:a => 10}, :safe => {:w => 2})
@coll.find.each {|r| results << r}
(expected_results + [10]).each do |a|
assert results.any? {|r| r['a'] == a}, "Could not find record for a => #{a} on second find"
Expand Down

0 comments on commit 02d39a7

Please sign in to comment.