gitlab_quality-test_tooling 0.9.0 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9bcb8c6202edb63313039592fdf1a6c953c0b43db4566d9e84105e31d2029d3
4
- data.tar.gz: 27dcc6d668da50a3ec76bd13b8898d61b24bbe2835faeee6fc6dbce684945388
3
+ metadata.gz: 4705c9599c4ff8fdad916cf3eb3ee62e4701f384fa76a8b8f358249c3f630142
4
+ data.tar.gz: c45ec5e61bac03819dec93d345577b8577f7279d4d0c8c6a1744d7d74e3bceb5
5
5
  SHA512:
6
- metadata.gz: cd3003fced80af3cd8ebafa3495d799eb63756b659b4c6e002c27557ea84beb3ec4bba1bbb08784cf27fe74ab6f4d1c6eb2ed7888fdbf317209683475247310b
7
- data.tar.gz: 579e87d66fa4107263220501f4959e3b08b0dbb887224ecb11917a69e5d6774e9cfdd2298d62a20992bc27b7b4be3f561e35574f599a4cbb165230331261e9c5
6
+ metadata.gz: 481900a88510d1b00a597209fc2e007d963d7a9defeb143ba96d9ecd8ee5bc4a60b5c50ca54b2613108cc41ae0212d7145edf5235f9fff01b40f1ba4ac7691fa
7
+ data.tar.gz: 70c9094e72cd9c4f7651390747eff6cf4f1ac3942a6c79ac5947a9b58cf8d30eaa983268de73de33c45b9697a3e8e29d8871e1498e4e2a64468df21ea6caa0e4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (0.9.0)
4
+ gitlab_quality-test_tooling (0.9.2)
5
5
  activesupport (>= 6.1, < 7.1)
6
6
  gitlab (~> 4.19)
7
7
  http (~> 5.0)
@@ -176,12 +176,10 @@ module GitlabQuality
176
176
  end
177
177
 
178
178
  def full_stacktrace(test)
179
- first_failure = test.failures.first
179
+ test.failures.each do |failure|
180
+ next if IGNORED_FAILURES.any? { |e| failure['message'].include?(e) }
180
181
 
181
- if first_failure['message_lines'].empty?
182
- first_failure['message']
183
- else
184
- first_failure['message_lines'].join("\n")
182
+ return failure['message_lines'].empty? ? failure['message'] : failure['message_lines'].join("\n")
185
183
  end
186
184
  end
187
185
 
@@ -193,9 +191,9 @@ module GitlabQuality
193
191
  end
194
192
 
195
193
  def cleaned_stacktrace_from_test(test)
