Sha256: 794465182c2062e738f90adb08a2a735bc7f05b3e080f02e1e7045fdcb83897b

Contents?: true

Size: 1 KB

Versions: 19

Compression:

Stored size: 1 KB

Contents

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'test_helper'
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
  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
      yield
    rescue Mongo::ConnectionFailure => ex
      puts "Rescue attempt #{retries}: from #{ex}"
      retries += 1
      raise ex if retries > max_retries
      sleep(2)
      retry
    end
  end
  
  def build_seeds(num_hosts)
    seeds = []
    num_hosts.times do |n|
      seeds << "#{@rs.host}:#{@rs.ports[n]}"
    end
    seeds
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
fluent-plugin-mongo-0.7.12 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.11 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.10 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.9 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.8 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.7 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.6 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.5 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.4 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.3 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.2 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.1 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.7.0 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.6.13 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.6.12 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.6.11 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.6.10 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.6.9 test/tools/rs_test_helper.rb
fluent-plugin-mongo-0.6.8 test/tools/rs_test_helper.rb