gitlab-qa 7.29.1 → 7.30.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: 6f3a8d250f26a5899d776475ac349829311045b51aeed7b73f1a40fc41cd23dc
4
- data.tar.gz: 2258303729505a302fe0a6d05b57f5deee6efe21f0d7cbfb2542e92febfe2dc7
3
+ metadata.gz: 04b20a54aa036ec24fb463e50ad5b4be00f81a054cdae02dee966b38c0538c56
4
+ data.tar.gz: d8c1715674a879d58359d8f8293452f68ae4d516e4c19d4ad888f34ac018498d
5
5
  SHA512:
6
- metadata.gz: 2ad81f0b8d7bcb59ff76963f0463ae2d221be28b262455c22e6ee11ad91a9c6b768291639ed25b9ff756c9b319566f4aa596281ca2c09d470a5a1374174f3929
7
- data.tar.gz: 6e5a9601b50167f4cae9c87fe1415b1a6a740c855e56580cc553559d481842f6ed9feced7760a0403bb7993ef5ba7e11c1fd5723d2812a06227d1a64b87aefd1
6
+ metadata.gz: 5ccf3ee587dfef9f148fa98aa47b043bb6e2487aca12eb699f489f86fdf05f3939e5ece80ddde46a4e01b9b183dfb24742b287ac616ebc0939665786e8bbeba0
7
+ data.tar.gz: bc1a167d1b2500974abe0b3ec7f7966debe7b7f211f79324f87685f2e0906606e0c2799164f03adfff69d1af97697cf10128c6fe45eec46534832ad4b4ff0fb5
@@ -70,6 +70,8 @@ workflow:
70
70
  variables:
71
71
  DOCKER_DRIVER: overlay2
72
72
  DOCKER_HOST: tcp://docker:2375
73
+ COLORIZED_LOGS: "true"
74
+ QA_DEBUG: "false"
73
75
  QA_CAN_TEST_GIT_PROTOCOL_V2: "true"
74
76
  QA_CAN_TEST_PRAEFECT: "false"
75
77
  QA_GENERATE_ALLURE_REPORT: "true"
data/.rubocop.yml CHANGED
@@ -36,3 +36,6 @@ Style/SignalException:
36
36
 
37
37
  Layout/SpaceBeforeFirstArg:
38
38
  Enabled: false
39
+
40
+ RSpec/MultipleMemoizedHelpers:
41
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -89,11 +89,6 @@ RSpec/LeakyConstantDeclaration:
89
89
  Exclude:
90
90
  - 'spec/gitlab/qa/scenario/test/instance/deployment_base_spec.rb'
91
91
 
92
- # Offense count: 221
93
- # Configuration parameters: AllowSubject.
94
- RSpec/MultipleMemoizedHelpers:
95
- Max: 22
96
-
97
92
  # Offense count: 1
98
93
  # Cop supports --auto-correct.
99
94
  Style/ExplicitBlockArgument:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-qa (7.29.1)
4
+ gitlab-qa (7.30.0)
5
5
  activesupport (~> 6.1)
6
6
  gitlab (~> 4.18.0)
7
7
  http (~> 5.0)
@@ -176,6 +176,7 @@ module Gitlab
176
176
  exec_commands << seed_admin_token_command if seed_admin_token
177
177
  exec_commands << seed_test_data_command if seed_db
178
178
  exec_commands << Runtime::Scenario.omnibus_exec_commands
179
+ exec_commands << add_git_server_hooks unless Runtime::Scenario.skip_server_hooks
179
180
 
180
181
  commands = exec_commands.flatten.uniq
181
182
  return if commands.empty?
@@ -184,14 +185,17 @@ module Gitlab
184
185
  commands.each { |command| @docker.exec(name, command) }
185
186
  end
186
187
 
187
- def sha_version
188
+ def rails_version
188
189
  json = @docker.read_file(
189
190
  @release.image, @release.tag,
190
191
  '/opt/gitlab/version-manifest.json'
191
192
  )
192
193
 
193
194
  manifest = JSON.parse(json)
194
- manifest['software']['gitlab-rails']['locked_version']
195
+ {
196
+ sha: manifest['software']['gitlab-rails']['locked_version'],
197
+ source: manifest['software']['gitlab-rails']['locked_source']['git']
198
+ }
195
199
  end
196
200
 
197
201
  def copy_key_file(env_key)
@@ -243,6 +247,25 @@ module Gitlab
243
247
  ["gitlab-rails runner #{DATA_PATH}/admin_access_token_seed.rb"]
244
248
  end
245
249
 
