gitlab-qa 7.25.1 → 7.26.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: 6d38407d98e8584368fc76399d9b317935ff72c3db389678582ea498dab1aa2e
4
- data.tar.gz: e8d15459029b84436c36394372084d7a28607e1836dc34ef6ee3445b549d283b
3
+ metadata.gz: afdf52b910858a3f1ec0729d2eef2d170938d282cd116af17af424afc92fcae0
4
+ data.tar.gz: 1fb9f558a932a9344b774bc3d873e9184f8c31dd8472c4f51aa0a7ac0626422e
5
5
  SHA512:
6
- metadata.gz: 25d386ced265585364f4482544d9d0ba72bb85dd2af7236caaae8ea1c7ac4c2af8701362eefbdd1a76ebaec8a80c7ca7b2e9cbd0fd2e935656a54f0183bb19ab
7
- data.tar.gz: 48a6a13c849393cb3d3ed7ef27b5f3fab21041e1a2073fa6dc95c8b973fb34e33183b7081388ac1e5db77fc9a223f9c45e3aefb6bb8dd306fbf41f2219b8c165
6
+ metadata.gz: 3cb4ab49fee9a1ade2abd1125bb5a8ae020c0343a06415d74130709fd5556f715a49010ee6e9b31e1abb9b0c8ece9dc7f3f63e3c85606f21a02434ab276da030
7
+ data.tar.gz: bd5310d35ede8bef9b8aabc2113a76841a530b11e95e15bc87d82d45e7242b0efb7d6c170f6d2c785d7f7cf8b603c8367dc0b2994f8d1481fff2c8eab8d908a5
@@ -11,7 +11,7 @@ ee:cloud-activation:
11
11
  - .combined-gitlab-qa-options-script
12
12
  variables:
13
13
  QA_RSPEC_TAGS: "--tag cloud_activation"
14
- GITLAB_QA_OPTIONS_COMBINED: "$GITLAB_QA_OPTIONS --seed-db license*.rb"
14
+ GITLAB_QA_OPTIONS_COMBINED: "$GITLAB_QA_OPTIONS --no-admin-token --seed-db license*.rb"
15
15
 
16
16
  ee:cloud-activation-quarantine:
17
17
  before_script:
@@ -27,4 +27,4 @@ ee:cloud-activation-quarantine:
27
27
  - .combined-gitlab-qa-options-script
28
28
  variables:
29
29
  QA_RSPEC_TAGS: "--tag cloud_activation"
30
- GITLAB_QA_OPTIONS_COMBINED: "$GITLAB_QA_OPTIONS --seed-db license*.rb"
30
+ GITLAB_QA_OPTIONS_COMBINED: "$GITLAB_QA_OPTIONS --no-admin-token --seed-db license*.rb"
@@ -11,3 +11,5 @@ If you feel that your issue can be categorized as a reproducible bug or a featur
11
11
 
12
12
  Thank you for helping to make GitLab a better product.
13
13
  -->
