gitlab-qa 11.2.0 → 12.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.gitlab/merge_request_templates/Release.md +7 -1
  4. data/.gitlab-ci.yml +3 -1
  5. data/.rubocop.yml +13 -2
  6. data/.rubocop_todo.yml +57 -85
  7. data/Gemfile.lock +44 -36
  8. data/docs/release_process.md +1 -1
  9. data/docs/running_against_remote_grid.md +6 -6
  10. data/gitlab-qa.gemspec +4 -2
  11. data/lib/gitlab/qa/component/base.rb +9 -9
  12. data/lib/gitlab/qa/component/gitaly.rb +2 -2
  13. data/lib/gitlab/qa/component/gitaly_cluster.rb +14 -8
  14. data/lib/gitlab/qa/component/gitlab.rb +27 -20
  15. data/lib/gitlab/qa/component/mail_hog.rb +1 -0
  16. data/lib/gitlab/qa/component/praefect.rb +2 -2
  17. data/lib/gitlab/qa/component/selenoid.rb +9 -6
  18. data/lib/gitlab/qa/component/specs.rb +5 -2
  19. data/lib/gitlab/qa/component/staging.rb +4 -4
  20. data/lib/gitlab/qa/component/telegraf.rb +2 -1
  21. data/lib/gitlab/qa/docker/engine.rb +6 -3
  22. data/lib/gitlab/qa/docker/volumes.rb +1 -1
  23. data/lib/gitlab/qa/release.rb +4 -4
  24. data/lib/gitlab/qa/runner.rb +10 -3
  25. data/lib/gitlab/qa/runtime/env.rb +23 -25
  26. data/lib/gitlab/qa/runtime/logger.rb +1 -1
  27. data/lib/gitlab/qa/runtime/omnibus_configuration.rb +1 -0
  28. data/lib/gitlab/qa/runtime/omnibus_configurations/object_storage_gcs.rb +2 -1
  29. data/lib/gitlab/qa/runtime/scenario.rb +1 -5
  30. data/lib/gitlab/qa/scenario/actable.rb +4 -4
  31. data/lib/gitlab/qa/scenario/test/instance/airgapped.rb +2 -2
  32. data/lib/gitlab/qa/scenario/test/instance/deployment_base.rb +2 -1
  33. data/lib/gitlab/qa/scenario/test/integration/group_saml.rb +1 -1
  34. data/lib/gitlab/qa/scenario/test/integration/ldap.rb +5 -6
  35. data/lib/gitlab/qa/scenario/test/integration/oauth.rb +6 -3
  36. data/lib/gitlab/qa/scenario/test/integration/registry_with_cdn.rb +3 -0
  37. data/lib/gitlab/qa/scenario/test/omnibus/update_from_previous.rb +1 -1
  38. data/lib/gitlab/qa/scenario/test/omnibus/upgrade.rb +1 -3
  39. data/lib/gitlab/qa/scenario/test/sanity/version.rb +1 -1
  40. data/lib/gitlab/qa/support/config_scripts.rb +1 -1
  41. data/lib/gitlab/qa/support/gitlab_version_info.rb +3 -5
  42. data/lib/gitlab/qa/support/shell_command.rb +1 -0
  43. data/lib/gitlab/qa/test_logger.rb +2 -2
  44. data/lib/gitlab/qa/version.rb +1 -1
  45. data/support/data/admin_access_token_seed.rb +1 -0
  46. data/support/data/license_usage_seed.rb +3 -1
  47. metadata +13 -8
  48. data/lib/gitlab/qa/runtime/omnibus_configurations/packages.rb +0 -17
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # rubocop:disable Metrics/AbcSize
3
4
 
4
5
  require 'securerandom'
@@ -17,19 +18,19 @@ module Gitlab
17
18
  using Rainbow
18
19
 
19
20
  attr_reader :release,
20
- :omnibus_configuration,
21
- :omnibus_gitlab_rails_env,
22
- :authority_volume,
23
- :ssl_volume
21
+ :omnibus_configuration,
22
+ :omnibus_gitlab_rails_env,
23
+ :authority_volume,
24
+ :ssl_volume
24
25
 
25
26
  attr_accessor :tls,
