gitlab_quality-test_tooling 1.7.0 → 1.8.0
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/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/exe/relate-failure-issue +4 -0
- data/lib/gitlab_quality/test_tooling/report/relate_failure_issue.rb +26 -1
- data/lib/gitlab_quality/test_tooling/test_metric/json_test_metric.rb +46 -0
- data/lib/gitlab_quality/test_tooling/test_metrics/json_test_metric_collection.rb +45 -0
- data/lib/gitlab_quality/test_tooling/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ee3407afd5274be75c1bb63c7f7aeeb0d2353cf62f0fb75c1393bd2103c8c1e
|
4
|
+
data.tar.gz: a4965dd9d979a58c4202c6f25315d60e08d597d51322db491a077a0ae797cf34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1619807ec2456f02c9d4a1c09dfb0aeba598de7d51fe7a0377c1e5a9f3f9fc82cf607fa34387bb5ee1691ad28b5637e75c18c38ce068269c3bba76e3c902df22
|
7
|
+
data.tar.gz: '0940057d402dfb8fbcd3a6d2d09f7ff698e26d140ebdda659fcc5347445574fa7f398b2bd91e8a39c872b0f8a9f368fa1f734e59e10262790ed2d507fb97e514'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -77,6 +77,8 @@ Usage: exe/prepare-stage-reports [options]
|
|
77
77
|
Purpose: Relate test failures to failure issues from RSpec report files (JSON or JUnit XML)
|
78
78
|
Usage: exe/relate-failure-issue [options]
|
79
79
|
-i, --input-files INPUT_FILES RSpec report files (JSON or JUnit XML)
|
80
|
+
-m METRICS_FILES, Test metrics files (JSON)
|
81
|
+
--metrics-files
|
80
82
|
--max-diff-ratio MAX_DIFF_RATO
|
81
83
|
Max stacktrace diff ratio for failure issues detection
|
82
84
|
-p, --project PROJECT Can be an integer or a group/project string
|
data/exe/relate-failure-issue
CHANGED
@@ -15,6 +15,10 @@ options = OptionParser.new do |opts|
|
|
15
15
|
params[:input_files] = input_files
|
16
16
|
end
|
17
17
|
|
18
|
+
opts.on('-m', '--metrics-files METRICS_FILES', String, 'Test metrics files (JSON)') do |metrics_files|
|
19
|
+
params[:metrics_files] = metrics_files
|
20
|
+
end
|
21
|
+
|
18
22
|
opts.on('--max-diff-ratio MAX_DIFF_RATO', Float, 'Max stacktrace diff ratio for failure issues detection') do |max_diff_ratio|
|
19
23
|
params[:max_diff_ratio] = max_diff_ratio
|
20
24
|
end
|
@@ -41,6 +41,7 @@ module GitlabQuality
|
|
41
41
|
system_logs: [],
|
42
42
|
base_issue_labels: nil,
|
43
43
|
exclude_labels_for_search: nil,
|
44
|
+
metrics_files: [],
|
44
45
|
**kwargs)
|
45
46
|
super
|
46
47
|
@max_diff_ratio = max_diff_ratio.to_f
|
@@ -49,11 +50,12 @@ module GitlabQuality
|
|
49
50
|
@exclude_labels_for_search = Set.new(exclude_labels_for_search)
|
50
51
|
@issue_type = 'issue'
|
51
52
|
@commented_issue_list = Set.new
|
53
|
+
@metrics_files = Array(metrics_files)
|
52
54
|
end
|
53
55
|
|
54
56
|
private
|
55
57
|
|
56
|
-
attr_reader :max_diff_ratio, :system_logs, :base_issue_labels, :exclude_labels_for_search
|
58
|
+
attr_reader :max_diff_ratio, :system_logs, :base_issue_labels, :exclude_labels_for_search, :metrics_files
|
57
59
|
|
58
60
|
def run!
|
59
61
|
puts "Reporting test failures in `#{files.join(',')}` as issues in project `#{project}` via the API at `#{Runtime::Env.gitlab_api_base}`."
|
@@ -66,16 +68,39 @@ module GitlabQuality
|
|
66
68
|
write_issues_log_file
|
67
69
|
end
|
68
70
|
|
71
|
+
def test_metric_collections
|
72
|
+
@test_metric_collections ||= Dir.glob(metrics_files).map do |path|
|
73
|
+
TestMetrics::JsonTestMetricCollection.new(path)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
69
77
|
def process_test_results(test_results)
|
70
78
|
systemic_failures = systemic_failures_for_test_results(test_results)
|
71
79
|
|
72
80
|
test_results.each do |test|
|
73
81
|
collect_issues(test, relate_failure_to_issue(test)) if should_report?(test, systemic_failures)
|
82
|
+
|
83
|
+
copy_failure_issue_to_test_metrics(test) if metrics_files.any?
|
74
84
|
end
|
75
85
|
|
76
86
|
test_results.write
|
77
87
|
end
|
78
88
|
|
89
|
+
def copy_failure_issue_to_test_metrics(test)
|
90
|
+
failure_issue = test.failure_issue
|
91
|
+
|
92
|
+
return unless failure_issue
|
93
|
+
|
94
|
+
test_metric_collections.find do |test_metric_collection|
|
95
|
+
test_metric = test_metric_collection.metric_for_test_id(test.example_id)
|
96
|
+
|
97
|
+
if test_metric
|
98
|
+
test_metric.fields['failure_issue'] = failure_issue
|
99
|
+
test_metric_collection.write
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
79
104
|
def systemic_failures_for_test_results(test_results)
|
80
105
|
test_results
|
81
106
|
.flat_map { |test| test.failures.map { |failure| failure['message'].lines.first.chomp } }
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GitlabQuality
|
4
|
+
module TestTooling
|
5
|
+
module TestMetric
|
6
|
+
class JsonTestMetric
|
7
|
+
attr_reader :metric
|
8
|
+
|
9
|
+
def initialize(metric)
|
10
|
+
@metric = metric
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
metric.fetch('name')
|
15
|
+
end
|
16
|
+
|
17
|
+
def time
|
18
|
+
metric.fetch('time')
|
19
|
+
end
|
20
|
+
|
21
|
+
def tags
|
22
|
+
@tags ||= metric.fetch('tags')
|
23
|
+
end
|
24
|
+
|
25
|
+
def fields
|
26
|
+
@fields ||= metric.fetch('fields')
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_json(*options)
|
30
|
+
as_json.to_json(*options)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def as_json
|
36
|
+
{
|
37
|
+
name: name,
|
38
|
+
time: time,
|
39
|
+
tags: tags,
|
40
|
+
fields: fields
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module GitlabQuality
|
6
|
+
module TestTooling
|
7
|
+
module TestMetrics
|
8
|
+
class JsonTestMetricCollection
|
9
|
+
include Enumerable
|
10
|
+
|
11
|
+
attr_reader :path, :metrics
|
12
|
+
|
13
|
+
def initialize(path)
|
14
|
+
@path = path
|
15
|
+
@metrics = process
|
16
|
+
end
|
17
|
+
|
18
|
+
def metric_for_test_id(test_id)
|
19
|
+
metrics.find do |metric|
|
20
|
+
metric.fields['id'] == test_id
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def write
|
25
|
+
File.write(path, JSON.pretty_generate(metrics))
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def parse
|
31
|
+
JSON.parse(File.read(path))
|
32
|
+
rescue JSON::ParserError
|
33
|
+
Runtime::Logger.debug("#{self.class.name}##{__method__} attempted to parse invalid JSON at path: #{path}")
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
|
37
|
+
def process
|
38
|
+
parse.map do |test|
|
39
|
+
GitlabQuality::TestTooling::TestMetric::JsonTestMetric.new(test)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab_quality-test_tooling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab Quality
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|
@@ -422,6 +422,8 @@ files:
|
|
422
422
|
- lib/gitlab_quality/test_tooling/system_logs/log_types/rails/graphql_log.rb
|
423
423
|
- lib/gitlab_quality/test_tooling/system_logs/shared_fields.rb
|
424
424
|
- lib/gitlab_quality/test_tooling/system_logs/system_logs_formatter.rb
|
425
|
+
- lib/gitlab_quality/test_tooling/test_metric/json_test_metric.rb
|
426
|
+
- lib/gitlab_quality/test_tooling/test_metrics/json_test_metric_collection.rb
|
425
427
|
- lib/gitlab_quality/test_tooling/test_result/base_test_result.rb
|
426
428
|
- lib/gitlab_quality/test_tooling/test_result/j_unit_test_result.rb
|
427
429
|
- lib/gitlab_quality/test_tooling/test_result/json_test_result.rb
|