roku_builder 4.9.4 → 4.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +8 -0
- data/lib/roku_builder/plugins/profiler.rb +89 -13
- data/lib/roku_builder/version.rb +1 -1
- data/test/roku_builder/plugins/test_analyzer.rb +1 -11
- data/test/roku_builder/plugins/test_profiler.rb +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f7dcf7f887352dabf7d59d8fcf47e53beb2846a
|
4
|
+
data.tar.gz: 0e069f0cc4769374a011a909e17c436bff3dbce3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8826d8af980a33ce0d182861e6e8a1346bbd14169035ff1cda0bd8f426323365e42c99622d72dfce4ef50a0595156eab36639608352975c4c3c33630e78aeb9f
|
7
|
+
data.tar.gz: 384b2ac125f3535754a2cc43beb20b640ce08646b87933cb2e8757547795903e1407916f94b1917b0958585492ebf4b08c06e641e0f8baddb5dfceb765063c32
|
data/CHANGELOG
CHANGED
@@ -10,7 +10,8 @@ module RokuBuilder
|
|
10
10
|
{
|
11
11
|
profile: {device: true},
|
12
12
|
sgperf: {device: true},
|
13
|
-
devlog: {device: true}
|
13
|
+
devlog: {device: true},
|
14
|
+
node_tracking: {device: true}
|
14
15
|
}
|
15
16
|
end
|
16
17
|
|
@@ -26,15 +27,24 @@ module RokuBuilder
|
|
26
27
|
options[:devlog] = t || "rendezvous"
|
27
28
|
options[:devlog_function] = f
|
28
29
|
end
|
30
|
+
parser.on("--node-tracking [INTERVAL]", "Take snapshots of the current nodes and print difference since last snapshot") do |interval|
|
31
|
+
options[:node_tracking] = true
|
32
|
+
options[:node_tracking_interval] = interval
|
33
|
+
end
|
34
|
+
parser.separator "Options:"
|
35
|
+
parser.on("--add-ids", "Add ids to stats command") do
|
36
|
+
options[:add_ids] = true
|
37
|
+
end
|
29
38
|
end
|
30
39
|
|
31
40
|
# Run the profiler commands
|
32
41
|
# @param command [Symbol] The profiler command to run
|
33
42
|
def profile(options:)
|
43
|
+
@options = options
|
34
44
|
@connection = nil
|
35
45
|
case options[:profile].to_sym
|
36
46
|
when :stats
|
37
|
-
|
47
|
+
print_all_node_stats
|
38
48
|
when :all
|
39
49
|
print_all_nodes
|
40
50
|
when :roots
|
@@ -95,33 +105,99 @@ module RokuBuilder
|
|
95
105
|
connection.puts("enhanced_dev_log #{options[:devlog]} #{options[:devlog_function]}\n")
|
96
106
|
end
|
97
107
|
|
108
|
+
def node_tracking(options:)
|
109
|
+
@options = options
|
110
|
+
@connection = nil
|
111
|
+
begin
|
112
|
+
current_nodes = nil
|
113
|
+
previous_nodes = nil
|
114
|
+
while true
|
115
|
+
current_nodes = get_stats
|
116
|
+
diff = diff_node_stats(current_nodes, previous_nodes)
|
117
|
+
print_stats(stats: diff)
|
118
|
+
previous_nodes = current_nodes
|
119
|
+
current_nodes = nil
|
120
|
+
STDIN.read(1)
|
121
|
+
end
|
122
|
+
rescue SystemExit, Interrupt
|
123
|
+
@connection.close if @connection
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
98
127
|
private
|
99
128
|
|
100
129
|
# Print the node stats
|
101
|
-
def
|
130
|
+
def print_all_node_stats
|
131
|
+
print_stats(stats: get_stats)
|
132
|
+
end
|
133
|
+
|
134
|
+
# Print the node stats
|
135
|
+
def get_stats
|
102
136
|
end_reg = /<\/All_Nodes>/
|
103
137
|
start_reg = /<All_Nodes>/
|
104
138
|
lines = get_command_response(command: "sgnodes all", start_reg: start_reg, end_reg: end_reg)
|
105
139
|
xml_string = lines.join("\n")
|
106
|
-
stats = {"Total" => 0}
|
140
|
+
stats = {"Total" => {count: 0}}
|
107
141
|
doc = Oga.parse_xml(xml_string)
|
108
142
|
handle_node(stats: stats, node: doc.children.first)
|
143
|
+
stats
|
144
|
+
end
|
145
|
+
|
146
|
+
def print_stats(stats:)
|
109
147
|
stats = stats.to_a
|
110
|
-
stats = stats.sort
|
111
|
-
|
148
|
+
stats = stats.sort do |a, b|
|
149
|
+
next -1 if a[0] == "Total"
|
150
|
+
next 1 if b[0] == "Total"
|
151
|
+
b[1][:count] <=> a[1][:count]
|
152
|
+
end
|
153
|
+
if @options[:add_ids]
|
154
|
+
printf "%30s | %5s | %s\n%s\n", "Name", "Count", "Ids", "-"*60
|
155
|
+
else
|
156
|
+
printf "%30s | %5s\n%s\n", "Name", "Count", "-"*60
|
157
|
+
end
|
112
158
|
stats.each do |key_pair|
|
113
|
-
|
159
|
+
if key_pair[0] == "Total" and key_pair[1][:total]
|
160
|
+
printf "%30s | %5d %5d", key_pair[0], key_pair[1][:count], key_pair[1][:total]
|
161
|
+
else
|
162
|
+
printf "%30s | %5d", key_pair[0], key_pair[1][:count]
|
163
|
+
end
|
164
|
+
if @options[:add_ids] and key_pair[1][:ids] and key_pair[1][:ids].count > 0
|
165
|
+
id_string = key_pair[1][:ids].join(",")
|
166
|
+
printf "[#{id_string}]"
|
167
|
+
end
|
168
|
+
printf "\n"
|
114
169
|
end
|
115
170
|
end
|
116
171
|
|
117
172
|
def handle_node(stats:, node:)
|
118
|
-
node
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
173
|
+
if node
|
174
|
+
node.children.each do |element|
|
175
|
+
next unless element.class == Oga::XML::Element
|
176
|
+
attributes = element.attributes.map{|attr| {"#{attr.name}": attr.value}}.reduce({}, :merge)
|
177
|
+
stats[element.name] ||= {count: 0, ids: []}
|
178
|
+
stats[element.name][:count] += 1
|
179
|
+
stats[element.name][:ids].push(attributes[:name]) if attributes[:name]
|
180
|
+
stats["Total"][:count] += 1
|
181
|
+
handle_node(stats: stats, node: element)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def diff_node_stats(current, previous)
|
187
|
+
return current unless previous
|
188
|
+
diff = current.deep_dup
|
189
|
+
diff.each_pair do |node, stats|
|
190
|
+
if previous[node]
|
191
|
+
stats[:count] = stats[:count] - previous[node][:count]
|
192
|
+
if stats[:count] == 0 and node != "Total"
|
193
|
+
diff.delete(node)
|
194
|
+
elsif stats[:ids]
|
195
|
+
stats[:ids] = stats[:ids] - previous[node][:ids]
|
196
|
+
end
|
197
|
+
end
|
124
198
|
end
|
199
|
+
diff["Total"][:total] = current["Total"][:count]
|
200
|
+
diff
|
125
201
|
end
|
126
202
|
|
127
203
|
def print_all_nodes
|
data/lib/roku_builder/version.rb
CHANGED
@@ -26,7 +26,6 @@ module RokuBuilder
|
|
26
26
|
def teardown
|
27
27
|
manifest = File.join(@root_dir, "manifest")
|
28
28
|
FileUtils.rm(manifest) if File.exist?(manifest)
|
29
|
-
remove_config
|
30
29
|
@request_stubs.each {|req| remove_request_stub(req)}
|
31
30
|
end
|
32
31
|
def test_analyzer_parse_commands
|
@@ -412,18 +411,9 @@ module RokuBuilder
|
|
412
411
|
end
|
413
412
|
|
414
413
|
def set_config(config_content)
|
415
|
-
config
|
416
|
-
File.open(config, "w") do |file|
|
417
|
-
file.write(config_content.to_json)
|
418
|
-
end
|
419
|
-
end
|
420
|
-
|
421
|
-
def remove_config
|
422
|
-
config = File.join(@root_dir, ".roku_builder_analyze.json")
|
423
|
-
FileUtils.rm(config) if File.exist? config
|
414
|
+
@config.project.merge!(config_content)
|
424
415
|
end
|
425
416
|
|
426
|
-
|
427
417
|
def print_all(warnings)
|
428
418
|
warnings.each do |warning|
|
429
419
|
puts warning[:message]
|
@@ -20,6 +20,38 @@ module RokuBuilder
|
|
20
20
|
parser.parse! argv
|
21
21
|
assert_equal "command", options[:profile]
|
22
22
|
end
|
23
|
+
def test_profiler_node_tracking
|
24
|
+
options = {profile: "stats"}
|
25
|
+
config, options = build_config_options_objects(ProfilerTest, options, false)
|
26
|
+
waitfor = Proc.new do |telnet_config, &blk|
|
27
|
+
assert_equal(/.+/, telnet_config["Match"])
|
28
|
+
assert_equal(1, telnet_config["Timeout"])
|
29
|
+
txt = "<All_Nodes><NodeA /><NodeB /><NodeC><NodeD /></NodeC></All_Nodes>\n"
|
30
|
+
blk.call(txt)
|
31
|
+
true
|
32
|
+
end
|
33
|
+
count = 0
|
34
|
+
read_stub = Proc.new do |size|
|
35
|
+
raise SystemExit if count = 2
|
36
|
+
count += 1
|
37
|
+
end
|
38
|
+
connection = Minitest::Mock.new
|
39
|
+
profiler = Profiler.new(config: config)
|
40
|
+
|
41
|
+
connection.expect(:puts, nil, ["sgnodes all\n"])
|
42
|
+
connection.expect(:waitfor, nil, &waitfor)
|
43
|
+
connection.expect(:close, nil)
|
44
|
+
|
45
|
+
Net::Telnet.stub(:new, connection) do
|
46
|
+
profiler.stub(:printf, nil) do
|
47
|
+
STDIN.stub(:read, read_stub) do
|
48
|
+
profiler.node_tracking(options: options)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
connection.verify
|
54
|
+
end
|
23
55
|
def test_profiler_stats
|
24
56
|
options = {profile: "stats"}
|
25
57
|
config, options = build_config_options_objects(ProfilerTest, options, false)
|
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.9.
|
4
|
+
version: 4.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- greeneca
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|