26
- :skip_availability_check,
27
- :runner_network,
28
- :seed_admin_token,
29
- :seed_db,
30
- :skip_server_hooks,
31
- :gitaly_tls,
32
- :secrets
27
+ :skip_availability_check,
28
+ :runner_network,
29
+ :seed_admin_token,
30
+ :seed_db,
31
+ :skip_server_hooks,
32
+ :gitaly_tls,
33
+ :secrets
33
34
 
34
35
  attr_writer :name, :relative_path
35
36
 
@@ -182,9 +183,9 @@ module Gitlab
182
183
  def reconfigure
183
184
  setup_omnibus
184
185
 
185
- @docker.attach(name) do |line, wait|
186
+ @docker.attach(name) do |line, _wait|
186
187
  # TODO, workaround which allows to detach from the container
187
- break if /gitlab Reconfigured!/.match?(line)
188
+ break if line.include?('gitlab Reconfigured!')
188
189
  end
189
190
  end
190
191
 
@@ -236,17 +237,23 @@ module Gitlab
236
237
  end
237
238
 
238
239
  def create_key_file(env_key)
239
- key_file = Tempfile.create(env_key.downcase, ENV['CI_PROJECT_DIR'] || Dir.tmpdir).then do |file|
240
+ directory = ENV['CI_PROJECT_DIR'] || Dir.tmpdir
241
+ unique_filename = "#{env_key.downcase}_#{Time.now.to_i}_#{rand(100)}"
242
+ key_file_path = File.join(directory, unique_filename)
243
+
244
+ File.open(key_file_path, 'w') do |file|
240
245
  file.write(ENV.fetch(env_key))
241
246
  file.fsync
242
- file.close
243
-
244
- file.path
245
247
  end
246
- File.chmod(0o744, key_file)
247
- @volumes[key_file] = key_file
248
248
 
249
- key_file
249
+ File.chmod(0o744, key_file_path)
250
+ @volumes[key_file_path] = key_file_path
251
+
252
+ key_file_path
253
+ end
254
+
255
+ def delete_key_file(path)
256
+ FileUtils.rm_f(path)
250
257
  end
251
258
 
252
259
  private
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # This component sets up the MailHog (https://github.com/mailhog/MailHog)
3
4
  # image with the proper configuration for SMTP email delivery from Gitlab
4
5
 
@@ -37,7 +37,7 @@ module Gitlab
37
37
  setup_omnibus
38
38
  @docker.attach(name) do |line|
39
39
  # TODO, workaround which allows to detach from the container
40
- break if /gitlab Reconfigured!/.match?(line)
40
+ break if line.include?('gitlab Reconfigured!')
41
41
  end
42
42
  end
43
43
 
@@ -50,7 +50,7 @@ module Gitlab
50
50
  def wait_until_ready
51
51
  @docker.exec(name, 'praefect -config /var/opt/gitlab/praefect/cluster_config.toml check || true') do |resp|
52
52
  Runtime::Logger.info(resp)
53
- break if /All checks passed/.match?(line)
53
+ break if line.include?('All checks passed')
54
54
  end
55
55
  end
56
56
 
@@ -29,10 +29,12 @@ module Gitlab
29
29
  pull_images
30
30
  docker.run(image: image, tag: tag, args:
31
31
  ['-video-recorder-image',
32
- QA::Runtime::Env.video_recorder_image,
33
- '-container-network',
34
- network]
35
- ) do |command|
32
+ QA::Runtime::Env.video_recorder_image,
33
+ '-container-network',
34
+ network,
35
+ '-timeout',
36
+ '10m0s']
37
+ ) do |command|
36
38
  set_command_args(command)
37
39
  set_volumes(command)
38
40
  end
@@ -53,14 +55,15 @@ module Gitlab
53
55
  private
54
56
 
55
57
  def grid_healthy?
56
- HTTP.get('http://docker:4444/ping').status&.success?
58
+ host = ENV['CI'] || ENV['CI_SERVER'] ? 'docker' : 'localhost'
59
+ HTTP.get("http://#{host}:4444/ping").status&.success?
57
60
  rescue HTTP::ConnectionError => e
58
61
  Runtime::Logger.debug(e)
