gitlab-qa 8.2.0 → 8.3.2

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: 8cc0b13405340964bb5e0a19cb21457d70543c5f3de8f023a31527b91feb8b0c
4
- data.tar.gz: 64f23b12774640295fe5093a45b00e3d721266440b5bb359b3aad754adf0a4b5
3
+ metadata.gz: fa9e003021256eefe3a65e372d66dbaa1f93f03f1414c7d5dbf26d0c8426ae1d
4
+ data.tar.gz: 73bdb9ee88fae3344272a4093ffb44bcc5e856208e69d4b736db13e11cb47464
5
5
  SHA512:
6
- metadata.gz: a65f92e629724d354ab3cf038367ffb1002d27b35b3a8e5add2e1c82c08a718e20c57bc59e11ad1cbb466aa25041a4f00c87882d3fce18b7b3f3337d2c93f329
7
- data.tar.gz: 977e2feec2033cd0a3cc325025c149568edab4a62b47e5f37a2bcda9ef6f2ec09f2183d48be1129d2bd85caea4b0911f96a882de45f4414d04cab4f86a400a05
6
+ metadata.gz: 1b64d8409adeced189d03087cc52e89a4b7336f6292c12302e90374d70c1e1b1e7945315a56d079ae6aa7c3dbb6226093b69eea83ee39f4847bb8f07da744c39
7
+ data.tar.gz: c6865b83358739d867f33c1f3961a52e3f2c7710ccc0854f83107b96719618f3517ea7229543d5c315798852ee23313a67394806bf3eb0bd8c82f7038b8cd727
@@ -5,10 +5,8 @@ ce:metrics:
5
5
  - .high-capacity
6
6
  - .ce-variables
7
7
  - .rspec-report-opts
8
- - .combined-gitlab-qa-options-script
9
8
  variables:
10
- GITLAB_QA_OPTIONS_COMBINED: "$GITLAB_QA_OPTIONS --omnibus-config metrics"
11
- QA_RSPEC_TAGS: "--tag metrics"
9
+ QA_SCENARIO: "Test::Integration::Metrics"
12
10
 
13
11
  ce:metrics-quarantine:
14
12
  extends:
@@ -18,10 +16,8 @@ ce:metrics-quarantine:
18
16
  - .ce-variables
19
17
  - .quarantine
20
18
  - .rspec-report-opts
21
- - .combined-gitlab-qa-options-script
22
19
  variables:
23
- GITLAB_QA_OPTIONS_COMBINED: "$GITLAB_QA_OPTIONS --omnibus-config metrics"
24
- QA_RSPEC_TAGS: "--tag metrics"
20
+ QA_SCENARIO: "Test::Integration::Metrics"
25
21
 
26
22
  ee:metrics:
27
23
  extends:
@@ -30,10 +26,8 @@ ee:metrics:
30
26
  - .high-capacity
31
27
  - .ee-variables
32
28
  - .rspec-report-opts
33
- - .combined-gitlab-qa-options-script
34
29
  variables:
35
- GITLAB_QA_OPTIONS_COMBINED: "$GITLAB_QA_OPTIONS --omnibus-config metrics"
36
- QA_RSPEC_TAGS: "--tag metrics"
30
+ QA_SCENARIO: "Test::Integration::Metrics"
37
31
 
38
32
  ee:metrics-quarantine:
39
33
  extends:
@@ -43,7 +37,5 @@ ee:metrics-quarantine:
43
37
  - .ee-variables
44
38
  - .quarantine
45
39
  - .rspec-report-opts
46
- - .combined-gitlab-qa-options-script
47
40
  variables:
48
- GITLAB_QA_OPTIONS_COMBINED: "$GITLAB_QA_OPTIONS --omnibus-config metrics"
49
- QA_RSPEC_TAGS: "--tag quarantine --tag metrics"
41
+ QA_SCENARIO: "Test::Integration::Metrics"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-qa (8.2.0)
4
+ gitlab-qa (8.3.2)
5
5
  activesupport (~> 6.1)
6
6
  gitlab (~> 4.18.0)
