fluent-plugin-mongo 0.7.16 → 0.8.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,39 +0,0 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require 'test_helper'
3
- require 'tools/repl_set_manager'
4
-
5
- class Test::Unit::TestCase
6
- # Ensure replica set is available as an instance variable and that
7
- # a new set is spun up for each TestCase class
8
- def self.setup_rs
9
- @@rs = ReplSetManager.new
10
- @@rs.start_set
11
- end
12
-
13
- def self.teardown_rs
14
- @@rs.cleanup_set
15
- end
16
-
17
- # Generic code for rescuing connection failures and retrying operations.
18
- # This could be combined with some timeout functionality.
19
- def rescue_connection_failure(max_retries=30)
20
- retries = 0
21
- begin
22
- yield
23
- rescue Mongo::ConnectionFailure => ex
24
- puts "Rescue attempt #{retries}: from #{ex}"
25
- retries += 1
26
- raise ex if retries > max_retries
27
- sleep(2)
28
- retry
29
- end
30
- end
31
-
32
- def build_seeds(num_hosts)
33
- seeds = []
34
- num_hosts.times do |n|
35
- seeds << "#{@@rs.host}:#{@@rs.ports[n]}"
36
- end
37
- seeds
38
- end
39
- end