rsmp 0.1.10 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +47 -49
- data/README.md +7 -1
- data/config/site.yaml +3 -4
- data/config/supervisor.yaml +2 -5
- data/config/tlc.yaml +44 -0
- data/documentation/classes.md +62 -0
- data/lib/rsmp.rb +1 -0
- data/lib/rsmp/archive.rb +11 -5
- data/lib/rsmp/cli.rb +15 -5
- data/lib/rsmp/component.rb +12 -2
- data/lib/rsmp/error.rb +10 -1
- data/lib/rsmp/message.rb +25 -2
- data/lib/rsmp/node.rb +33 -6
- data/lib/rsmp/probe.rb +5 -18
- data/lib/rsmp/proxy.rb +43 -43
- data/lib/rsmp/site.rb +7 -3
- data/lib/rsmp/site_base.rb +6 -4
- data/lib/rsmp/site_proxy.rb +103 -59
- data/lib/rsmp/supervisor.rb +6 -5
- data/lib/rsmp/supervisor_proxy.rb +84 -31
- data/lib/rsmp/tlc.rb +869 -0
- data/lib/rsmp/version.rb +1 -1
- data/lib/rsmp/wait.rb +149 -3
- data/rsmp.gemspec +9 -10
- metadata +28 -34
- data/lib/rsmp/supervisor_base.rb +0 -10
data/lib/rsmp/version.rb
CHANGED
data/lib/rsmp/wait.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# Helper for waiting for an Async condition using a block
|
2
2
|
|
3
3
|
module RSMP
|
4
|
-
|
4
|
+
module Wait
|
5
5
|
|
6
|
-
def
|
7
|
-
|
6
|
+
def wait_for condition, timeout, &block
|
7
|
+
raise RuntimeError.new("Can't wait for state because task is stopped") unless @task.running?
|
8
|
+
@task.with_timeout(timeout) do
|
8
9
|
while task.running? do
|
9
10
|
value = condition.wait
|
10
11
|
result = yield value
|
@@ -13,5 +14,150 @@ module RSMP
|
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
17
|
+
def capture_status_updates_or_responses task, type, options, m_id
|
18
|
+
task.annotate "wait for status update/response"
|
19
|
+
want = convert_status_list options[:status_list]
|
20
|
+
result = {}
|
21
|
+
# wait for a status update
|
22
|
+
item = @archive.capture(task,options.merge({
|
23
|
+
type: [type,'MessageNotAck'],
|
24
|
+
num: 1
|
25
|
+
})) do |item|
|
26
|
+
message = item[:message]
|
27
|
+
if message.is_a?(MessageNotAck) && message.attribute('oMId') == m_id
|
28
|
+
# set result to an exception, but don't raise it.
|
29
|
+
# this will be returned by the task and stored as the task result
|
30
|
+
# when the parent task call wait() on the task, the exception
|
31
|
+
# will be raised in the parent task, and caught by rspec.
|
32
|
+
# rspec will then show the error and record the test as failed
|
33
|
+
m_id_short = RSMP::Message.shorten_m_id m_id, 8
|
34
|
+
result = RSMP::MessageRejected.new "Status request #{m_id_short} was rejected: #{message.attribute('rea')}"
|
35
|
+
next true # done, no more messages wanted
|
36
|
+
end
|
37
|
+
found = []
|
38
|
+
# look through querues
|
39
|
+
want.each_with_index do |query,i|
|
40
|
+
# look through status items in message
|
41
|
+
item[:message].attributes['sS'].each do |input|
|
42
|
+
ok = status_match? query, input
|
43
|
+
if ok
|
44
|
+
result[query] = input
|
45
|
+
found << i # record which queries where matched succesfully
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
# remove queries that where matched
|
50
|
+
found.sort.reverse.each do |i|
|
51
|
+
want.delete_at i
|
52
|
+
end
|
53
|
+
want.empty? # any queries left to match?
|
54
|
+
end
|
55
|
+
result
|
56
|
+
rescue Async::TimeoutError
|
57
|
+
type_str = {'StatusUpdate'=>'update', 'StatusResponse'=>'response'}[type]
|
58
|
+
raise RSMP::TimeoutError.new "Did not received status #{type_str} in reply to #{m_id} within #{options[:timeout]}s"
|
59
|
+
end
|
60
|
+
|
61
|
+
def wait_for_status_updates_or_responses parent_task, type, options={}, &block
|
62
|
+
raise ArgumentError.new("component argument is missing") unless options[:component]
|
63
|
+
raise ArgumentError.new("status_list argument is missing") unless options[:status_list]
|
64
|
+
m_id = RSMP::Message.make_m_id # make message id so we can start waiting for it
|
65
|
+
|
66
|
+
# wait for command responses in an async task
|
67
|
+
task = parent_task.async do |task|
|
68
|
+
capture_status_updates_or_responses task, type, options, m_id
|
69
|
+
end
|
70
|
+
|
71
|
+
# call block, it should send command request using the given m_id
|
72
|
+
yield m_id
|
73
|
+
|
74
|
+
# wait for the response and return it, raise exception if NotAck received, it it timed out
|
75
|
+
task.wait
|
76
|
+
end
|
77
|
+
|
78
|
+
def wait_for_status_updates parent_task, options={}, &block
|
79
|
+
wait_for_status_updates_or_responses parent_task, 'StatusUpdate', options, &block
|
80
|
+
end
|
81
|
+
|
82
|
+
def wait_for_status_responses parent_task, options={}, &block
|
83
|
+
wait_for_status_updates_or_responses parent_task, 'StatusResponse', options, &block
|
84
|
+
end
|
85
|
+
|
86
|
+
def process_command_response message
|
87
|
+
log "Received #{message.type}", message: message, level: :log
|
88
|
+
acknowledge message
|
89
|
+
end
|
90
|
+
|
91
|
+
def command_match? query, item
|
92
|
+
return false if query[:sCI] && query[:sCI] != item['sCI']
|
93
|
+
return false if query[:n] && query[:n] != item['n']
|
94
|
+
if query[:s].is_a? Regexp
|
95
|
+
return false if query[:v] && item['v'] !~ query[:v]
|
96
|
+
else
|
97
|
+
return false if query[:v] && item['v'] != query[:v]
|
98
|
+
end
|
99
|
+
true
|
100
|
+
end
|
101
|
+
|
102
|
+
def capture_command_responses parent_task, type, options, m_id
|
103
|
+
task.annotate "wait for command response"
|
104
|
+
want = options[:command_list].clone
|
105
|
+
result = {}
|
106
|
+
item = @archive.capture(parent_task,options.merge({
|
107
|
+
type: [type,'MessageNotAck'],
|
108
|
+
num: 1
|
109
|
+
})) do |item|
|
110
|
+
message = item[:message]
|
111
|
+
if message.is_a?(MessageNotAck) && message.attribute('oMId') == m_id
|
112
|
+
# and message.attribute('oMId')==m_id
|
113
|
+
# set result to an exception, but don't raise it.
|
114
|
+
# this will be returned by the task and stored as the task result
|
115
|
+
# when the parent task call wait() on the task, the exception
|
116
|
+
# will be raised in the parent task, and caught by rspec.
|
117
|
+
# rspec will then show the error and record the test as failed
|
118
|
+
m_id_short = RSMP::Message.shorten_m_id m_id, 8
|
119
|
+
result = RSMP::MessageRejected.new "Command request #{m_id_short} was rejected: #{message.attribute('rea')}"
|
120
|
+
next true # done, no more messages wanted
|
121
|
+
end
|
122
|
+
|
123
|
+
found = []
|
124
|
+
# look through querues
|
125
|
+
want.each_with_index do |query,i|
|
126
|
+
# look through items in message
|
127
|
+
item[:message].attributes['rvs'].each do |input|
|
128
|
+
ok = command_match? query, input
|
129
|
+
if ok
|
130
|
+
result[query] = input
|
131
|
+
found << i # record which queries where matched succesfully
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
# remove queries that where matched
|
136
|
+
found.sort.reverse.each do |i|
|
137
|
+
want.delete_at i
|
138
|
+
end
|
139
|
+
want.empty? # any queries left to match?
|
140
|
+
end
|
141
|
+
result
|
142
|
+
rescue Async::TimeoutError
|
143
|
+
raise RSMP::TimeoutError.new "Did not receive command response to #{m_id} within #{options[:timeout]}s"
|
144
|
+
end
|
145
|
+
|
146
|
+
def wait_for_command_responses parent_task, options={}, &block
|
147
|
+
raise ArgumentError.new("component argument is missing") unless options[:component]
|
148
|
+
raise ArgumentError.new("command_list argument is missing") unless options[:command_list]
|
149
|
+
m_id = RSMP::Message.make_m_id # make message id so we can start waiting for it
|
150
|
+
|
151
|
+
# wait for command responses in an async task
|
152
|
+
task = parent_task.async do |task|
|
153
|
+
capture_command_responses task, 'CommandResponse', options, m_id
|
154
|
+
end
|
155
|
+
|
156
|
+
# call block, it should send command request using the given m_id
|
157
|
+
yield m_id
|
158
|
+
|
159
|
+
# wait for the response and return it, raise exception if NotAck received, it it timed out
|
160
|
+
task.wait
|
161
|
+
end
|
16
162
|
end
|
17
163
|
end
|
data/rsmp.gemspec
CHANGED
@@ -42,17 +42,16 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.require_paths = ["lib"]
|
43
43
|
|
44
44
|
spec.add_dependency "async", "~> 1.23.0"
|
45
|
-
spec.add_dependency "async-io", "~> 1.27.
|
45
|
+
spec.add_dependency "async-io", "~> 1.27.4"
|
46
46
|
spec.add_dependency "colorize", "~> 0.8.1"
|
47
|
-
spec.add_dependency "thor", "~> 0.
|
48
|
-
spec.add_dependency "json_schemer", "~> 0.2.
|
49
|
-
|
50
|
-
spec.add_development_dependency "bundler", "~> 2.
|
51
|
-
spec.add_development_dependency "rake", "~>
|
52
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
53
|
-
spec.add_development_dependency "rspec-expectations", "~> 3.
|
54
|
-
spec.add_development_dependency "rspec-with_params", "~> 0.2.0"
|
47
|
+
spec.add_dependency "thor", "~> 1.0.1"
|
48
|
+
spec.add_dependency "json_schemer", "~> 0.2.11"
|
49
|
+
|
50
|
+
spec.add_development_dependency "bundler", "~> 2.1.4"
|
51
|
+
spec.add_development_dependency "rake", "~> 13.0.1"
|
52
|
+
spec.add_development_dependency "rspec", "~> 3.9.0"
|
53
|
+
spec.add_development_dependency "rspec-expectations", "~> 3.9.1"
|
55
54
|
spec.add_development_dependency "timecop", "~> 0.9.1"
|
56
55
|
spec.add_development_dependency "cucumber", "~> 3.1.2"
|
57
|
-
spec.add_development_dependency "aruba", "~> 0.
|
56
|
+
spec.add_development_dependency "aruba", "~> 1.0.0"
|
58
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Tin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.27.
|
33
|
+
version: 1.27.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.27.
|
40
|
+
version: 1.27.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: colorize
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,98 +58,84 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 1.0.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 1.0.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: json_schemer
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.2.
|
75
|
+
version: 0.2.11
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.2.
|
82
|
+
version: 0.2.11
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 2.1.4
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 2.1.4
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 13.0.1
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 13.0.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 3.9.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 3.9.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec-expectations
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 3.
|
131
|
+
version: 3.9.1
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 3.
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rspec-with_params
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: 0.2.0
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: 0.2.0
|
138
|
+
version: 3.9.1
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: timecop
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,14 +170,14 @@ dependencies:
|
|
184
170
|
requirements:
|
185
171
|
- - "~>"
|
186
172
|
- !ruby/object:Gem::Version
|
187
|
-
version: 0.
|
173
|
+
version: 1.0.0
|
188
174
|
type: :development
|
189
175
|
prerelease: false
|
190
176
|
version_requirements: !ruby/object:Gem::Requirement
|
191
177
|
requirements:
|
192
178
|
- - "~>"
|
193
179
|
- !ruby/object:Gem::Version
|
194
|
-
version: 0.
|
180
|
+
version: 1.0.0
|
195
181
|
description: Easy RSMP site and supervisor communication.
|
196
182
|
email:
|
197
183
|
- zf0f@kk.dk
|
@@ -213,6 +199,8 @@ files:
|
|
213
199
|
- bin/setup
|
214
200
|
- config/site.yaml
|
215
201
|
- config/supervisor.yaml
|
202
|
+
- config/tlc.yaml
|
203
|
+
- documentation/classes.md
|
216
204
|
- exe/rsmp
|
217
205
|
- lib/rsmp.rb
|
218
206
|
- lib/rsmp/alarm.rb
|
@@ -232,8 +220,8 @@ files:
|
|
232
220
|
- lib/rsmp/site_base.rb
|
233
221
|
- lib/rsmp/site_proxy.rb
|
234
222
|
- lib/rsmp/supervisor.rb
|
235
|
-
- lib/rsmp/supervisor_base.rb
|
236
223
|
- lib/rsmp/supervisor_proxy.rb
|
224
|
+
- lib/rsmp/tlc.rb
|
237
225
|
- lib/rsmp/version.rb
|
238
226
|
- lib/rsmp/wait.rb
|
239
227
|
- lib/rsmp_schema/schema/core/aggregated_status.json
|
@@ -286,7 +274,10 @@ files:
|
|
286
274
|
- lib/rsmp_schema/schema/tlc/commands/M0017.json
|
287
275
|
- lib/rsmp_schema/schema/tlc/commands/M0018.json
|
288
276
|
- lib/rsmp_schema/schema/tlc/commands/M0019.json
|
277
|
+
- lib/rsmp_schema/schema/tlc/commands/M0020.json
|
278
|
+
- lib/rsmp_schema/schema/tlc/commands/M0021.json
|
289
279
|
- lib/rsmp_schema/schema/tlc/commands/M0103.json
|
280
|
+
- lib/rsmp_schema/schema/tlc/commands/M0104.json
|
290
281
|
- lib/rsmp_schema/schema/tlc/commands/command_requests.json
|
291
282
|
- lib/rsmp_schema/schema/tlc/commands/command_responses.json
|
292
283
|
- lib/rsmp_schema/schema/tlc/commands/commands.json
|
@@ -319,10 +310,13 @@ files:
|
|
319
310
|
- lib/rsmp_schema/schema/tlc/statuses/S0027.json
|
320
311
|
- lib/rsmp_schema/schema/tlc/statuses/S0028.json
|
321
312
|
- lib/rsmp_schema/schema/tlc/statuses/S0029.json
|
313
|
+
- lib/rsmp_schema/schema/tlc/statuses/S0030.json
|
314
|
+
- lib/rsmp_schema/schema/tlc/statuses/S0031.json
|
322
315
|
- lib/rsmp_schema/schema/tlc/statuses/S0091.json
|
323
316
|
- lib/rsmp_schema/schema/tlc/statuses/S0092.json
|
324
317
|
- lib/rsmp_schema/schema/tlc/statuses/S0095.json
|
325
318
|
- lib/rsmp_schema/schema/tlc/statuses/S0096.json
|
319
|
+
- lib/rsmp_schema/schema/tlc/statuses/S0097.json
|
326
320
|
- lib/rsmp_schema/schema/tlc/statuses/S0201.json
|
327
321
|
- lib/rsmp_schema/schema/tlc/statuses/S0202.json
|
328
322
|
- lib/rsmp_schema/schema/tlc/statuses/S0203.json
|
@@ -357,7 +351,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
357
351
|
- !ruby/object:Gem::Version
|
358
352
|
version: '0'
|
359
353
|
requirements: []
|
360
|
-
rubygems_version: 3.
|
354
|
+
rubygems_version: 3.1.2
|
361
355
|
signing_key:
|
362
356
|
specification_version: 4
|
363
357
|
summary: RoadSide Message Protocol (RSMP) library.
|