Class: Validator::SupervisorTester

Inherits:
Tester
  • Object
show all
Defined in:
spec/support/supervisor_tester.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tester

#config, #connected, #disconnected, #isolated, #reconnected, sentinel_errors, #stop

Class Attribute Details

.instanceObject

Returns the value of attribute instance.



11
12
13
# File 'spec/support/supervisor_tester.rb', line 11

def instance
  @instance
end

Class Method Details

.connected(options = {}, &block) ⇒ Object



13
14
15
# File 'spec/support/supervisor_tester.rb', line 13

def connected(options={}, &block)
  instance.connected(options, &block)
end

.disconnected(&block) ⇒ Object



21
22
23
# File 'spec/support/supervisor_tester.rb', line 21

def disconnected(&block)
  instance.disconnected(&block)
end

.isolated(options = {}, &block) ⇒ Object



25
26
27
# File 'spec/support/supervisor_tester.rb', line 25

def isolated(options={}, &block)
  instance.isolated(options, &block)
end

.reconnected(options = {}, &block) ⇒ Object



17
18
19
# File 'spec/support/supervisor_tester.rb', line 17

def reconnected(options={}, &block)
  instance.reconnected(options, &block)
end

Instance Method Details

#build_node(options) ⇒ Object

build local site



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'spec/support/supervisor_tester.rb', line 31

def build_node options
  klass = case config['type']
  when 'tlc'
    RSMP::TLC::TrafficControllerSite
  else
    RSMP::Site
  end
  @site = klass.new(
    site_settings: config.deep_merge(options),
    logger: Validator.logger,
    collect: options['collect']
  )
end

#wait_for_connectionObject



45
46
47
48
49
50
51
52
53
54
# File 'spec/support/supervisor_tester.rb', line 45

def wait_for_connection
  Validator::Log.log "Waiting for connection to supervisor"
  @proxy = @node.find_supervisor :any
  begin
    # wait for proxy to be connected (or ready)
    @proxy.wait_for_state [:connected,:ready], timeout: config['timeouts']['connect']
  rescue RSMP::TimeoutError
    raise RSMP::ConnectionError.new "Could not connect to supervisor within #{config['timeouts']['connect']}s"
  end
end

#wait_for_handshakeObject



56
57
58
59
60
61
62
63
# File 'spec/support/supervisor_tester.rb', line 56

def wait_for_handshake
  begin
    # wait for handshake to be completed
    @proxy.wait_for_state :ready, timeout: config['timeouts']['ready']
  rescue RSMP::TimeoutError
    raise RSMP::ConnectionError.new "Handshake didn't complete within #{config['timeouts']['ready']}s"
  end
end