Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor fixes to pool reuse tests (refactor, cleanup used connections)

  • Loading branch information...
commit c8ce44df25220a62fa0c30e51a2a7d0aaeb64b71 1 parent 057b799
@cheald cheald authored
Showing with 18 additions and 8 deletions.
  1. +18 −8 test/auxillary/pool_reuse_test.rb
View
26 test/auxillary/pool_reuse_test.rb
@@ -8,14 +8,22 @@ def count_open_file_handles
@conn["admin"].command(:serverStatus => 1)["connections"]["current"]
end
+ def setup
+ ensure_cluster(:rs, :replicas => 2, :arbiters => 1)
+ connect
+ end
+
def teardown
@@cluster.stop if @@cluster
+ @conn.close if @conn
end
- def test_pool_resources_are_reused
- ensure_cluster(:rs)
+ def connect
+ @conn.close if @conn
@conn = MongoReplicaSetClient.new(["%s:%s" % [@rs.primary.host, @rs.primary.port]])
+ end
+ def test_pool_resources_are_reused
handles_before_refresh = count_open_file_handles
10.times do
@conn.hard_refresh!
@@ -24,12 +32,12 @@ def test_pool_resources_are_reused
end
def test_pool_connectability_after_cycling_members
- ensure_cluster(:rs, :replicas => 2, :arbiters => 1)
- conn = MongoReplicaSetClient.new(["%s:%s" % [@rs.primary.host, @rs.primary.port]])
- db = conn['sample-db']
+ db = @conn['sample-db']
assert_equal db.collection_names, []
- @@cluster.primary.stop
+ old_primary = @@cluster.primary
+ @conn["admin"].command step_down_command rescue nil
+ old_primary.stop
rescue_connection_failure do
db.collection_names
@@ -39,10 +47,12 @@ def test_pool_connectability_after_cycling_members
assert_equal db.collection_names, []
# Start up the old primary
- @@cluster.restart
+ old_primary.start
# Stop the new primary
- @@cluster.primary.stop
+ primary = @@cluster.primary
+ @conn["admin"].command step_down_command rescue nil
+ primary.stop
# Wait for primary failover
rescue_connection_failure do
Please sign in to comment.
Something went wrong with that request. Please try again.