196
- first_test_failure_stacktrace = sanitize_stacktrace(full_stacktrace(test),
194
+ test_failure_stacktrace = sanitize_stacktrace(full_stacktrace(test),
197
195
  FAILURE_STACKTRACE_REGEX) || full_stacktrace(test)
198
- remove_unique_resource_names(first_test_failure_stacktrace)
196
+ remove_unique_resource_names(test_failure_stacktrace)
199
197
  end
200
198
 
201
199
  def compare_stack_traces(stack_trace_first, stack_trace_second)
@@ -10,6 +10,17 @@ module GitlabQuality
10
10
 
11
11
  FILE_BASE_URL = "https://gitlab.com/gitlab-org/gitlab/-/blob/master/"
12
12
 
13
+ OTHER_TESTS_MAX_DURATION = 45.40 # seconds
14
+
15
+ TestLevelSpecification = Struct.new(:regex, :max_duration)
16
+
17
+ TEST_LEVEL_SPECIFICATIONS = [
18
+ TestLevelSpecification.new(%r{spec/features/}, 50.13),
19
+ TestLevelSpecification.new(%r{spec/(controllers|requests)/}, 19.20),
20
+ TestLevelSpecification.new(%r{spec/lib/}, 27.12),
21
+ TestLevelSpecification.new(%r{qa/specs/features/}, 240)
22
+ ].freeze
23
+
13
24
  def initialize(token:, input_files:, project: nil, dry_run: false, **_kwargs)
14
25
  @project = project
15
26
  @gitlab = (dry_run ? GitlabIssueDryClient : GitlabIssueClient).new(token: token, project: project)
@@ -42,7 +53,10 @@ module GitlabQuality
42
53
  | ------ | ------ |
43
54
  | File | #{test_file_link(test)} |
44
55
  | Description | `#{test.name}` |
56
+ | Test level | #{test.level} |
45
57
  | Hash | `#{test_hash(test)}` |
58
+ | Duration | #{test.run_time} seconds |
59
+ | Expected duration | < #{max_duration_for_test(test)} seconds |
46
60
  #{"| Test case | #{test.testcase} |" if test.testcase}
47
61
  DESCRIPTION
48
62
  end
@@ -50,7 +64,7 @@ module GitlabQuality
50
64
  def test_file_link(test)
51
65
  path_prefix = test.file.start_with?('qa/') ? 'qa/' : ''
52
66
 
53
- "[`#{path_prefix}#{test.file}`](#{FILE_BASE_URL}#{path_prefix}#{test.file}#L#{test.line_number})"
67
+ "[`#{path_prefix}#{test.file}#L#{test.line_number}`](#{FILE_BASE_URL}#{path_prefix}#{test.file}#L#{test.line_number})"
54
68
  end
55
69
 
56
70
  def new_issue_labels(_test)
@@ -155,6 +169,15 @@ module GitlabQuality
155
169
  def ee_test?(test)
156
170
  test.file =~ %r{features/ee/(api|browser_ui)}
157
171
  end
172
+
173
+ def max_duration_for_test(test)
174
+ test_level_specification = TEST_LEVEL_SPECIFICATIONS.find do |test_level_specification|
175
+ test.example_id =~ test_level_specification.regex
176
+ end
177
+ return OTHER_TESTS_MAX_DURATION unless test_level_specification
178
+
179
+ test_level_specification.max_duration
180
+ end
158
181
  end
159
182
  end
160
183
  end
@@ -13,21 +13,11 @@ module GitlabQuality
13
13
  include Concerns::FindSetDri
14
14
  include Concerns::GroupAndCategoryLabels
15
15
 
16
- NEW_ISSUE_LABELS = Set.new(%w[test type::maintenance maintenance::performance priority::3 severity::3]).freeze
16
+ NEW_ISSUE_LABELS = Set.new(['test', 'type::maintenance', 'maintenance::performance', 'priority::3', 'severity::3', 'rspec profiling', 'rspec:slow test']).freeze
17
17
  SEARCH_LABELS = %w[test maintenance::performance].freeze
18
18
 
19
19
  MultipleIssuesFound = Class.new(StandardError)
20
20
 
21
- TestLevelSpecification = Struct.new(:regex, :max_duration)
22
-
23
- OTHER_TESTS_MAX_DURATION = 45.40 # seconds
24
-
25
- TEST_LEVEL_SPECIFICATIONS = [
26
- TestLevelSpecification.new(%r{/features/}, 50.13),
27
- TestLevelSpecification.new(%r{/controllers|requests/}, 19.20),
28
- TestLevelSpecification.new(%r{/lib/}, 27.12)
29
- ].freeze
30
-
31
21
  private
32
22
 
33
23
  def run!
@@ -47,13 +37,11 @@ module GitlabQuality
47
37
  end
48
38
 
49
39
  def new_issue_description(test)
50
- super + [
51
- "\n### Slow test",
52
- "Slow tests detected, see guides for more details and how to improve them:",
53
- "- [Top slow tests](https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#top-slow-tests)",
54
- "- [Test speed](https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#test-speed)",
55
- "**Duration**: #{test.run_time} seconds"
56
- ].compact.join("\n\n")
40
+ super +
41
+ <<~DESCRIPTION
42
+ Slow tests were detected, please see the [test speed best practices guide](https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#test-speed)
43
+ to improve them. More context available about this issue in the [top slow tests guide](https://docs.gitlab.com/ee/development/testing_guide/best_practices.html#top-slow-tests).
44
+ DESCRIPTION
57
45
  end
58
46
 
59
47
  def create_slow_issue(test)
@@ -73,15 +61,6 @@ module GitlabQuality
73
61
  def should_create_slow_issue?(test)
74
62
  test.run_time > max_duration_for_test(test)
75
63
  end
76
-
77
- def max_duration_for_test(test)
78
- test_level_specification = TEST_LEVEL_SPECIFICATIONS.find do |test_level_specification|
79
- test.example_id =~ test_level_specification.regex
80
- end
81
- return OTHER_TESTS_MAX_DURATION unless test_level_specification
82
-
83
- test_level_specification.max_duration
84
- end
85
64
  end
86
65
  end
87
66
  end
@@ -89,6 +89,10 @@ module GitlabQuality
89
89
  report['line_number']
90
90
  end
91
91
 
92
+ def level
93
+ report['level']
94
+ end
95
+
92
96
  def failures # rubocop:disable Metrics/AbcSize
93
97
  @failures ||=
94
98
  report.fetch('exceptions', []).filter_map do |exception|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "0.9.0"
5
+ VERSION = "0.9.2"
6
6
  end
7
7
  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: 0.9.0
4
+ version: 0.9.2
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-07-05 00:00:00.000000000 Z
11
+ date: 2023-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control