14
+
15
+ <!-- template sourced from https://gitlab.com/gitlab-org/gitlab-qa/-/blob/master/.gitlab/issue_templates/Default.md -->
@@ -44,3 +44,5 @@ This checklist encourages us to confirm any changes have been analyzed to reduce
44
44
  * [ ] I have evaluated the [MR acceptance checklist](https://docs.gitlab.com/ee/development/code_review.html#acceptance-checklist) for this MR.
45
45
 
46
46
  /label ~QA ~Quality
47
+
48
+ <!-- template sourced from https://gitlab.com/gitlab-org/gitlab-qa/-/blob/master/.gitlab/merge_request_templates/Default.md -->
data/.gitlab-ci.yml CHANGED
@@ -50,9 +50,8 @@ prepare:
50
50
  extends: .rules:never-on-version-change-or-tag
51
51
  script:
52
52
  - |
53
- if [[ $TOP_UPSTREAM_SOURCE_PROJECT == "gitlab-org/gitlab" && -n $TOP_UPSTREAM_SOURCE_REF ]]; then
54
- # Replace '\' with '-' and convert to downcase
55
- export QA_IMAGE_TAG=$(echo "${TOP_UPSTREAM_SOURCE_REF//\//-}" | tr '[:upper:]' '[:lower:]')
53
+ if [[ $TOP_UPSTREAM_SOURCE_PROJECT == "gitlab-org/gitlab" && -n $TOP_UPSTREAM_SOURCE_SHA ]]; then
54
+ export QA_IMAGE_TAG=${TOP_UPSTREAM_SOURCE_SHA}
56
55
  else
57
56
  export QA_IMAGE_TAG=master
58
57
  fi
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # rubocop:disable Metrics/AbcSize
2
3
 
3
4
  require 'securerandom'
4
5
  require 'net/http'
@@ -14,7 +15,7 @@ module Gitlab
14
15
  extend Forwardable
15
16
 
16
17
  attr_reader :release, :omnibus_configuration, :omnibus_gitlab_rails_env
17
- attr_accessor :tls, :skip_availability_check, :runner_network
18
+ attr_accessor :tls, :skip_availability_check, :runner_network, :seed_admin_token, :seed_db
18
19
  attr_writer :name, :relative_path
19
20
 
20
21
  def_delegators :release, :tag, :image, :edition
@@ -42,8 +43,10 @@ module Gitlab
42
43
  @volumes[@gitlab_cert_path] = SSL_PATH
43
44
  @volumes[@authority_cert_path] = TRUSTED_PATH
44
45
 
46
+ @seed_admin_token = Runtime::Scenario.seed_admin_token
47
+ @seed_db = Runtime::Scenario.seed_db
48
+
45
49
  self.release = 'CE'
46
- self.exec_commands += seed_test_data_command if Runtime::Scenario.seed_db
47
50
  end
48
51
 
49
52
  def set_formless_login_token
@@ -171,9 +174,13 @@ module Gitlab
171
174
  end
172
175
 
173
176
  def process_exec_commands
174
- @docker.copy(name, DATA_SEED_PATH, DATA_PATH) if Runtime::Scenario.seed_db
177
+ @docker.copy(name, DATA_SEED_PATH, DATA_PATH) if seed_admin_token || seed_db
178
+
179
+ self.exec_commands += seed_admin_token_command if seed_admin_token
180
+ self.exec_commands += seed_test_data_command if seed_db
175
181
 
176
- exec_commands.each { |command| @docker.exec(name, command) }
182
+ Runtime::Logger.info("Running exec_commands...")
183
+ exec_commands.flatten.uniq.each { |command| @docker.exec(name, command) }
177
184
  end
178
185
 
179
186
  def sha_version
@@ -231,6 +238,10 @@ module Gitlab
231
238
  cmd.uniq
232
239
  end
233
240
 
241
+ def seed_admin_token_command
242
+ ["gitlab-rails runner #{DATA_PATH}/admin_access_token_seed.rb"]
243
+ end
244
+
234
245
  class Availability
235
246
  def initialize(name, relative_path: '', scheme: 'http', protocol_port: 80)
236
247
  @docker = Docker::Engine.new
@@ -276,3 +287,4 @@ module Gitlab
276
287
  end
277
288
  end
278
289
  end
290
+ # rubocop:enable Metrics/AbcSize
@@ -101,6 +101,18 @@ module Gitlab
101
101
  end
102
102
  end
103
103
 
104
+ def upload_file(file_fullpath:)
105
+ ignore_gitlab_client_exceptions do
106
+ Gitlab.upload_file(project, file_fullpath)
107
+ end
108
+ end
109
+
110
+ def ignore_gitlab_client_exceptions
111
+ yield
112
+ rescue StandardError, SystemCallError, OpenSSL::SSL::SSLError, Net::OpenTimeout, Net::ReadTimeout, Gitlab::Error::Error => e
113
+ puts "Ignoring the following error: #{e}"
114
+ end
115
+
104
116
  def handle_gitlab_client_exceptions
105
117
  yield
106
118
  rescue Gitlab::Error::NotFound
@@ -72,6 +72,8 @@ module Gitlab
72
72
  issue = super
73
73
  puts "for test '#{test.name}'."
74
74
 
75
+ post_or_update_failed_job_note(issue, test)
76
+
75
77
  issue
76
78
  end
77
79
 
@@ -158,7 +160,8 @@ module Gitlab
158
160
  "\n\n### Stack trace",
159
161
  "```\n#{test.failures.first['message_lines'].join("\n")}\n```",
160
162
  "First happened in #{test.ci_job_url}.",
161
- "Related test case: #{test.testcase}."
163
+ "Related test case: #{test.testcase}.",
164
+ screenshot_section(test)
162
165
  ].join("\n\n")
163
166
  end
