gitlab-qa 7.24.6 → 7.26.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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab/ci/jobs/actioncable.gitlab-ci.yml +41 -0
  3. data/.gitlab/ci/jobs/base.gitlab-ci.yml +281 -0
  4. data/.gitlab/ci/jobs/cloud_activation.gitlab-ci.yml +30 -0
  5. data/.gitlab/ci/jobs/custom_parallel.gitlab-ci.yml +21 -0
  6. data/.gitlab/ci/jobs/ee_previous_to_ce_update.gitlab-ci.yml +18 -0
  7. data/.gitlab/ci/jobs/elasticsearch.gitlab-ci.yml +20 -0
  8. data/.gitlab/ci/jobs/geo.gitlab-ci.yml +18 -0
  9. data/.gitlab/ci/jobs/gitaly_cluster.gitlab-ci.yml +45 -0
  10. data/.gitlab/ci/jobs/group_saml.gitlab-ci.yml +20 -0
  11. data/.gitlab/ci/jobs/instance.gitlab-ci.yml +55 -0
  12. data/.gitlab/ci/jobs/instance_saml.gitlab-ci.yml +41 -0
  13. data/.gitlab/ci/jobs/integrations.gitlab-ci.yml +14 -0
  14. data/.gitlab/ci/jobs/jira.gitlab-ci.yml +41 -0
  15. data/.gitlab/ci/jobs/large_setup.gitlab-ci.yml +19 -0
  16. data/.gitlab/ci/jobs/ldap_no_server.gitlab-ci.yml +20 -0
  17. data/.gitlab/ci/jobs/ldap_no_tls.gitlab-ci.yml +41 -0
  18. data/.gitlab/ci/jobs/ldap_tls.gitlab-ci.yml +41 -0
  19. data/.gitlab/ci/jobs/mattermost.gitlab-ci.yml +41 -0
  20. data/.gitlab/ci/jobs/mtls.gitlab-ci.yml +17 -0
  21. data/.gitlab/ci/jobs/object_storage.gitlab-ci.yml +49 -0
  22. data/.gitlab/ci/jobs/object_storage_aws.gitlab-ci.yml +25 -0
  23. data/.gitlab/ci/jobs/object_storage_gcs.gitlab-ci.yml +23 -0
  24. data/.gitlab/ci/jobs/object_storage_registry_tls.gitlab-ci.yml +41 -0
  25. data/.gitlab/ci/jobs/omnibus_image.gitlab-ci.yml +15 -0
  26. data/.gitlab/ci/jobs/omnibus_upgrade.gitlab-ci.yml +28 -0
  27. data/.gitlab/ci/jobs/packages.gitlab-ci.yml +25 -0
  28. data/.gitlab/ci/jobs/praefect.gitlab-ci.yml +71 -0
  29. data/.gitlab/ci/jobs/registry.gitlab-ci.yml +41 -0
  30. data/.gitlab/ci/jobs/registry_with_cdn.gitlab-ci.yml +43 -0
  31. data/.gitlab/ci/jobs/relative_url.gitlab-ci.yml +65 -0
  32. data/.gitlab/ci/jobs/repository_storage.gitlab-ci.yml +41 -0
  33. data/.gitlab/ci/jobs/sanity_framework.gitlab-ci.yml +24 -0
  34. data/.gitlab/ci/jobs/service_ping_disabled.gitlab-ci.yml +19 -0
  35. data/.gitlab/ci/jobs/smtp.gitlab-ci.yml +19 -0
  36. data/.gitlab/ci/jobs/staging.gitlab-ci.yml +10 -0
  37. data/.gitlab/ci/jobs/update.gitlab-ci.yml +60 -0
  38. data/.gitlab/ci/rules.gitlab-ci.yml +19 -6
  39. data/.gitlab/issue_templates/Default.md +2 -0
  40. data/.gitlab/merge_request_templates/Default.md +2 -0
  41. data/.gitlab-ci.yml +110 -1333
  42. data/bin/notify_upstream +98 -0
  43. data/docs/what_tests_can_be_run.md +15 -0
  44. data/lib/gitlab/qa/component/base.rb +0 -1
  45. data/lib/gitlab/qa/component/gitlab.rb +48 -1
  46. data/lib/gitlab/qa/component/staging_ref.rb +1 -0
  47. data/lib/gitlab/qa/docker/engine.rb +4 -0
  48. data/lib/gitlab/qa/release.rb +1 -1
  49. data/lib/gitlab/qa/report/gitlab_issue_client.rb +12 -0
  50. data/lib/gitlab/qa/report/relate_failure_issue.rb +17 -2
  51. data/lib/gitlab/qa/report/test_result.rb +8 -0
  52. data/lib/gitlab/qa/report/update_screenshot_path.rb +28 -6
  53. data/lib/gitlab/qa/runner.rb +17 -0
  54. data/lib/gitlab/qa/runtime/env.rb +14 -1
  55. data/lib/gitlab/qa/runtime/omnibus_configuration.rb +1 -1
  56. data/lib/gitlab/qa/runtime/omnibus_configurations/ci_decomposition.rb +32 -0
  57. data/lib/gitlab/qa/scenario/test/instance/deployment_base.rb +5 -0
  58. data/lib/gitlab/qa/scenario/test/instance/staging_ref_geo.rb +27 -0
  59. data/lib/gitlab/qa/scenario/test/integration/geo.rb +2 -1
  60. data/lib/gitlab/qa/scenario/test/integration/gitaly_cluster.rb +2 -0
  61. data/lib/gitlab/qa/scenario/test/integration/mattermost.rb +5 -1
  62. data/lib/gitlab/qa/scenario/test/integration/mtls.rb +1 -0
  63. data/lib/gitlab/qa/scenario/test/integration/registry_with_cdn.rb +42 -0
  64. data/lib/gitlab/qa/scenario/test/omnibus/update.rb +1 -0
  65. data/lib/gitlab/qa/version.rb +1 -1
  66. data/lib/gitlab/qa.rb +3 -0
  67. data/scripts/generate-qa-jobs.rb +72 -0
  68. data/support/data/admin_access_token_seed.rb +24 -0
  69. data/support/data/license_usage_seed.rb +75 -0
  70. metadata +45 -3
  71. data/bin/notify_upstream_commit +0 -61
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'gitlab'
5
+
6
+ # Default to "Multi-pipeline (from 'gitlab-org/gitlab-qa' 'notify_upstream:*' jobs)" from current project
7
+ api_token = ENV.fetch('GITLAB_QA_PROJECT_ACCESS_TOKEN') do
8
+ puts "The $GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN variable is deprecated in favor of a dedicated project access token: $GITLAB_QA_PROJECT_ACCESS_TOKEN."
9
+ puts "See https://gitlab.com/groups/gitlab-org/quality/-/epics/17 for more details."
10
+ ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN']
11
+ end
12
+
13
+ # Configure credentials to be used with gitlab gem
14
+ Gitlab.configure do |config|
15
+ config.endpoint = 'https://gitlab.com/api/v4'
16
+ config.private_token = api_token
17
+ end
18
+
19
+ class CommitComment
20
+ UPSTREAM_COMMENT = <<~COMMENT
21
+ - The [`gitlab-qa-mirror` downstream pipeline](%<pipeline_url>s) for https://gitlab.com/%<project_path>s/-/merge_requests/%<mr_iid>s/diffs?commit_id=%<commit_sha>s %<status_with_icon>s
22
+ COMMENT
23
+ IDENTIFIABLE_NOTE_TAG = 'gitlab-qa:upstream-notification-note'
24
+
25
+ def self.mr?
26
+ ENV.key?('TOP_UPSTREAM_SOURCE_PROJECT') &&
27
+ ENV.key?('TOP_UPSTREAM_MERGE_REQUEST_IID') &&
28
+ ENV.key?('TOP_UPSTREAM_SOURCE_SHA') &&
29
+ !ENV['TOP_UPSTREAM_SOURCE_PROJECT'].to_s.empty? &&
30
+ !ENV['TOP_UPSTREAM_MERGE_REQUEST_IID'].to_s.empty? &&
31
+ !ENV['TOP_UPSTREAM_SOURCE_SHA'].to_s.empty?
32
+ end
33
+
34
+ def self.post!(status)
35
+ unless mr?
36
+ puts "All the 'TOP_UPSTREAM_SOURCE_PROJECT', 'TOP_UPSTREAM_MERGE_REQUEST_IID', and 'TOP_UPSTREAM_SOURCE_SHA' environment variables need to be present. We cannot post a comment on the upstream merge request."
37
+ return
38
+ end
39
+
40
+ # Look for an existing note
41
+ upstream_notification_note = Gitlab.merge_request_notes(project_path, mr_iid).auto_paginate.find do |note|
42
+ note.body.include?(IDENTIFIABLE_NOTE_TAG)
43
+ end
44
+
45
+ if upstream_notification_note
46
+ Gitlab.edit_merge_request_note(project_path, mr_iid, upstream_notification_note.id, [upstream_notification_note.body, build_comment(status)].join("\n"))
47
+ else
48
+ Gitlab.create_merge_request_comment(project_path, mr_iid, "<!-- #{IDENTIFIABLE_NOTE_TAG} -->\n#{build_comment(status)}")
49
+ end
50
+ rescue Gitlab::Error::Error => error
51
+ puts "Ignoring the following error: #{error}"
52
+ end
53
+
54
+ def self.project_path
55
+ ENV['TOP_UPSTREAM_SOURCE_PROJECT']
56
+ end
57
+
58
+ def self.mr_iid
59
+ ENV['TOP_UPSTREAM_MERGE_REQUEST_IID']
60
+ end
61
+
62
+ def self.pipeline_url
63
+ ENV['CI_PIPELINE_URL']
64
+ end
65
+
66
+ def self.commit_sha
67
+ ENV['TOP_UPSTREAM_SOURCE_SHA']
68
+ end
69
+
70
+ def self.build_comment(status)
71
+ format(UPSTREAM_COMMENT,
72
+ project_path: project_path,
73
+ mr_iid: mr_iid,
74
+ pipeline_url: pipeline_url,
75
+ status_with_icon: status_with_icon(status),
76
+ commit_sha: commit_sha
77
+ )
78
+ end
79
+
80
+ def self.status_with_icon(status)
81
+ case status
82
+ when :success
83
+ "passed. :white_check_mark:"
84
+ when :failure
85
+ "failed! :boom:"
86
+ end
87
+ end
88
+
89
+ def self.post_to_mr(project_id, mr_iid, comment)
90
+ Gitlab.create_merge_request_comment(project_id, mr_iid, comment)
91
+ end
92
+ end
93
+
94
+ status = ARGV.shift.to_s.strip
95
+
96
+ abort "Please provide a status!" if status == ''
97
+
98
+ CommitComment.post!(status.to_sym)
@@ -818,6 +818,21 @@ $ export GITLAB_PASSWORD="$GITLAB_QA_PASSWORD"
818
818
  $ gitlab-qa Test::Instance::StagingGeo