59
62
  false
60
63
  end
61
64
 
62
65
  def pull_images
63
- docker.pull(image: QA::Runtime::Env.browser_image, tag: Runtime::Env.browser_version)
66
+ docker.pull(image: QA::Runtime::Env.selenoid_browser_image, tag: Runtime::Env.selenoid_browser_version)
64
67
  docker.pull(image: QA::Runtime::Env.video_recorder_image, tag: QA::Runtime::Env.video_recorder_version)
65
68
  end
66
69
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # rubocop:disable Metrics/CyclomaticComplexity
3
4
  # rubocop:disable Metrics/AbcSize
4
5
 
@@ -56,8 +57,10 @@ module Gitlab
56
57
 
57
58
  feature_flag_sets = []
58
59
 
59
- # When `args` includes `[..., "--disable-feature", "a", "--enable-feature", "b", "--set-feature-flags", "c=enable", ...]`
60
- # `feature_flag_sets` will be set to `[["--disable-feature", "a"], ["--enable-feature", "b"], ["--set-feature-flags", "c=enable"]]`
60
+ # When `args` includes:
61
+ # `[..., "--disable-feature", "a", "--enable-feature", "b", "--set-feature-flags", "c=enable", ...]`
62
+ # `feature_flag_sets` will be set to:
63
+ # `[["--disable-feature", "a"], ["--enable-feature", "b"], ["--set-feature-flags", "c=enable"]]`
61
64
  # This will result in tests running three times, once with each feature flag option.
62
65
  while (index = args&.index { |x| x =~ /--.*-feature/ })
63
66
  feature_flag_sets << args.slice!(index, 2)
@@ -13,9 +13,9 @@ module Gitlab
13
13
 
14
14
  def self.release
15
15
  QA::Release.new(image)
16
- rescue Support::InvalidResponseError => ex
17
- warn ex.message
18
- warn "#{ex.response.code} #{ex.response.message}: #{ex.response.body}"
16
+ rescue Support::InvalidResponseError => e
17
+ warn e.message
18
+ warn "#{e.response.code} #{e.response.message}: #{e.response.body}"
19
19
  exit 1
20
20
  end
21
21
 
@@ -81,7 +81,7 @@ module Gitlab
81
81
  end
82
82
 
83
83
  def api_get!
84
- @response_body ||= # rubocop:disable Naming/MemoizedInstanceVariableName
84
+ @response_body ||=
85
85
  begin
86
86
  response = Support::GetRequest.new(uri, Runtime::Env.qa_access_token).execute!
87
87
  JSON.parse(response.body)
@@ -43,7 +43,8 @@ module Gitlab
43
43
  #
44
44
  # @return [void]
45
45
  def prepare
46
- @telegraf_config = File.open("#{Dir.mktmpdir(nil, ENV['CI_BUILDS_DIR'])}/telegraf.conf", 'w') do |file|
46
+ @telegraf_config = File.open("#{Dir.mktmpdir(nil, ENV.fetch('CI_BUILDS_DIR', nil))}/telegraf.conf",
47
+ 'w') do |file|
47
48
  file.write(config)
48
49
  file.path
49
50
  end
@@ -18,7 +18,8 @@ module Gitlab
18
18
  end
19
19
 
20
20
  def login(username:, password:, registry:)
