Class: GitlabQuality::TestTooling::KnapsackReports::SpecRunTime
- Inherits:
-
Object
- Object
- GitlabQuality::TestTooling::KnapsackReports::SpecRunTime
- Defined in:
- lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb
Constant Summary collapse
- ACTUAL_TO_EXPECTED_SPEC_RUN_TIME_RATIO_THRESHOLD =
actual run time is longer than expected by 50% +
1.5- SPEC_WEIGHT_PERCENTAGE_TRESHOLD =
a spec file takes 15%+ of the total test suite run time
15- SUITE_DURATION_THRESHOLD =
if test suite takes more than 70 minutes, job risks timing out
70 * 60
- FEATURE_CATEGORY_METADATA_REGEX =
/(?<=feature_category: :)(?<feature_category>\w+)/
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#actual_suite_duration ⇒ Object
readonly
Returns the value of attribute actual_suite_duration.
-
#expected ⇒ Object
readonly
Returns the value of attribute expected.
-
#expected_suite_duration ⇒ Object
readonly
Returns the value of attribute expected_suite_duration.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Instance Method Summary collapse
- #actual_percentage ⇒ Object
- #ci_job_link_markdown ⇒ Object
- #ci_pipeline_created_at ⇒ Object
- #ci_pipeline_url_markdown ⇒ Object
- #feature_category ⇒ Object
- #file_link_markdown ⇒ Object
-
#initialize(file:, expected:, actual:, expected_suite_duration:, actual_suite_duration:, token: '', project: Runtime::Env.ci_project_path, ref: Runtime::Env.ci_commit_ref_name) ⇒ SpecRunTime
constructor
A new instance of SpecRunTime.
- #name ⇒ Object
- #should_report? ⇒ Boolean
Constructor Details
#initialize(file:, expected:, actual:, expected_suite_duration:, actual_suite_duration:, token: '', project: Runtime::Env.ci_project_path, ref: Runtime::Env.ci_commit_ref_name) ⇒ SpecRunTime
Returns a new instance of SpecRunTime.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 14 def initialize( file:, expected:, actual:, expected_suite_duration:, actual_suite_duration:, token: '', project: Runtime::Env.ci_project_path, ref: Runtime::Env.ci_commit_ref_name) @file = file @expected = expected.to_f @actual = actual.to_f @expected_suite_duration = expected_suite_duration.to_f @actual_suite_duration = actual_suite_duration.to_f @token = token @project = project @ref = ref end |
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
7 8 9 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 7 def actual @actual end |
#actual_suite_duration ⇒ Object (readonly)
Returns the value of attribute actual_suite_duration.
7 8 9 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 7 def actual_suite_duration @actual_suite_duration end |
#expected ⇒ Object (readonly)
Returns the value of attribute expected.
7 8 9 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 7 def expected @expected end |
#expected_suite_duration ⇒ Object (readonly)
Returns the value of attribute expected_suite_duration.
7 8 9 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 7 def expected_suite_duration @expected_suite_duration end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 7 def file @file end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
7 8 9 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 7 def project @project end |
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
7 8 9 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 7 def ref @ref end |
Instance Method Details
#actual_percentage ⇒ Object
63 64 65 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 63 def actual_percentage (actual / actual_suite_duration * 100).round(2) end |
#ci_job_link_markdown ⇒ Object
55 56 57 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 55 def ci_job_link_markdown "[#{ci_job_name}](#{ci_job_url})" end |
#ci_pipeline_created_at ⇒ Object
51 52 53 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 51 def ci_pipeline_created_at ENV.fetch('CI_PIPELINE_CREATED_AT', nil) end |
#ci_pipeline_url_markdown ⇒ Object
47 48 49 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 47 def ci_pipeline_url_markdown "[#{ci_pipeline_id}](#{ci_pipeline_url})" end |
#feature_category ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 33 def feature_category file_lines.each do |line| match = FEATURE_CATEGORY_METADATA_REGEX.match(line) next unless match break match[:feature_category] end end |
#file_link_markdown ⇒ Object
59 60 61 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 59 def file_link_markdown "[#{file}](#{file_link})" end |
#name ⇒ Object
67 68 69 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 67 def name nil end |
#should_report? ⇒ Boolean
42 43 44 45 |
# File 'lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb', line 42 def should_report? # guideline proposed in https://gitlab.com/gitlab-org/quality/engineering-productivity/team/-/issues/354 exceed_actual_to_expected_ratio_threshold? && test_suite_bottleneck? end |