Sha256: 5485d760b5c91946c1ee012eee32511a896e27295f7e62ea97a0d4081891ca18

Contents?: true

Size: 1.02 KB

Versions: 47

Compression:

Stored size: 1.02 KB

Contents

$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require './test/test_helper'
require './test/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

47 entries across 47 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.7.4 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.7.3 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.7.2 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.7.1 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.7.0 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.6.9 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.6.8 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.6.7 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.6.6 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.6.5 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.6.4 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.6.3 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.6.2 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.6.1 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.6.0 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.5.17 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.5.16 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.5.15 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb
classiccms-0.5.14 vendor/bundle/gems/mongo-1.6.2/test/replica_sets/rs_test_helper.rb