21
- Docker::Command.execute(%(login --username "#{username}" --password "#{password}" #{registry}), mask_secrets: password)
21
+ Docker::Command.execute(%(login --username "#{username}" --password "#{password}" #{registry}),
22
+ mask_secrets: password)
22
23
  end
23
24
 
24
25
  def pull(image:, tag: nil, quiet: true)
@@ -63,7 +64,8 @@ module Gitlab
63
64
  Class.new do
64
65
  # @param file The name of the file
65
66
  # @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
+ # @param expand_vars Set false if you need to write an environment variable '$' to a file.
68
+ # The variable should be escaped \\\$
67
69
  def self.write(file, contents, expand_vars = true)
68
70
  if expand_vars
69
71
  %(echo "#{contents}" > #{file};)
@@ -82,7 +84,8 @@ module Gitlab
82
84
  def exec(name, command, mask_secrets: nil)
83
85
  cmd = ['exec']
84
86
  cmd << '--privileged' if privileged_command?(command)
85
- Docker::Command.execute(%(#{cmd.join(' ')} #{name} bash -c "#{command.gsub('"', '\\"')}"), mask_secrets: mask_secrets)
87
+ Docker::Command.execute(%(#{cmd.join(' ')} #{name} bash -c "#{command.gsub('"', '\\"')}"),
88
+ mask_secrets: mask_secrets)
86
89
  end
87
90
 
88
91
  def read_file(image, tag, path, &block)
@@ -20,7 +20,7 @@ module Gitlab
20
20
  # but Docker on macOS exposes /private and disallow exposing /var/
21
21
  # so we need to get the real tmpdir path
22
22
  Dir.mktmpdir('gitlab-qa-', File.realpath(Dir.tmpdir)).tap do |dir|
23
- yield Hash[@volumes.map { |k, v| ["#{dir}/#{k}", v] }]
23
+ yield @volumes.transform_keys { |k| "#{dir}/#{k}" }
24
24
  end
25
25
  end
26
26
  end
@@ -11,7 +11,7 @@ module Gitlab
11
11
  (-qa)?
12
12
  (:(?<tag>.+))?
13
13
  \z
14
- /xi.freeze
14
+ /xi
15
15
  CUSTOM_GITLAB_IMAGE_REGEX = %r{
16
16
  \A
17
17
  (?<image_without_tag>
@@ -23,7 +23,7 @@ module Gitlab
23
23
  (-qa)?
24
24
  (:(?<tag>.+))?
25
25
  \z
26
- }xi.freeze
26
+ }xi
27
27
 
28
28
  delegate :ci_project_path, to: Gitlab::QA::Runtime::Env
29
29
 
@@ -39,7 +39,7 @@ module Gitlab
39
39
  \A
40
40
  (?<version>\d+\.\d+.\d+(?:-rc\d+)?)-(?<edition>ce|ee|jh)
41
41
  \z
42
- /xi.freeze
42
+ /xi
43
43
 
44
44
  # Dev tag example:
45
45
  # 12.1.201906121026-325a6632895.b340d0bd35d
@@ -53,7 +53,7 @@ module Gitlab
53
53
  \A
54
54
  (?<version>\d+\.\d+(.\d+)?)\.(?<timestamp>\d+)-(?<gitlab_ref>[A-Za-z0-9]+)\.(?<omnibus_ref>[A-Za-z0-9]+)
55
55
  \z
56
- /xi.freeze
56
+ /xi
57
57
 
58
58
  DEFAULT_TAG = 'latest'
59
59
  DEFAULT_CANONICAL_TAG = 'nightly'
@@ -29,7 +29,8 @@ module Gitlab
29
29
  Runtime::Scenario.define(:teardown, false)
30
30
  end
31
31
 
32
- opts.on('--no-tests', 'Orchestrates the docker containers but does not run the tests. Implies --no-teardown') do
32
+ opts.on('--no-tests',
33
+ 'Orchestrates the docker containers but does not run the tests. Implies --no-teardown') do
33
34
  Runtime::Scenario.define(:run_tests, false)
34
35
  Runtime::Scenario.define(:teardown, false)
35
36
  end
@@ -42,7 +43,12 @@ module Gitlab
42
43
  Runtime::Scenario.define(:skip_server_hooks, true)
43
44
  end
44
45
 
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|
46
+ opts.on(
47
+ '--qa-image QA_IMAGE',
48
+ String,
49
+ "Specifies a QA image to be used instead of inferring it from the GitLab image." \
50
+ "See Gitlab::QA::Release#qa_image"
51
+ ) do |value|
46
52
  Runtime::Scenario.define(:qa_image, value)
47
53
  end
48
54
 
@@ -58,7 +64,8 @@ module Gitlab
58
64
  end
59
65
  end
60
66
 
61
- opts.on('--seed-db search_pattern1[,search_pattern2,...]', 'Seed application database with sample test data') do |file_pattern|
67
+ opts.on('--seed-db search_pattern1[,search_pattern2,...]',
68
+ 'Seed application database with sample test data') do |file_pattern|
62
69
  file_pattern.split(',').each do |pattern|
63
70
  @seed_scripts << pattern
64
71
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support'
3
4
  require 'active_support/core_ext/object/blank'
4
5
  require 'securerandom'
5
6
 
@@ -22,12 +23,12 @@ module Gitlab
22
23
  'QA_REMOTE_MOBILE_DEVICE_NAME' => :remote_mobile_device_name,
23
24
  'QA_REMOTE_TUNNEL_ID' => :remote_tunnel_id,
24
25
  'QA_BROWSER' => :browser,
25
- 'QA_BROWSER_VERSION' => :browser_version,
26
+ 'QA_SELENOID_BROWSER_VERSION' => :selenoid_browser_version,
26
27
  'QA_RECORD_VIDEO' => :record_video,
27
28
  'QA_LAYOUT' => :layout,
28
29
  'QA_VIDEO_RECORDER_IMAGE' => :video_recorder_image,
29
30
  'QA_VIDEO_RECORDER_VERSION' => :video_recorder_version,
30
- 'QA_BROWSER_IMAGE' => :browser_image,
31
+ 'QA_SELENOID_BROWSER_IMAGE' => :selenoid_browser_image,
31
32
  'QA_ADDITIONAL_REPOSITORY_STORAGE' => :qa_additional_repository_storage,
32
33
  'QA_PRAEFECT_REPOSITORY_STORAGE' => :qa_praefect_repository_storage,
33
34
  'QA_GITALY_NON_CLUSTER_STORAGE' => :qa_gitaly_non_cluster_storage,
@@ -89,6 +90,7 @@ module Gitlab
89
90
  'RSPEC_SKIPPED_TESTS_REPORT_PATH' => :skipped_tests_report_path,
90
91
  'CI' => :ci,
91
92
  'CI_JOB_NAME' => :ci_job_name,
93
+ 'CI_JOB_NAME_SLUG' => :ci_job_name_slug,
92
94
  'CI_JOB_URL' => :ci_job_url,
93
95
  'CI_JOB_TOKEN' => :ci_job_token,
94
96
  'CI_RUNNER_ID' => :ci_runner_id,
@@ -156,9 +158,7 @@ module Gitlab
156
158
  attr_writer(method_name)
157
159
 
158
160
  define_method(method_name) do
159
- env_var_value_if_defined(env_name) || (if instance_variable_defined?("@#{method_name}")
160
- instance_variable_get("@#{method_name}")
161
- end)
161
+ env_var_value_if_defined(env_name) || (instance_variable_get("@#{method_name}") if instance_variable_defined?("@#{method_name}"))
162
162
  end
163
163
  end
164
164
 
@@ -169,7 +169,7 @@ module Gitlab
169
169
  value = env_var_name_if_defined(name) || send(attribute) # rubocop:disable GitlabSecurity/PublicSend
170
170
  vars[name] = value if value
171
171
  end
172
- qa_variables = ENV.each_with_object({}) do |(name, value), vars|
172
+ qa_variables = ENV.each_with_object({}) do |(name, _value), vars|
173
173
  next unless name.start_with?('QA_')
174
174
 
175
175
  var_name = env_var_name_if_defined(name)
@@ -180,7 +180,7 @@ module Gitlab
180
180
  end
181
181
 
182
182
  def debug?
183
- enabled?(ENV['QA_DEBUG'], default: true)
183
+ enabled?(ENV.fetch('QA_DEBUG', nil), default: true)
184
184
  end
185
185
 
186
186
  def log_level
@@ -208,7 +208,7 @@ module Gitlab
208
208
  end
209
209
 
210
210
  def colorized_logs?
211
- enabled?(ENV['COLORIZED_LOGS'], default: false)
211
+ enabled?(ENV.fetch('COLORIZED_LOGS', nil), default: false)
212
212
  end
213
213
 
214
214
  def dev_access_token_variable
@@ -265,32 +265,30 @@ module Gitlab
265
265
 
266
266
  def require_aws_s3_environment!
267
267
  %w[AWS_S3_REGION AWS_S3_KEY_ID AWS_S3_ACCESS_KEY AWS_S3_BUCKET_NAME].each do |env_key|
268
- unless ENV.key?(env_key)
269
- raise ArgumentError, "Environment variable #{env_key} must be set to run AWS S3 object storage specs"
270
- end
268
+ raise ArgumentError, "Environment variable #{env_key} must be set to run AWS S3 object storage specs" unless ENV.key?(env_key)
271
269
  end
272
270
  end
273
271
 
274
272
  def require_gcs_environment!
275
273
  %w[GOOGLE_PROJECT GOOGLE_CLIENT_EMAIL GOOGLE_JSON_KEY GCS_BUCKET_NAME].each do |env_key|
276
- unless ENV.key?(env_key)
277
- raise ArgumentError, "Environment variable #{env_key} must be set to run GCS object storage specs"
278
- end
274
+ raise ArgumentError, "Environment variable #{env_key} must be set to run GCS object storage specs" unless ENV.key?(env_key)
279
275
  end
280
276
  end
281
277
 
282
278
  def require_gcs_with_cdn_environment!
283
- %w[GOOGLE_CDN_JSON_KEY GCS_CDN_BUCKET_NAME GOOGLE_CDN_LB GOOGLE_CDN_SIGNURL_KEY GOOGLE_CDN_SIGNURL_KEY_NAME].each do |env_key|
284
- unless ENV.key?(env_key)
285
- raise ArgumentError, "Environment variable #{env_key} must be set to run GCS with CDN enabled scenario"
286
- end
279
+ %w[GOOGLE_CDN_JSON_KEY GCS_CDN_BUCKET_NAME GOOGLE_CDN_LB GOOGLE_CDN_SIGNURL_KEY
280
+ GOOGLE_CDN_SIGNURL_KEY_NAME].each do |env_key|
281
+ raise ArgumentError, "Environment variable #{env_key} must be set to run GCS with CDN enabled scenario" unless ENV.key?(env_key)
287
282
  end
288
283
  end
289
284
 
290
285
  def require_oauth_environment!
291
286
  %w[QA_GITHUB_OAUTH_APP_ID QA_GITHUB_OAUTH_APP_SECRET QA_GITHUB_USERNAME
292
- QA_GITHUB_PASSWORD QA_1P_EMAIL QA_1P_PASSWORD QA_1P_SECRET QA_1P_GITHUB_UUID].each do |env_key|
293
- raise ArgumentError, "Environment variable #{env_key} must be set to run OAuth specs" unless ENV.key?(env_key)
287
+ QA_GITHUB_PASSWORD QA_1P_EMAIL QA_1P_PASSWORD QA_1P_SECRET QA_1P_GITHUB_UUID].each do |env_key|
288
+ unless ENV.key?(env_key)
289
+ raise ArgumentError,
290
+ "Environment variable #{env_key} must be set to run OAuth specs"
291
+ end
294
292
  end
295
293
  end
296
294
 
@@ -342,12 +340,12 @@ module Gitlab
342
340
  env_var_value_if_defined('QA_VIDEO_RECORDER_VERSION') || 'latest'
343
341
  end
344
342
 
345
- def browser_image
346
- env_var_value_if_defined('QA_BROWSER_IMAGE') || 'selenoid/chrome'
343
+ def selenoid_browser_image
344
+ env_var_value_if_defined('QA_SELENOID_BROWSER_IMAGE') || 'selenoid/chrome'
347
345
  end
348
346
 
349
- def browser_version
350
- env_var_value_if_defined('QA_BROWSER_VERSION') || '111.0'
347
+ def selenoid_browser_version
348
+ env_var_value_if_defined('QA_SELENOID_BROWSER_VERSION') || '111.0'
351
349
  end
352
350
 
353
351
  def qa_run_type
@@ -440,7 +438,7 @@ module Gitlab
440
438
  end
441
439
 
442
440
  def env_var_value_if_defined(variable)
443
- return ENV[variable] if env_var_value_valid?(variable)
441
+ return ENV.fetch(variable, nil) if env_var_value_valid?(variable)
444
442
  end
445
443
 
446
444
  def env_var_name_if_defined(variable)
@@ -14,7 +14,7 @@ module Gitlab
14
14
  def self.logger
15
15
  @logger ||= begin
16
16
  log_path = Env.log_path
17
- ::FileUtils.mkdir_p(log_path) unless File.exist?(log_path)
17
+ ::FileUtils.mkdir_p(log_path)
18
18
 
19
19
  TestLogger.logger(level: Env.log_level, path: log_path)
20
20
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support'
3
4
  require 'active_support/core_ext/object/blank'
4
5
 
5
6
  module Gitlab
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'tempfile'
3
4
 
4
5
  module Gitlab
@@ -26,7 +27,7 @@ module Gitlab
26
27
  end
27
28
 
28
29
  def setup_json_key
29
- Tempfile.open('gcs-json-key', ENV['CI_PROJECT_DIR']) do |file|
30
+ Tempfile.open('gcs-json-key', ENV.fetch('CI_PROJECT_DIR', nil)) do |file|
30
31
  file.write(ENV.fetch('GOOGLE_JSON_KEY'))
31
32
 
32
33
  file
@@ -18,18 +18,14 @@ module Gitlab
18
18
 
19
19
  define_singleton_method(attribute) do
20
20
  attributes[attribute.to_sym].tap do |value|
21
- if value.to_s.empty?
22
- raise ArgumentError, "Empty `#{attribute}` attribute!"
23
- end
21
+ raise ArgumentError, "Empty `#{attribute}` attribute!" if value.to_s.empty?
24
22
  end
25
23
  end
26
24
  end
27
25
 
28
- # rubocop:disable Style/MethodMissing
29
26
  def method_missing(name, *)
30
27
  raise ArgumentError, "Scenario attribute `#{name}` not defined!"
31
28
  end
32
- # rubocop:enable Style/MethodMissing
33
29
  end
34
30
  end
35
31
  end
@@ -4,8 +4,8 @@ module Gitlab
4
4
  module QA
5
5
  module Scenario
6
6
  module Actable
7
- def act(*args, &block)
8
- instance_exec(*args, &block)
7
+ def act(...)
8
+ instance_exec(...)
9
9
  end
10
10
 
11
11
  def self.included(base)
@@ -17,8 +17,8 @@ module Gitlab
17
17
  yield new if block_given?
18
18
  end
19
19
 
20
- def act(*args, &block)
21
- new.act(*args, &block)
20
+ def act(...)
21
+ new.act(...)
22
22
  end
23
23
  end
24
24
  end
@@ -80,10 +80,10 @@ module Gitlab
80
80
  iptables -A OUTPUT -p tcp -m tcp --sport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
81
81
  iptables -A INPUT -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
82
82
 
83
- # some exceptions to allow runners access network https://gitlab.com/gitlab-org/gitlab-qa/-/issues/700
83
+ # some exceptions to allow runners access network https://gitlab.com/gitlab-org/gitlab-qa/-/issues/700#{' '}
84
84
  iptables -A OUTPUT -p tcp -d #{gitlab_registry_ip} -j ACCEPT
85
85
  iptables -A OUTPUT -p tcp -d #{dev_gitlab_registry_ip} -j ACCEPT
86
- # allow access to praefect node
86
+ # allow access to praefect node#{' '}
87
87
  iptables -A OUTPUT -p tcp -d #{praefect_ip} -j ACCEPT
88
88
 
89
89
  # Should now fail to ping gitlab_ip, port 22/80 should be open
@@ -37,7 +37,8 @@ module Gitlab
37
37
  end
38
38
 
39
39
  def deployment_component
40
- raise NotImplementedError, 'Please define the Component for the deployment environment associated with this scenario.'
40
+ raise NotImplementedError,
41
+ 'Please define the Component for the deployment environment associated with this scenario.'
41
42
  end
42
43
  end
43
44
  end
@@ -18,7 +18,7 @@ module Gitlab
18
18
  raise ArgumentError, 'Group SAML is EE only feature!' unless release.ee?
19
19
  end
20
20
 
21
- def configure(gitlab, saml)
21
+ def configure(gitlab, _saml)
22
22
  gitlab.omnibus_configuration << <<~OMNIBUS
23
23
  gitlab_rails['omniauth_enabled'] = true;
24
24
  gitlab_rails['omniauth_providers'] = [{ name: 'group_saml' }];
@@ -66,16 +66,14 @@ module Gitlab
66
66
  end
67
67
  end
68
68
 
69
- def orchestrate_ldap
69
+ def orchestrate_ldap(&block)
70
70
  Component::LDAP.perform do |ldap|
71
71
  ldap.name = 'ldap-server'
72
72
  ldap.network = 'test'
73
73
  ldap.set_gitlab_credentials
74
74
  ldap.tls = tls
75
75
 
76
- ldap.instance do
77
- yield
78
- end
76
+ ldap.instance(&block)
79
77
  end
80
78
  end
81
79
 
@@ -90,8 +88,9 @@ module Gitlab
90
88
  if orchestrate_ldap_server
91
89
  orchestrate_ldap { run_specs(gitlab, {}, *rspec_args) }
92
90
  else
93
- volumes = { 'admin': File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'qa/fixtures/ldap/admin'),
94
- 'non_admin': File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'qa/fixtures/ldap/non_admin') }
91
+ volumes = { admin: File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'qa/fixtures/ldap/admin'),
92
+ non_admin: File.join(Docker::Volumes::QA_CONTAINER_WORKDIR,
93
+ 'qa/fixtures/ldap/non_admin') }
95
94
  run_specs(gitlab, volumes, *rspec_args)
96
95
  end
97
96
  end
@@ -11,7 +11,7 @@ module Gitlab
11
11
  attr_reader :gitlab_name
12
12
 
13
13
  def initialize
14
- @gitlab_name = 'gitlab-oauth'
14
+ @gitlab_name = 'gitlab'
15
15
  end
16
16
 
17
17
  def perform(release, *rspec_args)
@@ -23,8 +23,9 @@ module Gitlab
23
23
  gitlab.release = release
24
24
  gitlab.network = 'test'
25
25
  gitlab.name = gitlab_name
26
+ gitlab.tls = true
26
27
 
27
- gitlab.omnibus_configuration << gitlab_omnibus_configuration
28
+ gitlab.omnibus_configuration << gitlab_omnibus_configuration(gitlab.address)
28
29
 
29
30
  gitlab.instance do
30
31
  Runtime::Logger.info('Running OAuth specs!')
@@ -43,7 +44,7 @@ module Gitlab
43
44
 
44
45
  private
45
46
 
46
- def gitlab_omnibus_configuration
47
+ def gitlab_omnibus_configuration(gitlab_address)
47
48
  <<~OMNIBUS
48
49
  gitlab_rails['omniauth_enabled'] = true;
49
50
  gitlab_rails['omniauth_allow_single_sign_on'] = ['github'];
@@ -58,6 +59,8 @@ module Gitlab
58
59
  args: { scope: 'user:email' }
59
60
  }
60
61
  ];
62
+ letsencrypt['enable'] = false;
63
+ external_url '#{gitlab_address}';
61
64
  OMNIBUS
62
65
  end
63
66
  end
@@ -32,6 +32,9 @@ module Gitlab
32
32
  specs.network = gitlab.network
33
33
  specs.args = [gitlab.address, *rspec_args]
34
34
  end
35
+ ensure
36
+ gitlab.delete_key_file(sign_url_key_path)
37
+ gitlab.delete_key_file(cdn_gcloud_path)
35
38
  end
36
39
  end
37
40
  end
@@ -115,7 +115,7 @@ module Gitlab
115
115
  # @param [Gitlab::QA::Release] release
116
116
  # @return [Boolean]
117
117
  def run_specs?(release)
118
- [upgrade_path.first, current_release].any? { |rel| rel == release }
118
+ [upgrade_path.first, current_release].any?(release)
119
119
  end
120
120
  end
121
121
  end
@@ -12,9 +12,7 @@ module Gitlab
12
12
  def perform(image = 'CE', *rspec_args)
13
13
  ce_release = QA::Release.new(image)
14
14
 
15
- if ce_release.ee?
16
- raise ArgumentError, 'Only CE can be upgraded to EE!'
17
- end
15
+ raise ArgumentError, 'Only CE can be upgraded to EE!' if ce_release.ee?
18
16
 
19
17
  Docker::Volumes.new.with_temporary_volumes do |volumes|
20
18
  Scenario::Test::Instance::Image