Class: Validator::SiteTester
- Defined in:
- spec/support/site_tester.rb
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
-
.instance ⇒ Object
Returns the value of attribute instance.
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 Tester
#config, #connected, #disconnected, #isolated, #reconnected, sentinel_errors, #stop
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
43 44 45 |
# File 'spec/support/site_tester.rb', line 43 def instance @instance end |
Class Method Details
.connected(options = {}, &block) ⇒ Object
45 46 47 |
# File 'spec/support/site_tester.rb', line 45 def connected(={}, &block) instance.connected(, &block) end |
.disconnected(&block) ⇒ Object
53 54 55 |
# File 'spec/support/site_tester.rb', line 53 def disconnected(&block) instance.disconnected(&block) end |
.isolated(options = {}, &block) ⇒ Object
57 58 59 |
# File 'spec/support/site_tester.rb', line 57 def isolated(={}, &block) instance.isolated(, &block) end |
.reconnected(options = {}, &block) ⇒ Object
49 50 51 |
# File 'spec/support/site_tester.rb', line 49 def reconnected(={}, &block) instance.reconnected(, &block) end |
.stop ⇒ Object
61 62 63 |
# File 'spec/support/site_tester.rb', line 61 def stop instance.stop end |
Instance Method Details
#build_node(options) ⇒ Object
build local supervisor
93 94 95 96 97 98 99 |
# File 'spec/support/site_tester.rb', line 93 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 90 |
# File 'spec/support/site_tester.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 = { 'max_sites' => 1, 'guest' => guest_settings } @supervisor_config['port'] = config['port'] if config['port'] [ '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
102 103 104 105 106 107 108 109 |
# File 'spec/support/site_tester.rb', line 102 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
112 113 114 115 116 117 |
# File 'spec/support/site_tester.rb', line 112 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 |