roku_builder 4.25.5 → 4.25.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/intergration/roku_builder/test_helper.rb +2 -3
- data/intergration/roku_builder/test_profiler.rb +1 -1
- data/lib/roku_builder/config_parser.rb +4 -5
- data/lib/roku_builder/device_manager.rb +100 -0
- data/lib/roku_builder/plugins/core.rb +3 -1
- data/lib/roku_builder/plugins/inspector.rb +36 -26
- data/lib/roku_builder/plugins/linker.rb +29 -22
- data/lib/roku_builder/plugins/loader.rb +30 -11
- data/lib/roku_builder/plugins/monitor.rb +19 -17
- data/lib/roku_builder/plugins/navigator.rb +40 -34
- data/lib/roku_builder/plugins/packager.rb +109 -92
- data/lib/roku_builder/plugins/profiler.rb +24 -15
- data/lib/roku_builder/plugins/tester.rb +15 -13
- data/lib/roku_builder/util.rb +39 -17
- data/lib/roku_builder/version.rb +1 -1
- data/lib/roku_builder.rb +3 -19
- data/roku_builder.gemspec +3 -2
- data/test/roku_builder/plugins/test_core.rb +2 -3
- data/test/roku_builder/plugins/test_inspector.rb +48 -8
- data/test/roku_builder/plugins/test_linker.rb +66 -10
- data/test/roku_builder/plugins/test_loader.rb +44 -15
- data/test/roku_builder/plugins/test_monitor.rb +33 -16
- data/test/roku_builder/plugins/test_navigator.rb +55 -14
- data/test/roku_builder/plugins/test_packager.rb +118 -34
- data/test/roku_builder/plugins/test_profiler.rb +153 -78
- data/test/roku_builder/plugins/test_tester.rb +20 -5
- data/test/roku_builder/test_device_manager.rb +187 -0
- data/test/roku_builder/test_helper.rb +6 -0
- data/test/roku_builder/test_roku_builder.rb +5 -42
- metadata +23 -6
@@ -11,6 +11,8 @@ module RokuBuilder
|
|
11
11
|
@connection = Minitest::Mock.new
|
12
12
|
@requests = []
|
13
13
|
|
14
|
+
@device_manager = Minitest::Mock.new
|
15
|
+
|
14
16
|
@requests.push(stub_request(:post, "http://192.168.0.100:8060/keypress/Home").
|
15
17
|
to_return(status: 200, body: "", headers: {}))
|
16
18
|
@requests.push(stub_request(:post, "http://192.168.0.100/plugin_install").
|
@@ -19,6 +21,7 @@ module RokuBuilder
|
|
19
21
|
to_return(status: 200, body: "", headers: {}))
|
20
22
|
end
|
21
23
|
def teardown
|
24
|
+
@device_manager.verify
|
22
25
|
@connection.verify
|
23
26
|
@requests.each {|req| remove_request_stub(req)}
|
24
27
|
end
|
@@ -37,8 +40,14 @@ module RokuBuilder
|
|
37
40
|
@connection.expect(:waitfor, nil, [/\*+\s*End testing\s*\*+/])
|
38
41
|
@connection.expect(:puts, nil, ["cont\n"])
|
39
42
|
|
40
|
-
|
41
|
-
|
43
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
44
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
45
|
+
@device_manager.expect(:release_device, nil, [device])
|
46
|
+
|
47
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
48
|
+
Net::Telnet.stub(:new, @connection) do
|
49
|
+
tester.test(options: options)
|
50
|
+
end
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
@@ -55,9 +64,15 @@ module RokuBuilder
|
|
55
64
|
@connection.expect(:waitfor, nil, &waitfor)
|
56
65
|
@connection.expect(:puts, nil, ["cont\n"])
|
57
66
|
|
58
|
-
|
59
|
-
|
60
|
-
|
67
|
+
device = RokuBuilder::Device.new("roku", config.raw[:devices][:roku])
|
68
|
+
@device_manager.expect(:reserve_device, device, no_lock: false)
|
69
|
+
@device_manager.expect(:release_device, nil, [device])
|
70
|
+
|
71
|
+
RokuBuilder.stub(:device_manager, @device_manager) do
|
72
|
+
Net::Telnet.stub(:new, @connection) do
|
73
|
+
tester.stub(:handle_text, false) do
|
74
|
+
tester.test(options: options)
|
75
|
+
end
|
61
76
|
end
|
62
77
|
end
|
63
78
|
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
# ********** Copyright Viacom, Inc. Apache 2.0 **********
|
2
|
+
|
3
|
+
require_relative "test_helper.rb"
|
4
|
+
|
5
|
+
module RokuBuilder
|
6
|
+
class DeviceManagerTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
Logger.set_testing
|
9
|
+
@ping = Minitest::Mock.new
|
10
|
+
clean_device_locks(["roku", "test2"])
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
@ping.verify
|
15
|
+
clean_device_locks(["roku", "test2"])
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_device_manager_init
|
19
|
+
config, options = build_config_options_objects(DeviceManagerTest)
|
20
|
+
manager = DeviceManager.new(config: config, options: options)
|
21
|
+
assert_equal config, manager.instance_variable_get(:@config)
|
22
|
+
assert_equal options, manager.instance_variable_get(:@options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_device_manager_reserve_device
|
26
|
+
Net::Ping::External.stub(:new, @ping) do
|
27
|
+
config, options = build_config_options_objects(DeviceManagerTest)
|
28
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
29
|
+
manager = DeviceManager.new(config: config, options: options)
|
30
|
+
device = manager.reserve_device
|
31
|
+
assert_kind_of Device, device
|
32
|
+
assert_equal "roku", device.name
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_device_manager_reserve_device_default_offline
|
37
|
+
Net::Ping::External.stub(:new, @ping) do
|
38
|
+
config, options = build_config_options_objects(DeviceManagerTest)
|
39
|
+
@ping.expect(:ping?, false, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
40
|
+
manager = DeviceManager.new(config: config, options: options)
|
41
|
+
assert_raises(DeviceError) do
|
42
|
+
device = manager.reserve_device
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_device_manager_reserve_device_all_used
|
48
|
+
Net::Ping::External.stub(:new, @ping) do
|
49
|
+
config, options = build_config_options_objects(DeviceManagerTest)
|
50
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
51
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
52
|
+
manager = DeviceManager.new(config: config, options: options)
|
53
|
+
device1 = manager.reserve_device
|
54
|
+
assert_raises(DeviceError) do
|
55
|
+
device2 = manager.reserve_device
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_device_manager_reserve_device_no_lock_first
|
61
|
+
Net::Ping::External.stub(:new, @ping) do
|
62
|
+
config, options = build_config_options_objects(DeviceManagerTest)
|
63
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
64
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
65
|
+
manager = DeviceManager.new(config: config, options: options)
|
66
|
+
device1 = manager.reserve_device(no_lock: true)
|
67
|
+
device2 = manager.reserve_device
|
68
|
+
assert_equal "roku", device1.name
|
69
|
+
assert_equal "roku", device2.name
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_device_manager_release_device
|
74
|
+
Net::Ping::External.stub(:new, @ping) do
|
75
|
+
config, options = build_config_options_objects(DeviceManagerTest)
|
76
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
77
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
78
|
+
manager = DeviceManager.new(config: config, options: options)
|
79
|
+
device1 = manager.reserve_device
|
80
|
+
manager.release_device(device1)
|
81
|
+
device2 = manager.reserve_device
|
82
|
+
assert_equal "roku", device2.name
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_device_manager_reserve_device_2_devices
|
87
|
+
Net::Ping::External.stub(:new, @ping) do
|
88
|
+
options = {validate: true}
|
89
|
+
config = good_config(DeviceManagerTest)
|
90
|
+
config[:devices][:test2] = {
|
91
|
+
ip: "192.168.0.101",
|
92
|
+
user: "user",
|
93
|
+
password: "password"
|
94
|
+
}
|
95
|
+
config, options = build_config_options_objects(DeviceManagerTest, options, true, config)
|
96
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
97
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
98
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:test2][:ip], 1, 0.2, 1])
|
99
|
+
manager = DeviceManager.new(config: config, options: options)
|
100
|
+
device1 = manager.reserve_device
|
101
|
+
device2 = manager.reserve_device
|
102
|
+
assert_equal "roku", device1.name
|
103
|
+
assert_equal "test2", device2.name
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_device_manager_reserve_device_2_devices_default_missing
|
108
|
+
Net::Ping::External.stub(:new, @ping) do
|
109
|
+
options = {validate: true}
|
110
|
+
config = good_config(DeviceManagerTest)
|
111
|
+
config[:devices][:test2] = {
|
112
|
+
ip: "192.168.0.101",
|
113
|
+
user: "user",
|
114
|
+
password: "password"
|
115
|
+
}
|
116
|
+
config, options = build_config_options_objects(DeviceManagerTest, options, true, config)
|
117
|
+
@ping.expect(:ping?, false, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
118
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:test2][:ip], 1, 0.2, 1])
|
119
|
+
@ping.expect(:ping?, false, [config.raw[:devices][:roku][:ip], 1, 0.2, 1])
|
120
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:test2][:ip], 1, 0.2, 1])
|
121
|
+
manager = DeviceManager.new(config: config, options: options)
|
122
|
+
device1 = manager.reserve_device
|
123
|
+
assert_raises(DeviceError) do
|
124
|
+
device2 = manager.reserve_device
|
125
|
+
end
|
126
|
+
assert_equal "test2", device1.name
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_device_manager_reserve_device_specified
|
131
|
+
Net::Ping::External.stub(:new, @ping) do
|
132
|
+
options = {validate: true, device: "test2"}
|
133
|
+
config = good_config(DeviceManagerTest)
|
134
|
+
config[:devices][:test2] = {
|
135
|
+
ip: "192.168.0.101",
|
136
|
+
user: "user",
|
137
|
+
password: "password"
|
138
|
+
}
|
139
|
+
config, options = build_config_options_objects(DeviceManagerTest, options, true, config)
|
140
|
+
@ping.expect(:ping?, true, [config.raw[:devices][:test2][:ip], 1, 0.2, 1])
|
141
|
+
manager = DeviceManager.new(config: config, options: options)
|
142
|
+
device = manager.reserve_device
|
143
|
+
assert_kind_of Device, device
|
144
|
+
assert_equal "test2", device.name
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_device_manager_reserve_device_blocking
|
149
|
+
Net::Ping::External.stub(:new, FakePing.new) do
|
150
|
+
Thread.abort_on_exception = true
|
151
|
+
options = {validate: true, device_blocking: true}
|
152
|
+
config, options = build_config_options_objects(DeviceManagerTest, options)
|
153
|
+
manager = DeviceManager.new(config: config, options: options)
|
154
|
+
device = manager.reserve_device
|
155
|
+
t = Thread.new do
|
156
|
+
Thread.current[:device] = manager.reserve_device
|
157
|
+
end
|
158
|
+
manager.release_device(device)
|
159
|
+
t.join
|
160
|
+
assert_equal "roku", t[:device].name
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_device_manager_reserve_device_blocking_timeout
|
165
|
+
Net::Ping::External.stub(:new, FakePing.new) do
|
166
|
+
options = {validate: true, device_blocking: true}
|
167
|
+
config, options = build_config_options_objects(DeviceManagerTest, options)
|
168
|
+
manager = DeviceManager.new(config: config, options: options)
|
169
|
+
manager.instance_variable_set(:@timeout_duration, 0.01)
|
170
|
+
device = manager.reserve_device
|
171
|
+
assert_raises(DeviceError) do
|
172
|
+
puts manager.reserve_device.name
|
173
|
+
puts device.name
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
class FakePing
|
179
|
+
def initialize(ret: true)
|
180
|
+
@ret = ret
|
181
|
+
end
|
182
|
+
def ping?(*args)
|
183
|
+
@ret
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
@@ -28,6 +28,12 @@ def register_plugins(plugin_class)
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
|
+
def clean_device_locks(names=["roku"])
|
32
|
+
names.each do |device|
|
33
|
+
path = File.join(Dir.tmpdir, device)
|
34
|
+
File.delete(path) if File.exist?(path)
|
35
|
+
end
|
36
|
+
end
|
31
37
|
def build_config_options_objects(klass, options = {validate: true}, empty_plugins = true, config_hash = nil)
|
32
38
|
options = build_options(options, empty_plugins)
|
33
39
|
config = RokuBuilder::Config.new(options: options)
|
@@ -65,7 +65,7 @@ module RokuBuilder
|
|
65
65
|
RokuBuilder.class_variable_set(:@@plugins, [])
|
66
66
|
RokuBuilder.setup_plugins
|
67
67
|
register_plugins(Packager)
|
68
|
-
assert_raises
|
68
|
+
assert_raises InvalidOptions do
|
69
69
|
RokuBuilder.run(options: {package: true, in: "/in/path", debug: true, config: config})
|
70
70
|
end
|
71
71
|
end
|
@@ -79,47 +79,6 @@ module RokuBuilder
|
|
79
79
|
logger.verify
|
80
80
|
Logger.set_testing
|
81
81
|
end
|
82
|
-
def test_roku_builder_check_devices_good
|
83
|
-
Net::Ping::External.stub(:new, @ping) do
|
84
|
-
@ping.expect(:ping?, true, [@parsed[:device_config][:ip], 1, 0.2, 1])
|
85
|
-
RokuBuilder.check_devices
|
86
|
-
end
|
87
|
-
end
|
88
|
-
def test_roku_builder_check_devices_no_devices
|
89
|
-
Net::Ping::External.stub(:new, @ping) do
|
90
|
-
@ping.expect(:ping?, false, [@parsed[:device_config][:ip], 1, 0.2, 1])
|
91
|
-
@ping.expect(:ping?, false, [@raw[:devices][:a][:ip], 1, 0.2, 1])
|
92
|
-
@ping.expect(:ping?, false, [@raw[:devices][:b][:ip], 1, 0.2, 1])
|
93
|
-
assert_raises DeviceError do
|
94
|
-
RokuBuilder.check_devices
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
def test_roku_builder_check_devices_changed_device
|
99
|
-
Net::Ping::External.stub(:new, @ping) do
|
100
|
-
@ping.expect(:ping?, false, [@parsed[:device_config][:ip], 1, 0.2, 1])
|
101
|
-
@ping.expect(:ping?, true, [@raw[:devices][:a][:ip], 1, 0.2, 1])
|
102
|
-
RokuBuilder.check_devices
|
103
|
-
assert_equal @raw[:devices][:a][:ip], @config.parsed[:device_config][:ip]
|
104
|
-
end
|
105
|
-
end
|
106
|
-
def test_roku_builder_check_devices_bad_device
|
107
|
-
Net::Ping::External.stub(:new, @ping) do
|
108
|
-
@options[:device_given] = true
|
109
|
-
@ping.expect(:ping?, false, [@parsed[:device_config][:ip], 1, 0.2, 1])
|
110
|
-
assert_raises DeviceError do
|
111
|
-
RokuBuilder.check_devices
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
def test_roku_builder_check_devices
|
116
|
-
Net::Ping::External.stub(:new, @ping) do
|
117
|
-
@options = build_options({validate: true, device_given: false, working: true})
|
118
|
-
RokuBuilder.class_variable_set(:@@options, @options)
|
119
|
-
RokuBuilder.check_devices
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
82
|
def test_roku_builder_logger_debug
|
124
83
|
tests = [
|
125
84
|
{options: {debug: true}, method: :set_debug},
|
@@ -154,6 +113,10 @@ module RokuBuilder
|
|
154
113
|
assert_equal "b:c", options[:a]
|
155
114
|
assert_equal "e:f", options[:d]
|
156
115
|
end
|
116
|
+
def test_roku_builder_device_manager
|
117
|
+
manager = RokuBuilder.device_manager
|
118
|
+
assert_kind_of DeviceManager, manager
|
119
|
+
end
|
157
120
|
def test_roku_builder_plugins_empty
|
158
121
|
RokuBuilder.class_variable_set(:@@plugins, nil)
|
159
122
|
RokuBuilder.process_plugins
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roku_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.25.
|
4
|
+
version: 4.25.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- greeneca
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -30,14 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.3'
|
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: '
|
40
|
+
version: '2.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday-multipart
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: faraday-digestauth
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,14 +198,14 @@ dependencies:
|
|
184
198
|
requirements:
|
185
199
|
- - "~>"
|
186
200
|
- !ruby/object:Gem::Version
|
187
|
-
version: '5.
|
201
|
+
version: '5.16'
|
188
202
|
type: :development
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
206
|
- - "~>"
|
193
207
|
- !ruby/object:Gem::Version
|
194
|
-
version: '5.
|
208
|
+
version: '5.16'
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: minitest-autotest
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -477,6 +491,7 @@ files:
|
|
477
491
|
- lib/roku_builder/config.rb
|
478
492
|
- lib/roku_builder/config_parser.rb
|
479
493
|
- lib/roku_builder/config_validator.rb
|
494
|
+
- lib/roku_builder/device_manager.rb
|
480
495
|
- lib/roku_builder/errors.rb
|
481
496
|
- lib/roku_builder/git.rb
|
482
497
|
- lib/roku_builder/hash.rb
|
@@ -526,6 +541,7 @@ files:
|
|
526
541
|
- test/roku_builder/test_config.rb
|
527
542
|
- test/roku_builder/test_config_parser.rb
|
528
543
|
- test/roku_builder/test_config_validator.rb
|
544
|
+
- test/roku_builder/test_device_manager.rb
|
529
545
|
- test/roku_builder/test_files/analyzer_test/analyzer_config.json
|
530
546
|
- test/roku_builder/test_files/analyzer_test/images/focus.png
|
531
547
|
- test/roku_builder/test_files/analyzer_test/images/focus_hd.png
|
@@ -654,6 +670,7 @@ test_files:
|
|
654
670
|
- test/roku_builder/test_config.rb
|
655
671
|
- test/roku_builder/test_config_parser.rb
|
656
672
|
- test/roku_builder/test_config_validator.rb
|
673
|
+
- test/roku_builder/test_device_manager.rb
|
657
674
|
- test/roku_builder/test_files/analyzer_test/analyzer_config.json
|
658
675
|
- test/roku_builder/test_files/analyzer_test/images/focus.png
|
659
676
|
- test/roku_builder/test_files/analyzer_test/images/focus_hd.png
|