164
167
 
@@ -194,6 +197,18 @@ module Gitlab
194
197
 
195
198
  false
196
199
  end
200
+
201
+ def screenshot_section(test)
202
+ section = ''
203
+
204
+ if test.screenshot? && !test.failures.first['message'].include?('500 Internal Server Error')
205
+ relative_url = gitlab.upload_file(file_fullpath: test.failure_screenshot)
206
+
207
+ section = "### Screenshot: #{relative_url.markdown}"
208
+ end
209
+
210
+ section
211
+ end
197
212
  end
198
213
  end
199
214
  end
@@ -95,6 +95,14 @@ module Gitlab
95
95
  report['quarantine']['issue'] if quarantine?
96
96
  end
97
97
 
98
+ def screenshot?
99
+ report['screenshot'].present?
100
+ end
101
+
102
+ def failure_screenshot
103
+ report['screenshot']['image'] if screenshot?
104
+ end
105
+
98
106
  private
99
107
 
100
108
  # rubocop:disable Metrics/AbcSize
@@ -1,4 +1,6 @@
1
1
  require 'nokogiri'
2
+ require 'json'
3
+ require 'active_support/core_ext/object/blank'
2
4
 
3
5
  module Gitlab
4
6
  module QA
@@ -9,30 +11,50 @@ module Gitlab
9
11
  end
10
12
 
11
13
  REGEX = %r{(?<gitlab_qa_run>gitlab-qa-run-.*?(?=\/))\/(?<gitlab_ce_ee_qa>gitlab-(ee|ce)-qa-.*?(?=\/))}
14
+ CONTAINER_PATH = File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'tmp').freeze
12
15
 
13
16
  def invoke!
14
17
  Dir.glob(@files).each do |rspec_report_file|
15
- report = rewrite_each_screenshot_path(rspec_report_file)
18
+ match_data = rspec_report_file.match(REGEX)
19
+ artifact_path = "#{match_data[:gitlab_qa_run]}/#{match_data[:gitlab_ce_ee_qa]}"
16
20
 
17
- File.write(rspec_report_file, report)
21
+ xml_report = rewrite_each_xml_screenshot_path(rspec_report_file, artifact_path)
22
+
23
+ File.write(rspec_report_file, xml_report)
18
24
 
19
25
  puts "Saved #{rspec_report_file}"
26
+
27
+ json_rspec_report_file = rspec_report_file.gsub('.xml', '.json')
28
+ json_report = rewrite_each_json_screenshot_path(json_rspec_report_file, artifact_path)
29
+
30
+ File.write(json_rspec_report_file, json_report)
31
+
32
+ puts "Saved #{json_rspec_report_file}"
20
33
  end
21
34
  end
22
35
 
23
36
  private
24
37
 
25
- def rewrite_each_screenshot_path(rspec_report_file)
38
+ def rewrite_each_xml_screenshot_path(rspec_report_file, artifact_path)
26
39
  report = Nokogiri::XML(File.open(rspec_report_file))
27
40
 
28
- match_data = rspec_report_file.match(REGEX)
29
-
30
41
  report.xpath('//system-out').each do |system_out|
31
- system_out.content = system_out.content.gsub(File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'tmp'), "#{match_data[:gitlab_qa_run]}/#{match_data[:gitlab_ce_ee_qa]}")
42
+ system_out.content = system_out.content.gsub(CONTAINER_PATH, artifact_path)
32
43
  end
33
44
 
34
45
  report.to_s
35
46
  end
47
+
48
+ def rewrite_each_json_screenshot_path(json_rspec_report_file, artifact_path)
49
+ report = JSON.parse(File.read(json_rspec_report_file))
50
+ examples = report['examples']
51
+
52
+ examples.each do |example|
53
+ example['screenshot']['image'] = example['screenshot']['image'].gsub(CONTAINER_PATH, artifact_path) if example['screenshot'].present?
54
+ end
55
+
56
+ JSON.pretty_generate(report)
57
+ end
36
58
  end
37
59
  end
38
60
  end
@@ -13,6 +13,8 @@ module Gitlab
13
13
  Runtime::Scenario.define(:qa_image, Runtime::Env.qa_image) if Runtime::Env.qa_image
14
14
  Runtime::Scenario.define(:omnibus_configuration, Runtime::OmnibusConfiguration.new)
15
15
  Runtime::Scenario.define(:seed_db, false)
