gitlab-qa 6.10.1 → 6.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7798682f401a1349003d47532109adc5523cca0d4dfb43a0036669d0432168f
4
- data.tar.gz: eaa7d08e48b241b2d2a521f493543f40beebaef4dcb86e04584eb34cbfbba1c8
3
+ metadata.gz: a196452581ca78bf81e38487d2563675d1f1afce26754e6ae14f754c9386bac8
4
+ data.tar.gz: 3e6f876da229512eb72d93a98e5affc28c809c4e01b0fadf2dcd13a1e743ba12
5
5
  SHA512:
6
- metadata.gz: fd9312eb0cf93c3ec671b1115d96ae3926fe977de8c11134817fa90cdfb431b88015ce0c28dab8009492f7a14cba173ec13ffca8e466115e37e1b547f5cbe56d
7
- data.tar.gz: cd2810c3e560b25337835d9f8e324549bff222cd45529ae7bd372351284a7080c33aaa611bfe95605f2cb12b3a7c958f272436d2e587b98fa8a425cdfdccfd90
6
+ metadata.gz: 6b87108ae34a262954ea9ce8ef0129383c76a9e73812819286aa35e5ff8200a7763fb048144c7ce316a4c45f7d5d11ffb1349864f3d493e588fde1fbfbaa6516
7
+ data.tar.gz: e37a184f29e23f5b02c58365f5628066cbac40158cbd764dfc118bf62176a1cd7690835ede80e8e9a0a5ab8d230dc1e5b509d35d7bb77626fd3b31bc779ed3b7
@@ -1,8 +1,8 @@
1
1
  stages:
2
2
  - check
3
- - release
4
3
  - test
5
4
  - report
5
+ - deploy
6
6
  - notify
7
7
 
8
8
  default:
@@ -65,21 +65,6 @@ rubocop:
65
65
  rspec:
66
66
  extends: .check-base
67
67
 
68
- release:
69
- stage: release
70
- rules:
71
- - if: '$CI_COMMIT_TAG'
72
- script:
73
- - gem update --system
74
- - ruby --version
75
- - gem env version
76
- - gem build gitlab-qa.gemspec
77
- - gem push gitlab-qa*.gem
78
- artifacts:
79
- paths:
80
- - gitlab-qa*.gem
81
- expire_in: 30 days
82
-
83
68
  .test:
84
69
  stage: test
85
70
  services:
@@ -95,8 +80,8 @@ release:
95
80
  reports:
96
81
  junit: gitlab-qa-run-*/**/rspec-*.xml
97
82
  script:
98
- - 'echo "Running: exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS"'
99
- - exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS || test_run_exit_code=$?
83
+ - 'echo "Running: exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} $GITLAB_QA_OPTS -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS"'
84
+ - exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} $GITLAB_QA_OPTS -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS || test_run_exit_code=$?
100
85
  - exe/gitlab-qa-report --update-screenshot-path "gitlab-qa-run-*/**/rspec-*.xml"
101
86
  - export GITLAB_QA_ACCESS_TOKEN="$GITLAB_QA_PRODUCTION_ACCESS_TOKEN"
102
87
  - if [ "$TOP_UPSTREAM_SOURCE_REF" == "master" ] || [[ "$TOP_UPSTREAM_SOURCE_JOB" == https://ops.gitlab.net* ]]; then exe/gitlab-qa-report --report-in-issues "gitlab-qa-run-*/**/rspec-*.json" --project "$QA_TESTCASES_REPORTING_PROJECT" || true; fi
@@ -175,8 +160,8 @@ ee:sanity-framework:
175
160
  # The custom jobs are for manually running specific/alternative tests in MRs, so we don't report them in issues
176
161
  ce:custom-parallel:
177
162
  script:
178
- - 'echo "Running: exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS"'
179
- - exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS
163
+ - 'echo "Running: exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} $GITLAB_QA_OPTS -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS"'
164
+ - exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} $GITLAB_QA_OPTS -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS
180
165
  extends:
181
166
  - .test
182
167
  - .high-capacity
@@ -187,8 +172,8 @@ ce:custom-parallel:
187
172
 
188
173
  ee:custom-parallel:
189
174
  script:
190
- - 'echo "Running: exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS"'
191
- - exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS
175
+ - 'echo "Running: exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} $GITLAB_QA_OPTS -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS"'
176
+ - exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} $GITLAB_QA_OPTS -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS
192
177
  extends:
193
178
  - .test
194
179
  - .high-capacity
@@ -1012,3 +997,7 @@ notify_slack:
1012
997
  - echo "CI_PIPELINE_URL is $CI_PIPELINE_URL"
1013
998
  - echo "TOP_UPSTREAM_SOURCE_JOB is $TOP_UPSTREAM_SOURCE_JOB"
1014
999
  - 'bin/slack $NOTIFY_CHANNEL "☠️ QA against $RELEASE failed! ☠️ See the test session report: $(cat REPORT_ISSUE_URL), and pipeline: $CI_PIPELINE_URL (triggered from $TOP_UPSTREAM_SOURCE_JOB)" ci_failing'
1000
+
1001
+ include:
1002
+ - project: 'gitlab-org/quality/pipeline-common'
1003
+ file: '/ci/gem-release.yml'
@@ -30,6 +30,6 @@ with the latest commit from https://gitlab.com/gitlab-org/gitlab-qa/commits/mast
30
30
  - [ ] Release notes are accurate.
31
31
 
32
32
  - Checklist after merging:
33
- - [ ] [Create a tag for the new release version](docs/release_process.md#how-to).
33
+ - [ ] [Update the release notes for the newly created tag](docs/release_process.md#how-to).
34
34
 
35
35
  /label ~Quality ~"feature::maintenance"
@@ -24,12 +24,13 @@ when we make a change - no matter the size of the change.
24
24
  - If not, update [`lib/gitlab/qa/version.rb`] to an appropriate [semantic version](https://semver.org) in a new merge request using the [release template](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/.gitlab/merge_request_templates/Release.md)
25
25
  and title the MR like `"Bump version to <version>"`.
26
26
  - Merge the merge request.
27
- - Create a new tag via the UI (https://gitlab.com/gitlab-org/gitlab-qa/-/tags/new).
28
- * **Tag name**: The same version found in [`lib/gitlab/qa/version.rb`], prefixed with `v`, e.g. if the version is `4.7.1`, the tag would be `v4.7.1`.
29
- * **Message**: Set it to "Version x.y.z", e.g. if the version is `4.7.1`, the message would be "Version 4.7.1".
27
+ - The new version should automatically be tagged and pushed to Rubygems by the `gem-release` job in the merge commit pipeline.
28
+ - Update the release notes for the newly created tag (https://gitlab.com/gitlab-org/gitlab-qa/-/tags):
30
29
  * **Release notes**: Copy the release notes from the merge request.
31
- * Click *Create Tag*.
32
-
33
- GitLab will then start a pipeline for this new tag, and the `release` job will build and push the new version of `gitlab-qa` to RubyGems.
30
+
31
+ Note: The `gem-release` job uses:
32
+
33
+ - the `GITLAB_API_TOKEN` environment variable to authenticate against GitLab.com's API in order to create the tag
34
+ - the `GEM_HOST_API_KEY` environment variable to authenticate against Rubygems.org's API in order to release the gem
34
35
 
35
36
  [`lib/gitlab/qa/version.rb`]: https://gitlab.com/gitlab-org/gitlab-qa/blob/master/lib/gitlab/qa/version.rb#L3
@@ -4,7 +4,7 @@
4
4
 
5
5
  The [maven repository spec](https://gitlab.com/gitlab-org/gitlab/-/blob/master/qa/qa/specs/features/ee/browser_ui/5_package/maven_repository_spec.rb) creates a Maven artifact and links it to a GitLab project. The artifact is created within a [Maven docker image](https://gitlab.com/gitlab-org/gitlab/-/blob/master/qa/qa/service/docker_run/maven.rb#L8).
6
6
 
7
- Using `gitlab-qa` to run these tests reduces the liklihood of network errors between the maven container and GitLab instance.
7
+ Using `gitlab-qa` to run these tests reduces the likelihood of network errors between the maven container and GitLab instance.
8
8
 
9
9
  To run this with `gitlab-qa` you can use the `Test::Instance::Image` that is needed for your test. For example:
10
10
 
@@ -84,6 +84,7 @@ All environment variables used by GitLab QA should be defined in [`lib/gitlab/qa
84
84
  | `JIRA_ADMIN_PASSWORD` |- | Password for authenticating with Jira server as admin. | No|
85
85
  | `CACHE_NAMESPACE_NAME` | `true` | Cache namespace name for groups. | No|
86
86
  | `DEPLOY_VERSION` |- | The version of GitLab being tested against. | No|
87
+ | `GITLAB_QA_USER_AGENT` |- | The browser user-agent to use instead of the default Chrome user-agent. | No|
87
88
 
88
89
  ## [Supported Remote Grid environment variables](./running_against_remote_grid.md)
89
90
 
@@ -6,6 +6,7 @@ module Gitlab
6
6
  class GenerateTestSession < ReportAsIssue
7
7
  private
8
8
 
9
+ # rubocop:disable Metrics/AbcSize
9
10
  def run!
10
11
  puts "Generating test results in `#{files.join(',')}` as issues in project `#{project}` via the API at `#{Runtime::Env.gitlab_api_base}`."
11
12
 
@@ -16,22 +17,26 @@ module Gitlab
16
17
  end
17
18
 
18
19
  issue = gitlab.create_issue(
19
- title: "Test session report | #{Runtime::Env.deploy_environment}",
20
+ title: "Test session report | #{pipeline}",
20
21
  description: generate_description(tests),
21
- labels: ['Quality', 'QA', 'triage report']
22
+ labels: ['Quality', 'QA', 'triage report', pipeline_name_label]
22
23
  )
23
24
 
24
25
  File.write('REPORT_ISSUE_URL', issue.web_url)
25
26
  end
27
+ # rubocop:enable Metrics/AbcSize
26
28
 
27
29
  def generate_description(tests)
28
30
  <<~MARKDOWN
29
31
  ## Session summary
30
32
 
31
33
  * Deploy version: #{Runtime::Env.deploy_version}
32
- * Pipeline: [#{Runtime::Env.ci_pipeline_id}](#{Runtime::Env.ci_pipeline_url})
34
+ * Deploy environment: #{Runtime::Env.deploy_environment}
35
+ * Pipeline: #{Runtime::Env.pipeline_from_project_name} [#{Runtime::Env.ci_pipeline_id}](#{Runtime::Env.ci_pipeline_url})
33
36
  #{generate_summary(tests: tests)}
34
37
 
38
+ #{generate_failed_jobs_listing}
39
+
35
40
  #{generate_stages_listing(tests)}
36
41
 
37
42
  ## Release QA issue
@@ -55,6 +60,33 @@ module Gitlab
55
60
  MARKDOWN
56
61
  end
57
62
 
63
+ def generate_failed_jobs_listing
64
+ failed_jobs = []
65
+
66
+ client = Gitlab.client(
67
+ endpoint: Runtime::Env.ci_api_v4_url,
68
+ private_token: Runtime::Env.gitlab_ci_api_token)
69
+
70
+ gitlab.handle_gitlab_client_exceptions do
71
+ failed_jobs = client.pipeline_jobs(
72
+ Runtime::Env.ci_project_id,
73
+ Runtime::Env.ci_pipeline_id,
74
+ scope: 'failed')
75
+ end
76
+
77
+ listings = failed_jobs.map do |job|
78
+ allowed_to_fail = ' (allowed to fail)' if job.allow_failure
79
+
80
+ "* [#{job.name}](#{job.web_url})#{allowed_to_fail}"
81
+ end.join("\n")
82
+
83
+ <<~MARKDOWN.chomp if failed_jobs.any?
84
+ ## Failed jobs
85
+
86
+ #{listings}
87
+ MARKDOWN
88
+ end
89
+
58
90
  def generate_stages_listing(tests)
59
91
  generate_tests_by_stage(tests).map do |stage, tests_for_stage|
60
92
  tests_by_status = tests_for_stage.group_by(&:status)
@@ -185,7 +217,7 @@ module Gitlab
185
217
  tests_with_same_testcase.select(&:failure_issue)
186
218
 
187
219
  if tests_having_failure_issue.any?
188
- items = tests_having_failure_issue.map do |test|
220
+ items = tests_having_failure_issue.uniq(&:failure_issue).map do |test|
189
221
  "<li>[ ] [failure issue](#{test.failure_issue})</li>"
190
222
  end.join(' ')
191
223
 
@@ -82,17 +82,20 @@ module Gitlab
82
82
  # Search with the `search` param returns 500 errors, so we filter by ~QA and then filter further in Ruby
83
83
  failure_issues(test).each_with_object({}) do |issue, memo|
84
84
  relevant_issue_stacktrace = find_issue_stacktrace(issue)
85
- unless relevant_issue_stacktrace
86
- puts " => [DEBUG] Found issue #{issue.web_url} but stacktrace doesn't match."
87
- next
88
- end
85
+ next unless relevant_issue_stacktrace
89
86
 
90
87
  distance = ld.call(first_test_failure_stacktrace, relevant_issue_stacktrace)
91
88
  diff_ratio = (distance.to_f / first_test_failure_stacktrace.size).round(3)
92
89
  if diff_ratio <= max_diff_ratio
93
- memo[issue] = diff_ratio
90
+ puts " => [DEBUG] Issue #{issue} has an acceptable diff ratio of #{(diff_ratio * 100).round(2)}%."
91
+ # The `Gitlab::ObjectifiedHash` class overrides `#hash` which is used by `Hash#[]=` to compute the hash key.
92
+ # This leads to a `TypeError Exception: no implicit conversion of Hash into Integer` error, so we convert the object to a hash before using it as a Hash key.
93
+ # See:
94
+ # - https://gitlab.com/gitlab-org/gitlab-qa/-/merge_requests/587#note_453336995
95
+ # - https://github.com/NARKOZ/gitlab/commit/cbdbd1e32623f018a8fae39932a8e3bc4d929abb?_pjax=%23js-repo-pjax-container#r44484494
96
+ memo[issue.to_h] = diff_ratio
94
97
  else
95
- puts " => [DEBUG] Found issue #{issue.web_url} but stacktrace is too different (#{(diff_ratio * 100).round(2)}%)."
98
+ puts " => [DEBUG] Found issue #{issue.web_url} but stacktraces are too different (#{(diff_ratio * 100).round(2)}%)."
96
99
  end
97
100
  end
98
101
  end
@@ -103,7 +106,7 @@ module Gitlab
103
106
  if issue_stacktrace_match
104
107
  issue_stacktrace_match[2].gsub(/^#.*$/, '').strip
105
108
  else
106
- puts "\n => Stacktrace couldn't be found for #{issue.web_url}:\n\n#{issue.description}\n\n----------------------------------\n"
109
+ puts " => [DEBUG] Stacktrace couldn't be found for #{issue.web_url}:\n\n#{issue.description}\n\n----------------------------------\n"
107
110
  end
108
111
  end
109
112
 
@@ -118,6 +121,9 @@ module Gitlab
118
121
  raise(MultipleIssuesFound, %(Too many issues found for test '#{test.name}' (`#{test.file}`)!))
119
122
  end
120
123
 
124
+ # Re-instantiate a `Gitlab::ObjectifiedHash` object after having converted it to a hash in #find_relevant_failure_issues above.
125
+ best_matching_issue = Gitlab::ObjectifiedHash.new(best_matching_issue)
126
+
121
127
  test.failure_issue ||= best_matching_issue.web_url
122
128
 
123
129
  [best_matching_issue, smaller_diff_ratio]
@@ -131,36 +137,19 @@ module Gitlab
131
137
  ].join("\n\n")
132
138
  end
133
139
 
134
- def deploy_environment_label
135
- environment = Runtime::Env.deploy_environment
136
-
137
- case environment
138
- when 'production'
139
- 'found:gitlab.com'
140
- when 'canary', 'staging'
141
- "found:#{environment}.gitlab.com"
142
- when 'preprod'
143
- 'found:pre.gitlab.com'
144
- when 'staging-orchestrated', 'nightly', 'master'
145
- "found:#{environment}"
146
- else
147
- raise "No `found:*` label for the `#{environment}` environment!"
148
- end
149
- end
150
-
151
140
  def new_issue_labels(test)
152
141
  NEW_ISSUE_LABELS + up_to_date_labels(test: test)
153
142
  end
154
143
 
155
144
  def up_to_date_labels(test:, issue: nil)
156
- super << deploy_environment_label
145
+ super << pipeline_name_label
157
146
  end
158
147
 
159
148
  def post_failed_job_note(issue, test)
160
149
  gitlab.create_issue_note(iid: issue.iid, note: "/relate #{test.testcase}")
161
150
  end
162
151
 
163
- def title_from_test(test)
152
+ def new_issue_title(test)
164
153
  "Failure in #{super}"
165
154
  end
166
155
  end
@@ -28,6 +28,10 @@ module Gitlab
28
28
  raise NotImplementedError
29
29
  end
30
30
 
31
+ def new_issue_title(test)
32
+ "#{partial_file_path(test.file)} | #{search_safe(test.name)}".strip
33
+ end
34
+
31
35
  def new_issue_description(test)
32
36
  "### Full description\n\n#{search_safe(test.name)}\n\n### File path\n\n#{test.file}"
33
37
  end
@@ -100,6 +104,21 @@ module Gitlab
100
104
  labels
101
105
  end
102
106
 
107
+ def pipeline_name_label
108
+ case pipeline
109
+ when 'production'
110
+ 'found:gitlab.com'
111
+ when 'canary', 'staging'
112
+ "found:#{pipeline}.gitlab.com"
113
+ when 'preprod'
114
+ 'found:pre.gitlab.com'
115
+ when 'staging-orchestrated', 'nightly', 'master'
116
+ "found:#{pipeline}"
117
+ else
118
+ raise "No `found:*` label for the `#{pipeline}` pipeline!"
119
+ end
120
+ end
121
+
103
122
  def ee_test?(test)
104
123
  test.file =~ %r{features/ee/(api|browser_ui)}
105
124
  end
@@ -113,7 +132,7 @@ module Gitlab
113
132
  end
114
133
 
115
134
  def title_from_test(test)
116
- title = "#{partial_file_path(test.file)} | #{search_safe(test.name)}".strip
135
+ title = new_issue_title(test)
117
136
 
118
137
  return title unless title.length > MAX_TITLE_LENGTH
119
138
 
@@ -85,7 +85,8 @@ module Gitlab
85
85
  'JIRA_ADMIN_USERNAME' => :jira_admin_username,
86
86
  'JIRA_ADMIN_PASSWORD' => :jira_admin_password,
87
87
  'CACHE_NAMESPACE_NAME' => :cache_namespace_name,
88
- 'DEPLOY_VERSION' => :deploy_version
88
+ 'DEPLOY_VERSION' => :deploy_version,
89
+ 'GITLAB_QA_USER_AGENT' => :gitlab_qa_user_agent
89
90
  }.freeze
90
91
 
91
92
  ENV_VARIABLES.each do |env_name, method_name|
@@ -115,6 +116,14 @@ module Gitlab
115
116
  ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN']
116
117
  end
117
118
 
119
+ def gitlab_ci_api_token
120
+ ENV['GITLAB_CI_API_TOKEN']
121
+ end
122
+
123
+ def ci_api_v4_url
124
+ ENV['CI_API_V4_URL']
125
+ end
126
+
118
127
  def ci_job_name
119
128
  ENV['CI_JOB_NAME']
120
129
  end
@@ -135,8 +144,8 @@ module Gitlab
135
144
  ENV['CI_PIPELINE_ID']
136
145
  end
137
146
 
138
- def ci_project_name
139
- ENV['CI_PROJECT_NAME']
147
+ def ci_project_id
148
+ ENV['CI_PROJECT_ID']
140
149
  end
141
150
 
142
151
  def ci_commit_ref_name
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module QA
3
- VERSION = '6.10.1'.freeze
3
+ VERSION = '6.15.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-qa
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.10.1
4
+ version: 6.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grzegorz Bizon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-19 00:00:00.000000000 Z
11
+ date: 2020-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control