250
+ def add_git_server_hooks
251
+ global_server_prereceive_hook = <<~SCRIPT
252
+ #!/usr/bin/env bash
253
+
254
+ if [[ \\\$GL_PROJECT_PATH =~ 'reject-prereceive' ]]; then
255
+ echo 'GL-HOOK-ERR: Custom error message rejecting prereceive hook for projects with GL_PROJECT_PATH matching pattern reject-prereceive'
256
+ exit 1
257
+ fi
258
+ SCRIPT
259
+
260
+ [
261
+ @docker.exec(name, 'mkdir -p /opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive.d'),
262
+ @docker.write_files(name) do |f|
263
+ f.write('/opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive.d/pre-receive.d', global_server_prereceive_hook, false)
264
+ end,
265
+ @docker.exec(name, 'chmod +x /opt/gitlab/embedded/service/gitlab-shell/hooks/pre-receive.d/*')
266
+ ]
267
+ end
268
+
246
269
  class Availability
247
270
  def initialize(name, relative_path: '', scheme: 'http', protocol_port: 80)
248
271
  @docker = Docker::Engine.new
@@ -61,8 +61,15 @@ module Gitlab
61
61
  def write_files(name)
62
62
  exec(name, yield(
63
63
  Class.new do
64
- def self.write(file, contents)
65
- %(echo "#{contents}" > #{file};)
64
+ # @param file The name of the file
65
+ # @param contents The content of the file to write
66
+ # @param expand_vars Set false if you need to write an environment variable '$' to a file. The variable should be escaped \\\$
67
+ def self.write(file, contents, expand_vars = true)
68
+ if expand_vars
69
+ %(echo "#{contents}" > #{file};)
70
+ else
71
+ %(echo '#{contents}' > #{file};)
72
+ end
66
73
  end
67
74
 
68
75
  def self.append(file, contents)
@@ -210,10 +210,10 @@ module Gitlab
210
210
 
211
211
  failure = full_stacktrace(test)
212
212
 
213
- if test.screenshot? && !failure.include?('500 Internal Server Error') && !failure.include?('fabricate_via_api!')
213
+ if test.screenshot? && !['500 Internal Server Error', 'fabricate_via_api!', 'Error Code 500'].any? { |e| failure.include?(e) }
214
214
  relative_url = gitlab.upload_file(file_fullpath: test.failure_screenshot)
215
215
 
216
- section = "### Screenshot: #{relative_url.markdown}"
216
+ section = "### Screenshot: #{relative_url.markdown}" if relative_url
217
217
  end
218
218
 
219
219
  section
@@ -7,7 +7,9 @@ module Gitlab
7
7
  class ReportResults < ReportAsIssue
8
8
  attr_accessor :testcase_project_reporter, :results_issue_project_reporter, :files, :test_case_project, :results_issue_project, :gitlab
9
9
 
10
- def initialize(token:, input_files:, test_case_project:, results_issue_project:, dry_run: false, **kwargs)
10
+ IGNORE_EXCEPTIONS = ['Net::ReadTimeout'].freeze
11
+
12
+ def initialize(token:, input_files:, test_case_project: nil, results_issue_project: nil, dry_run: false, **kwargs)
11
13
  @testcase_project_reporter = Gitlab::QA::Report::ResultsInTestCases.new(token: token, input_files: input_files, project: test_case_project, dry_run: dry_run, **kwargs)
12
14
  @results_issue_project_reporter = Gitlab::QA::Report::ResultsInIssues.new(token: token, input_files: input_files, project: results_issue_project, dry_run: dry_run, **kwargs)
13
15
  @test_case_project = test_case_project
@@ -32,7 +34,7 @@ module Gitlab
32
34
  test_results.each do |test|
33
35
  puts "Reporting test: #{test.file} | #{test.name}\n"
34
36
 
35
- report_test(test) unless test.skipped
37
+ report_test(test) if should_report?(test)
36
38
  end
37
39
 
38
40
  test_results.write
@@ -54,6 +56,40 @@ module Gitlab
54
56
  testcase_project_reporter.update_testcase(testcase, test)
55
57
  results_issue_project_reporter.update_issue(issue, test)
56
58
  end
59
+
60
+ # Checks if a test result should be reported.
61
+ #
62
+ # @return [Boolean] false if the test was skipped or failed because of a transient error that can be ignored.
63
+ # Otherwise returns true.
64
+ def should_report?(test)
65
+ return false if test.skipped
66
+
67
+ if test.report.key?('exceptions')
68
+ reason = ignore_failure_reason(test.report['exceptions'])
69
+
70
+ if reason
71
+ puts "Issue update skipped because #{reason}"
72
+
73
+ return false
74
+ end
75
+ end
76
+
77
+ true
78
+ end
79
+
80
+ # Determine any reason to ignore a failure.
81
+ #
82
+ # @param [Array<Hash>] exceptions the exceptions associated with the failure.
83
+ # @return [String] the reason to ignore the exceptions, or `nil` if any exceptions should not be ignored.
84
+ def ignore_failure_reason(exceptions)
85
+ exception_classes = exceptions
86
+ .filter_map { |exception| exception['class'] if IGNORE_EXCEPTIONS.include?(exception['class']) }
87
+ .compact
88
+ return if exception_classes.empty? || exception_classes.size < exceptions.size
89
+
90
+ msg = exception_classes.many? ? 'the errors were' : 'the error was'
91
+ "#{msg} #{exception_classes.join(', ')}"
92
+ end
57
93
  end
58
94
  end
59
95
  end
@@ -35,7 +35,7 @@ module Gitlab
35
35
  note_posted = note_status(issue, test)
36
36
 
37
37
  if labels_updated || note_posted
38
- puts "Issue updated."
38
+ puts "Issue updated: #{issue.web_url}"
39
39
  else
40
40
  puts "Test passed, no results issue update needed."
41
41
  end
@@ -15,6 +15,7 @@ module Gitlab
15
15
  Runtime::Scenario.define(:seed_db, false)
16
16
  Runtime::Scenario.define(:seed_admin_token, true) # Create an admin access token for root user by default
17
17
  Runtime::Scenario.define(:omnibus_exec_commands, [])
18
+ Runtime::Scenario.define(:skip_server_hooks, false)
18
19
 
19
20
  # Omnibus Configurators specified by flags
20
21
  @active_configurators = []
@@ -37,6 +38,10 @@ module Gitlab
37
38
  Runtime::Scenario.define(:seed_admin_token, false)
38
39
  end
39
40
 
41
+ opts.on('--skip-server-hooks', 'Skip adding global git server hooks') do
42
+ Runtime::Scenario.define(:skip_server_hooks, true)
43
+ end
44
+
40
45
  opts.on('--qa-image QA_IMAGE', String, 'Specifies a QA image to be used instead of inferring it from the GitLab image. See Gitlab::QA::Release#qa_image') do |value|
41
46
  Runtime::Scenario.define(:qa_image, value)
42
47
  end
@@ -12,22 +12,43 @@ module Gitlab
12
12
  # the window defined by the `weekday_hours` method.
13
13
  # We perform a single API call to get the commit
14
14
  class Version < Scenario::Template
15
+ SOURCE_MAP = {
16
+ 'git@dev.gitlab.org:gitlab/gitlab-ee.git' => {
17
+ host: 'dev.gitlab.org',
18
+ project: 'gitlab/gitlab-ee'
19
+ },
20
+ 'git@dev.gitlab.org:gitlab/gitlabhq.git' => {
21
+ host: 'dev.gitlab.org',
22
+ project: 'gitlab/gitlabhq'
23
+ },
24
+ 'git@gitlab.com:gitlab-org/gitlab.git' => {
25
+ host: 'gitlab.com',
26
+ project: 'gitlab-org/gitlab'
27
+ },
28
+ 'git@gitlab.com:gitlab-org/gitlab-foss.git' => {
29
+ host: 'gitlab.com',
30
+ project: 'gitlab-org/gitlab-foss'
31
+ }
32
+ }.freeze
33
+
15
34
  def perform(release = 'ce')
16
35
  version = Component::Gitlab.perform do |gitlab|
17
36
  gitlab.release = release
18
37
  gitlab.act do
19
38
  pull
20
- sha_version
39
+ rails_version
21
40
  end
22
41
  end
23
42
 
24
- project = "gitlab-org/#{QA::Release.new(release).api_project_name}"
25
- commit = api_commit_detail(project, version)
43
+ project = SOURCE_MAP[version[:source]][:project]
44
+ host = SOURCE_MAP[version[:source]][:host]
45
+ sha = version[:sha]
46
+ commit = api_commit_detail(host, project, sha)
26
47
 
27
48
  if commit_within_hours?(commit['created_at'], weekday_hours(commit['created_at']))
28
- puts "Found commit #{version} in recent history of #{project}"
49
+ puts "Found commit #{sha} in recent history of #{project} on #{host}"
29
50
  else
30
- puts "Did not find #{version} in recent history of #{project}"
51
+ puts "Did not find #{sha} in recent history of #{project} on #{host}"
31
52
  exit 1
32
53
  end
33
54
  end
@@ -51,9 +72,14 @@ module Gitlab
51
72
  Time.at(Time.parse(commit_time_string).utc).to_datetime > Time.at((Time.now - hours * 60 * 60).utc).to_datetime
52
73
  end
53
74
 
54
- def api_commit_detail(project, commit_id)
55
- api = 'https://gitlab.com/api/v4'
56
- url = "#{api}/projects/#{CGI.escape(project)}/repository/commits/#{commit_id}"
75
+ def api_commit_detail(host, project, sha)
76
+ url = "https://#{host}/api/v4/projects/#{CGI.escape(project)}/repository/commits/#{sha}"
77
+
78
+ if host == 'dev.gitlab.org'
79
+ Runtime::Env.require_qa_dev_access_token!
80
+
81
+ url = "#{url}?private_token=#{Runtime::Env.qa_dev_access_token}"
82
+ end
57
83
 
58
84
  JSON.parse(Net::HTTP.get(URI(url)))
59
85
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module QA
5
- VERSION = '7.29.1'
5
+ VERSION = '7.30.0'
6
6
  end
7
7
  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: 7.29.1
4
+ version: 7.30.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: 2022-05-31 00:00:00.000000000 Z
11
+ date: 2022-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control