16
+ Runtime::Scenario.define(:seed_admin_token, true) # Create an admin access token for root user by default
17
+ Runtime::Scenario.define(:omnibus_exec_commands, [])
16
18
 
17
19
  # Omnibus Configurators specified by flags
18
20
  @active_configurators = []
@@ -31,6 +33,10 @@ module Gitlab
31
33
  Runtime::Scenario.define(:teardown, false)
32
34
  end
33
35
 
36
+ opts.on('--no-admin-token', 'Skip admin token creation for root user') do
37
+ Runtime::Scenario.define(:seed_admin_token, false)
38
+ end
39
+
34
40
  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|
35
41
  Runtime::Scenario.define(:qa_image, value)
36
42
  end
@@ -135,6 +141,7 @@ module Gitlab
135
141
  # # Runtime::OmnibusConfiguration::Packages
136
142
  # gitlab_rails['packages_enabled'] = true
137
143
  Runtime::Scenario.omnibus_configuration << "# #{configurator.class.name}"
144
+ Runtime::Scenario.omnibus_exec_commands << configurator.exec_commands
138
145
 
139
146
  # Load the configuration
140
147
  configurator.configuration.split("\n").each { |c| Runtime::Scenario.omnibus_configuration << c }
@@ -33,7 +33,7 @@ module Gitlab
33
33
  # @return Any instance of [Gitlab::QA::Component::Base]
34
34
  def prepare; end
35
35
 
36
- # Commands to execute before GitLab boots
36
+ # Commands to execute before tests are run against GitLab (after reconfigure)
37
37
  def exec_commands
38
38
  []
39
39
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitlab
4
+ module QA
5
+ module Runtime
6
+ module OmnibusConfigurations
7
+ class CiDecomposition < Default
8
+ def configuration
9
+ # HACK: commenting commands out as these commands should be run *after* the first
10
+ # reconfiguration (see first command in #exec_commands)
11
+ <<~OMNIBUS
12
+ #gitlab_rails['databases']['main']['enable'] = true
13
+ #gitlab_rails['databases']['ci']['enable'] = true
14
+ #gitlab_rails['databases']['ci']['db_database'] = 'gitlabhq_production_ci'
15
+ OMNIBUS
16
+ end
17
+
18
+ def exec_commands
19
+ [
20
+ "sed -i 's/#gitlab_rails/gitlab_rails/g' /etc/gitlab/gitlab.rb",
21
+ "gitlab-ctl reconfigure",
22
+ "gitlab-psql -c 'create database gitlabhq_production_ci owner gitlab'",
23
+ "gitlab-psql -d gitlabhq_production_ci -c 'create extension btree_gist'",
24
+ "gitlab-psql -d gitlabhq_production_ci -c 'create extension pg_trgm'",
25
+ "gitlab-rake db:structure:load:ci"
26
+ ].freeze
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -27,6 +27,7 @@ module Gitlab
27
27
  specs.suite = @suite
28
28
  specs.release = release
29
29
  specs.args = non_rspec_args.push(*args)
30
+ specs.volumes[host_knapsack_report_path] = "/home/gitlab/qa/knapsack" if host_knapsack_report_path
30
31
  end
31
32
  end
32
33
 
@@ -37,6 +38,10 @@ module Gitlab
37
38
  def deployment_component
38
39
  raise NotImplementedError, 'Please define the Component for the deployment environment associated with this scenario.'
39
40
  end
41
+
42
+ def host_knapsack_report_path
43
+ ENV["QA_KNAPSACK_REPORT_PATH"]
44
+ end
40
45
  end
41
46
  end
42
47
  end
@@ -16,6 +16,7 @@ module Gitlab
16
16
  primary.release = release
17
17
  primary.name = 'gitlab-primary'
18
18
  primary.network = 'geo'
19
+ primary.seed_admin_token = false
19
20
  primary.omnibus_configuration << <<~OMNIBUS
20
21
  gitlab_rails['db_key_base'] = '4dd58204865eb41bca93bd38131d51cc';
21
22
  geo_primary_role['enable'] = true;
@@ -54,7 +55,7 @@ module Gitlab
54
55
  sidekiq['concurrency'] = 2;
55
56
  puma['worker_processes'] = 2;
56
57
  OMNIBUS
57
- secondary.exec_commands = fast_ssh_key_lookup_commands + QA::Scenario::CLICommands.git_lfs_install_commands
58
+ secondary.exec_commands += fast_ssh_key_lookup_commands + QA::Scenario::CLICommands.git_lfs_install_commands
58
59
 