7
7
  http (~> 5.0)
@@ -7,13 +7,14 @@ module Gitlab
7
7
  include Scenario::Actable
8
8
 
9
9
  attr_reader :docker
10
- attr_accessor :volumes, :network, :environment, :runner_network
10
+ attr_accessor :volumes, :ports, :network, :environment, :runner_network
11
11
  attr_writer :name, :exec_commands
12
12
 
13
13
  def initialize
14
14
  @docker = Docker::Engine.new
15
15
  @environment = {}
16
16
  @volumes = {}
17
+ @ports = []
17
18
  @network_aliases = []
18
19
  @exec_commands = []
19
20
  end
@@ -85,6 +86,10 @@ module Gitlab
85
86
  command << "--net #{network}"
86
87
  command << "--hostname #{hostname}"
87
88
 
89
+ @ports.each do |mapping|
90
+ command.port(mapping)
91
+ end
92
+
88
93
  @volumes.to_h.each do |to, from|
89
94
  command.volume(to, from, 'Z')
90
95
  end
@@ -17,7 +17,7 @@ module Gitlab
17
17
  using Rainbow
18
18
 
19
19
  attr_reader :release, :omnibus_configuration, :omnibus_gitlab_rails_env
20
- attr_accessor :tls, :skip_availability_check, :runner_network, :seed_admin_token, :seed_db
20
+ attr_accessor :tls, :skip_availability_check, :runner_network, :seed_admin_token, :seed_db, :skip_server_hooks
21
21
  attr_writer :name, :relative_path
22
22
 
23
23
  def_delegators :release, :tag, :image, :edition
@@ -47,6 +47,7 @@ module Gitlab
47
47
 
48
48
  @seed_admin_token = Runtime::Scenario.seed_admin_token
49
49
  @seed_db = Runtime::Scenario.seed_db
50
+ @skip_server_hooks = Runtime::Scenario.skip_server_hooks
50
51
 
51
52
  self.release = 'CE'
52
53
  end
@@ -84,8 +85,8 @@ module Gitlab
84
85
  tls ? 'https' : 'http'
85
86
  end
86
87
 
87
- def port
88
- tls ? '443:443' : '80'
88
+ def gitlab_port
89
+ tls ? ["443:443"] : ["80"]
89
90
  end
90
91
 
91
92
  def gitaly_tls
@@ -136,11 +137,15 @@ module Gitlab
136
137
  ensure_configured!
137
138
 
138
139
  docker.run(image: image, tag: tag) do |command|
139
- command << "-d -p #{port}"
140
+ command << "-d"
140
141
  command << "--name #{name}"
141
142
  command << "--net #{network}"
142
143
  command << "--hostname #{hostname}"
143
144
 
145
+ [*@ports, *gitlab_port].each do |mapping|
146
+ command.port(mapping)
147
+ end
148
+
144
149
  @volumes.to_h.each do |to, from|
145
150
  command.volume(to, from, 'Z')
146
151
  end
@@ -179,7 +184,7 @@ module Gitlab
179
184
  name,
180
185
  relative_path: relative_path,
181
186
  scheme: scheme,
182
- protocol_port: port.to_i
187
+ protocol_port: gitlab_port.first.to_i
183
188
  )
184
189
 
185
190
  Runtime::Logger.info("Waiting for GitLab to become healthy ...")
@@ -197,7 +202,7 @@ module Gitlab
197
202
  exec_commands << seed_admin_token_command if seed_admin_token
198
203
  exec_commands << seed_test_data_command if seed_db
199
204
  exec_commands << Runtime::Scenario.omnibus_exec_commands
200
- exec_commands << add_git_server_hooks unless Runtime::Scenario.skip_server_hooks
205
+ exec_commands << add_git_server_hooks unless skip_server_hooks
201
206
 
202
207
  commands = exec_commands.flatten.uniq
203
208
  return if commands.empty?
