Class: GitlabQuality::TestTooling::Report::RelateFailureIssue

Inherits:
ReportAsIssue
  • Object
show all
Includes:
Amatch, Concerns::FindSetDri, Concerns::GroupAndCategoryLabels, Concerns::IssueReports
Defined in:
lib/gitlab_quality/test_tooling/report/relate_failure_issue.rb

Overview

Uses the API to create or update GitLab issues with the results of tests from RSpec report files.

  • Uses the API to create or update GitLab issues with the results of tests from RSpec report files.
  • Takes the JSON test run reports, e.g. $CI_PROJECT_DIR/gitlab-qa-run-*/**/rspec-*.json
  • Takes a project where failure issues should be created
  • Find issue by title (with test description or test file), then further filter by stack trace, then pick the better-matching one
  • Add the failed job to the issue description, and update labels

Constant Summary collapse

DEFAULT_MAX_DIFF_RATIO_FOR_DETECTION =
0.15
SYSTEMIC_EXCEPTIONS_THRESHOLD =
10
SPAM_THRESHOLD_FOR_FAILURE_ISSUES =
3
FAILURE_STACKTRACE_REGEX =
%r{(?:(?:.*Failure/Error:(?<stacktrace>.+))|(?<stacktrace>.+))}m
ISSUE_STACKTRACE_REGEX =
/### Stack trace\s*(```)#{FAILURE_STACKTRACE_REGEX}(```)\n*\n###/m
NEW_ISSUE_LABELS =
Set.new(%w[test failure::new priority::2]).freeze
IGNORED_FAILURES =
[
  'Net::ReadTimeout',
  '403 Forbidden - Your account has been blocked'
].freeze
SCREENSHOT_IGNORED_ERRORS =
['500 Internal Server Error', 'fabricate_via_api!', 'Error Code 500'].freeze
MultipleIssuesFound =
Class.new(StandardError)

Constants included from Concerns::IssueReports

Concerns::IssueReports::FAILED_JOB_DESCRIPTION_REGEX, Concerns::IssueReports::JOB_URL_REGEX, Concerns::IssueReports::REPORT_ITEM_REGEX

Constants included from Concerns::Utils

Concerns::Utils::MAX_TITLE_LENGTH

Instance Method Summary collapse

Methods included from Concerns::IssueReports

#add_report_to_issue_description, #failed_issue_job_url, #failed_issue_job_urls, #initial_reports_section

Methods included from Concerns::GroupAndCategoryLabels

#labels_inference, #new_issue_labels

Methods included from Concerns::FindSetDri

#set_dri_via_group

Methods inherited from ReportAsIssue

#invoke!

Methods included from Concerns::Utils

#partial_file_path, #pipeline, #search_safe, #title_from_test

Constructor Details

#initialize(max_diff_ratio: DEFAULT_MAX_DIFF_RATIO_FOR_DETECTION, system_logs: [], base_issue_labels: nil, exclude_labels_for_search: nil, metrics_files: [], **kwargs) ⇒ RelateFailureIssue

Returns a new instance of RelateFailureIssue.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/gitlab_quality/test_tooling/report/relate_failure_issue.rb', line 39

def initialize(
  max_diff_ratio: DEFAULT_MAX_DIFF_RATIO_FOR_DETECTION,
  system_logs: [],
  base_issue_labels: nil,
  exclude_labels_for_search: nil,
  metrics_files: [],
  **kwargs)
  super
  @max_diff_ratio = max_diff_ratio.to_f
  @system_logs = Dir.glob(system_logs)
  @base_issue_labels = Set.new(base_issue_labels)
  @exclude_labels_for_search = Set.new(exclude_labels_for_search)
  @issue_type = 'issue'
  @commented_issue_list = Set.new
  @metrics_files = Array(metrics_files)
end