59
60
  secondary.act do
60
61
  # TODO, we do not wait for secondary to start because of
@@ -37,6 +37,7 @@ module Gitlab
37
37
  praefect.name = @praefect_node_name
38
38
  praefect.network = @network
39
39
  praefect.skip_availability_check = true
40
+ praefect.seed_admin_token = false
40
41
 
41
42
  praefect.omnibus_configuration << praefect_omnibus_configuration
42
43
 
@@ -196,6 +197,7 @@ module Gitlab
196
197
  gitaly.name = name
197
198
  gitaly.network = @network
198
199
  gitaly.skip_availability_check = true
200
+ gitaly.seed_admin_token = false
199
201
  gitaly.omnibus_configuration << gitaly_omnibus_configuration
200
202
  gitaly.instance(skip_teardown: true)
201
203
  end
@@ -19,6 +19,7 @@ module Gitlab
19
19
  gitaly.name = @gitaly_name
20
20
  gitaly.network = @network
21
21
  gitaly.skip_availability_check = true
22
+ gitaly.seed_admin_token = false
22
23
 
23
24
  gitaly.omnibus_configuration << gitaly_omnibus
24
25
  gitaly.gitaly_tls
@@ -16,6 +16,7 @@ module Gitlab
16
16
  gitlab.release = previous_release
17
17
  gitlab.volumes = volumes
18
18
  gitlab.network = 'test'
19
+ gitlab.seed_admin_token = false
19
20
  gitlab.launch_and_teardown_instance
20
21
  end
21
22
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module QA
5
- VERSION = '7.25.1'
5
+ VERSION = '7.26.0'
6
6
  end
7
7
  end
data/lib/gitlab/qa.rb CHANGED
@@ -20,6 +20,7 @@ module Gitlab
20
20
  autoload :ObjectStorageGcs, 'gitlab/qa/runtime/omnibus_configurations/object_storage_gcs'
21
21
  autoload :LicenseMode, 'gitlab/qa/runtime/omnibus_configurations/license_mode'
22
22
  autoload :RegistryObjectStorage, 'gitlab/qa/runtime/omnibus_configurations/registry_object_storage'
23
+ autoload :CiDecomposition, 'gitlab/qa/runtime/omnibus_configurations/ci_decomposition'
23
24
  end
24
25
  end
25
26
 
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AdminAccessTokenSeed
4
+ TOKEN_VALUE = 'yF4CpxN55A1V0sHMuYQa'
5
+ SCOPES = Gitlab::Auth.all_available_scopes
6
+
7
+ def self.seed!
8
+ admin_user = User.find_by(username: 'root')
9
+
10
+ token_params = {
11
+ scopes: SCOPES.map(&:to_s),
12
+ name: 'admin-api-token'
13
+ }
14
+
15
+ admin_user.personal_access_tokens.build(token_params).tap do |pat|
16
+ pat.set_token(TOKEN_VALUE)
17
+ pat.save!
18
+ end
19
+
20
+ puts 'Personal access token seeded for root user.'
21
+ end
22
+ end
23
+
24
+ AdminAccessTokenSeed.seed!
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.25.1
4
+ version: 7.26.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-03 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control
@@ -335,6 +335,7 @@ files:
335
335
  - lib/gitlab/qa/runtime/env.rb
336
336
  - lib/gitlab/qa/runtime/logger.rb
337
337
  - lib/gitlab/qa/runtime/omnibus_configuration.rb
338
+ - lib/gitlab/qa/runtime/omnibus_configurations/ci_decomposition.rb
338
339
  - lib/gitlab/qa/runtime/omnibus_configurations/default.rb
339
340
  - lib/gitlab/qa/runtime/omnibus_configurations/license_mode.rb
340
341
  - lib/gitlab/qa/runtime/omnibus_configurations/object_storage.rb
@@ -398,6 +399,7 @@ files:
398
399
  - lib/gitlab/qa/test_logger.rb
399
400
  - lib/gitlab/qa/version.rb
400
401
  - scripts/generate-qa-jobs.rb
402
+ - support/data/admin_access_token_seed.rb
401
403
  - support/data/license_usage_seed.rb
402
404
  - tls_certificates/authority/ca.crt
403
405
  - tls_certificates/authority/ca.key