test/tools/rs_test_helper.rb in fluent-plugin-mongo-0.7.12 vs test/tools/rs_test_helper.rb in fluent-plugin-mongo-0.7.13
- old
+ new
@@ -3,19 +3,19 @@
require 'tools/repl_set_manager'
class Test::Unit::TestCase
# Ensure replica set is available as an instance variable and that
# a new set is spun up for each TestCase class
- def ensure_rs
- unless defined?(@@current_class) and @@current_class == self.class
- @@current_class = self.class
- @@rs = ReplSetManager.new
- @@rs.start_set
- end
- @rs = @@rs
+ def self.setup_rs
+ @@rs = ReplSetManager.new
+ @@rs.start_set
end
+ def self.teardown_rs
+ @@rs.cleanup_set
+ end
+
# Generic code for rescuing connection failures and retrying operations.
# This could be combined with some timeout functionality.
def rescue_connection_failure(max_retries=30)
retries = 0
begin
@@ -30,10 +30,10 @@
end
def build_seeds(num_hosts)
seeds = []
num_hosts.times do |n|
- seeds << "#{@rs.host}:#{@rs.ports[n]}"
+ seeds << "#{@@rs.host}:#{@@rs.ports[n]}"
end
seeds
end
end