Class: Validator::Site
Overview
The block will pass an RSMP::SiteProxy object, which can be used to communicate with the site. For example you can send commands, wait for responses, subscribe to statuses, etc.
Class Attribute Summary collapse
-
.testee ⇒ Object
Returns the value of attribute testee.
Class Method Summary collapse
- .connected(options = {}, &block) ⇒ Object
- .disconnected(&block) ⇒ Object
- .isolated(options = {}, &block) ⇒ Object
- .reconnected(options = {}, &block) ⇒ Object
- .stop ⇒ Object
Instance Method Summary collapse
-
#build_node(options) ⇒ Object
build local supervisor.
- #parse_config ⇒ Object
-
#wait_for_connection ⇒ Object
Wait for an rsmp site to connect to the supervisor.
-
#wait_for_handshake ⇒ Object
Wait for an the rsmp handshake to complete.
Methods inherited from Testee
#config, #connected, #disconnected, #isolated, #reconnected, sentinel_errors, #stop
Class Attribute Details
.testee ⇒ Object
Returns the value of attribute testee.
43 44 45 |
# File 'spec/support/test_site.rb', line 43 def testee @testee end |
Class Method Details
.connected(options = {}, &block) ⇒ Object
45 46 47 |
# File 'spec/support/test_site.rb', line 45 def connected ={}, &block testee.connected , &block end |
.disconnected(&block) ⇒ Object
53 54 55 |
# File 'spec/support/test_site.rb', line 53 def disconnected &block testee.disconnected &block end |
.isolated(options = {}, &block) ⇒ Object
57 58 59 |
# File 'spec/support/test_site.rb', line 57 def isolated ={}, &block testee.isolated , &block end |
.reconnected(options = {}, &block) ⇒ Object
49 50 51 |
# File 'spec/support/test_site.rb', line 49 def reconnected ={}, &block testee.reconnected , &block end |
.stop ⇒ Object
61 62 63 |
# File 'spec/support/test_site.rb', line 61 def stop testee.stop end |
Instance Method Details
#build_node(options) ⇒ Object
build local supervisor
92 93 94 95 96 97 98 |
# File 'spec/support/test_site.rb', line 92 def build_node RSMP::Supervisor.new( supervisor_settings: @supervisor_config.deep_merge(), logger: Validator.logger, collect: ['collect'] ) end |
#parse_config ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'spec/support/test_site.rb', line 66 def parse_config # build rsmp supervisor config by # picking elements from the config want = ['sxl','intervals','timeouts','components','rsmp_versions','core_version','skip_validation'] guest_settings = config.select { |key| want.include? key } @supervisor_config = { 'port' => config['port'], 'max_sites' => 1, 'guest' => guest_settings } [ 'connect', 'ready', 'status_response', 'status_update', 'subscribe', 'command', 'command_response', 'alarm', 'disconnect', ].each do |key| raise "config 'timeouts/#{key}' is missing" unless config['timeouts'][key] end end |
#wait_for_connection ⇒ Object
Wait for an rsmp site to connect to the supervisor
101 102 103 104 105 106 107 108 |
# File 'spec/support/test_site.rb', line 101 def wait_for_connection @proxy = @node.proxies.first return if @proxy Validator::Log.log "Waiting for site to connect" @proxy = @node.wait_for_site(:any, timeout:config['timeouts']['connect']) rescue RSMP::TimeoutError raise RSMP::ConnectionError.new "Site did not connect within #{config['timeouts']['connect']}s" end |
#wait_for_handshake ⇒ Object
Wait for an the rsmp handshake to complete
111 112 113 114 115 116 |
# File 'spec/support/test_site.rb', line 111 def wait_for_handshake return if @proxy.ready? Validator::Log.log "Waiting for handskake to complete" @proxy.wait_for_state :ready, timeout:config['timeouts']['ready'] Validator::Log.log "Ready" end |