test-prof-autopilot 0.0.2 → 0.0.5
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/lib/test_prof/autopilot/cli.rb +32 -5
- data/lib/test_prof/autopilot/configuration.rb +12 -9
- data/lib/test_prof/autopilot/dsl.rb +6 -0
- data/lib/test_prof/autopilot/event_prof/printer.rb +2 -2
- data/lib/test_prof/autopilot/event_prof/profiling_executor.rb +1 -0
- data/lib/test_prof/autopilot/event_prof/report.rb +16 -0
- data/lib/test_prof/autopilot/event_prof/writer.rb +20 -0
- data/lib/test_prof/autopilot/factory_prof/profiling_executor.rb +1 -1
- data/lib/test_prof/autopilot/factory_prof/writer.rb +25 -0
- data/lib/test_prof/autopilot/logging.rb +1 -1
- data/lib/test_prof/autopilot/merger.rb +56 -0
- data/lib/test_prof/autopilot/patches/event_prof_patch.rb +1 -1
- data/lib/test_prof/autopilot/patches/factory_prof_patch.rb +23 -1
- data/lib/test_prof/autopilot/patches/stack_prof_patch.rb +1 -1
- data/lib/test_prof/autopilot/patches/tag_prof_patch.rb +29 -0
- data/lib/test_prof/autopilot/profiling_executor/base.rb +3 -2
- data/lib/test_prof/autopilot/report_builder.rb +1 -1
- data/lib/test_prof/autopilot/report_writer.rb +40 -0
- data/lib/test_prof/autopilot/runner.rb +2 -2
- data/lib/test_prof/autopilot/stack_prof/profiling_executor.rb +1 -1
- data/lib/test_prof/autopilot/stack_prof/writer.rb +6 -9
- data/lib/test_prof/autopilot/tag_prof/printer.rb +21 -0
- data/lib/test_prof/autopilot/tag_prof/profiling_executor.rb +34 -0
- data/lib/test_prof/autopilot/tag_prof/report.rb +64 -0
- data/lib/test_prof/autopilot/tag_prof/writer.rb +33 -0
- data/lib/test_prof/autopilot/version.rb +1 -1
- data/lib/test_prof/autopilot.rb +1 -0
- metadata +26 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da180b01be948feec684ca0b80005809678834cec159dc8af26b8dcc8549d31f
|
4
|
+
data.tar.gz: e42323a7e60dbd7198cf4772153f6c42e3544a4b60fc55f66c1fb335055e0aad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18ec8fffa21d68373ff74f32da3ff1f08c9146a0e74c22e9fd420dc469f61fec1ef7808f06f614caea0ca8c11967cf159163724248a9411fb2ace7f081671e2f
|
7
|
+
data.tar.gz: 5db488c8dd13b78fc623eddf05ca69465f212e1bb8f6492dd62370f9415e061cc455448d7067f9e05bfce8ef8aac048e471487a61c32c983927dd6ba0fcaaf63
|
@@ -2,22 +2,31 @@
|
|
2
2
|
|
3
3
|
require "optparse"
|
4
4
|
require "test_prof/autopilot/runner"
|
5
|
+
require "test_prof/autopilot/merger"
|
5
6
|
|
6
7
|
module TestProf
|
7
8
|
module Autopilot
|
8
9
|
class CLI
|
9
|
-
attr_reader :command, :plan_path
|
10
|
+
attr_reader :command, :plan_path, :mode, :merge_type, :report_paths
|
10
11
|
|
11
12
|
def run(args = ARGV)
|
13
|
+
@mode = "runner"
|
14
|
+
|
12
15
|
optparser.parse!(args)
|
13
16
|
|
14
|
-
|
17
|
+
if mode == "runner"
|
18
|
+
raise "Test command must be specified. See -h for options" unless command
|
19
|
+
|
20
|
+
raise "Plan path must be specified. See -h for options" unless plan_path
|
15
21
|
|
16
|
-
|
22
|
+
raise "Plan #{plan_path} doesn't exist" unless File.file?(plan_path)
|
17
23
|
|
18
|
-
|
24
|
+
Runner.invoke(plan_path, command)
|
25
|
+
elsif mode == "merger"
|
26
|
+
raise "Report paths must be specified. See -h for options" unless report_paths
|
19
27
|
|
20
|
-
|
28
|
+
Merger.invoke(merge_type, report_paths)
|
29
|
+
end
|
21
30
|
end
|
22
31
|
|
23
32
|
private
|
@@ -38,6 +47,24 @@ module TestProf
|
|
38
47
|
opts.on("-i FILE", "--plan", "Path to test plan") do |val|
|
39
48
|
@plan_path = val
|
40
49
|
end
|
50
|
+
|
51
|
+
# Merger-specific options
|
52
|
+
opts.on("--merge=TYPE", "Merge existing reports of the specified type") do |val|
|
53
|
+
@mode = "merger"
|
54
|
+
@merge_type = val
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on("--reports=PATH", "Reports path glob or comma-separated paths") do |val|
|
58
|
+
@report_paths = val.split(",")
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.on("--merge-format=FORMAT", "Combined report format") do |val|
|
62
|
+
Autopilot.config.merge_format = val
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.on("--merge-file=PATH", "Where to store combined report") do |val|
|
66
|
+
Autopilot.config.merge_file = File.absolute_path?(val) ? val : File.expand_path(val)
|
67
|
+
end
|
41
68
|
end
|
42
69
|
end
|
43
70
|
end
|
@@ -2,28 +2,31 @@
|
|
2
2
|
|
3
3
|
module TestProf
|
4
4
|
module Autopilot
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@config ||= new
|
10
|
-
end
|
5
|
+
class << self
|
6
|
+
def config
|
7
|
+
@config ||= Configuration.new
|
8
|
+
end
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
10
|
+
def configure
|
11
|
+
yield config
|
15
12
|
end
|
13
|
+
end
|
16
14
|
|
15
|
+
# Global configuration
|
16
|
+
class Configuration
|
17
17
|
attr_accessor :output,
|
18
18
|
:tmp_dir,
|
19
19
|
:artifacts_dir,
|
20
20
|
:plan_path,
|
21
|
+
:merge_format,
|
22
|
+
:merge_file,
|
21
23
|
:command
|
22
24
|
|
23
25
|
def initialize
|
24
26
|
@output = $stdout
|
25
27
|
@tmp_dir = "tmp/test_prof_autopilot"
|
26
28
|
@artifacts_dir = "test_prof_autopilot"
|
29
|
+
@merge_format = "info"
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
@@ -2,8 +2,14 @@
|
|
2
2
|
|
3
3
|
require "test_prof/autopilot/event_prof/printer"
|
4
4
|
require "test_prof/autopilot/event_prof/profiling_executor"
|
5
|
+
require "test_prof/autopilot/event_prof/writer"
|
6
|
+
|
7
|
+
require "test_prof/autopilot/tag_prof/printer"
|
8
|
+
require "test_prof/autopilot/tag_prof/profiling_executor"
|
9
|
+
require "test_prof/autopilot/tag_prof/writer"
|
5
10
|
|
6
11
|
require "test_prof/autopilot/factory_prof/printer"
|
12
|
+
require "test_prof/autopilot/factory_prof/writer"
|
7
13
|
require "test_prof/autopilot/factory_prof/profiling_executor"
|
8
14
|
|
9
15
|
require "test_prof/autopilot/stack_prof/printer"
|
@@ -20,10 +20,10 @@ module TestProf
|
|
20
20
|
msgs <<
|
21
21
|
<<~MSG
|
22
22
|
EventProf results for #{result["event"]}
|
23
|
-
|
23
|
+
|
24
24
|
Total time: #{result["total_time"].duration} of #{result["absolute_run_time"].duration} (#{result["time_percentage"]}%)
|
25
25
|
Total events: #{result["total_count"]}
|
26
|
-
|
26
|
+
|
27
27
|
Top #{result["top_count"]} slowest suites (by #{result["rank_by"]}):
|
28
28
|
MSG
|
29
29
|
|
@@ -25,6 +25,22 @@ module TestProf
|
|
25
25
|
def paths
|
26
26
|
@raw_report["groups"].reduce("") { |paths, group| "#{paths} #{group["location"]}" }.strip
|
27
27
|
end
|
28
|
+
|
29
|
+
def merge(other)
|
30
|
+
raise ArgumentError, "Incompatible events: #{raw_report["event"]} and #{other.raw_report["event"]}" if raw_report["event"] != other.raw_report["event"]
|
31
|
+
|
32
|
+
report = raw_report.dup
|
33
|
+
|
34
|
+
%w[total_time absolute_run_time total_count].each do |field|
|
35
|
+
report[field] += other.raw_report[field]
|
36
|
+
end
|
37
|
+
|
38
|
+
report["time_percentage"] = (report["total_time"] / report["absolute_run_time"]) * 100
|
39
|
+
|
40
|
+
report["groups"] = (report["groups"] + other.raw_report["groups"]).sort { |a, b| b["time"] <=> a["time"] }.take(report["top_count"])
|
41
|
+
|
42
|
+
Report.new(report)
|
43
|
+
end
|
28
44
|
end
|
29
45
|
end
|
30
46
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_prof/autopilot/report_writer"
|
4
|
+
|
5
|
+
module TestProf
|
6
|
+
module Autopilot
|
7
|
+
module EventProf
|
8
|
+
# Class is used for writing :event_prof report in different formats
|
9
|
+
class Writer < ReportWriter
|
10
|
+
Registry.register(:event_prof_writer, self)
|
11
|
+
|
12
|
+
ARTIFACT_FILE = "event_prof_report"
|
13
|
+
|
14
|
+
def generate_json
|
15
|
+
JSON.generate(report.raw_report)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TestProf
|
4
|
+
module Autopilot
|
5
|
+
module FactoryProf
|
6
|
+
# Module is used for writing :factory_prof report in different formats
|
7
|
+
module Writer
|
8
|
+
Registry.register(:factory_prof_writer, self)
|
9
|
+
|
10
|
+
ARTIFACT_FILE = "factory_prof_report"
|
11
|
+
|
12
|
+
def write_report(report, file_name: ARTIFACT_FILE)
|
13
|
+
dir_path = FileUtils.mkdir_p(Autopilot.config.artifacts_dir)[0]
|
14
|
+
file_path = File.join(dir_path, file_name + ".json")
|
15
|
+
|
16
|
+
File.write(file_path, JSON.generate(report.raw_report))
|
17
|
+
|
18
|
+
Logging.log "FactoryProf report saved: #{file_path}"
|
19
|
+
end
|
20
|
+
|
21
|
+
module_function :write_report
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_prof/autopilot/configuration"
|
4
|
+
require "test_prof/autopilot/registry"
|
5
|
+
require "test_prof/autopilot/logging"
|
6
|
+
require "test_prof/autopilot/dsl"
|
7
|
+
require "fileutils"
|
8
|
+
|
9
|
+
module TestProf
|
10
|
+
module Autopilot
|
11
|
+
class Merger
|
12
|
+
prepend Dsl
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def invoke(type, paths)
|
16
|
+
Logging.log "Merging #{type} reports at #{paths.join(", ")}..."
|
17
|
+
|
18
|
+
paths = paths.flat_map(&Dir.method(:glob))
|
19
|
+
|
20
|
+
new(type, paths).print_report
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_reader :type, :report_class, :paths
|
25
|
+
|
26
|
+
def initialize(type, paths)
|
27
|
+
@type = type
|
28
|
+
@paths = paths
|
29
|
+
@report_class = Registry.fetch(:"#{type}_report")
|
30
|
+
end
|
31
|
+
|
32
|
+
def print_report
|
33
|
+
format = Autopilot.config.merge_format
|
34
|
+
if format == "info"
|
35
|
+
info agg_report
|
36
|
+
else
|
37
|
+
save agg_report, format: format, file_name: Autopilot.config.merge_file
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def agg_report
|
44
|
+
return @agg_report if instance_variable_defined?(:@agg_report)
|
45
|
+
|
46
|
+
initial = report_class.new(JSON.parse(File.read(paths.pop)))
|
47
|
+
|
48
|
+
paths.reduce(initial) do |acc, path|
|
49
|
+
report = report_class.new(JSON.parse(File.read(path)))
|
50
|
+
|
51
|
+
acc.merge(report)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -36,7 +36,7 @@ module TestProf
|
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
39
|
-
dir_path = FileUtils.mkdir_p(
|
39
|
+
dir_path = FileUtils.mkdir_p(Autopilot.config.tmp_dir)[0]
|
40
40
|
file_path = File.join(dir_path, ARTIFACT_FILE)
|
41
41
|
|
42
42
|
File.write(file_path, JSON.generate(profiler_hash))
|
@@ -27,7 +27,29 @@ module TestProf
|
|
27
27
|
}
|
28
28
|
end
|
29
29
|
|
30
|
-
dir_path = FileUtils.mkdir_p(
|
30
|
+
dir_path = FileUtils.mkdir_p(Autopilot.config.tmp_dir)[0]
|
31
|
+
file_path = File.join(dir_path, ARTIFACT_FILE)
|
32
|
+
|
33
|
+
File.write(file_path, JSON.generate(profiler_hash))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
TestProf::FactoryProf::Printers::Flamegraph.module_eval do
|
38
|
+
def self.dump(result, **)
|
39
|
+
profiler_hash =
|
40
|
+
if result.raw_stats == {}
|
41
|
+
{
|
42
|
+
error: "No factories detected"
|
43
|
+
}
|
44
|
+
else
|
45
|
+
{
|
46
|
+
total_stacks: result.stacks.size,
|
47
|
+
total: result.total_count,
|
48
|
+
roots: convert_stacks(result)
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
dir_path = FileUtils.mkdir_p(Autopilot.config.tmp_dir)[0]
|
31
53
|
file_path = File.join(dir_path, ARTIFACT_FILE)
|
32
54
|
|
33
55
|
File.write(file_path, JSON.generate(profiler_hash))
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TestProf
|
4
|
+
module Autopilot
|
5
|
+
module Patches
|
6
|
+
# Monkey-patch for 'TestProf::TagProf::RSpecListener'.
|
7
|
+
# Redefined 'report' method provides writing artifact to the directory
|
8
|
+
# instead of printing report
|
9
|
+
module TagProfPatch
|
10
|
+
ARTIFACT_FILE = "tag_prof_report.json"
|
11
|
+
|
12
|
+
def patch
|
13
|
+
TestProf::TagProf::RSpecListener.class_eval do
|
14
|
+
def report
|
15
|
+
dir_path = FileUtils.mkdir_p(Autopilot.config.tmp_dir)[0]
|
16
|
+
file_path = File.join(dir_path, ARTIFACT_FILE)
|
17
|
+
|
18
|
+
File.write(file_path, result.to_json)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module_function :patch
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
TestProf::Autopilot::Patches::TagProfPatch.patch
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "test_prof/autopilot/command_executor"
|
4
4
|
require "test_prof/autopilot/event_prof/report"
|
5
|
+
require "test_prof/autopilot/tag_prof/report"
|
5
6
|
require "test_prof/autopilot/factory_prof/report"
|
6
7
|
require "test_prof/autopilot/stack_prof/report"
|
7
8
|
|
@@ -47,9 +48,9 @@ module TestProf
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def build_command
|
50
|
-
return
|
51
|
+
return Autopilot.config.command if @options[:paths].nil?
|
51
52
|
|
52
|
-
"#{
|
53
|
+
"#{Autopilot.config.command} #{@options[:paths]}"
|
53
54
|
end
|
54
55
|
|
55
56
|
def build_report
|
@@ -15,7 +15,7 @@ module TestProf
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def fetch_report
|
18
|
-
file_path = File.join(
|
18
|
+
file_path = File.join(Autopilot.config.tmp_dir, self::ARTIFACT_FILE)
|
19
19
|
File.read(file_path)
|
20
20
|
rescue Errno::ENOENT => e
|
21
21
|
e.message.prepend(ARTIFACT_MISSING_HINT)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TestProf
|
4
|
+
module Autopilot
|
5
|
+
# Base class for report writers classes
|
6
|
+
class ReportWriter
|
7
|
+
include Logging
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def write_report(report, **options)
|
11
|
+
new(report).write(**options)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :report
|
16
|
+
|
17
|
+
def initialize(report)
|
18
|
+
@report = report
|
19
|
+
end
|
20
|
+
|
21
|
+
def write(file_name: nil, format: "json")
|
22
|
+
file_path = file_name || self.class::ARTIFACT_FILE
|
23
|
+
|
24
|
+
if File.absolute_path?(file_path)
|
25
|
+
FileUtils.mkdir_p(File.dirname(file_path))
|
26
|
+
else
|
27
|
+
dir_path = FileUtils.mkdir_p(Autopilot.config.artifacts_dir)[0]
|
28
|
+
file_path = File.join(dir_path, file_path + ".#{format}")
|
29
|
+
end
|
30
|
+
|
31
|
+
File.write(file_path, public_send("generate_#{format}"))
|
32
|
+
|
33
|
+
log "Report saved: #{file_path}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def generate_json
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -15,14 +15,14 @@ module TestProf
|
|
15
15
|
|
16
16
|
class << self
|
17
17
|
def invoke(plan_path, command)
|
18
|
-
|
18
|
+
Autopilot.configure do |config|
|
19
19
|
config.plan_path = plan_path
|
20
20
|
config.command = command
|
21
21
|
end
|
22
22
|
|
23
23
|
Logging.log "Reading #{plan_path}..."
|
24
24
|
|
25
|
-
new.instance_eval(File.read(
|
25
|
+
new.instance_eval(File.read(Autopilot.config.plan_path))
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -1,22 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "test_prof/autopilot/report_writer"
|
4
|
+
|
3
5
|
module TestProf
|
4
6
|
module Autopilot
|
5
7
|
module StackProf
|
6
|
-
#
|
7
|
-
|
8
|
+
# Class is used for writing :stack_prof report in different formats
|
9
|
+
class Writer < ReportWriter
|
8
10
|
Registry.register(:stack_prof_writer, self)
|
9
11
|
|
10
12
|
ARTIFACT_FILE = "stack_prof_report"
|
11
13
|
|
12
|
-
def
|
13
|
-
|
14
|
-
file_path = File.join(dir_path, file_name + ".json")
|
15
|
-
|
16
|
-
File.write(file_path, JSON.generate(report.data))
|
14
|
+
def generate_json
|
15
|
+
JSON.generate(report.data)
|
17
16
|
end
|
18
|
-
|
19
|
-
module_function :write_report
|
20
17
|
end
|
21
18
|
end
|
22
19
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_prof"
|
4
|
+
require "test_prof/tag_prof/printers/simple"
|
5
|
+
|
6
|
+
module TestProf
|
7
|
+
module Autopilot
|
8
|
+
module TagProf
|
9
|
+
# Module is used for printing :tag_prof report
|
10
|
+
module Printer
|
11
|
+
Registry.register(:tag_prof_printer, self)
|
12
|
+
|
13
|
+
def print_report(report)
|
14
|
+
TestProf::TagProf::Printers::Simple.dump(report.result)
|
15
|
+
end
|
16
|
+
|
17
|
+
module_function :print_report
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_prof/autopilot/profiling_executor/base"
|
4
|
+
|
5
|
+
module TestProf
|
6
|
+
module Autopilot
|
7
|
+
module TagProf
|
8
|
+
# Provides :tag_prof specific validations, env and command building.
|
9
|
+
class ProfilingExecutor < ProfilingExecutor::Base
|
10
|
+
Registry.register(:tag_prof_executor, self)
|
11
|
+
|
12
|
+
def initialize(options)
|
13
|
+
super
|
14
|
+
@profiler = :tag_prof
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def validate_profiler!
|
20
|
+
super
|
21
|
+
@options[:event] = @options[:events].join(",") if @options[:events]
|
22
|
+
@options[:tag] ||= "type"
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_env
|
26
|
+
super.tap do |env|
|
27
|
+
env["TAG_PROF"] = @options[:tag]
|
28
|
+
env["TAG_PROF_EVENT"] = @options[:event] if @options[:event]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "test_prof/autopilot/report_builder"
|
5
|
+
require "test_prof/tag_prof/result"
|
6
|
+
|
7
|
+
module TestProf
|
8
|
+
module Autopilot
|
9
|
+
module TagProf
|
10
|
+
# :tag_prof report allows to add additional functionality
|
11
|
+
# for it's instances
|
12
|
+
class Report
|
13
|
+
Registry.register(:tag_prof_report, self)
|
14
|
+
|
15
|
+
extend ReportBuilder
|
16
|
+
|
17
|
+
ARTIFACT_FILE = "tag_prof_report.json"
|
18
|
+
|
19
|
+
SYMBOLIC_DATA_KEYS = %w[value count time].freeze
|
20
|
+
|
21
|
+
attr_reader :type, :raw_report
|
22
|
+
|
23
|
+
def initialize(raw_report)
|
24
|
+
@type = :tag_prof
|
25
|
+
@raw_report = raw_report
|
26
|
+
end
|
27
|
+
|
28
|
+
def result
|
29
|
+
@result ||= TestProf::TagProf::Result.new(raw_report["tag"], raw_report["events"]).tap do |result|
|
30
|
+
raw_report["data"].each do |tag_data|
|
31
|
+
result.data[tag_data["value"]] = tag_data.transform_keys do |key|
|
32
|
+
SYMBOLIC_DATA_KEYS.include?(key) ? key.to_sym : key
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def merge(other)
|
39
|
+
raise ArgumentError, "Tags must be identical: #{raw_report["tag"]} and #{other.raw_report["tag"]}" unless raw_report["tag"] == other.raw_report["tag"]
|
40
|
+
|
41
|
+
new_report = raw_report.dup
|
42
|
+
|
43
|
+
(raw_report["data"] + other.raw_report["data"]).each_with_object({}) do |tag_data, acc|
|
44
|
+
if acc.key?(tag_data["value"])
|
45
|
+
el = acc[tag_data["value"]]
|
46
|
+
tag_data.each do |field, val|
|
47
|
+
next if field == "value"
|
48
|
+
next unless el.key?(field)
|
49
|
+
|
50
|
+
el[field] += val
|
51
|
+
end
|
52
|
+
else
|
53
|
+
acc[tag_data["value"]] = tag_data.dup
|
54
|
+
end
|
55
|
+
end.then do |new_data|
|
56
|
+
new_report["data"] = new_data.values
|
57
|
+
end
|
58
|
+
|
59
|
+
Report.new(new_report)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "test_prof/autopilot/report_writer"
|
4
|
+
require "test_prof/tag_prof/printers/html"
|
5
|
+
|
6
|
+
module TestProf
|
7
|
+
module Autopilot
|
8
|
+
module TagProf
|
9
|
+
# Class is used for writing :tag_prof report in different formats
|
10
|
+
class Writer < ReportWriter
|
11
|
+
Registry.register(:tag_prof_writer, self)
|
12
|
+
|
13
|
+
ARTIFACT_FILE = "tag_prof_report"
|
14
|
+
|
15
|
+
def generate_json
|
16
|
+
report.result.to_json
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_html
|
20
|
+
path = TestProf::Utils::HTMLBuilder.generate(
|
21
|
+
data: report.result,
|
22
|
+
template: TestProf::TagProf::Printers::HTML::TEMPLATE,
|
23
|
+
output: TestProf::TagProf::Printers::HTML::OUTPUT_NAME
|
24
|
+
)
|
25
|
+
|
26
|
+
File.read(path).tap do
|
27
|
+
FileUtils.rm(path)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/test_prof/autopilot.rb
CHANGED
@@ -3,5 +3,6 @@
|
|
3
3
|
require "test-prof"
|
4
4
|
require "test_prof/autopilot/configuration"
|
5
5
|
require "test_prof/autopilot/patches/event_prof_patch"
|
6
|
+
require "test_prof/autopilot/patches/tag_prof_patch"
|
6
7
|
require "test_prof/autopilot/patches/factory_prof_patch"
|
7
8
|
require "test_prof/autopilot/patches/stack_prof_patch"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-prof-autopilot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Shakirov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-06-
|
12
|
+
date: 2022-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: test-prof
|
@@ -26,61 +26,61 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: bundler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
35
|
-
type: :
|
34
|
+
version: '1.15'
|
35
|
+
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: '1.15'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: rake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '13.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '13.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '3.10'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '3.10'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: stackprof
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 0.2.9
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: 0.2.9
|
84
84
|
description: Automatic TestProf runner
|
85
85
|
email:
|
86
86
|
- ruslan@shakirov.dev
|
@@ -103,21 +103,30 @@ files:
|
|
103
103
|
- lib/test_prof/autopilot/event_prof/printer.rb
|
104
104
|
- lib/test_prof/autopilot/event_prof/profiling_executor.rb
|
105
105
|
- lib/test_prof/autopilot/event_prof/report.rb
|
106
|
+
- lib/test_prof/autopilot/event_prof/writer.rb
|
106
107
|
- lib/test_prof/autopilot/factory_prof/printer.rb
|
107
108
|
- lib/test_prof/autopilot/factory_prof/profiling_executor.rb
|
108
109
|
- lib/test_prof/autopilot/factory_prof/report.rb
|
110
|
+
- lib/test_prof/autopilot/factory_prof/writer.rb
|
109
111
|
- lib/test_prof/autopilot/logging.rb
|
112
|
+
- lib/test_prof/autopilot/merger.rb
|
110
113
|
- lib/test_prof/autopilot/patches/event_prof_patch.rb
|
111
114
|
- lib/test_prof/autopilot/patches/factory_prof_patch.rb
|
112
115
|
- lib/test_prof/autopilot/patches/stack_prof_patch.rb
|
116
|
+
- lib/test_prof/autopilot/patches/tag_prof_patch.rb
|
113
117
|
- lib/test_prof/autopilot/profiling_executor/base.rb
|
114
118
|
- lib/test_prof/autopilot/registry.rb
|
115
119
|
- lib/test_prof/autopilot/report_builder.rb
|
120
|
+
- lib/test_prof/autopilot/report_writer.rb
|
116
121
|
- lib/test_prof/autopilot/runner.rb
|
117
122
|
- lib/test_prof/autopilot/stack_prof/printer.rb
|
118
123
|
- lib/test_prof/autopilot/stack_prof/profiling_executor.rb
|
119
124
|
- lib/test_prof/autopilot/stack_prof/report.rb
|
120
125
|
- lib/test_prof/autopilot/stack_prof/writer.rb
|
126
|
+
- lib/test_prof/autopilot/tag_prof/printer.rb
|
127
|
+
- lib/test_prof/autopilot/tag_prof/profiling_executor.rb
|
128
|
+
- lib/test_prof/autopilot/tag_prof/report.rb
|
129
|
+
- lib/test_prof/autopilot/tag_prof/writer.rb
|
121
130
|
- lib/test_prof/autopilot/version.rb
|
122
131
|
homepage: http://github.com/test-prof/test-prof-autopilot
|
123
132
|
licenses:
|
@@ -131,14 +140,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
140
|
requirements:
|
132
141
|
- - ">="
|
133
142
|
- !ruby/object:Gem::Version
|
134
|
-
version: '2.
|
143
|
+
version: '2.7'
|
135
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
145
|
requirements:
|
137
146
|
- - ">="
|
138
147
|
- !ruby/object:Gem::Version
|
139
148
|
version: '0'
|
140
149
|
requirements: []
|
141
|
-
rubygems_version: 3.3.
|
150
|
+
rubygems_version: 3.3.7
|
142
151
|
signing_key:
|
143
152
|
specification_version: 4
|
144
153
|
summary: Automatic TestProf runner
|