Class: Validator::Supervisor

Inherits:
Testee
  • Object
show all
Defined in:
spec/support/test_supervisor.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Testee

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

Class Attribute Details

.testeeObject

Returns the value of attribute testee.



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

def testee
  @testee
end

Class Method Details

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



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

def connected options={}, &block
  testee.connected options, &block
end

.disconnected(&block) ⇒ Object



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

def disconnected &block
  testee.disconnected &block
end

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



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

def isolated options={}, &block
  testee.isolated options, &block
end

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



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

def reconnected options={}, &block
  testee.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/test_supervisor.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/test_supervisor.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/test_supervisor.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