Module: Validator::HandshakeHelper
- Defined in:
- spec/support/handshake_helper.rb
Overview
Helpers for validating the sequence of messages during rsmp connection establishment
Instance Method Summary collapse
- #check_sequence(version) ⇒ Object
-
#check_sequence_3_1_1_to_3_1_3(core_version) ⇒ Object
Validate the connection sequence for core 3.1.1, 3.1.2 and 3.1.3 In these earliser version of core, both the site and and the supervisor sends a Version message simulatenously as soon as the connection is opened, and then acknowledged.
-
#check_sequence_3_1_4_or_later(version) ⇒ Object
Validate the connection sequence for core 3.1.4 and later From 3.1.4, the site must send a Version first, so the sequence is fixed and can be directly verified.
-
#get_connection_message(core_version, length) ⇒ Object
Wait for the site to connect and collect a specified number of messages, which can then be analysed.
Instance Method Details
#check_sequence(version) ⇒ Object
87 88 89 90 91 92 93 94 95 96 |
# File 'spec/support/handshake_helper.rb', line 87 def check_sequence version case version when '3.1.1', '3.1.2', '3.1.3' check_sequence_3_1_1_to_3_1_3 version when '3.1.4', '3.1.5', '3.2', '3.2.1', '3.2.2' check_sequence_3_1_4_or_later version else raise "Unkown rsmp version #{version}" end end |
#check_sequence_3_1_1_to_3_1_3(core_version) ⇒ Object
Validate the connection sequence for core 3.1.1, 3.1.2 and 3.1.3 In these earliser version of core, both the site and and the supervisor sends a Version message simulatenously as soon as the connection is opened, and then acknowledged. We therefore cannot expect a specific sequence of the first four messages, but we can check that the set of messages is correct The same is the case with the next four messages, which is the exchange of Watchdogs
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'spec/support/handshake_helper.rb', line 36 def check_sequence_3_1_1_to_3_1_3 core_version = [ 'in:Version', 'out:MessageAck', 'out:Version', 'in:MessageAck', ] = [ 'in:Watchdog', 'out:MessageAck', 'out:Watchdog', 'in:MessageAck', ] length = .length + .length got = core_version, length = got[0..3] expect( .include?('in:AggregatedStatus') ).to be_falsy, "AggregatedStatus not allowed during version exchange: #{}" expect( .include?('in:Watchdog') ).to be_falsy, "Watchdog not allowed during version exchange: #{}" expect( .include?('in:Alarm') ).to be_falsy, "Alarms not allowed during version exchange: #{}" expect().to match_array(), "Wrong version part, must contain #{}, got #{}" = got[4..7] expect( .include?('in:AggregatedStatus') ).to be_falsy, "AggregatedStatus not allowed during watchdog exchange: #{}" expect( .include?('in:Alarm') ).to be_falsy, "Alarms not allowed during watchdog exchange: #{}" expect().to match_array(), "Wrong watchdog part, must contain #{}, got #{}" end |
#check_sequence_3_1_4_or_later(version) ⇒ Object
Validate the connection sequence for core 3.1.4 and later From 3.1.4, the site must send a Version first, so the sequence is fixed and can be directly verified
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'spec/support/handshake_helper.rb', line 72 def check_sequence_3_1_4_or_later version expected = [ 'in:Version', 'out:MessageAck', 'out:Version', 'in:MessageAck', 'in:Watchdog', 'out:MessageAck', 'out:Watchdog', 'in:MessageAck', ] got = version, expected.length expect(got).to eq(expected) end |
#get_connection_message(core_version, length) ⇒ Object
Wait for the site to connect and collect a specified number of messages, which can then be analysed.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'spec/support/handshake_helper.rb', line 8 def core_version, length timeout = Validator.get_config('timeouts','ready') got = nil Validator::Site.isolated( 'collect' => {timeout: timeout, num: length, ingoing: true, outgoing: true}, 'guest' => { 'rsmp_versions' => [core_version], } ) do |task,supervisor,site| expect(site.ready?).to be true collector = site.collector collector.use_task task collector.wait! got = collector..map { || "#{.direction}:#{.type}" } end got rescue Async::TimeoutError => e raise "Did not collect #{length} messages within #{timeout}s" end |