saal 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/saal_denkovi_relays +34 -0
- data/lib/denkovi.rb +101 -0
- data/lib/saal.rb +2 -1
- data/lib/sensors.rb +9 -0
- data/saal.gemspec +7 -2
- data/test/denkovi.json.erb +39 -0
- data/test/denkovi_test.rb +212 -0
- data/test/test_denkovi_sensors.yml +39 -0
- data/test/test_helper.rb +1 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90aa53b1093427163af28bee630532e79ccefea47de44463641c3e387f038640
|
4
|
+
data.tar.gz: 41fca314cb32d91ca10bfb1982cf7e60a6b584c3c521b8ddcd148b18f465fd86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff26de3ff3cca4750a365b9672a82165d449f7c11fb3bd57d7f3f27758636a521d766ae99dc84b50cd30e940453eb30826ad485e44f9e50d723bb5625cd07915
|
7
|
+
data.tar.gz: f93e18eacc3a2eb6555c95b9ea91f74506a39af91c6083ab6dbb3acc1ef2d83387db9ed59a573afcb7bbd1354cfdf7af51ec11122d9f48f287baf273c235debf
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.dirname(__FILE__)+'/../lib/saal.rb'
|
4
|
+
|
5
|
+
def usage
|
6
|
+
$stderr.puts "USAGE: saal_denkovi_relays <host>"
|
7
|
+
$stderr.puts "USAGE: saal_denkovi_relays <host> <num> <ON/OFF>"
|
8
|
+
end
|
9
|
+
|
10
|
+
if ARGV.size != 1 && ARGV.size != 3
|
11
|
+
usage()
|
12
|
+
exit(1)
|
13
|
+
end
|
14
|
+
|
15
|
+
denkovi = SAAL::Denkovi::OutletGroup::new(
|
16
|
+
:host => ARGV[0],
|
17
|
+
)
|
18
|
+
|
19
|
+
if ARGV.size == 3
|
20
|
+
num = ARGV[1].to_i
|
21
|
+
newstate = ARGV[2]
|
22
|
+
if !["ON","OFF"].include? newstate
|
23
|
+
$stderr.puts "ERROR: Unknown state '#{newstate}'"
|
24
|
+
usage()
|
25
|
+
exit(1)
|
26
|
+
end
|
27
|
+
puts "Setting Relay #{num} to #{newstate}"
|
28
|
+
denkovi.set_state(num, newstate)
|
29
|
+
end
|
30
|
+
|
31
|
+
(1..16).each do |num|
|
32
|
+
puts "Relay #{num} is #{denkovi.state(num)}"
|
33
|
+
end
|
34
|
+
|
data/lib/denkovi.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module SAAL
|
5
|
+
module Denkovi
|
6
|
+
class Outlet < SensorUnderlying
|
7
|
+
writeable!
|
8
|
+
|
9
|
+
def initialize(num, outletgroup)
|
10
|
+
@num = num
|
11
|
+
@og = outletgroup
|
12
|
+
end
|
13
|
+
|
14
|
+
def sensor_type
|
15
|
+
:onoff
|
16
|
+
end
|
17
|
+
|
18
|
+
def read(uncached = false)
|
19
|
+
{'ON' => 1.0, 'OFF' => 0.0}[@og.state(@num)]
|
20
|
+
end
|
21
|
+
|
22
|
+
def write(value)
|
23
|
+
newstate = {1.0 => 'ON', 0.0 => 'OFF'}[value]
|
24
|
+
if newstate
|
25
|
+
@og.set_state(@num,newstate)
|
26
|
+
value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class OutletGroup
|
32
|
+
DEFAULT_TIMEOUT = 2
|
33
|
+
DEFAULT_CACHE_TIMEOUT = 60
|
34
|
+
DEFAULT_OUTLETS = {}
|
35
|
+
DEFAULT_DESCRIPTIONS = {}
|
36
|
+
|
37
|
+
attr_accessor :host, :port, :pass, :timeout, :cache_timeout
|
38
|
+
|
39
|
+
def initialize(opts={})
|
40
|
+
@host = opts[:host] || opts['host'] || 'localhost'
|
41
|
+
@port = opts[:port] || opts['port'] || 80
|
42
|
+
@pass = opts[:pass] || opts['pass'] || 'admin'
|
43
|
+
@timeout = opts[:timeout] || opts['timeout'] || DEFAULT_TIMEOUT
|
44
|
+
@cache_timeout = opts[:cache_timeout] || opts['cache_timeout'] || DEFAULT_CACHE_TIMEOUT
|
45
|
+
@outlets = opts[:outlets] || opts["outlets"] || DEFAULT_OUTLETS
|
46
|
+
@descriptions = opts[:descriptions] || opts["descriptions"] || DEFAULT_DESCRIPTIONS
|
47
|
+
@cache = nil
|
48
|
+
@cachehit = nil
|
49
|
+
@cachetime = nil
|
50
|
+
end
|
51
|
+
|
52
|
+
def state(num)
|
53
|
+
if !@cachetime or @cachetime < Time.now - @cache_timeout
|
54
|
+
@cache = do_get("/current_state.json?pw=#{@pass}")
|
55
|
+
@cachetime = Time.now
|
56
|
+
end
|
57
|
+
return nil if !@cache
|
58
|
+
json = JSON.parse(@cache.body)
|
59
|
+
num = num - 1
|
60
|
+
if json &&
|
61
|
+
json["CurrentState"] &&
|
62
|
+
json["CurrentState"]["Output"] &&
|
63
|
+
json["CurrentState"]["Output"][num] &&
|
64
|
+
json["CurrentState"]["Output"][num]["Value"]
|
65
|
+
val = json["CurrentState"]["Output"][num]["Value"]
|
66
|
+
{"1" => "ON", "0" => "OFF"}[val]
|
67
|
+
else
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def set_state(num, state)
|
73
|
+
@cachetime = nil
|
74
|
+
val = {"ON" => "1", "OFF" => "0"}[state]
|
75
|
+
if val
|
76
|
+
response = do_get("/current_state.json?pw=#{@pass}&Relay#{num}=#{val}")
|
77
|
+
response != nil
|
78
|
+
else
|
79
|
+
false
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_sensors
|
84
|
+
sensors = {}
|
85
|
+
(1..16).each do |num|
|
86
|
+
name = @outlets[num]
|
87
|
+
if name
|
88
|
+
description = @descriptions[num] || ""
|
89
|
+
sensors[name] = [Outlet.new(num, self), description]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
sensors
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
def do_get(path)
|
97
|
+
SAAL::do_http_get(@host, @port, path, nil, nil, @timeout)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/lib/saal.rb
CHANGED
@@ -10,7 +10,7 @@ module SAAL
|
|
10
10
|
DBCONF = CONFDIR+"database.yml"
|
11
11
|
CHARTSCONF = CONFDIR+"charts.yml"
|
12
12
|
|
13
|
-
VERSION = '0.3.
|
13
|
+
VERSION = '0.3.3'
|
14
14
|
end
|
15
15
|
|
16
16
|
require File.dirname(__FILE__)+'/dbstore.rb'
|
@@ -25,4 +25,5 @@ require File.dirname(__FILE__)+'/outliercache.rb'
|
|
25
25
|
require File.dirname(__FILE__)+'/dinrelay.rb'
|
26
26
|
require File.dirname(__FILE__)+'/envoy.rb'
|
27
27
|
require File.dirname(__FILE__)+'/http.rb'
|
28
|
+
require File.dirname(__FILE__)+'/denkovi.rb'
|
28
29
|
|
data/lib/sensors.rb
CHANGED
@@ -61,6 +61,15 @@ module SAAL
|
|
61
61
|
return sensors.map do |name, underlying|
|
62
62
|
Sensor.new(dbstore, name, underlying, defs, opts)
|
63
63
|
end
|
64
|
+
elsif defs['denkovi']
|
65
|
+
defs = defs['denkovi'].merge('prefix' => name)
|
66
|
+
denkovi = SAAL::Denkovi::OutletGroup::new(defs)
|
67
|
+
sensors = denkovi.create_sensors
|
68
|
+
return sensors.map do |name, vals|
|
69
|
+
underlying, description = vals
|
70
|
+
defs.merge!('name' => description)
|
71
|
+
Sensor.new(dbstore, name, underlying, defs, opts)
|
72
|
+
end
|
64
73
|
else
|
65
74
|
$stderror.puts "WARNING: Couldn't figure out a valid sensor type for #{name}"
|
66
75
|
end
|
data/saal.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
7
|
|
8
8
|
s.name = 'saal'
|
9
|
-
s.version = '0.3.
|
10
|
-
s.date = '2020-12-
|
9
|
+
s.version = '0.3.3'
|
10
|
+
s.date = '2020-12-28'
|
11
11
|
|
12
12
|
s.summary = "Thin abstraction layer for interfacing and recording sensors (currently onewire) and actuators (currently dinrelay)"
|
13
13
|
s.description = <<EOF
|
@@ -45,6 +45,7 @@ EOF
|
|
45
45
|
bin/dinrelaystatus
|
46
46
|
bin/saal_chart
|
47
47
|
bin/saal_daemon
|
48
|
+
bin/saal_denkovi_relays
|
48
49
|
bin/saal_dump_database
|
49
50
|
bin/saal_envoy_generate_config
|
50
51
|
bin/saal_envoy_read
|
@@ -55,6 +56,7 @@ EOF
|
|
55
56
|
lib/charts.rb
|
56
57
|
lib/daemon.rb
|
57
58
|
lib/dbstore.rb
|
59
|
+
lib/denkovi.rb
|
58
60
|
lib/dinrelay.rb
|
59
61
|
lib/envoy.rb
|
60
62
|
lib/http.rb
|
@@ -69,6 +71,8 @@ EOF
|
|
69
71
|
test/charts_test.rb
|
70
72
|
test/daemon_test.rb
|
71
73
|
test/dbstore_test.rb
|
74
|
+
test/denkovi.json.erb
|
75
|
+
test/denkovi_test.rb
|
72
76
|
test/dinrelay.html.erb
|
73
77
|
test/dinrelay_test.rb
|
74
78
|
test/nonexistant_sensor.yml
|
@@ -77,6 +81,7 @@ EOF
|
|
77
81
|
test/sensors_test.rb
|
78
82
|
test/test_charts.yml
|
79
83
|
test/test_db.yml
|
84
|
+
test/test_denkovi_sensors.yml
|
80
85
|
test/test_dinrelay_sensors.yml
|
81
86
|
test/test_helper.rb
|
82
87
|
test/test_sensor_cleanups.yml
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
|
3
|
+
"CurrentState": {
|
4
|
+
|
5
|
+
"Output": [
|
6
|
+
|
7
|
+
<% (1..16).each do |num| %>
|
8
|
+
<% state = outlets[num] %>
|
9
|
+
<% val = state == "ON" ? "1" : "0" %>
|
10
|
+
<% if num < 16 %>
|
11
|
+
{"Name": "RELAY<%= num %>", "Value": "<%= val %>"},
|
12
|
+
<% else %>
|
13
|
+
{"Name": "RELAY<%= num %>", "Value": "<%= val %>"}
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
],
|
18
|
+
|
19
|
+
"Auto-reboot": {
|
20
|
+
|
21
|
+
"RebootsNumber": "0",
|
22
|
+
|
23
|
+
"LastReboot": "-"
|
24
|
+
|
25
|
+
},
|
26
|
+
|
27
|
+
"Device": {
|
28
|
+
|
29
|
+
"Name": "SMARTDEN_IP-16R",
|
30
|
+
|
31
|
+
"MAC": "E8:EA:DA:AA:AA:AA"
|
32
|
+
|
33
|
+
}
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
|
@@ -0,0 +1,212 @@
|
|
1
|
+
require File.dirname(__FILE__)+'/test_helper.rb'
|
2
|
+
require 'webrick'
|
3
|
+
require 'benchmark'
|
4
|
+
|
5
|
+
class TestDenkoviRelay < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@@serv_num ||= 0
|
8
|
+
@@serv_num += 1
|
9
|
+
|
10
|
+
@og=SAAL::Denkovi::OutletGroup.new(service_opts)
|
11
|
+
@vals={1=>"OFF",2=>"OFF",3=>"ON",4=>"OFF",5=>"ON",6=>"ON",7=>"ON",8=>"OFF",
|
12
|
+
9=>"OFF",10=>"OFF",11=>"ON",12=>"OFF",13=>"ON",14=>"ON",15=>"ON",16=>"OFF"}
|
13
|
+
@rvals={1=>"ON",2=>"ON",3=>"OFF",4=>"ON",5=>"OFF",6=>"OFF",7=>"OFF",8=>"ON",
|
14
|
+
9=>"ON",10=>"ON",11=>"OFF",12=>"ON",13=>"OFF",14=>"OFF",15=>"OFF",16=>"ON"}
|
15
|
+
|
16
|
+
defs = YAML::load(File.new(TEST_SENSORS_DENKOVI_FILE))
|
17
|
+
@pass = defs["group1"]["denkovi"]["pass"]
|
18
|
+
defs['group1']['denkovi']['port'] = service_opts[:port]
|
19
|
+
tempfile = Tempfile.new('denkovi_test_yml')
|
20
|
+
File.open(tempfile.path,'w') {|f| f.write(YAML::dump defs)}
|
21
|
+
@test_sensors_denkovi_file = tempfile.path
|
22
|
+
end
|
23
|
+
|
24
|
+
def service_opts
|
25
|
+
base_opts = {:host => 'localhost', :pass =>"somepass"}
|
26
|
+
base_opts.merge(:port => 3333+@@serv_num)
|
27
|
+
end
|
28
|
+
|
29
|
+
class BasicServing < WEBrick::HTTPServlet::AbstractServlet
|
30
|
+
def self.get_instance(config, opts)
|
31
|
+
new(opts)
|
32
|
+
end
|
33
|
+
def initialize(opts)
|
34
|
+
@html = opts[:html]
|
35
|
+
@pass = opts[:pass]
|
36
|
+
@status = opts[:status] || 200
|
37
|
+
@feedback = opts[:feedback] || {}
|
38
|
+
@sleep = opts[:sleep] || 0
|
39
|
+
end
|
40
|
+
def do_GET(req, res)
|
41
|
+
sleep @sleep
|
42
|
+
@feedback[:uris] ||= []
|
43
|
+
@feedback[:uris] << req.request_uri.to_s
|
44
|
+
@feedback[:uri] = req.request_uri.to_s
|
45
|
+
@feedback[:nrequests] = (@feedback[:nrequests]||0)+1
|
46
|
+
res.body = @html
|
47
|
+
res.status = @status
|
48
|
+
res['Content-Type'] = "text/html"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def with_webrick(opts)
|
53
|
+
opts = service_opts.merge(opts)
|
54
|
+
|
55
|
+
Socket.do_not_reverse_lookup = true # Speed up startup
|
56
|
+
log = WEBrick::Log.new($stderr, WEBrick::Log::ERROR)
|
57
|
+
access_log = [[log, WEBrick::AccessLog::COMBINED_LOG_FORMAT]]
|
58
|
+
s = WEBrick::HTTPServer.new(:Port => opts[:port],
|
59
|
+
:Logger => log,
|
60
|
+
:AccessLog => access_log)
|
61
|
+
s.mount('/', BasicServing, opts.merge(:feedback => (f = {})))
|
62
|
+
|
63
|
+
thread = Thread.new do
|
64
|
+
s.start
|
65
|
+
end
|
66
|
+
while s.status != :Running; sleep 0.1; end # Make sure the server is up
|
67
|
+
yield f
|
68
|
+
s.shutdown
|
69
|
+
thread.exit
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_current_state_json(hash)
|
73
|
+
outlets = hash
|
74
|
+
erb = ERB.new(File.open(File.dirname(__FILE__)+'/denkovi.json.erb').read)
|
75
|
+
erb.result(binding)
|
76
|
+
end
|
77
|
+
|
78
|
+
def assert_path(path, uri)
|
79
|
+
assert_equal "http://localhost:#{service_opts[:port]}"+path, uri
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_read_state
|
83
|
+
with_webrick(:html=>create_current_state_json(@vals)) do |feedback|
|
84
|
+
@vals.each do |num, state|
|
85
|
+
assert_equal state, @og.state(num)
|
86
|
+
assert_path "/current_state.json?pw=#{@pass}", feedback[:uri]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_set_state
|
92
|
+
with_webrick(:html=>create_current_state_json(@rvals)) do |feedback|
|
93
|
+
@vals.each do |num, state|
|
94
|
+
newstate = state == "ON" ? "OFF" : "ON"
|
95
|
+
val = {"ON" => "1", "OFF" => "0"}[newstate]
|
96
|
+
assert @og.set_state(num,newstate), "State change not working"
|
97
|
+
assert_path "/current_state.json?pw=#{@pass}&Relay#{num}=#{val}", feedback[:uri]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_enumerate_sensors
|
103
|
+
sensors = SAAL::Sensors.new(@test_sensors_denkovi_file, TEST_DBCONF)
|
104
|
+
assert_equal((1..16).map{|i| "name#{i.to_s.rjust(2, "0")}"}, sensors.map{|s| s.name}.sort)
|
105
|
+
assert_equal((1..16).map{|i| "description#{i.to_s.rjust(2, "0")}"}, sensors.map{|s| s.description}.sort)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_sensor_type
|
109
|
+
SAAL::Sensors.new(TEST_SENSORS_DENKOVI_FILE, TEST_DBCONF).each do |s|
|
110
|
+
assert_equal :onoff, s.sensor_type
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_read_sensors
|
115
|
+
sensors = SAAL::Sensors.new(@test_sensors_denkovi_file, TEST_DBCONF)
|
116
|
+
with_webrick(:html=>create_current_state_json(@vals)) do |feedback|
|
117
|
+
@vals.each do |num, state|
|
118
|
+
value = state == "ON" ? 1.0 : 0.0
|
119
|
+
assert_equal value, sensors.send('name'+num.to_s.rjust(2, "0")).read
|
120
|
+
assert_path "/current_state.json?pw=#{@pass}", feedback[:uri]
|
121
|
+
end
|
122
|
+
assert_equal 1, feedback[:nrequests], "denkovi request caching not working"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_set_sensors
|
127
|
+
sensors = SAAL::Sensors.new(@test_sensors_denkovi_file, TEST_DBCONF)
|
128
|
+
with_webrick(:html=>create_current_state_json(@rvals)) do |feedback|
|
129
|
+
@vals.each do |num, state|
|
130
|
+
newval = state == "ON" ? 0.0 : 1.0
|
131
|
+
newstate = state == "ON" ? "OFF" : "ON"
|
132
|
+
assert_equal newval, sensors.send('name'+num.to_s.rjust(2, "0")).write(newval),
|
133
|
+
"State change not working"
|
134
|
+
val = {"ON" => "1", "OFF" => "0"}[newstate]
|
135
|
+
assert_path "/current_state.json?pw=#{@pass}&Relay#{num}=#{val}", feedback[:uris][-2]
|
136
|
+
assert_path "/current_state.json?pw=#{@pass}", feedback[:uris][-1]
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Test that write invalidates any caching
|
142
|
+
def test_write_read_sensors
|
143
|
+
sensors = SAAL::Sensors.new(@test_sensors_denkovi_file, TEST_DBCONF)
|
144
|
+
with_webrick(:html=>create_current_state_json(@vals)) do |feedback|
|
145
|
+
@vals.each do |num, state|
|
146
|
+
sensors.send('name'+num.to_s.rjust(2, "0")).write(0.0)
|
147
|
+
sensors.send('name'+num.to_s.rjust(2, "0")).read
|
148
|
+
end
|
149
|
+
assert_equal 32, feedback[:nrequests], "denkovi caching too much"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Test that the cache times out
|
154
|
+
def test_cache_invalidation
|
155
|
+
_sensors = SAAL::Sensors.new(@test_sensors_denkovi_file, TEST_DBCONF)
|
156
|
+
@og.cache_timeout = 0.1
|
157
|
+
with_webrick(:html=>create_current_state_json(@vals)) do |feedback|
|
158
|
+
@og.state(1)
|
159
|
+
sleep 0.2
|
160
|
+
@og.state(1)
|
161
|
+
assert_equal 2, feedback[:nrequests], "denkovi caching not invalidating"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_failed_connection
|
166
|
+
@vals.each do |num, state|
|
167
|
+
assert_equal nil, @og.state(num)
|
168
|
+
assert !@og.set_state(num,"ON"), "State change working without a server?!"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_failed_request
|
173
|
+
with_webrick(:html=>create_current_state_json(@vals),:status=>404) do |feedback|
|
174
|
+
@vals.each do |num, state|
|
175
|
+
assert_equal nil, @og.state(num)
|
176
|
+
assert !@og.set_state(num,"ON"), "State change working without a server?!"
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_fast_open_timeout
|
182
|
+
#FIXME: Find a way to make this test address more generic
|
183
|
+
@og=SAAL::Denkovi::OutletGroup.new(service_opts.merge(:host => "10.254.254.254",
|
184
|
+
:timeout=>0.1))
|
185
|
+
with_webrick(:html=>create_current_state_json(@vals)) do |feedback|
|
186
|
+
time = Benchmark.measure do
|
187
|
+
@vals.each do |num, state|
|
188
|
+
assert_equal nil, @og.state(num), "Read not timing out?"
|
189
|
+
assert !@og.set_state(num,"ON"), "State change not timing out?"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
total_time = @og.timeout*2*@vals.keys.size
|
193
|
+
assert time.total < total_time
|
194
|
+
"Doing the reads took too long, are we really timing out?"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_fast_read_timeout
|
199
|
+
@og=SAAL::Denkovi::OutletGroup.new(service_opts.merge(:timeout=>0.1))
|
200
|
+
with_webrick(:html=>create_current_state_json(@vals),:sleep=>10) do |feedback|
|
201
|
+
time = Benchmark.measure do
|
202
|
+
@vals.each do |num, state|
|
203
|
+
assert_equal nil, @og.state(num), "Read not timing out?"
|
204
|
+
assert !@og.set_state(num,"ON"), "State change not timing out?"
|
205
|
+
end
|
206
|
+
end
|
207
|
+
total_time = @og.timeout*2*@vals.keys.size
|
208
|
+
assert time.total < total_time
|
209
|
+
"Doing the reads took too long, are we really timing out?"
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
group1:
|
2
|
+
denkovi:
|
3
|
+
host: localhost
|
4
|
+
port: 33333
|
5
|
+
pass: somepass
|
6
|
+
outlets:
|
7
|
+
1: name01
|
8
|
+
2: name02
|
9
|
+
3: name03
|
10
|
+
4: name04
|
11
|
+
5: name05
|
12
|
+
6: name06
|
13
|
+
7: name07
|
14
|
+
8: name08
|
15
|
+
9: name09
|
16
|
+
10: name10
|
17
|
+
11: name11
|
18
|
+
12: name12
|
19
|
+
13: name13
|
20
|
+
14: name14
|
21
|
+
15: name15
|
22
|
+
16: name16
|
23
|
+
descriptions:
|
24
|
+
1: description01
|
25
|
+
2: description02
|
26
|
+
3: description03
|
27
|
+
4: description04
|
28
|
+
5: description05
|
29
|
+
6: description06
|
30
|
+
7: description07
|
31
|
+
8: description08
|
32
|
+
9: description09
|
33
|
+
10: description10
|
34
|
+
11: description11
|
35
|
+
12: description12
|
36
|
+
13: description13
|
37
|
+
14: description14
|
38
|
+
15: description15
|
39
|
+
16: description16
|
data/test/test_helper.rb
CHANGED
@@ -6,6 +6,7 @@ require File.dirname(__FILE__)+'/../lib/saal.rb'
|
|
6
6
|
class Test::Unit::TestCase
|
7
7
|
TEST_SENSORS_FILE = File.dirname(__FILE__)+'/test_sensors.yml'
|
8
8
|
TEST_SENSORS_DINRELAY_FILE = File.dirname(__FILE__)+'/test_dinrelay_sensors.yml'
|
9
|
+
TEST_SENSORS_DENKOVI_FILE = File.dirname(__FILE__)+'/test_denkovi_sensors.yml'
|
9
10
|
TEST_SENSOR_CLEANUPS_FILE = File.dirname(__FILE__)+'/test_sensor_cleanups.yml'
|
10
11
|
TEST_NONEXIST_SENSOR_FILE = File.dirname(__FILE__)+'/nonexistant_sensor.yml'
|
11
12
|
TEST_CHARTS_FILE = File.dirname(__FILE__)+'/test_charts.yml'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Côrte-Real
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ownet
|
@@ -76,6 +76,7 @@ executables:
|
|
76
76
|
- saal_import_mysql
|
77
77
|
- saal_dump_database
|
78
78
|
- saal_readall
|
79
|
+
- saal_denkovi_relays
|
79
80
|
- saal_chart
|
80
81
|
- saal_daemon
|
81
82
|
- saal_envoy_generate_config
|
@@ -94,6 +95,7 @@ files:
|
|
94
95
|
- bin/dinrelaystatus
|
95
96
|
- bin/saal_chart
|
96
97
|
- bin/saal_daemon
|
98
|
+
- bin/saal_denkovi_relays
|
97
99
|
- bin/saal_dump_database
|
98
100
|
- bin/saal_envoy_generate_config
|
99
101
|
- bin/saal_envoy_read
|
@@ -104,6 +106,7 @@ files:
|
|
104
106
|
- lib/charts.rb
|
105
107
|
- lib/daemon.rb
|
106
108
|
- lib/dbstore.rb
|
109
|
+
- lib/denkovi.rb
|
107
110
|
- lib/dinrelay.rb
|
108
111
|
- lib/envoy.rb
|
109
112
|
- lib/http.rb
|
@@ -118,6 +121,8 @@ files:
|
|
118
121
|
- test/charts_test.rb
|
119
122
|
- test/daemon_test.rb
|
120
123
|
- test/dbstore_test.rb
|
124
|
+
- test/denkovi.json.erb
|
125
|
+
- test/denkovi_test.rb
|
121
126
|
- test/dinrelay.html.erb
|
122
127
|
- test/dinrelay_test.rb
|
123
128
|
- test/nonexistant_sensor.yml
|
@@ -126,6 +131,7 @@ files:
|
|
126
131
|
- test/sensors_test.rb
|
127
132
|
- test/test_charts.yml
|
128
133
|
- test/test_db.yml
|
134
|
+
- test/test_denkovi_sensors.yml
|
129
135
|
- test/test_dinrelay_sensors.yml
|
130
136
|
- test/test_helper.rb
|
131
137
|
- test/test_sensor_cleanups.yml
|
@@ -164,6 +170,7 @@ test_files:
|
|
164
170
|
- test/charts_test.rb
|
165
171
|
- test/daemon_test.rb
|
166
172
|
- test/dbstore_test.rb
|
173
|
+
- test/denkovi_test.rb
|
167
174
|
- test/dinrelay_test.rb
|
168
175
|
- test/outliercache_test.rb
|
169
176
|
- test/sensor_test.rb
|