@@ -33,6 +33,10 @@ module Gitlab
33
33
  tap { @args.push(%(--env #{name}="#{value}")) }
34
34
  end
35
35
 
36
+ def port(mapping)
37
+ tap { @args.push("-p #{mapping}") }
38
+ end
39
+
36
40
  def to_s
37
41
  "docker #{@args.join(' ')}"
38
42
  end
@@ -119,19 +119,11 @@ module Gitlab
119
119
  end
120
120
 
121
121
  def container_exists?(name)
122
- Docker::Command.execute("container inspect #{name}")
123
- rescue Docker::Shellout::StatusError
124
- false
125
- else
126
- true
122
+ !Docker::Command.execute("container list --all --format '{{.Names}}' --filter name=^#{name}$").empty?
127
123
  end
128
124
 
129
125
  def network_exists?(name)
130
- Docker::Command.execute("network inspect #{name}")
131
- rescue Docker::Shellout::StatusError
132
- false
133
- else
134
- true
126
+ !Docker::Command.execute("network list --format '{{.Name}}' --filter name=^#{name}$").empty?
135
127
  end
136
128
 
137
129
  def network_create(name)
@@ -9,19 +9,19 @@ module Gitlab
9
9
  (-qa)?
10
10
  (:(?<tag>.+))?
11
11
  \z
12
- /xi
12
+ /xi.freeze
13
13
  CUSTOM_GITLAB_IMAGE_REGEX = %r{
14
14
  \A
15
15
  (?<image_without_tag>
16
- (?<registry>[^\/:]+(:(?<port>\d+))?)
17
- .+
16
+ (?<registry>[^/:]+(:(?<port>\d+))?)
17
+ (?<project>.+)
18
18
  gitlab-
19
19
  (?<edition>ce|ee)
20
20
  )
21
21
  (-qa)?
22
22
  (:(?<tag>.+))?
23
23
  \z
24
- }xi
24
+ }xi.freeze
25
25
 
26
26
  # Official dev tag example:
27
27
  # 12.5.4(-rc42)-ee
@@ -35,7 +35,7 @@ module Gitlab
35
35
  \A
36
36
  (?<version>\d+\.\d+.\d+(?:-rc\d+)?)-(?<edition>ce|ee)
37
37
  \z
38
- /xi
38
+ /xi.freeze
39
39
 
40
40
  # Dev tag example:
41
41
  # 12.1.201906121026-325a6632895.b340d0bd35d
@@ -47,9 +47,9 @@ module Gitlab
47
47
  # version
48
48
  DEV_TAG_REGEX = /
49
49
  \A
50
- (?<version>\d+\.\d+(.\d+)?)\.(?<timestamp>\d+)\-(?<gitlab_ref>[A-Za-z0-9]+)\.(?<omnibus_ref>[A-Za-z0-9]+)
50
+ (?<version>\d+\.\d+(.\d+)?)\.(?<timestamp>\d+)-(?<gitlab_ref>[A-Za-z0-9]+)\.(?<omnibus_ref>[A-Za-z0-9]+)
51
51
  \z
52
- /xi
52
+ /xi.freeze
53
53
 
54
54
  DEFAULT_TAG = 'latest'
55
55
  DEFAULT_CANONICAL_TAG = 'nightly'
@@ -63,8 +63,9 @@ module Gitlab
63
63
 
64
64
  def initialize(release)
65
65
  @release = release.to_s.downcase
66
+ return if valid?
66
67
 
67
- raise InvalidImageNameError, "The release image name '#{@release}' does not have the expected format." unless valid?
68
+ raise InvalidImageNameError, "The release image name '#{@release}' does not have the expected format."
68
69
  end
69
70
 
70
71
  def to_s
@@ -106,7 +107,14 @@ module Gitlab
106
107
  end
107
108
 
108
109
  def qa_image
109
- "#{image}-qa"
110
+ @qa_image ||= if omnibus_mirror?
111
+ omnibus_project = image.match(CUSTOM_GITLAB_IMAGE_REGEX)[:project]
112
+ gitlab_project = "/gitlab-org/gitlab/"
113
+
114
+ "#{image.gsub(omnibus_project, gitlab_project)}-qa"
115
+ else
116
+ "#{image}-qa"
117
+ end
110
118
  end
111
119
 
112
120
  def project_name
@@ -133,7 +141,7 @@ module Gitlab
133
141
  if dev_gitlab_org? && (match_data = tag.match(DEV_TAG_REGEX))
134
142
  "#{match_data[:version]}-#{match_data[:gitlab_ref]}"
135
143
  else
136
- tag.sub(/[-\.]([ce]e)(\.(\d+))?\z/, '-\1')
144
+ tag.sub(/[-.]([ce]e)(\.(\d+))?\z/, '-\1')
137
145
  end
138
146
  end
139
147
 
@@ -158,6 +166,7 @@ module Gitlab
158
166
 
159
167
  [Runtime::Env.gitlab_username, Runtime::Env.qa_access_token]
160
168
  end
169
+
161
170
  {
162
171
  username: username,
163
172
  password: password,
@@ -36,14 +36,12 @@ module Gitlab
36
36
  'QA_SLOW_CONNECTION_LATENCY_MS' => :qa_slow_connection_latency_ms,
37
37
  'QA_SLOW_CONNECTION_THROUGHPUT_KBPS' => :qa_slow_connection_throughput_kbps,
38
38
  'QA_GENERATE_ALLURE_REPORT' => :generate_allure_report,
39
- 'QA_EE_ACTIVATION_CODE' => :ee_activation_code,
40
39
  'QA_EXPORT_TEST_METRICS' => :qa_export_test_metrics,
41
40
  'QA_INFLUXDB_URL' => :qa_influxdb_url,
42
41
  'QA_INFLUXDB_TOKEN' => :qa_influxdb_token,
43
42
  'QA_RUN_TYPE' => :qa_run_type,
44
43
  'QA_SKIP_PULL' => :qa_skip_pull,
45
44
  'QA_VALIDATE_RESOURCE_REUSE' => :qa_validate_resource_reuse,
46
- 'QA_USE_PUBLIC_IP_API' => :qa_use_public_ip_api,
47
45
  'GITLAB_API_BASE' => :api_base,
48
46
  'GITLAB_ADMIN_USERNAME' => :admin_username,
49
47
  'GITLAB_ADMIN_PASSWORD' => :admin_password,
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitlab
4
+ module QA
5
+ module Scenario
6
+ module Test
7
+ module Integration
8
+ class Metrics < Scenario::Template
9
+ PUMA_METRICS_SERVER_PORT = 8083
10
+ SIDEKIQ_METRICS_SERVER_PORT = 8082
11
+
12
+ def perform(release, *rspec_args)
13
+ Component::Gitlab.perform do |gitlab|
14
+ gitlab.release = release
15
+ gitlab.network = 'test'
16
+ gitlab.name = 'gitlab'
17
+ gitlab.ports = [PUMA_METRICS_SERVER_PORT, SIDEKIQ_METRICS_SERVER_PORT]
18
+
19
+ gitlab.omnibus_configuration << <<~RUBY
20
+ puma['exporter_enabled'] = true
21
+ puma['exporter_address'] = '0.0.0.0'
22
+ puma['exporter_port'] = #{PUMA_METRICS_SERVER_PORT}
23
+ sidekiq['metrics_enabled'] = true
24
+ sidekiq['listen_address'] = '0.0.0.0'
25
+ sidekiq['listen_port'] = #{SIDEKIQ_METRICS_SERVER_PORT}
26
+ RUBY
27
+
28
+ gitlab.instance do
29
+ Component::Specs.perform do |specs|
30
+ specs.suite = 'Test::Integration::Metrics'
31
+ specs.release = gitlab.release
32
+ specs.network = gitlab.network
33
+ specs.args = [gitlab.address, *rspec_args]
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitlab
4
+ module QA
5
+ module Scenario
6
+ module Test
7
+ module Omnibus
8
+ class UpdateFromPrevious < Scenario::Template
9
+ using Rainbow
10
+
11
+ # Test update from N - 1 (major|minor|patch) version to current release
12
+ # Run smoke test suite on previous release to populate some data in database before update
13
+ #
14
+ # @example
15
+ # perform(gitlab-ee:dev-tag, 15.3.0-pre, major)
16
+ # => will perform upgrades 14.9.5 -> 15.0.5 -> gitlab-ee:dev-tag
17
+ #
18
+ # @param [String] release current release docker image
19
+ # @param [String] current_version current gitlab version associated with docker image
20
+ # @param [String] semver_component semver component for N - 1 version detection, major|minor|patch
21
+ # @param [Array] *rspec_args rspec arguments
22
+ # @return [void]
23
+ def perform(release, current_version, semver_component, *rspec_args)
24
+ @current_release = QA::Release.new(release)
25
+ @upgrade_path = Support::GitlabUpgradePath.new(
26
+ current_version,
27
+ semver_component,
28
+ @current_release.edition
29
+ ).fetch
30
+
31
+ upgrade_info = "#{[*upgrade_path, current_release].join(' => ')} (#{current_version})".bright
32
+ Runtime::Logger.info("Performing gitlab update: #{upgrade_info}")
33
+
34
+ update(rspec_args)
35
+ end
36
+
37
+ private
38
+
39
+ attr_reader :current_release, :upgrade_path
40
+
41
+ # Perform update
42
+ #
43
+ # @param [Array] rspec_args
44
+ # @return [void]
45
+ def update(rspec_args)
46
+ Docker::Volumes.new.with_temporary_volumes do |volumes|
47
+ # deploy first release in upgrade path and run specs to populate db
48
+ run_gitlab(upgrade_path.first, volumes, ["--", "--tag", "smoke"])
49
+
50
+ # deploy releases in upgrade path
51
+ upgrade_path[1..].each { |release| run_gitlab(release, volumes, skip_setup: true) }
52
+
53
+ # deploy current release and run tests
54
+ run_gitlab(current_release, volumes, rspec_args, skip_setup: true)
55
+ end
56
+ end
57
+
58
+ # Deploy gitlab instance and optionally run specs
59
+ #
60
+ # @param [Gitlab::QA::Release] release
61
+ # @param [Hash] volumes
62
+ # @return [void]
63
+ def run_gitlab(release, volumes, rspec_args = [], skip_setup: false)
64
+ Runtime::Logger.info("Deploying release: #{release.to_s.bright}")
65
+
66
+ Component::Gitlab.perform do |gitlab|
67
+ gitlab.release = release
68
+ gitlab.volumes = volumes
69
+ gitlab.network = 'test'
70
+
71
+ if skip_setup
72
+ gitlab.skip_server_hooks = true
73
+ gitlab.seed_db = false
74
+ gitlab.seed_admin_token = false
75
+ end
76
+
77
+ next gitlab.launch_and_teardown_instance unless run_specs?(release)
78
+
79
+ gitlab.instance { run_specs(gitlab, release, rspec_args) }
80
+ end
81
+ end
82
+
83
+ # Run specs
84
+ #
85
+ # @param [Gitlab::QA::Component::Gitlab] gitlab
86
+ # @param [Gitlab::QA::Release] release
87
+ # @param [Array] rspec_args
88
+ # @return [void]
89
+ def run_specs(gitlab, release, rspec_args)
90
+ Component::Specs.perform do |specs|
91
+ specs.release = release
92
+ specs.suite = 'Test::Instance::All'
93
+ specs.hostname = "qa-e2e-specs.#{gitlab.network}"
94
+ specs.network = gitlab.network
95
+ specs.args = [gitlab.address, *rspec_args]
96
+ end
97
+ rescue Docker::Shellout::StatusError => e
98
+ raise e if release == current_release # only fail on current release
99
+
100
+ Runtime::Logger.warn("Test run for release '#{gitlab.release}' finished with errors!")
101
+ end
102
+
103
+ # Run specs on first release to populate database and release being tested
104
+ #
105
+ # @param [Gitlab::QA::Release] release
106
+ # @return [Boolean]
107
+ def run_specs?(release)
108
+ [upgrade_path.first, current_release].any? { |rel| rel == release }
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/module/delegation"
4
+ require "yaml"
5
+
6
+ module Gitlab
7
+ module QA
8
+ module Support
9
+ class GitlabUpgradePath
10
+ # Get upgrade path between N - 1 and current version not including current release
11
+ #
12
+ # @param [String] current_version
13
+ # @param [String] semver_component version number component for previous version detection - major|minor|patch
14
+ # @param [String] edition GitLab edition - ee or ce
15
+ def initialize(current_version, semver_component, edition)
16
+ @version_info = GitlabVersionInfo.new(current_version, edition)
17
+ @current_version = Gem::Version.new(current_version)
18
+ @semver_component = semver_component
19
+ @edition = edition
20
+ @logger = Runtime::Logger.logger
21
+ end
22
+
23
+ # Get upgrade path between releases
24
+ #
25
+ # Return array with only previous version for updates from previous minor, patch versions
26
+ #
27
+ # @return [Array<QA::Release>]
28
+ def fetch
29
+ return [release(latest_patch(previous_version))] unless major_upgrade?
30
+
31
+ # get versions between previous major and current version in gitlab upgrade path
32
+ path = full_upgrade_path.each_with_object([]) do |ver, arr|
33
+ next if ver <= previous_version || ver >= current_version
34
+
35
+ arr << ver
36
+ end
37
+
38
+ [previous_version, *path].map do |ver|
39
+ release(version_info.latest_patch(ver))
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ delegate :latest_patch, to: :version_info
46
+
47
+ attr_reader :version_info, :current_version, :semver_component, :edition, :logger
48
+
49
+ # Upgrade from previous major
50
+ #
51
+ # @return [Boolean]
52
+ def major_upgrade?
53
+ semver_component == "major"
54
+ end
55
+
56
+ # Docker release image
57
+ #
58
+ # @param [String] version
59
+ # @return [QA::Release]
60
+ def release(version)
61
+ QA::Release.new("gitlab/gitlab-#{edition}:#{version}-#{edition}.0")
62
+ end
63
+
64
+ # Previous gitlab version
65
+ #
66
+ # @return [Gem::Version]
67
+ def previous_version
68
+ @previous_version ||= version_info.previous_version(semver_component)
69
+ end
70
+
71
+ # Gitlab upgrade path
72
+ #
73
+ # @return [Array<Gem::Version>]
74
+ def full_upgrade_path
75
+ @full_upgrade_path ||= ::YAML
76
+ .safe_load(upgrade_path_yml, symbolize_names: true)
77
+ .map { |version| Gem::Version.new("#{version[:major]}.#{version[:minor]}") }
78
+ end
79
+
80
+ # Upgrade path yml
81
+ #
82
+ # @return [String]
83
+ def upgrade_path_yml
84
+ @upgrade_path_yml ||= begin
85
+ logger.info("Fetching gitlab upgrade path from 'gitlab-com/support/toolbox/upgrade-path' project")
86
+ HttpRequest.make_http_request(
87
+ url: "https://gitlab.com/gitlab-com/support/toolbox/upgrade-path/-/raw/main/upgrade-path.yml"
88
+ ).body
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,180 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitlab
4
+ module QA
5
+ module Support
6
+ class GitlabVersionInfo
7
+ VERSION_PATTERN = /^(?<version>\d+\.\d+\.\d+)/.freeze
8
+ COMPONENT_PATTERN = /^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/.freeze
9
+
10
+ # Get previous gitlab version
11
+ #
12
+ # @param [String] current_version
13
+ # @param [String] edition GitLab edition - ee or ce
14
+ def initialize(current_version, edition)
15
+ @current_version = current_version
16
+ @edition = edition
17
+ @logger = Runtime::Logger.logger
18
+ end
19
+
20
+ # Get N - 1 version number
21
+ #
22
+ # @param [String] semver_component version number component for previous version detection - major|minor|patch
23
+ # @return [Gem::Version]
24
+ def previous_version(semver_component)
25
+ case semver_component
26
+ when "major"
27
+ previous_major
28
+ when "minor"
29
+ previous_minor
30
+ when "patch"
31
+ previous_patch
32
+ else
33
+ raise("Unsupported semver component, must be major|minor|patch")
34
+ end
35
+ end
36
+
37
+ # Get latest patch for specific version number
38
+ #
39
+ # @example
40
+ # latest_patch(Gem::Version.new("14.10")) => "14.10.5"
41
+ #
42
+ # @param [Gem::Version] version
43
+ # @return [String]
44
+ def latest_patch(version)
45
+ versions.find { |ver| ver.to_s.match?(/^#{version}/) }
46
+ end
47
+
48
+ private
49
+
50
+ attr_reader :current_version, :edition, :logger
51
+
52
+ # Current versions major version
53
+ #
54
+ # @return [Integer]
55
+ def current_major
56
+ @current_major ||= current_version.match(COMPONENT_PATTERN)[:major].to_i
57
+ end
58
+
59
+ # Current versions minor version
60
+ #
61
+ # @return [Integer]
62
+ def current_minor
63
+ @current_minor ||= current_version.match(COMPONENT_PATTERN)[:minor].to_i
64
+ end
65
+
66
+ # Current versions patch version
67
+ #
68
+ # @return [Integer]
69
+ def current_patch
70
+ @current_patch ||= current_version.match(COMPONENT_PATTERN)[:patch].to_i
71
+ end
72
+
73
+ # Previous major version
74
+ #
75
+ # @return [String]
76
+ def previous_major
77
+ return fallback_major unless tags
78
+
79
+ versions.find { |version| version.to_s.start_with?((current_major - 1).to_s) }
80
+ end
81
+
82
+ # Previous first major version image
83
+ #
84
+ # @return [String]
85
+ def fallback_major
86
+ previous_fallback_version(current_major - 1)
87
+ end
88
+
89
+ # Previous minor version
90
+ #
91
+ # @return [String]
92
+ def previous_minor
93
+ return fallback_minor unless tags
94
+ return previous_major if current_minor.zero?
95
+
96
+ versions.find { |version| version.to_s.match?(/^#{current_major}\.#{current_minor - 1}/) }
97
+ end
98
+
99
+ # Previous first minor version
100
+ #
101
+ # @return [String]
102
+ def fallback_minor
103
+ return previous_fallback_version(current_major, current_minor - 1) unless current_minor.zero?
104
+
105
+ previous_major
106
+ end
107
+
108
+ # Previous patch version
109
+ #
110
+ # @return [String]
111
+ def previous_patch
112
+ return fallback_patch unless tags
113
+ return previous_minor if current_patch.zero?
114
+
115
+ versions.find { |version| version.to_s.match?(/^#{current_major}\.#{current_minor}\.#{current_patch - 1}/) }
116
+ end
117
+
118
+ # Previous first patch version
119
+ #
120
+ # @return [String]
121
+ def fallback_patch
122
+ return previous_fallback_version(current_major, current_minor, current_patch - 1) unless current_patch.zero?
123
+
124
+ previous_minor
125
+ end
126
+
127
+ # Version number from docker tag
128
+ #
129
+ # @param [String] tag
130
+ # @return [String]
131
+ def version(tag)
132
+ tag.match(VERSION_PATTERN)[:version]
133
+ end
134
+
135
+ # Fallback version
136
+ #
137
+ # @param [Integer] major_component
138
+ # @param [Integer] minor_component
139
+ # @param [Integer] patch_component
140
+ # @return [Gem::Version]
141
+ def previous_fallback_version(major_component, minor_component = 0, patch_component = 0)
142
+ Gem::Version.new("#{major_component}.#{minor_component}.#{patch_component}")
143
+ end
144
+
145
+ # All available gitlab versions
146
+ #
147
+ # @return [Array<String>]
148
+ def versions
149
+ @versions = tags
150
+ .map { |tag| Gem::Version.new(tag.match(VERSION_PATTERN)[:version]) }
151
+ .sort
152
+ .reverse # reverse array so first match by .find always returns latest version
153
+ end
154
+
155
+ # All available docker tags
156
+ #
157
+ # @return [Array<String>]
158
+ def tags
159
+ return @tags if defined?(@tags)
160
+
161
+ logger.info("Fetching docker tags from 'gitlab/gitlab-#{edition}' registry")
162
+ response = HttpRequest.make_http_request(
163
+ url: "https://registry.hub.docker.com/v1/repositories/gitlab/gitlab-#{edition}/tags",
164
+ fail_on_error: false
165
+ )
166
+
167
+ unless response.code == 200
168
+ logger.error(" failed to fetch docker tags - code: #{response.code}, response: '#{response.body}'")
169
+ return @tags = nil
170
+ end
171
+
172
+ @tags = JSON
173
+ .parse(response.body, symbolize_names: true)
174
+ .map { |tag| tag[:name] }
175
+ .select { |tag| tag.match?(VERSION_PATTERN) }
176
+ end
177
+ end
178
+ end
179
+ end
180
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module QA
5
- VERSION = '8.2.0'
5
+ VERSION = '8.3.2'
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: 8.2.0
4
+ version: 8.3.2
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-07-29 00:00:00.000000000 Z
11
+ date: 2022-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control
@@ -358,7 +358,6 @@ files:
358
358
  - lib/gitlab/qa/runtime/omnibus_configurations/decomposition_single_db.rb
359
359
  - lib/gitlab/qa/runtime/omnibus_configurations/default.rb
360
360
  - lib/gitlab/qa/runtime/omnibus_configurations/license_mode.rb
361
- - lib/gitlab/qa/runtime/omnibus_configurations/metrics.rb
362
361
  - lib/gitlab/qa/runtime/omnibus_configurations/object_storage.rb
363
362
  - lib/gitlab/qa/runtime/omnibus_configurations/object_storage_aws.rb
364
363
  - lib/gitlab/qa/runtime/omnibus_configurations/object_storage_gcs.rb
@@ -398,6 +397,7 @@ files:
398
397
  - lib/gitlab/qa/scenario/test/integration/ldap_no_tls.rb
399
398
  - lib/gitlab/qa/scenario/test/integration/ldap_tls.rb
400
399
  - lib/gitlab/qa/scenario/test/integration/mattermost.rb
400
+ - lib/gitlab/qa/scenario/test/integration/metrics.rb
401
401
  - lib/gitlab/qa/scenario/test/integration/mtls.rb
402
402
  - lib/gitlab/qa/scenario/test/integration/opensearch.rb
403
403
  - lib/gitlab/qa/scenario/test/integration/praefect.rb
@@ -410,11 +410,14 @@ files:
410
410
  - lib/gitlab/qa/scenario/test/integration/ssh_tunnel.rb
411
411
  - lib/gitlab/qa/scenario/test/omnibus/image.rb
412
412
  - lib/gitlab/qa/scenario/test/omnibus/update.rb
413
+ - lib/gitlab/qa/scenario/test/omnibus/update_from_previous.rb
413
414
  - lib/gitlab/qa/scenario/test/omnibus/upgrade.rb
414
415
  - lib/gitlab/qa/scenario/test/sanity/version.rb
415
416
  - lib/gitlab/qa/slack/post_to_slack.rb
416
417
  - lib/gitlab/qa/support/dev_ee_qa_image.rb
417
418
  - lib/gitlab/qa/support/get_request.rb
419
+ - lib/gitlab/qa/support/gitlab_upgrade_path.rb
420
+ - lib/gitlab/qa/support/gitlab_version_info.rb
418
421
  - lib/gitlab/qa/support/http_request.rb
419
422
  - lib/gitlab/qa/support/invalid_response_error.rb
420
423
  - lib/gitlab/qa/test_logger.rb
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gitlab
4
- module QA
5
- module Runtime
6
- module OmnibusConfigurations
7
- class Metrics < Default
8
- def configuration
9
- <<~RUBY
10
- puma['exporter_enabled'] = true
11
- puma['exporter_port'] = 8083
12
- sidekiq['metrics_enabled'] = true
13
- sidekiq['listen_port'] = 8082
14
- RUBY
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end