gitlab_quality-test_tooling 2.3.0 → 2.5.0

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: 349ae941a991eb8ad7c3c863cc0b840c84541d32ff742948bf06796be3b5263a
4
- data.tar.gz: f23b333320ea5b242d7bda47f895fa6d56c8c63f2206657353749980a7470b6e
3
+ metadata.gz: cd181fe7622793361cd772d2f949d1a8922f4b0762c2d50ae9f839fdfd69bb86
4
+ data.tar.gz: aaa900d8e19eff7ae0016bda52bf6dc3722aa4e4fe288f16c16d6685254c831a
5
5
  SHA512:
6
- metadata.gz: 489db862072fc1f574e35de9f5eae7c8adc0909a5c1c76d3e7d30d9f0c8633b9af0e5c0b7e26cc80802bf2ca8afb599ed151133ce1fb13b2fbe719a01a9e9ede
7
- data.tar.gz: 4cba020c783aabde06a85dc48bd68b95f97b5df9fbe0471ff85f7e1d7788912404a2e996a1a95b54e6d276fc0e1c48f7d9b6202fb6f3231f85e5a4bd0da85a29
6
+ metadata.gz: 5b5e1a85230726944574ec3c92c9fbe0e8a547776a6a7f7ce07d4db1889abf1a23b35a8b13b55d79eaf90eb3b7cfac4ec47960efa9eedaa509ffa02dd9655077
7
+ data.tar.gz: 47f438135b5ac5d4cc2cfc95a30e6a917f6de4c714bd8f42ed74c4d51439af925ac1424bf2105e71c76cd581f5faf287d8d0a415bf4c220df36df2fd85ec6149
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (2.3.0)
4
+ gitlab_quality-test_tooling (2.5.0)
5
5
  activesupport (>= 7.0, < 7.2)
6
6
  amatch (~> 0.4.1)
7
7
  fog-google (~> 1.24, >= 1.24.1)
@@ -7,6 +7,38 @@ module GitlabQuality
7
7
  class JobTraceAnalyzer
8
8
  attr_reader :project, :token, :job_id
9
9
 
10
+ FailureTraceDefinition = Struct.new(:type, :trace_start, :trace_end, :language, :label, keyword_init: true)
11
+ FAILURE_TRACE_DEFINITIONS = [
12
+ FailureTraceDefinition.new(
13
+ type: :rspec,
14
+ trace_start: "Failures:\n",
15
+ trace_end: "[TEST PROF INFO]",
16
+ language: :ruby,
17
+ label: '~backend'
18
+ ),
19
+ FailureTraceDefinition.new(
20
+ type: :jest,
21
+ trace_start: "Summary of all failing tests\n",
22
+ trace_end: "\nRan all test suites.",
23
+ language: :javascript,
24
+ label: '~frontend'
25
+ ),
26
+ FailureTraceDefinition.new(
27
+ type: :workhorse,
28
+ trace_start: "make: Entering directory '/builds/gitlab-org/gitlab/workhorse'",
29
+ trace_end: "make: Leaving directory '/builds/gitlab-org/gitlab/workhorse'",
30
+ language: :go,
31
+ label: '~workhorse'
32
+ ),
33
+ FailureTraceDefinition.new(
34
+ type: :rubocop,
35
+ trace_start: "Running RuboCop in graceful mode:",
36
+ trace_end: "section_end",
37
+ language: :ruby,
38
+ label: '~backend'
39
+ )
40
+ ].freeze
41
+
10
42
  TRANSIENT_ROOT_CAUSE_TO_TRACE_MAP =
11
43
  {
12
44
  failed_to_pull_image: ['job failed: failed to pull image'],
@@ -35,13 +67,16 @@ module GitlabQuality
35
67
  'segmentation fault',
36
68
  'no space left on device',
37
69
  'Check free disk space',
38
- 'CLUSTERDOWN'
70
+ 'CLUSTERDOWN',
71
+ 'Redis client could not fetch cluster information: Connection refused'
39
72
  ],
40
73
  flaky_test: [
41
74
  "We have detected a PG::QueryCanceled error in the specs, so we're failing early"
42
75
  ]
43
76
  }.freeze
44
77
 
78
+ AFTER_SCRIPT_TRACE_START_MARKER = 'Running after_script'
79
+
45
80
  def initialize(project:, token:, job_id:)
46
81
  @project = project
47
82
  @token = token
@@ -49,8 +84,10 @@ module GitlabQuality
49
84
  end
50
85
 
51
86
  def found_infrastructure_error?
87
+ trace_to_search = failure_summary || main_trace
88
+
52
89
  TRANSIENT_ROOT_CAUSE_TO_TRACE_MAP[:infrastructure].any? do |search_string|
53
- found = job_trace.downcase.include?(search_string.downcase)
90
+ found = trace_to_search.downcase.include?(search_string.downcase)
54
91
 
55
92
  puts "Found infrastructure error stacktrace: #{search_string}" if found
56
93
 
@@ -60,9 +97,35 @@ module GitlabQuality
60
97
 
61
98
  private
62
99
 
100
+ def detected_failure_trace_definition
101
+ return @detected_failure_trace_definition if defined?(@detected_failure_trace_definition)
102
+
103
+ @detected_failure_trace_definition = FAILURE_TRACE_DEFINITIONS.find do |failure_trace_definition|
104
+ job_trace.include?(failure_trace_definition.trace_start) &&
105
+ job_trace.include?(failure_trace_definition.trace_end)
106
+ end
107
+ end
108
+
63
109
  def job_trace
64
110
  @job_trace ||= GitlabClient::JobClient.new(project: project, token: token, job_id: job_id).job_trace
65
111
  end
112
+
113
+ def main_trace
114
+ return job_trace unless job_trace.include?(AFTER_SCRIPT_TRACE_START_MARKER)
115
+
116
+ job_trace.split(AFTER_SCRIPT_TRACE_START_MARKER).first
117
+ end
118
+
119
+ def failure_summary
120
+ return unless detected_failure_trace_definition
121
+
122
+ @failure_summary ||= main_trace
123
+ .split(detected_failure_trace_definition.trace_start)
124
+ .last
125
+ .split(detected_failure_trace_definition.trace_end)
126
+ .first
127
+ .chomp
128
+ end
66
129
  end
67
130
  end
68
131
  end
@@ -106,7 +106,7 @@ module GitlabQuality
106
106
  begin
107
107
  issue = find_issue_and_update_reports(test)
108
108
 
109
- issue = create_issue(test) unless issue || test.quarantine?
109
+ issue = create_issue(test) unless issue || (test.quarantine? && !test.conditional_quarantine?)
110
110
 
111
111
  issue
112
112
  rescue MultipleIssuesFound => e
@@ -100,6 +100,12 @@ module GitlabQuality
100
100
  !!quarantine
101
101
  end
102
102
 
103
+ def conditional_quarantine?
104
+ return true if quarantine? && quarantine.is_a?(Hash) && quarantine.has_key?('only')
105
+
106
+ false
107
+ end
108
+
103
109
  def file
104
110
  @file ||= relative_file.start_with?('qa/') ? "qa/#{relative_file}" : relative_file
105
111
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "2.3.0"
5
+ VERSION = "2.5.0"
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: 2.3.0
4
+ version: 2.5.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: 2024-11-28 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control