819
819
  ```
820
820
 
821
+ ### `Test::Instance::StagingRefGeo`
822
+
823
+ This scenario tests that the Geo staging deployment (with [`staging-ref.gitlab.com`](https://staging-ref.gitlab.com) as the primary site and [`geo.staging-ref.gitlab.com`](https://geo.staging-ref.gitlab.com) as the secondary site) works as expected by running tests tagged `:geo` against it. This is done by spinning up a GitLab QA (`gitlab/gitlab-qa`) container and running the `QA::EE::Scenario::Test::Geo` scenario. Note that the Geo setup steps in the `QA::EE::Scenario::Test::Geo` scenario are skipped when testing a live Geo deployment.
824
+
825
+ Scenario requirements are the same as [`Test::Instance::StagingGeo`](#testinstancestaginggeo) described above.
826
+
827
+ ```
828
+ $ export GITLAB_QA_ACCESS_TOKEN=your_api_access_token
829
+ $ export GITLAB_QA_DEV_ACCESS_TOKEN=your_dev_registry_access_token
830
+ $ export GITLAB_USERNAME="gitlab-qa"
831
+ $ export GITLAB_PASSWORD="$GITLAB_QA_PASSWORD"
832
+
833
+ $ gitlab-qa Test::Instance::StagingRefGeo
834
+ ```
835
+
821
836
  ### `Test::Instance::Production`
822
837
 
823
838
  This scenario functions the same as `Test::Instance::Staging`
@@ -124,7 +124,6 @@ module Gitlab
124
124
 
125
125
  return unless docker.running?(name)
126
126
 
127
- docker.stop(name)
128
127
  docker.remove(name)
129
128
  end
130
129
 
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
+ # rubocop:disable Metrics/AbcSize
2
3
 
3
4
  require 'securerandom'
4
5
  require 'net/http'
5
6
  require 'uri'
6
7
  require 'forwardable'
7
8
  require 'openssl'
9
+ require 'tempfile'
8
10
 
9
11
  module Gitlab
10
12
  module QA
@@ -13,15 +15,17 @@ module Gitlab
13
15
  extend Forwardable
14
16
 
15
17
  attr_reader :release, :omnibus_configuration, :omnibus_gitlab_rails_env
16
- attr_accessor :tls, :skip_availability_check, :runner_network
18
+ attr_accessor :tls, :skip_availability_check, :runner_network, :seed_admin_token, :seed_db
17
19
  attr_writer :name, :relative_path
18
20
 
19
21
  def_delegators :release, :tag, :image, :edition
20
22
 
21
23
  CERTIFICATES_PATH = File.expand_path('../../../../tls_certificates', __dir__)
24
+ DATA_SEED_PATH = File.expand_path('../../../../support/data', __dir__)
22
25
 
23
26
  SSL_PATH = '/etc/gitlab/ssl'
24
27
  TRUSTED_PATH = '/etc/gitlab/trusted-certs'
28
+ DATA_PATH = '/tmp/data-seeds'
25
29
 
26
30
  def initialize
27
31
  super
@@ -39,6 +43,9 @@ module Gitlab
39
43
  @volumes[@gitlab_cert_path] = SSL_PATH
40
44
  @volumes[@authority_cert_path] = TRUSTED_PATH
41
45
 
46
+ @seed_admin_token = Runtime::Scenario.seed_admin_token
47
+ @seed_db = Runtime::Scenario.seed_db
48
+
42
49
  self.release = 'CE'
43
50
  end
44
51
 
@@ -166,6 +173,16 @@ module Gitlab
166
173
  end
167
174
  end
168
175
 
176
+ def process_exec_commands
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
181
+
182
+ Runtime::Logger.info("Running exec_commands...")
183
+ exec_commands.flatten.uniq.each { |command| @docker.exec(name, command) }
184
+ end
185
+
169
186
  def sha_version
170
187
  json = @docker.read_file(
171
188
  @release.image, @release.tag,
@@ -176,6 +193,19 @@ module Gitlab
176
193
  manifest['software']['gitlab-rails']['locked_version']
177
194
  end
178
195
 
196
+ def copy_key_file(env_key)
197
+ key_dir = ENV['CI_PROJECT_DIR'] || Dir.tmpdir
198
+ key_file = Tempfile.new(env_key.downcase, key_dir)
199
+ key_file.write(ENV.fetch(env_key))
200
+ key_file.close
201
+
202
+ File.chmod(0o744, key_file.path)
203
+
204
+ @volumes[key_file.path] = key_file.path
205
+
206
+ key_file.path
207
+ end
208
+
179
209
  private
180
210
 
181
211
  # Copy certs to a temporary directory in current working directory.
@@ -196,6 +226,22 @@ module Gitlab
196
226
  end
197
227
  end
198
228
 
229
+ def seed_test_data_command
230
+ cmd = []
231
+
232
+ Runtime::Scenario.seed_db.each do |file_patterns|
233
+ Dir["#{DATA_SEED_PATH}/#{file_patterns}"].map { |f| File.basename f }.each do |file|
234
+ cmd << "gitlab-rails runner #{DATA_PATH}/#{file}"
235
+ end
236
+ end
237
+
238
+ cmd.uniq
239
+ end
240
+
241
+ def seed_admin_token_command
242
+ ["gitlab-rails runner #{DATA_PATH}/admin_access_token_seed.rb"]
243
+ end
244
+
199
245
  class Availability
200
246
  def initialize(name, relative_path: '', scheme: 'http', protocol_port: 80)
201
247
  @docker = Docker::Engine.new
@@ -241,3 +287,4 @@ module Gitlab
241
287
  end
242
288
  end
243
289
  end
290
+ # rubocop:enable Metrics/AbcSize
@@ -3,6 +3,7 @@ module Gitlab
3
3
  module Component
4
4
  class StagingRef < Staging
5
5
  ADDRESS = 'https://staging-ref.gitlab.com'.freeze
6
+ GEO_SECONDARY_ADDRESS = 'https://geo.staging-ref.gitlab.com'.freeze
6
7
  end
7
8
  end
8
9
  end
@@ -76,6 +76,10 @@ module Gitlab
76
76
  Docker::Command.execute("attach --sig-proxy=false #{name}", &block)
77
77
  end
78
78
 
79
+ def copy(name, src_path, dest_path)
80
+ Docker::Command.execute("cp #{src_path} #{name}:#{dest_path}")
81
+ end
82
+
79
83
  def restart(name)
80
84
  Docker::Command.execute("restart #{name}")
81
85
  end
@@ -147,7 +147,7 @@ module Gitlab
147
147
  registry: DEV_REGISTRY
148
148
  }
149
149
  elsif omnibus_mirror?
150
- username, password = if Runtime::Env.ci_job_token && Runtime::Env.ci_pipeline_source == 'pipeline'
150
+ username, password = if Runtime::Env.ci_job_token && Runtime::Env.ci_pipeline_source.include?('pipeline')
151
151
  ['gitlab-ci-token', Runtime::Env.ci_job_token]
152
152
  elsif Runtime::Env.qa_container_registry_access_token
153
153
  [Runtime::Env.gitlab_username, Runtime::Env.qa_container_registry_access_token]
@@ -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
@@ -47,7 +47,7 @@ module Gitlab
47
47
  puts " => Searching issues for test '#{test.name}'..."
48
48
 
49
49
  begin
50
- issue = find_and_link_issue(test) || create_issue(test)
50
+ issue = test.quarantine? ? find_and_link_issue(test) : find_and_link_issue(test) || create_issue(test)
51
51
  return unless issue
52
52
 
53
53
  update_labels(issue, test)
@@ -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
@@ -12,9 +12,13 @@ module Gitlab
12
12
  Runtime::Scenario.define(:run_tests, true)
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
+ 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, [])
15
18
 
16
19
  # Omnibus Configurators specified by flags
17
20
  @active_configurators = []
21
+ @seed_scripts = []
18
22
  @omnibus_configurations = %w[default] # always load default configuration
19
23
 
20
24
  @options = OptionParser.new do |opts|
@@ -29,6 +33,10 @@ module Gitlab
29
33
  Runtime::Scenario.define(:teardown, false)
30
34
  end
31
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
+
32
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|
33
41
  Runtime::Scenario.define(:qa_image, value)
34
42
  end
@@ -45,6 +53,14 @@ module Gitlab
45
53
  end
46
54
  end
47
55
 
56
+ opts.on('--seed-db search_pattern1[,search_pattern2,...]', 'Seed application database with sample test data') do |file_pattern|
57
+ file_pattern.split(',').each do |pattern|
58
+ @seed_scripts << pattern
59
+ end
60
+
61
+ Runtime::Scenario.define(:seed_db, @seed_scripts)
62
+ end
63
+
48
64
  opts.on_tail('-h', '--help', 'Show the usage') do
49
65
  puts opts
50
66
  exit
@@ -125,6 +141,7 @@ module Gitlab
125
141
  # # Runtime::OmnibusConfiguration::Packages
126
142
  # gitlab_rails['packages_enabled'] = true
127
143
  Runtime::Scenario.omnibus_configuration << "# #{configurator.class.name}"
144
+ Runtime::Scenario.omnibus_exec_commands << configurator.exec_commands
128
145
 
129
146
  # Load the configuration
130
147
  configurator.configuration.split("\n").each { |c| Runtime::Scenario.omnibus_configuration << c }
@@ -127,6 +127,11 @@ module Gitlab
127
127
  'GOOGLE_PROJECT' => :google_project,
128
128
  'GOOGLE_CLIENT_EMAIL' => :google_client_email,
129
129
  'GOOGLE_JSON_KEY' => :google_json_key,
130
+ 'GOOGLE_CDN_JSON_KEY' => :google_cdn_json_key,
131
+ 'GOOGLE_CDN_LB' => :google_cdn_load_balancer,
132
+ 'GOOGLE_CDN_SIGNURL_KEY' => :google_cdn_signurl_key,
133
+ 'GOOGLE_CDN_SIGNURL_KEY_NAME' => :google_cdn_signurl_key_name,
134
+ 'GCS_CDN_BUCKET_NAME' => :gcs_cdn_bucket_name,
130
135
  'GCS_BUCKET_NAME' => :gcs_bucket_name,
131
136
  'SMOKE_ONLY' => :smoke_only,
132
137
  'NO_ADMIN' => :no_admin,
@@ -212,7 +217,7 @@ module Gitlab
212
217
  end
213
218
 
214
219
  def elastic_version
215
- env_var_value_if_defined('ELASTIC_VERSION') || '6.4.2'.freeze
220
+ env_var_value_if_defined('ELASTIC_VERSION') || '7.17.0'.freeze
216
221
  end
217
222
 
218
223
  def require_license!
@@ -275,6 +280,14 @@ module Gitlab
275
280
  end
276
281
  end
277
282
 
283
+ def require_gcs_with_cdn_environment!
284
+ %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|
285
+ unless ENV.key?(env_key)
286
+ raise ArgumentError, "Environment variable #{env_key} must be set to run GCS with CDN enabled scenario"
287
+ end
288
+ end
289
+ end
290
+
278
291
  def require_initial_password!
279
292
  return unless env_var_value_if_defined('GITLAB_INITIAL_ROOT_PASSWORD').to_s.strip.empty?
280
293
 
@@ -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
@@ -0,0 +1,27 @@
1
+ module Gitlab
2
+ module QA
3
+ module Scenario
4
+ module Test
5
+ module Instance
6
+ class StagingRefGeo < DeploymentBase
7
+ def initialize
8
+ @suite = 'QA::EE::Scenario::Test::Geo'
9
+ end
10
+
11
+ def deployment_component
12
+ Component::StagingRef
13
+ end
14
+
15
+ def non_rspec_args
16
+ [
17
+ '--primary-address', deployment_component::ADDRESS,
18
+ '--secondary-address', deployment_component::GEO_SECONDARY_ADDRESS,
19
+ '--without-setup'
20
+ ]
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ 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
@@ -22,7 +22,11 @@ module Gitlab
22
22
  specs.suite = 'Test::Integration::Mattermost'
23
23
  specs.release = gitlab.release
24
24
  specs.network = gitlab.network
25
- specs.args = [gitlab.address, mattermost_external_url, *rspec_args]
25
+ specs.args = [
26
+ gitlab.address,
27
+ "--mattermost-address", mattermost_external_url,
28
+ *rspec_args
29
+ ]
26
30
  end
27
31
  end
28
32
  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